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

Fixed submission:
import logging
import copy

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    S = input()
    S_len = len(S)
    child = [1 for _ in range(S_len)]
    logging.info("Hello!")

    R_counter = 1
    L_counter = 0
    R = [0 for _ in range(S_len)]
    L = [0 for _ in range(S_len)]
    L2R = 0
    R2L = 0
    
    for i in range(1, S_len):
        if S[i] == "R" and S[i - 1] == "R":
            R_counter += 1
        elif S[i] == "L" and S[i - 1] == "R":
            R2L = i
            R[i - 1] = R_counter
            R_counter = 0
            L_counter += 1
        elif S[i] == "L" and S[i - 1] == "L":
            L_counter += 1
        elif S[i] == "R" and S[i - 1] == "L":
            R[R2L] = L_counter
            L_counter = 0
            R_counter += 1

        if i == S_len - 1:
            R[R2L] = L_counter

    logging.info(R)

    counter = 0
    while counter < S_len:
        if (R[counter] != 0):
            temp1 = R[counter]
            temp2 = R[counter + 1]
            R[counter] = (temp1 - temp1 // 2) + (temp2 // 2)
            R[counter + 1] = (temp1 // 2) + (temp2 - temp2 // 2)
            
            counter += 1
        counter += 1
            

    answer = ""
    for x in R:
        answer += str(x)
        answer += " "

    print(answer)
            
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import logging
import copy

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    S = input()
    S_len = len(S)
    child = [1 for _ in range(S_len)]
    logging.info("Hello!")

    R_counter = 1
    L_counter = 0
    R = [0 for _ in range(S_len)]
    L = [0 for _ in range(S_len)]
    L2R = 0
    R2L = 0
    
    for i in range(1, S_len):
        if S[i] == "R" and S[i - 1] == "R":
            R_counter += 1
        elif S[i] == "L" and S[i - 1] == "R":
            R2L = i
            R[i - 1] = R_counter
            R_counter = 0
            L_counter += 1
        elif S[i] == "L" and S[i - 1] == "L":
            L_counter += 1
        elif S[i] == "R" and S[i - 1] == "L":
            R[R2L] = L_counter
            L_counter = 0
            R_counter += 1

        if i == S_len - 1:
            R[R2L] = L_counter

    logging.info(R)
    
    for i in range(1, S_len):
        if R[i] != 0 and i % 2 == 1:
            temp1 = (R[i] + R[i + 1]) // 2
            temp2 = R[i] + R[i+1] - temp1
            R[i] = temp1
            R[i + 1] = temp2

    answer = ""
    for x in R:
        answer += str(x)
        answer += " "

    print(answer)
            
    
if __name__ == "__main__":
    main()
Problem p02984 (python)

Fixed submission:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

N = int(input())
a_ = list(int(x) for x in input().split())
X_ = [0 for _ in range(N)]

X_sum = sum(a_)
logging.info("sum = " + str(X_sum))

X_[0] = X_sum - 2 * sum(a_[1::2])
logging.info("X_1 = " + str(X_[0]))

for i in range(1, N):
    X_[i] = 2 * a_[i - 1] - X_[i - 1]

answer = ""
for i in X_:
    answer += str(i)
    answer += " "

print(answer)

Buggy submission (verdict: Runtime Error):
from numpy.linalg import solve

N = int(input())
right = list(int(x) * 2 for x in input().split())
 
left = []

for i in range(N):
    num = []
    for j in range(N):
        if j == i or j == (i + 1):
            num.append(1)
        else:
            num.append(0)
        if i == N - 1:
            num[0] = 1        
    left.append(num)

answer = ""
for a in solve(left, right):
    answer += str(int(a))
    answer += " "

print(answer)
Problem p02990 (python)

Fixed submission:
import logging
import math

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

def P(n, r):
    return math.factorial(n) // math.factorial(abs(n - r))

def C(n, r):
    return P(n, r) // math.factorial(r)

N, K = (int(x) for x in input().split())
red_N = N -K


for i in range(1, K + 1):
    div_red_c = 0
    div_blue_c = C(K - 1, i - 1)
    div_red_c = C(red_N + 1, i)
    
    ans = (div_blue_c * div_red_c) % (10 ** 9 + 7)
    print(ans)

Buggy submission (verdict: Runtime Error):
import logging
import math

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

def P(n, r):
    return math.factorial(n) // math.factorial(n - r)

def C(n, r):
    return P(n, r) // math.factorial(r)

N, K = (int(x) for x in input().split())
red_N = N -K


for i in range(1, K + 1):
    div_red_c = 0
    div_blue_c = C(K - 1, i - 1)
    div_red_c = C(red_N + 1, i)
    
    ans = (div_blue_c * div_red_c) % (10 ** 9 + 7)
    print(ans)
Problem p03013 (python)

Fixed submission:
import logging
from math import factorial

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

steps_memo =[0 for _ in range(150000)]
def cal_steps(num):
    steps_memo[0] = 1
    steps_memo[1] = 1

    for i in range(2, num):
        steps_memo[i] = steps_memo[i - 1] + steps_memo[i - 2]

    return steps_memo[num - 1]
    
def main():
    N, M = (int(x) for x in input().split())
    a_s = [int(input()) for _ in range(M)]

    logging.info(a_s)
    
    a_s.append(N + 1)
    a_s.insert(0, -1)
    diff_a = [a_s[i + 1] - a_s[i] - 1 for i in range(M + 1)]

    if diff_a[0] == 0:
        diff_a[0] = 1
    
    logging.info(diff_a)

    
    answer = 1
    for i in diff_a:
        answer *= int(cal_steps(i))

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

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import logging
from math import factorial

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

steps_memo =[0 for _ in range(100000)]
def cal_steps(num):
    steps_memo[0] = 1
    steps_memo[1] = 1

    for i in range(2, num):
        steps_memo[i] = steps_memo[i - 1] + steps_memo[i - 2]

    return steps_memo[num - 1]
    
def main():
    N, M = (int(x) for x in input().split())
    a_s = [int(input()) for _ in range(M)]

    logging.info(a_s)
    
    a_s.append(N + 1)
    a_s.insert(0, -1)
    diff_a = [a_s[i + 1] - a_s[i] - 1 for i in range(M + 1)]

    if diff_a[0] == 0:
        diff_a[0] = 1
    
    logging.info(diff_a)

    
    answer = 1
    for i in diff_a:
        answer *= int(cal_steps(i))

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

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import logging
from math import factorial

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

steps_memo =[0 for _ in range(10000)]
def cal_steps(num):
    steps_memo[0] = 1
    steps_memo[1] = 1

    for i in range(2, num):
        steps_memo[i] = steps_memo[i - 1] + steps_memo[i - 2]

    return steps_memo[num - 1]
    
def main():
    N, M = (int(x) for x in input().split())
    a_s = [int(input()) for _ in range(M)]

    logging.info(a_s)
    
    a_s.append(N + 1)
    a_s.insert(0, -1)
    diff_a = [a_s[i + 1] - a_s[i] - 1 for i in range(M + 1)]

    if diff_a[0] == 0:
        diff_a[0] = 1
    
    logging.info(diff_a)

    
    answer = 1
    for i in diff_a:
        answer *= int(cal_steps(i))

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

if __name__ == "__main__":
    main()
Problem p02753 (python)

Fixed submission:
s = input()
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
for n in range(10000):
    x = math.floor(n * 0.08)
    y = math.floor(n * 0.1)
    if a == x and b == y:
        print(n)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
for _ in range(q):
    split = input().split()
    if split[0] == '1':
        s = s[::-1]
    else:
        if split[1] == '1':
            s = split[2] + s
        else:
            s = s + split[2]
print(s)
Problem p02819 (python)

Fixed submission:
x = int(input())
flag = 1

while True:
    if x == 2:
        break
    for i in range(3, x):
    #print("i is " + str(i))
        if x % i == 0:
            flag = 0
            break
    if flag == 1:
        break
    else:
        flag=1
        x += 1
print(x)

Buggy submission (verdict: Runtime Error):
x = int(input())
flag = 1

while True:
    if x == 2:
        break
    for i in range(3, x):
    #print("i is " + str(i))
    if x % i == 0:
        flag = 0
        break
    if flag == 1:
        break
    else:
        flag=1
        x += 1
print(x)
Problem p02831 (python)

Fixed submission:
from fractions import gcd

def lcm(a,b):
    return a*b//gcd(a,b)


A,B=map(int,input().split())
print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import numpy as np

def lcm(a,b):
    return a*b//np.gcd(a,b)


A,B=map(int,input().split())
print(lcm(A,B))
Problem p02860 (python)

Fixed submission:
def SsSl(): return list(map(lambda x: x, input()))

n = int(input())
#List = [s for s in input().split()]
List = SsSl()

if n%2==1:
    print("No")
else:
    if List[0:(n//2)]==List[(n//2):]:
        print("Yes")
    else:
        #print(List[0:(n/2)])
        #print(List[(n/2):])
        print("No")

Buggy submission (verdict: Runtime Error):
def SsSl(): return list(map(lambda x: x, input()))

n = int(input())
#List = [s for s in input().split()]
List = SsSl()

if n%2==1:
    print("No")
else:
    if List[0:(n/2)]==List[(n/2):]:
        print("Yes")
    else:
        #print(List[0:(n/2)])
        #print(List[(n/2):])
        print("No")

Buggy submission (verdict: Runtime Error):
def SsSl(): return list(map(lambda x: x, input()))

n = int(input())
#List = [s for s in input().split()]
List = SsSl()

if n%2==1:
    print('No')
else:
    if List[0:(n/2)]==List[(n/2):]:
        print('Yes')
    else:
        #print(List[0:(n/2)])
        #print(List[(n/2):])
        print('No')

Buggy submission (verdict: Runtime Error):
def SsSl(): return list(map(lambda x: x, input()))

n = int(input())
#List = [s for s in input().split()]
List = SsSl()

if n%2==1:
    print('No')
else:
    if List[0:(n/2)]==List[(n/2):]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
def SsSl(): return list(map(lambda x: x, input()))

n = int(input())
#List = [s for s in input().split()]
List = SsSl()

if n%2==1:
    print('No')
else:
    if List[0:(n/2)]==List[(n/2):]:
        print('Yes')
    else:
        print('No')
Problem p02862 (python)

Fixed submission:
from numpy.linalg import solve

#制約
MOD = 10**9 +7
MAX = 10**6

#　組み合わせ計算
def COM(n, r):
    fac = [1, 1]
    finv = [1, 1]
    inv = [0, 1]
    for i in range(2, MAX):
        fac.append(fac[i - 1] * i % MOD)
        inv.append(-inv[MOD % i] * (MOD // i))
        finv.append(finv[i - 1] * inv[i] % MOD)
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD

x,y = map(int,input().split())

if (x+y)%3 != 0:
    print(0)
    exit()

l = solve([[2, 1], [1, 2]], [x, y])
if l[0] < 0 or l[1] < 0: #n,m <0の時0
    print(0)
    exit()
# n+m回のうち，どのn回で移動するか n+mCOMnを計算
print(COM(int(l[0]+l[1]), int(l[0])))

Buggy submission (verdict: Runtime Error):
from numpy.linalg import solve

#制約
MOD = 10**9 +7
MAX = 10**6

#　組み合わせ計算
def COM(n, r):
    fac = [1, 1]
    finv = [1, 1]
    inv = [0, 1]
    for i in range(2, MAX):
        fac.append(fac[i - 1] * i % MOD)
        inv.append(-inv[MOD % i] * (MOD // i))
        finv.append(finv[i - 1] * inv[i] % MOD)
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD

x,y = map(int,input().split())

if (x+y)%3 != 0:
    print(0)
    exit()

l = solve([[2, 1], [1, 2]], [x, y])
if l[0] < 0 or l[1] < 0: #n,m <0の時0
    print(0)
    exit()
# n+m回のうち，どのn回で移動するか n+mCOMnを計算
print(COM(int(l[0]+l[1]), int(l[0])))
Problem p02879 (python)

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

if (a<=9) and (b<=9):
    print(a*b)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
flag = 0

for i in range(1,10):
    for j in range(1,10):
        if i*j == n:
            flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")
Problem p02622 (python)

Fixed submission:
input1 = input()
input2 = input()

def match(x, y):
    i = 0
    if x is y:
        i = 1
    return i

result_list = list(map(match, input1, input2))
print(result_list.count(0))

Buggy submission (verdict: Runtime Error):
input1 = input()
input2 = input()

def match(x, y):
    i = 0
    if x is y:
        i = 1
    return i

result_list = map(match, input1, input2)
print(result_list.count(0))
Problem p02831 (python)

Fixed submission:
import fractions
(A, B) = list(map(int, input().split()))
print((A * B) // fractions.gcd(A, B))

Buggy submission (verdict: Runtime Error):
from fractions import math
(A, B) = list(map(int, input().split()))
print((A * B) // gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math
(A, B) = list(map(int, input().split()))
print((A * B) // math.gcd(A, B))
Problem p03104 (python)

Fixed submission:
start_A, end_B = map(long, raw_input().split())

result = 0
if start_A == end_B:
  result = start_A
else:
  num_count = end_B - start_A + 1
  if start_A % 2 == 0:
    num_pair = num_count // 2
    if num_count % 2 == 0:
      result = num_pair % 2
    else:
      result = (num_pair % 2) ^ end_B
  else:
    num_pair = (num_count - 1) // 2
    if (num_count - 1) % 2 == 0:
      result = start_A ^ (num_pair % 2)       
    else:
      result = start_A ^ (num_pair % 2) ^ end_B

print result

Buggy submission (verdict: Runtime Error):
start_A, end_B = map(long, raw_input().split())
  
xor_result = start_A
for i in range(start_A + 1, end_B + 1):
  xor_result = xor_result ^ i
print(xor_result)

Buggy submission (verdict: Runtime Error):
start_A, end_B = map(long, raw_input().split())
  
xor_result = start_A
if start_A == end_B:
  xor_result = 0
else:
  for i in range(start_A + 1, end_B + 1):
    xor_result = xor_result ^ i
print(xor_result)

Buggy submission (verdict: Runtime Error):
start_A, end_B = map(long, raw_input().split())
  
xor_result = start_A
if start_A == end_B:
  xor_result = 0
else:
  for i in range(start_A + 1, end_B + 1):
    xor_result = xor_result ^ i
    print("  %d %s %d %s" % (i, bin(i), xor_result, bin(xor_result)))
print(xor_result)

Buggy submission (verdict: Runtime Error):
start_A, end_B = map(long, raw_input().split())
  
xor_result = start_A
for i in range(start_A + 1, end_B + 1):
  xor_result = xor_result ^ i
print(xor_result)

Buggy submission (verdict: Runtime Error):
start_A, end_B = map(int, raw_input().split())
  
xor_result = start_A
for i in range(start_A + 1, end_B + 1):
  xor_result = xor_result ^ i
print(xor_result)
Problem p02771 (python)

Fixed submission:
l = list(map(int, input().split()))
A = l[0]
B = l[1]
C = l[2]

if(A == B):
    if(A != C):
        print("Yes")
    else:
        print("No")
else:
    if(A != C):
        if(B == C):
            print("Yes")
        else: print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = (int)(input())
A = [input() for i in range(N)]

B = Counter(A)


max = [kv for kv in B.items() if kv[1] == max(B.values())]

for i in reversed(max):
    print(i[0])
Problem p02679 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
# sys.setrecursionlimit(1000000)
N = int(input())
data = defaultdict(int)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a, b = (0,0)はそれを入れるのみなので，
# カウントから抜かして(a,b)の数を最後に足せば良い
# どちらかが0の場合は，
# a=0ならb=0のモノが対比となる

cnt_zero = 0

for i in range(N):
    a, b = map(int, input().split())
    div = gcd(abs(a), abs(b))

    # マイナスはaだけ
    if a <0 and b <0:
        a, b = -a, -b
    elif b < 0:
        a, b = -a, -b

    if a ==0 and b==0:
        cnt_zero += 1
        continue

    if a ==0:
        data[(0, 1)] += 1
        data[(1, 0)] += 0
        continue

    if b ==0:
        data[(1, 0)] += 1
        data[(0, 1)] += 0
        continue

    data[(a//div, b//div)] += 1
    if a > 0:
        data[(-b//div, a//div)] += 0
    else:
        data[(b // div, -a // div)] += 0

mod = 1000000007
res = 1


for d in data:
    if d[0]>0 and d[1]>0:
        val = data[d]
        a1 = data[(-d[1], d[0])]
        # print(d, val, a1)
        if val == 0:
            res *= pow(2, a1, mod)
        elif a1 > 0:
            res *= pow(2, val, mod) + pow(2, a1, mod) - 1
            data[(-d[1], d[0])] = 0
        else:
            res *= pow(2, val, mod)
        res %= mod
        # print(res)
    # aが0の場合
    if d[0]==0:
        val = data[d]
        a1 = data[(1, 0)]

        if val == 0:
            res *= pow(2, a1, mod)
        elif a1 > 0:
            res *= pow(2, val, mod) + pow(2, a1, mod) - 1
        else:
            res *= pow(2, val, mod)
        res %= mod

print((res+cnt_zero-1)%mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
# sys.setrecursionlimit(1000000)
N = int(input())
data = defaultdict(int)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a, b = (0,0)はそれを入れるのみなので，
# カウントから抜かして(a,b)の数を最後に足せば良い
# どちらかが0の場合は，
# a=0ならb=0のモノが対比となる

cnt_zero = 0

for i in range(N):
    a, b = map(int, input().split())
    div = gcd(abs(a), abs(b))

    # マイナスはaだけ
    if a <0 and b <0:
        a, b = -a, -b
    elif b < 0:
        a, b = -a, -b

    if a ==0 and b==0:
        cnt_zero += 1
        continue

    if a ==0:
        data[(0, 1)] += 1
        data[(1, 0)] += 0
        continue

    if b ==0:
        data[(1, 0)] += 1
        data[(0, 1)] += 0
        continue

    data[(a//div, b//div)] += 1
    if a > 0:
        data[(-b//div, a//div)] += 0
    else:
        data[(b // div, -a // div)] += 0

mod = 1000000007
res = 1


for d in data:
    if d[0]>=0 and d[1]>=0:
        val = data[d]
        a1 = data[(-d[1], d[0])]
        # print(d, val, a1)
        if val == 0:
            res *= pow(2, a1, mod)
        elif a1 > 0:
            res *= pow(2, val, mod) + pow(2, a1, mod) - 1
            data[(-d[1], d[0])] = 0
        else:
            res *= pow(2, val, mod)
        res %= mod
        # print(res)


print(res+cnt_zero-1)
Problem p02729 (python)

Fixed submission:
# -*- coding: utf-8 -*-

'''
2 1
'''

# n1 偶数
n1, n2 = map(int, input().split())

# 奇数＋奇数 /  偶数+偶数
print(int(n1 * (n1-1) / 2 + (n2 * (n2-1))/2))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import numpy as np

H, W, K = map(int, input().split())

data = np.array([[None] * W for _ in range(H)])

for i in range(H):
    temp = input()
    for j in range(W):
        data[i, j] = int(temp[j])


current_best = np.inf

# Hに関する全ての場合を試す
for cnt in range(2 ** (H-1)):
    # bitで1の場所が切れ目とする
    option_h = np.array([int(s) for s in list(bin(cnt))[2:][::-1]])
    kireme = np.where(option_h == 1)[0]

    # 各グループについて1の数を集計する
    li = 0
    g = np.array([[None] * W for _ in range(len(kireme) + 1)])
    if len(kireme) == 0:
        g[0] = data[li:, :].sum(axis=0)
    else:
        for cnt, j in enumerate(kireme):
            g[cnt] = data[li:j+1, :].sum(axis=0)
            li = j + 1
        g[-1] = data[li:, :].sum(axis=0)

    # 左から順に足していく
    score = len(kireme)
    if score > current_best:
        # すでにこの時点で回数かかっていれば探索打ち切り
        continue
    cnt = np.zeros(len(kireme) + 1)
    for col in range(W):
        cnt = cnt + g[:, col]
        # どこか1つのグループでもKを超えてしまったらその左で切る
        if (cnt > K).any():
            score += 1
            # 最小を求めたいので、それまでの結果と同じ値になってしまったら終了
            if score >= current_best:
                break
            cnt = g[:, col]
            # 現在の列だけで条件を満たせないのであれば不可能なので終了
            if (cnt > K).any():
                score = np.inf
                break
    # スコアの更新
    if score < current_best:
        current_best = score


print(current_best)
Problem p02763 (python)

Fixed submission:
# -*- coding: utf-8 -*-

'''
7
abcdbbd
6
2 3 6
1 5 z
2 1 1
1 4 a
1 7 d
2 1 7
'''

# from helper import elapsed_time
from bisect import bisect_left, insort_left


N = int(input())
s = list(input())
Q = int(input())

# a-zまでの26文字に対して、s文字列の各文字に該当するindexを格納しておく
d = {i: [] for i in range(26)}
for i, c in enumerate(s):
    d[ord(c) - ord("a")].append(i)


# @elapsed_time
def convert(d: dict, s: list, q1: int, q2: str):
    if s[q1] == q2:
        return d, s

    didx_before = ord(s[q1]) - ord("a")
    didx_after = ord(q2) - ord("a")

    idx = bisect_left(d[didx_before], q1)
    d[didx_before].pop(idx)
    s[q1] = q2
    insort_left(d[didx_after], q1)

    return d, s


# @elapsed_time
def calc(d: dict, q1: int, q2: int):
    ans = 0
    for i in range(26):
        idx = bisect_left(d[i], q1)
        if d[i] and q1 <= d[i][-1] and d[i][idx] < q2 + 1:
            ans += 1

    return ans


for _ in range(Q):
    q, q1, q2 = input().split()
    q = int(q)
    if q == 1:
        d, s = convert(d, s, int(q1) - 1, q2)
    if q == 2:
        print(calc(d, int(q1) - 1, int(q2) - 1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

'''
111
abcdbbdtyyuhgjhguytuhgjhguyrtyetrdhggjutftfuyfyyabcdbbdtyyuhgjhguytuhgjhguyrtyetrdhggjutftfuyfyyabcdbbdtyyuhgjh
6
2 3 6
1 5 z
2 1 50000
1 4 a
1 7 d
2 1 1000000
'''

'''
7
abcdbbd
6
2 3 6
1 5 z
2 1 1
1 4 a
1 7 d
2 1 7
'''

from helper import elapsed_time
from bisect import bisect_left, insort_left


N = int(input())
s = list(input())
Q = int(input())

# s = s * 5000
# print()
# print(len(s))

# a-zまでの26文字に対して、s文字列の各文字に該当するindexを格納しておく
d = {i: [] for i in range(26)}
for i, c in enumerate(s):
    d[ord(c) - ord("a")].append(i)
# print(d)


@elapsed_time
def convert(d: dict, s: list, q1: int, q2: str):
    if s[q1] == q2:
        return d, s

    didx_before = ord(s[q1]) - ord("a")
    didx_after = ord(q2) - ord("a")

    idx = bisect_left(d[didx_before], q1)
    d[didx_before].pop(idx)
    s[q1] = q2
    insort_left(d[didx_after], q1)

    # return s[:q1] + q2 + s[q1+1:]
    # s[q1] = q2
    return d, s


@elapsed_time
def calc(d: dict, q1: int, q2: int):
    ans = 0
    for i in range(26):
        idx = bisect_left(d[i], q1)
        if d[i] and q1 <= d[i][-1] and d[i][idx] < q2:
            ans += 1
    '''
    st = time.time()
    temp1 = s[q1:q2 + 1]
    print(f'>>- extract: {time.time()-st}')

    st = time.time()
    temp2 = set(temp1)
    print(f'>>- to set: {time.time()-st}')
    ans = len(list(temp2))
    '''

    return ans


for _ in range(Q):
    q, q1, q2 = input().split()
    q = int(q)
    if q == 1:
        d, s = convert(d, s, int(q1) - 1, q2)
    if q == 2:
        print(calc(d, int(q1) - 1, int(q2) - 1))
Problem p02815 (python)

Fixed submission:

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

ans = 0
mod = 10**9 + 7

for l in range(N):
    r = N - l - 1
    if r > 0:
        ans += C[l] * (pow(2, r-1, mod) * r + pow(2, r, mod)) * pow(2, l, mod)
    else:
        ans += C[l] * (pow(2, r, mod)) * pow(2, l, mod)
        
print(int(ans * pow(2, N, mod)) % mod)

Buggy submission (verdict: Runtime Error):

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

ans = 0
mod = 10**9 + 7

for l in range(N):
    r = N - l - 1
    ans += C[l] * (pow(2, r-1, mod) * r + pow(2, r, mod)) * pow(2, l, mod)

print(int(ans * pow(2, N, mod)) % mod)
Problem p02831 (python)

Fixed submission:

import fractions
a, b = map(int, input().split())

print(int(a * b / fractions.gcd(a, b)))

Buggy submission (verdict: Runtime Error):

import math
a, b = map(int, input().split())

print(int(a * b / math.gcd(a, b)))
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = map(int, input().split())
C = 0
for i in range(A,B+1):
  if i%K == 0:
    print('OK')
    C = 1
    break
if C == 0:
  print('NG')

Buggy submission (verdict: Runtime Error):
K = int(input().split())
A, B = map(int, input().split())
for i in range(A,B+1):
  if i%K == 0:
    print('OK')
  else:
    print('NG')