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

Fixed submission:
# 入力の取得
s = input()

even = ""
odd  = ""

#1文字ずつループ
for idx,s in enumerate(s):
    if idx == 0 or idx % 2 == 0:
        even += s
    else:
        odd += s

#判定
even = even.replace('R', '').replace('U', '').replace('D', '')
odd  = odd.replace('L', '').replace('U', '').replace('D', '')


if even == "" and odd == "":
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# 入力の取得
s = input()

even = ""
odd  = ""

#1文字ずつループ
for idx,s in enumerate(s):
    if idx = 0 or idx % 2 == 0:
        even += s
    else:
        odd += s

#判定
even = even.replace('R', '').replace('U', '').replace('D', '')
odd  = odd.replace('L', '').replace('U', '').replace('D', '')


if even = "" and odd = "":
    print("Yes")
else:
    print("No")
Problem p03000 (python)

Fixed submission:
# 入力の取得(1行目。数値)
i = list(map(int, input().split()))

# 変数セット
boundCnt = i[0]
limit = i[1]

# 入力の取得(2行目。数値)
landpoints = list(map(int, input().split()))
#1回目のバウンド情報を加算(0座標)
landpoints.insert(0,0)
boundCnt += 1

nowCnt = 0
nowLandpoints = 0

for i in range(boundCnt):

   nowLandpoints += landpoints[i]
   if nowLandpoints > limit:
      break

   nowCnt += 1

print(nowCnt )

Buggy submission (verdict: Runtime Error):
# 入力の取得(1行目。数値)
i = list(map(int, input().split()))

# 変数セット
boundCnt = i[0]
limit = i[1]

# 入力の取得(2行目。数値)
landpoints = list(map(int, input().split()))

nowCnt = 0
nowLandpoints = 0
for i in range(boundCnt + 1):
    if nowLandpoints > limit:
        break
    nowCnt += 1
    nowLandpoints += landpoints[i]

print(nowCnt)
Problem p02613 (python)

Fixed submission:
n=int(input())
a=0
w=0
t=0
r=0
for i in range(n):
    code=input()
    if code=='AC':
        a += 1
    elif code=='WA':
        w += 1
    elif code=='TLE':
        t += 1
    else:
        r += 1
print('AC x ',a)
print('WA x ',w)
print('TLE x ',t)
print('RE x ',r)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=0
w=0
t=0
r=0
for i in range(n):
    code=input()
    if code=='AC':
        a += 1
    elif code=='WA':
        w += 1
    elif code=='TLE':
        t += 1
    else:
        r += 1
print('AC x 'a)
print('WA x 'w)
print('TLE x 't)
print('RE x 'r)
Problem p02811 (python)

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

if 500*K >= X:
  print('Yes')
else:
  print('No')

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

if 500＊K　>=　X:
  print('yes')
else:
  print('no')

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

if 500*K >= X:
  print('yes')
else:
  print('no')

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

if 500*K>=X:
  print('yes')
else:
  print('no')

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

if 500*K>=X:
  print("yes")
else:
  print("no")

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

if 500*K>=X:
  print("yes")
else:
  print("no")

Buggy submission (verdict: Runtime Error):
K,X=input().split
if K*2>X:
  print("yes")
else:
  print("no")
Problem p02848 (python)

Fixed submission:
N=int(input())
S=input()
abc_list="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L=len(abc_list)
ans= " "
for i in S:
  ans += abc_list[(abc_list.index(i)+N) % L]
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
abc_list="abcdefghijklmnopqrstuvwxyz"
L=len(abc_list)
ans= " "
for i in S:
  ans += abc_list[(abc_list.index(i)+N) % L]
print(ans)
Problem p02909 (python)

Fixed submission:
s=("Sunny","Cloudy","Rainy")
print(s[(s.index(input())+1)%3])

Buggy submission (verdict: Runtime Error):
s=("sunny","cloudy","rainy")
print(s[(s.index(input())+1)%3])
Problem p02923 (python)

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

ans=0
sum=0
for i in range(N-1):
    if H[i]>=H[i+1]:
        sum += 1
    else:
        sum = 0
    ans = max(ans,sum)
