Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03469 (python)

Fixed submission:
s = input()
print(s.replace('2017', '2018'))

Buggy submission (verdict: Runtime Error):
N, Y = list(map(int, input().split()))
results = [-1, -1, -1]
for x in range(N + 1):
    for y in range(N - x + 1):
        z = (N - x - y)
        if 0 <= z <= 2000 and Y == 10000 * x + 5000 * y + 1000 * z:
            results = [x, y, z]
            print(results)
            exit()
print(results)

Buggy submission (verdict: Runtime Error):
N, Y = list(map(int, input().split()))
results = [-1, -1, -1]
for x in range(N + 1):
    for y in range(N - x + 1):
        z = (N - x - y)
        if 0 <= z <= 2000 and Y == 10000 * x + 5000 * y + 1000 * z:
            results = [x, y, z]
            print(results)
            exit()
print(results)
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 10000*x+5000*y+1000*z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Buggy submission (verdict: Runtime Error):
results = [-1, -1, -1]
for x in range(N + 1):
    for y in range(N - x + 1):
        if Y == 10000 * x + 5000 * y + 1000 * (N - x - y):
            results = [x, y, (N - x - y)]
            print(results)
            exit()
Problem p03693 (python)

Fixed submission:
r, g, b = input().split()
a = int(r + g + b)
if a % 4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
r, g, b = input()
a = int(r + g + b)
if a % 4 == 0:
    print('YES')
else:
    print('NO')
Problem p02612 (python)

Fixed submission:
n = int(input())
print(- n - (-n // 1000) * 1000)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(n - (-n // 1000) * 1000
Problem p03308 (python)

Fixed submission:
a = int(input())
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  else:
    if l[i]>M:
      M = l[i]
    else:
      pass
print(M-m)

Buggy submission (verdict: Runtime Error):
a = int.input()
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  else:
    if l[i]>M:
      M = l[i]
    else:
      pass
print(M-m)

Buggy submission (verdict: Runtime Error):
a = int.input()
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  else:
    if l[i]>M:
      M=l[i]
    else:
      pass
  
print(M-m)

Buggy submission (verdict: Runtime Error):
a = int.input()
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  if l[i]>M:
    M=l[i]
print(M-m)

Buggy submission (verdict: Runtime Error):
a = int.input()
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = i[i]
  if l[i]>M:
    M=l[i]
print(M-m)
Problem p03338 (python)

Fixed submission:
n = int(input())
s = input()
Alphabet = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]
h = 0
for j in range(1,n):
    StringL = s[0:j]
    StringR = s[j:n]
    r = 0
    for i in Alphabet:
        if StringL.count(i) == 0:
            pass
        else:
            if StringR.count(i) == 0:
                pass
            else: r = r + 1
        if r > h:
            h = r
print(h)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
Alphabet = [q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m]
for j in range(1,n):
  r = 0
  StringL = s[0:j]
  StringR = s[j:n]
  for i in Alphabet:
    if StringL.count(i) == 0:
      pass
    else:
      if StringR.count(i) == 0:
        pass
      else: r = r + 1
print(r)
Problem p03379 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(a)
b.sort()
c = int(n/2)
ML=b[c-1]
MR=b[c]
for i in range(0,n):
    if a[i] >= MR:
        print(ML)
    else:
        print(MR)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map((int,input.split())))
c = int(n / 2)
b = list(a)
for j in range(1,c):
    M = max(b)
    m= min(b)
    b.remove(M)
    b.remove(m)
ML = min(b)
MR = max(b)
for i in range(0,n):
    if a[i] > MR:
        print(ML)
    else:
        print(MR)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map((int,input.split()))
c = int(n / 2)
b = list(a)
for j in range(1,c):
    M = max(b)
    m= min(b)
    b.remove(M)
    b.remove(m)
ML = min(b)
MR = max(b)
for i in range(0,n):
    if a[i] > MR:
        print(ML)
    else:
        print(MR)
Problem p02705 (python)

Fixed submission:
import math

R = int(input())
print(R*2*math.pi)

Buggy submission (verdict: Runtime Error):
import macpath

R = int(input())
print(R*2*math.pi)
Problem p02706 (python)

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

if N-sum(A) < 0:
    print("-1")
else:
    print(N-sum(A))

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

if N-sum(A) < 0:
    print("-1")
else:
    print(N-sum(A))

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

print(N-sum(A))
Problem p02730 (python)