print(ans)

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

L=[]
for i in range(N-1):
    sum=0
    while H[i]>=H[i+1] :
        sum += 1
        i += 1
        if i==N-1:
            break
    L += str(sum)
print(max(L))
Problem p03006 (python)

Fixed submission:
n=int(input())
L=[]
for _ in range(n):
    l=list(map(int,input().split()))
    L.append(l)
if n==1:
    print(1)
    exit()
pq=[]
ans=[]
for i in range(n-1):
    for j in range(i+1,n):
        x=L[i][0]-L[j][0]
        y=L[i][1]-L[j][1]
        if [x,y] in pq:
            ans[pq.index([x,y])] += 1
        elif [-x,-y] in pq:
            ans[pq.index([-x,-y])] += 1
        else:
            pq.append([x,y])
            ans.append(1)

print(n-max(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
L=[]
for _ in range(n):
    l=list(map(int,input().split()))
    L.append(l)
pq=[]
ans=[]
for i in range(n-1):
    for j in range(i+1,n):
        x=L[i][0]-L[j][0]
        y=L[i][1]-L[j][1]
        if [x,y] in pq:
            ans[pq.index([x,y])] += 1
        elif [-x,-y] in pq:
            ans[pq.index([-x,-y])] += 1
        else:
            pq.append([x,y])
            ans.append(1)

print(n-max(ans))
Problem p03089 (python)

Fixed submission:
n=int(input())
L=list(map(int,input().split()))
for i in range(n):
    if L[i]>i+1:
        print(-1)
        exit()
def mal(x):
    if len(x)==0:
        return []
    else:
        t=max(x)
        i=x.index(t)
        k=i-1
        while k>i-t:
            if x[k]>t-i+k:
                t=x[k]
                i=k
            k -= 1
        after=x[:i-t+1]
        before=x[i-t+1:]
        before.remove(t)
        return mal(before)+[t]+mal(after)
ans=mal(L)

for i in range(n):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
L=list(map(int,input().split()))
ans=[]
for i in range(n):
    if L[i]>i+1:
        print(-1)
        exit()
def mal(x):
    if len(x)==0:
        return []
    else:
        t=max(x)
        i=x.index(t)
        after=x[:i-t+1]
        before=x[i-t+1:]
        before.remove(t)
        return mal(before)+[t]+mal(after)
ans=mal(L)

for i in range(n):
    print(ans[i])
Problem p03229 (python)

Fixed submission:
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))
     
if n==2:
    print(abs(a[0]-a[1]))
    exit()

a=sorted(a)
turn=(n-1)//2
pre=a[0]*2
ans=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans += new-pre
        m=p-a[n-i-3]
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans += pre-new
        m=a[i+2]-p
    pre=new

if n%2==0:
    ans += m

a=sorted(a,reverse=True)
pre=a[0]*2
ans1=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans1 += pre-new
        m=a[n-i-3]-p
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans1 += new-pre
        m=p-a[i+2]
    pre=new

if n%2==0:
    ans1 += m

las=max(ans,ans1)
print(las)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))

a=sorted(a)
turn=(n-1)//2
pre=a[0]*2
ans=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans += new-pre
        m=p-a[n-i-3]
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans += pre-new
        m=a[i+2]-p
    pre=new

if n%2==0:
    ans += m

a=sorted(a,reverse=True)
pre=a[0]*2
ans1=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans1 += pre-new
        m=a[n-i-3]-p
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans1 += new-pre
        m=p-a[i+2]
    pre=new

if n%2==0:
    ans1 += m

las=max(ans,ans1)
print(las)
Problem p03565 (python)

Fixed submission:
s=list(input())
ls=len(s)
t=list(input())
lt=len(t)
can=[]
for i in range(ls-lt,-1,-1):
    ok=0
    for j in range(lt):
        if s[i+j]==t[j] or s[i+j]=='?':
            ok+=1
    if ok==lt:
        c=[0]*ls
        for k in range(ls):
            if s[k]=='?':
                if k<i or k>=i+lt:
                    c[k]='a'
                else:
                    c[k]=t[k-i]
            else:
                c[k]=s[k]
        can.append(''.join(c))
if len(can)==0:
    print('UNRESTORABLE')
else:
    print(sorted(list(can))[0])

Buggy submission (verdict: Runtime Error):
s=list(input())
ls=len(s)
t=list(input())
lt=len(t)
can=set()
for i in range(ls-lt,-1,-1):
    ok=0
    for j in range(lt):
        if s[i+j]==t[j] or s[i+j]=='?':
            ok+=1
    if ok==lt:
        c=s
        for k in range(ls):
            if c[k]=='?':
                if k<i:
                    c[k]='a'
                else:
                    c[k]=t[k-i]
        can.add(''.join(c))
if len(can)==0:
    print('UNRESTORABLE')
else:
    print(list(can)[0])

Buggy submission (verdict: Runtime Error):
s=list(input())
ls=len(s)
t=list(input())
lt=len(t)
clear=0
for i in range(ls-lt,-1,-1):
    ok=0
    for j in range(lt):
        if s[i+j]==t[j] or s[i+j]=='?':
            ok+=1
    if ok==lt:
        clear=1
        break
if clear==0:
    print('UNRESTORABLE')
else:
    for k in range(ls):
        if s[k]=='?':
            if k<i:
                s[k]='a'
            else:
                s[k]=t[k-i]
    print(''.join(s))
Problem p03569 (python)

Fixed submission:
s=list(input())

ch=[]
for i in range(len(s)):
    if s[i]!='x':
        ch.append(s[i])

if len(ch)==0:
    print(0)
    exit()