Fixed submission:
s = input()
end = (len(s)-1)//2
start = (len(s)+3)//2
if s[0:end] == s[end-1::-1]:
    if s[start-1::] == s[-1:start-2:-1]:
        if s[0::] == s[::-1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
end = (len(s)-1)//2
start = (len(s)+3)//2
if s[0:end] == s[end-1::-1]:
    if s[start-1::] == s[-1:start-2:-1]:
        if s[0::] == s[::-1]
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")
Problem p02732 (python)

Fixed submission:
N = int(input())
array = list(map(int, input().split()))
sameNum = [0]*(N)
sum = 0
# kを削除していないlistでの組み合わせを調べる
for i in range(N):
    sameNum[array[i]-1] += 1
for i in range(N):
    sum += sameNum[i]*(sameNum[i]-1)//2

for k in range(1, N+1):
    sumT = sum
    print(sumT - sameNum[array[k-1]-1] + 1)

Buggy submission (verdict: Runtime Error):
N = int(input())
array = list(map(int, input().split()))
sameNum = [0]*(N)

for i in range(N):
    sameNum[array[i]-1] += 1

for k in range(1, N+1):
    answer = 0
    sameNumT = sameNum.copy()
    sameNumT[array[k-1]-1] -= 1
    for l in range(N):
        answer += sameNumT[l]*(sameNumT[l]-1)//2
    print(answer)
Problem p02743 (python)

Fixed submission:
import math

a, b, c = map(int, input().split())
if (c - a - b) ** 2 > 4 * a * b and c - a - b > 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math

a, b, c = map(int, input().split())
if (c - a - b) * * 2 > 4 * a * b:
    print("Yes")
else:
    print("No")
Problem p02811 (python)

Fixed submission:
k,x = map(int,input().split())

if k*500 >= x:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(N-2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        ans += 1
print(ans)
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(N-2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(N):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        ans += 1
print(ans)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)
test = a[0]
count = 0
while test%2 ==0:
    test = test//2
    count += 1
for i in range(N):
    if (a[i]//2**count)%2 == 0:
        print(0)
        exit()
print((M+lcm//2)//lcm)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)
print((M+lcm//2)//lcm)
Problem p02900 (python)

Fixed submission:
import fractions
A,B = map(int,input().split())
GCD = fractions.gcd(A,B)
if GCD == 1:
    print(1)
    exit()
    
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

Bunkai = factorization(GCD) 
print(len(Bunkai) + 1)

Buggy submission (verdict: Runtime Error):
import math
import collections
A,B = map(int,input().split())
GCD = math.gcd(A,B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

Bunkai = factorization(GCD) 
print(len(Bunkai) + 1)
Problem p02924 (python)

Fixed submission:
N = int(input())
print(N*(N-1)//2)

Buggy submission (verdict: Runtime Error):
 N = int(input())
print(N*(N-1)//2)
Problem p02995 (python)

Fixed submission:
import fractions
A, B , C , D = map(int, input().split())

bc = B // C 
bd = B // D
bcd = B // (C*D//fractions.gcd(C, D))
ans = B- (bc + bd - bcd)
ac = (A-1) // C
ad = (A-1) // D
acd = (A-1) //(C*D//fractions.gcd(C, D))
ans2=  A-1 - (ac + ad - acd)
ans = ans - ans2
print(ans)

Buggy submission (verdict: Runtime Error):
import math
A, B , C , D = map(int, input().split())

bc = B // C 
bd = B // D
bcd = B // (C*D//math.gcd(C, D))
ans = B- (bc + bd - bcd)
ac = (A-1) // C
ad = (A-1) // D
acd = (A-1) //(C*D//math.gcd(C, D))
ans2=  A-1 - (ac + ad - acd)
ans = ans - ans2
print(ans)
Problem p03164 (python)

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

v = [0] * N
w = [0] * N
for i in range(N):
    w[i],v[i] = map(int,input().split())
sumv = sum(v)+1
dp = [[float('inf')] * (sumv) for _ in range(N+1)]
for i in range(N):
    dp[i][0] = 0
for i in range(1, N+1):
    for j in range(1, sumv):
        if v[i-1] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j],w[i-1]+dp[i-1][j-v[i-1]])
ans = 0
for i in range(1, sumv+1):
    if dp[N][-i] <= W:
        ans = sumv - i
        break
print(ans)

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

v = [0] * N
w = [0] * N
for i in range(N):
    w[i],v[i] = map(int,input().split())

dp = [[0] * (W+1) for _ in range(N)]

for i in range(N):
    for j in range(1, W+1):
        if w[i] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],v[i]+dp[i-1][j-w[i]])

print(max(dp[N-1]))
Problem p03474 (python)

Fixed submission:
import re
A, B = map(str,input().split())
S = input()
pattern = r'[0-9]{'+A+'}-[0-9]{'+B+'}'
matchObj = re.match(pattern, S)
if matchObj:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import re
A, B = map(str,input().split())
S = input()
pattern = r'[0-9]{'+A+'}-[0-9]{'+B+'}'
matchObj = re.fullmatch(pattern, S)
if matchObj:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import re
A, B = map(str,input().split())
S = input()
pattern = r'[0-9]{'+A+'}-[0-9]{'+B+'}'
matchObj = re.fullmatch(pattern, S)
if matchObj:
    print("Yes")
else:
    print("No")
Problem p03543 (python)

Fixed submission:
N = input()

if N[0] == N[1] and N[1] == N[2]:
    print("Yes")
elif N[2] == N[1] and N[3] == N[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())

if N[0] == N[1] and N[1] == N[2]:
    print("Yes")
elif N[2] == N[1] and N[3] == N[2]:
    print("Yes")
else:
    print("No")
Problem p02952 (python)

Fixed submission:
import numpy as np
N=int(input())
#N以下の正の整数の文字列を生成



list_a=np.arange(1, N+1)
list_b =[]


#print(list_a)
#print(len(str(list_a)))

for i in list_a:
    if  len(str(i))%2 !=0:
        #print(i)
        list_b.append(i)

print(len(list_b))

Buggy submission (verdict: Runtime Error):
N=int(input())
#N以下の正の整数の文字列を生成



list_a=np.arange(1, N+1)
list_b =[]


#print(list_a)
#print(len(str(list_a)))

for i in list_a:
    if  len(str(i))%2 !=0:
        #print(i)
        list_b.append(i)

print(len(list_b))
Problem p02994 (python)

Fixed submission:
N, L = list(map(int, input().split()))
t = []
for i in range(N):
    t.append(L+i)
# print(t)
base = sum(t)
ans = -1
r = float('inf')
for j in range(N):
    if abs(t[j]) < r:
        r = abs(t[j])
        ans = j
print(base-t[ans])

Buggy submission (verdict: Runtime Error):
import numpy as np
 
# 2つの整数の入力
N, L = map(int, input().split())
 
# 味を数列化
taste = np.arange(L, L + N, 1)
 
# 味の最小・最大ともに0以上の場合は最小値を選ぶ
if np.min(taste) >= 0 and np.max(taste) >= 0:
  print("{}".format(np.sum(taste) - np.min(taste)))
 
# 味の最小・最大ともに0以下の場合は最大値を選ぶ
elif np.min(taste) <= 0 and np.max(taste) <= 0:
  print("{}".format(np.sum(taste) - np.max(taste)))
 
# それ以外の場合は0を選ぶ
else:
  print("{}".format(np.sum(taste)))
import numpy as np

# 2つの整数の入力
N, L = map(int, input().split())

# 味を数列化
taste = np.arange(L, L + N, 1)

# 味の最小・最大ともに0以上の場合は最小値を選ぶ
if np.min(taste) >= 0 and np.max(taste) >= 0:
  print("{}".format(np.sum(taste) - np.min(taste)))

# 味の最小・最大ともに0以下の場合は最大値を選ぶ
elif np.min(taste) <= 0 and np.max(taste) <= 0:
  print("{}".format(np.sum(taste) - np.max(taste)))

# それ以外の場合は0を選ぶ
else:
  print("{}".format(np.sum(taste)))
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int c = a * b;
    if (c % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}
Problem p02812 (python)

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

cnt = 0

for i in range(N) :
    if N >= i+2 and S[i:i+3] == 'ABC' : 
        cnt = cnt + 1

print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

cnt = 0

for i in range(N) :
    if N >= i+2 and S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C' : 
        cnt = cnt + 1

print(cnt)
Problem p02639 (python)

Fixed submission:
lst = []

a, b, c, d, e = map(int, input().split())

lst.append(a)
lst.append(b)
lst.append(c)
lst.append(d)
lst.append(e)

n=lst.index(0)
print(n+1)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

if x*4<y:
    print("No")

elif y/2<x:
    print ("No")

elif y % 2 == 0:
    print("Yes")

else:
    print("No")

Buggy submission (verdict: Runtime Error):
lst = []

for i in range (5):
    element = int(input())
    lst.append(element)

n=lst.index(0)
print(n+1)
Problem p02684 (python)

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

A = [i-1 for i in map(int, input().split())]

used = [False] * N
loop = [0]  # startは0→町1
now = 0  # now+1が町
while not used[A[now]]:
    used[A[now]] = True
    loop.append(A[now])
    now = A[now]

ind = loop.index(A[now])
# new_loop = loop[(befo):]
if K < ind:
    print(loop[K]+1)
else:
    K -= ind
    K %= len(loop)-ind

    print(loop[ind+K]+1)

# print([i+1 for i in loop])
# print(new_loop[(K-befo) % (len(new_loop))]+1)

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

A = [i-1 for i in map(int, input().split())]

used = [False] * N
loop = [0]  # startは0→町1
now = 0  # now+1が町
while not used[A[now]]:
    used[A[now]] = True
    loop.append(A[now])
    now = A[now]

ind = loop.index(A[now])
# new_loop = loop[(befo):]
if K < ind:
    print(loop[K]+1)
else:
    K -= ind
    K %= len[loop]-x

    print(loop[x+K]+1)

# print([i+1 for i in loop])
# print(new_loop[(K-befo) % (len(new_loop))]+1)

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

A = [i for i in map(int, input().split())]
# print(N, K)
# print(A)
loop = [0]  # startは0→町1
now = 0  # now+1が町
for i in range(N)
  now = A[now] - 1
   if now in loop:
        loop.append(now)

        break
    else:
        loop.append(now)

befo = loop.index(now)+1
new_loop = loop[(befo):]

# print([i+1 for i in loop])
print(new_loop[(K-befo) % (len(new_loop))]+1)
Problem p02953 (python)

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

for i in range(n-1):
    if l_list[i+1]-l_list[i] == -1:
        l_list[i+1] += 1
    elif l_list[i+1]-l_list[i] < -1:
        print("No")
        break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
l_list = list(map(int, input().split()))
while 1:
    if i == n:
        print("Yes")
    if l_list[i]+1 <= max(l_list[i+1:]):
        print("No")
        break
    i += 1
Problem p03047 (python)

Fixed submission:
n, k = map(int, input().split())
print(n-k+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
x_max = (n+1/4)**(1/2) - 1/2
for x in range(1, int(x_max + 1)):

    m = (n-x) // x
    if (n-x) % x == 0 and x < m:
        ans += m


print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
x_max = (n+1/4)**(1/2) - 1/2
for x in range(1, int(x_max + 1)):

    m = (n-x) // x
    if (n-x) % x == 0 and x < m:
        ans += m


print(ans)
Problem p03238 (python)

Fixed submission:
n = int(input())

if n == 1:
    print("Hello World")
elif n == 2:
    a = int(input())
    b = int(input())

    print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())

if n == 1:
    print("Hello World")
elif n == 2:
    print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())

if n == 1:
    print("Hello World")
else:
    print(a+b)
Problem p02613 (python)

Fixed submission:



N = int(input())
cnt = [0] * 4
for n in range(N):
    s = input()
    if s == 'AC':
        cnt[0] += 1
    elif s == 'WA':
        cnt[1] += 1
    elif s == 'TLE':
        cnt[2] += 1
    elif s == 'RE':
        cnt[3] += 1

print('AC x ',cnt[0])
print('WA x ',cnt[1])
print('TLE x ',cnt[2])
print('RE x ',cnt[3])

Buggy submission (verdict: Runtime Error):



N = int(input())
cnt = [0] * 4
for n in range(N):
    s = int(input())
    if s == 'AC':
        cnt[0] += 1
    elif s == 'WA':
        cnt[1] += 1
    elif s == 'TLE':
        cnt[2] += 1
    elif s == 'RE':
        cnt[3] += 1

print('AC x ',cnt[0])
print('WA x ',cnt[1])
print('TLE x ',cnt[2])
print('RE x ',cnt[3])
Problem p02630 (python)

Fixed submission:


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (10**5+1)
for i in range(len(A)):
    # print(A[i], A)
    nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
    # print(nizi)
    B, C = map(int, input().split())
    sumall += (C-B) * nizi[B]
    nizi[C] += nizi[B]
    nizi[B] = 0
    print(sumall)

Buggy submission (verdict: Runtime Error):


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (10**5)
for i in range(len(A)):
    # print(A[i], A)
    nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
    # print(nizi)
    B, C = map(int, input().split())
    sumall += (C-B) * nizi[B]
    nizi[C] += nizi[B]
    nizi[B] = 0
    print(sumall)

Buggy submission (verdict: Runtime Error):


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (10)
for i in range(len(A)):
    # print(A[i], A)
    nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
    # print(nizi)
    B, C = map(int, input().split())
    sumall += (C-B) * nizi[B]
    nizi[C] += nizi[B]
    nizi[B] = 0
    print(sumall)

Buggy submission (verdict: Runtime Error):


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (10**5)
for i in range(len(A)):
    # print(A[i], A)
    nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
    B, C = map(int, input().split())
    sumall += (C-B) * nizi[B]
    nizi[C] =+ nizi[B]
    nizi[B] = 0
    print(sumall)

Buggy submission (verdict: Runtime Error):


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (max(A)+1)
for i in range(len(A)):
    # print(A[i], A)
    nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
    B, C = map(int, input().split())
    sumall += (C-B) * nizi[B]
    nizi[C] =+ nizi[B]
    nizi[B] = 0
    print(sumall)

Buggy submission (verdict: Runtime Error):


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (max(A)+1)
for i in range(len(A)):
    print(A[i], A)
    nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
    B, C = map(int, input().split())
    sumall += (C-B) * nizi[B]
    nizi[C] =+ nizi[B]
    nizi[B] = 0
    print(sumall)
Problem p02714 (python)

Fixed submission:


N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')

for i in range(N-2):
    for j in range(i,N-1):
        k = 2*j-i
        if  k<=N-1:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k] :
                cnt -= 1


print(cnt)

Buggy submission (verdict: Runtime Error):


N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')
# for i in range(1,N-1):
#     for j in range(i+1,N):
#         if S[i-1] != S[j-1]:
#             for k in range(j+1,N+1):
#                 if S[i-1]!=S[k-1] and S[j-1]!=S[k-1] and j-i!=k-j:
#                     cnt += 1
for i in range(N-2):
    for j in range(i,N-1):
        k = 2*j-i
        if k>j and k<=N:
            if S[i]==S[j] or S[i]==S[k] or S[j]==S[k] :
                cnt -= 1


print(cnt)

Buggy submission (verdict: Runtime Error):


N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')
# for i in range(1,N-1):
#     for j in range(i+1,N):
#         if S[i-1] != S[j-1]:
#             for k in range(j+1,N+1):
#                 if S[i-1]!=S[k-1] and S[j-1]!=S[k-1] and j-i!=k-j:
#                     cnt += 1
for i in range(1,N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if k>j and k-1<=N:
            if S[i-1]==S[j-1] or S[i-1]==S[k-1] or S[j-1]==S[k-1] :
                cnt -= 1


print(cnt)

Buggy submission (verdict: Runtime Error):


N = int(input())
S = input()
S = S[::-1]

cnt = 0

for i in range(1,N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if S[i-1]==S[j-1] or S[i-1]==S[k-1] or S[j-1]==S[k-1] :
            cnt += 1


print(N-cnt)

Buggy submission (verdict: Runtime Error):


N = int(input())
S = input()
S = S[::-1]

cnt = 0
# for i in range(1,N-1):
#     for j in range(i+1,N):
#         if S[i-1] != S[j-1]:
#             for k in range(j+1,N+1):
#                 if S[i-1]!=S[k-1] and S[j-1]!=S[k-1] and j-i!=k-j:
#                     cnt += 1
for i in range(1,N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if S[i-1]==S[k-1] or S[j-1]==S[k-1] :
            cnt += 1


print(N-cnt)

Buggy submission (verdict: Runtime Error):


N = int(input())
S = input()
S = S[::-1]

cnt = 0
# for i in range(1,N-1):
#     for j in range(i+1,N):
#         if S[i-1] != S[j-1]:
#             for k in range(j+1,N+1):
#                 if S[i-1]!=S[k-1] and S[j-1]!=S[k-1] and j-i!=k-j:
#                     cnt += 1
for i in range(1,N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if S[i-1]==S[k-1] or S[j-1]==S[k-1] :
            cnt += 1


print(N**3-cnt)