for i in range(len(ch)//2):
    if ch[i]!=ch[len(ch)-i-1]:
        print(-1)
        exit()

ans=0
li=0
ri=0
for i in range(len(ch)//2+1):
    x=0
    while s[li]!=ch[i]:
        x += 1
        li += 1
    li += 1
    y=0
    while s[len(s)-1-ri]!=ch[len(ch)-1-i]:
        y += 1
        ri += 1
    ri += 1
    ans += abs(x-y)

print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())

ch=[]
for i in range(len(s)):
    if s[i]!='x':
        ch.append(s[i])
        
error=0
for i in range(len(ch)//2):
    if ch[i]!=ch[len(ch)-i-1]:
        error=1
        break

if error==1:
    print('-1')
else:
    ans=0
    li=0
    ri=0
    for i in range(len(ch)//2+1):
        x=0
        while s[li]!=ch[i]:
            x += 1
            li += 1
        li += 1
        y=0
        while s[len(s)-1-ri]!=ch[len(ch)-1-i]:
            y += 1
            ri += 1
        ri += 1
        ans += abs(x-y)
    print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())

ch=[]
for i in range(len(s)):
    if s[i]!='x':
        ch.append(s[i])
for i in range(len(ch)//2):
    if ch[i]!=ch[len(ch)-i-1]:
        print('-1')
        exit()

ans=0
li=0
ri=0
for i in range(len(ch)//2+1):
    x=0
    while s[li]!=ch[i]:
        x += 1
        li += 1
    li += 1
    y=0
    while s[len(s)-1-ri]!=ch[len(ch)-1-i]:
        y += 1
        ri += 1
    ri += 1
    ans += abs(x-y)
print(ans)
Problem p02658 (python)

Fixed submission:
N = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
prod = 1
for i in arr:
	prod *= i
	if prod>10**18:
		prod = -1
		break
print(prod)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = [int(x) for x in input().split()]
ans = arr[0]
for i in range(1,n):
	ans *= arr[i]
	if ans>1000000000000000000:
		ans = -1
        break
print(ans)
Problem p02574 (python)

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

def eratosthenes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    
    return [i for i in range(n+1) if is_prime[i]]

primecount = {}
primenum = [-1] * (A_MAX+1)
for p in eratosthenes(A_MAX):
    primecount[p] = 0
    for i in range(p, A_MAX+1, p):
        primenum[i] = p
    
for a in A:
    while a > 1:
        p = primenum[a]
        while a % p == 0:
            a //= p
        primecount[p] += 1

primecount[1] = 1
cnt = max(primecount.values())

if cnt == 1:    
    print('pairwise coprime')
elif cnt < N:
    print('setwise coprime')
else:
    print('not coprime')

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

def eratosthenes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    
    return [i for i in range(n+1) if is_prime[i]]

primecount = {}
primenum = [-1] * (A_MAX+1)
for p in eratosthenes(A_MAX):
    primecount[p] = 0
    for i in range(p, A_MAX+1, p):
        primenum[i] = p
    
for a in A:
    while a > 1:
        p = primenum[a]
        while a % p == 0:
            a //= p
        primecount[p] += 1

cnt = max(primecount.values())
if cnt == 1:    
    print('pairwise coprime')
elif cnt < N:
    print('setwise coprime')
else:
    print('not coprime')
Problem p02576 (python)

Fixed submission:
import math


n, x, t = map(int, input().split())
print(math.ceil(n / x) * t)

Buggy submission (verdict: Runtime Error):
from collections import deque


def solvemaze(y, x, num):
    maps.append([])
    dx, dy = (-1, 0, 1, 0), (0, -1, 0, 1)
    maze[y][x] = num
    que = deque()
    que.append((y, x))
    while que:
        y_, x_ = que.popleft()
        maps[num].append((y_, x_))
        for i in range(4):
            y2 = y_ + dy[i]
            x2 = x_ + dx[i]
            if 0 <= y2 < h and 0 <= x2 < w and maze[y2][x2] == '.':
                maze[y2][x2] = num
                que.append((y2, x2))

def makeroute(s_maps, num):
    for y, x in s_maps:
        for i in range(-2, 3):
            for j in range(-2, 3):
                y2 = y + i
                x2 = x + j
                if 0 <= y2 < h and 0 <= x2 < w:
                    num2 = maze[y2][x2]
                    if not  num2 in [0, '#'] + E[num]:
                        E[num].append(num2)
                        E[num2].append(num)
    

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [[x for x in input()] for _ in range(h)]
maps = []

num = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            solvemaze(i, j, num)
            num += 1

E = [[] for _ in range(num)]
for i in range(num):
    makeroute(maps[i], i)

s = maze[Ch-1][Cw-1]
g = maze[Dh-1][Dw-1]
used = [False] * num
used[s] = True
que = deque()
que.append((0, s))
cost = [float('inf')] * num
cost[s] = 0
while que:
    c, v = que.popleft()
    for e in E[v]:
        if not used[e]:
            que.append((c+1, e))
            cost[e] = c+1
            used[e] = True

if not used[g]:
    print(-1)
else:
    print(cost[g])
Problem p02675 (python)

Fixed submission:
N = input()
e = int(N[-1])
if e in (2,4,5,7,9):
    print('hon')
elif e in (0,1,6,8):
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
N = int(input())
e = int(N[-1])
if e in (2,4,5,7,9):
    print('hon')
elif e in (0,1,6,8):
    print('pon')
else:
    print('bon')
Problem p02747 (python)

Fixed submission:
string = input()
for i in range(len(string)):
    if i % 2 == 0:
        if string[i] == 'h':
            continue
        else:
            print('No')
            break
    elif i % 2 == 1:
        if string[i] == 'i':
            continue
        else:
            print('No')
            break
else:
    if len(string) % 2 == 1:
        print('No')
    else:
        print('Yes')

Buggy submission (verdict: Runtime Error):
s=input()
if len(s)%2=0 and s == 'hi'*len(s)//2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=input()
if len(s)%2=0 and s == 'hi'*len(s)//2:
    print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
string = input()
for i in range(len(string)):
    if i % 2 == 0:
        if string[i] == 'h':
            continue
        else:
            print('No')
            break
    elif i % 2 == 1:
        if string[i] == 'i':
            continue
        else:
            print('No')
            break
else:
  	if len(string) == 1:
      	print('No')
    else:
    	print('Yes')
Problem p02606 (python)

Fixed submission:
L,R,d = map(int,input().split())

ans = 0
for i in range(L,R+1):
    if i%d == 0:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
L,R,d = map(int,input().split())

ans = 0
for i in range(L,R+1):
    if i%d == 0
    ans += 1

print(ans)
Problem p02616 (python)

Fixed submission:
"""
9 5
-4 -3 -2 -1 0 1 2 3
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Am = []
Ap = []
for a in A:
    if a < 0:
        Am.append(a)
    else:
        Ap.append(a)

mod = 10**9 + 7

ans = 1

if N == K:
    for a in A:
        ans *= a
        ans %= mod

elif A[-1] < 0:
    if K % 2 == 1:
        for i in range(K):
            ans *= Am[-1-i]
            ans %= mod
    else:
        for i in range(K):
            ans *= Am[i]
            ans %= mod

else:
    if K%2 == 1:
        ans *= Ap[-1]
        ans %= mod
        K -= 1
        del Ap[-1]
    Amd = []     
    Apd = []
    for i in range(len(Ap)//2):
        Apd.append(Ap[-1-(2*i)]*Ap[-1-(2*i+1)])
    for i in range(len(Am)//2):
        Amd.append(Am[2*i]*Am[2*i+1])
    Apd.append(-1)
    Amd.append(-1)
    
    ip = 0
    im = 0
    while K > 0:
        if Apd[ip] >= Amd[im]:
            ans *= Apd[ip]
            ip += 1
        else:
            ans *= Amd[im]
            im += 1
        ans %= mod
        K -= 2


ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
"""
9 5
-4 -3 -2 -1 0 1 2 3
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Am = []
Ap = []
for a in A:
    if a < 0:
        Am.append(a)
    else:
        Ap.append(a)

mod = 10**9 + 7

ans = 1

if N == K:
    for a in A:
        ans *= a
        ans %= mod

elif A[-1] < 0:
    if K % 2 = 1
        for i in range(K):
            ans *= Am[-1-i]
            ans %= mod
    else:
        for i in range(K):
            ans *= Am[i]
            ans %= mod

else:
    if K%2 == 1:
        ans *= Ap[-1]
        ans %= mod
        K -= 1
        del Ap[-1]
    Amd = []     
    Apd = []
    for i in range(len(Ap)//2):
        Apd.append(Ap[-1-(2*i)]*Ap[-1-(2*i+1)])
    for i in range(len(Am)//2):
        Amd.append(Am[2*i]*Am[2*i+1])
    Apd.append(-1)
    Amd.append(-1)
    
    ip = 0
    im = 0
    while K > 0:
        if Apd[ip] >= Amd[im]:
            ans *= Apd[ip]
            ip += 1
        else:
            ans *= Amd[im]
            im += 1
        ans %= mod
        K -= 2


ans %= mod
print(ans)
Problem p02632 (python)

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

mod = 10**9+7

power25 = [1]*(K+1)
power26 = [1]*(K+1)

def mod_factorial(n, m):
    mod_factorials = [1] * (n + 1)
    for i in range(1, n+1):
        mod_factorials[i] = mod_factorials[i-1]*i
        mod_factorials[i] %= m
    return mod_factorials

# 1!,2!,3!,...,n! の逆元 (mod m)
def mod_inv_factorials2(n, m):
    mod_invs = [1] * (n + 1)
    invs = [1] * (n + 1)
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    for i in range(1, n+1):
        mod_invs[i] = invs[i]*mod_invs[i-1]
        mod_invs[i] %= m
    return mod_invs

factrials = mod_factorial(K+N,mod)
inv_factrials = mod_inv_factorials2(max(N,K+1),mod)

for i in range(1,K+1):
    power25[i] = (power25[i-1]*25)%mod
for i in range(1,K+1):
    power26[i] = (power26[i-1]*26)%mod

ans = 0
for i in range(K+1):
    rk = K-i
    ans += power25[rk]*factrials[rk+N-1]*inv_factrials[N-1]*inv_factrials[rk]*power26[i]
    ans %= mod

print(ans)

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

mod = 10**9+7

power25 = [1]*(K+1)
power26 = [1]*(K+1)

def mod_factorial(n, m):
    mod_factorials = [1] * (n + 1)
    for i in range(1, n+1):
        mod_factorials[i] = mod_factorials[i-1]*i
        mod_factorials[i] %= m
    return mod_factorials

# 1!,2!,3!,...,n! の逆元 (mod m)
def mod_inv_factorials2(n, m):
    mod_invs = [1] * (n + 1)
    invs = [1] * (n + 1)
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    for i in range(1, n+1):
        mod_invs[i] = invs[i]*mod_invs[i-1]
        mod_invs[i] %= m
    return mod_invs

factrials = mod_factorial(K+N,mod)
inv_factrials = mod_inv_factorials2(K+1,mod)

for i in range(1,K+1):
    power25[i] = (power25[i-1]*25)%mod
for i in range(1,K+1):
    power26[i] = (power26[i-1]*26)%mod

ans = 0
for i in range(K+1):
    rk = K-i
    ans += power25[rk]*factrials[rk+N-1]*inv_factrials[N-1]*inv_factrials[rk]*power26[i]
    ans %= mod

print(ans)
Problem p02639 (python)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0)+1)

Buggy submission (verdict: Runtime Error):
import bisect as bc
 
N = int(input())
A = list(map(int,input().split()))
A.sort()
 
dp = [True for _ in range(A[-1]+1)]
 
for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        dp[ai*j] = False
 
ans = 0
for i in range(N):
    if dp[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False
 
print(ans)
Problem p02642 (python)

Fixed submission:
import bisect as bc

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

dp = [True for _ in range(A[-1]+1)]

for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        if dp[ai*j]:
            dp[ai*j] = False

ans = 0
finish = [True for _ in range(A[-1]+1)]
for i in range(N):
    if dp[A[i]] and finish[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect as bc
 
N = int(input())
A = list(map(int,input().split()))
A.sort()
 
dp = [True for _ in range(A[-1]+1)]
 
for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        dp[ai*j] = False
 
ans = 0
for i in range(N):
    if dp[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False
 
print(ans)
Problem p02705 (python)

Fixed submission:
R=int(input())
print(2*R*3.1415926535)

Buggy submission (verdict: Runtime Error):
R=int(input())
print(2*R*3.1415926535

Buggy submission (verdict: Runtime Error):
R=int(input())
print(2*R*3.1415926535
Problem p02714 (python)

Fixed submission:
N=int(input())
S=input()
R=[0]*N
G=[0]*N
B=[0]*N

for i in range(N):
    if S[i]=="R":
        R[i]=1
    elif S[i]=="G":
        G[i]=1
    else:
        B[i]=1
R_S=[0]*N
G_S=[0]*N
B_S=[0]*N
R_S[0] = R[0]
G_S[0] = G[0]
B_S[0] = B[0]
for i in range(1,N):
    R_S[i]=R_S[i-1]+R[i]
    G_S[i]=G_S[i-1]+G[i]
    B_S[i]=B_S[i-1]+B[i]

ans=0
for j in range(1,N-1):
    char=S[j]
    if char=="G":
        ans += R_S[j-1]*(B_S[N-1]-B_S[j])
        ans += B_S[j-1]*(R_S[N-1]-R_S[j])
        min_len=min(j,N-1-j)
        for i in range(1,min_len+1):
            if (S[j-i]=="R" and S[j+i]=="B") or (S[j-i]=="B" and S[j+i]=="R"):
                ans -= 1
    if char=="R":
        ans += G_S[j-1]*(B_S[N-1]-B_S[j])
        ans += B_S[j-1]*(G_S[N-1]-G_S[j])
        min_len=min(j,N-1-j)
        for i in range(1,min_len+1):
            if (S[j-i]=="G" and S[j+i]=="B") or (S[j-i]=="B" and S[j+i]=="G"):
                ans -= 1
    if char=="B":
        ans += G_S[j-1]*(R_S[N-1]-R_S[j])
        ans += R_S[j-1]*(G_S[N-1]-G_S[j])
        min_len=min(j,N-1-j)
        for i in range(1,min_len+1):
            if (S[j-i]=="G" and S[j+i]=="R") or (S[j-i]=="R" and S[j+i]=="G"):
                ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
A=[a.rstrip() for a in sys.stdin.readlines(3)]
N=int(A[0])
S="".join(["A",A[1]])

a=0
ans=S.count("R")*S.count("G")*S.count("B")

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