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

Fixed submission:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    def is_valid(i, j):
        if (i > 0 and s[i - 1][j] == '#' or 
            i < H - 1 and s[i + 1][j] == '#' or 
            j > 0 and s[i][j - 1] == '#' or 
            j < W - 1 and s[i][j + 1] == '#'):
            return True
        return False

    for i, R in enumerate(s):
        for j, c in enumerate(R):
            if c == '#' and not is_valid(i, j):
                print(NO)
                return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    def is_valid(i, j):
        if (i > 0 and s[i - 1][j] == '#' or 
            i < H - 1 and s[i + 1][j] == '#' or 
            j > 0 and s[i][j - 1] == '#' or 
            j < W - 1 and s[i][j + 1] == '#'):
            return True
        return False

    for i, R in enumerate(s):
        for j, c in enumerate(R):
            if c == '#' and not is_valid(i, j):
                print(NO)
                return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(W) ]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()
Problem p03657 (python)

Fixed submission:
#!/usr/bin/env python3
import sys

YES = "Possible"  # type: str
NO = "Impossible"  # type: str

def solve(A: int, B: int):
    if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]", b: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[a[i] - 1].append(b[i] - 1)
        conn[b[i] - 1].append(a[i] - 1)

    def dfs(idx, cur, conn, dis):
        dis[idx] = cur
        for nex in conn[idx]:
            if dis[nex] is None:
                dfs(nex, cur + 1, conn, dis)
        return None

    f_dis = [None] * N
    f_dis[0] = 0
    dfs(0, 0, conn, f_dis)

    s_dis = [None] * N
    s_dis[N - 1] = 0
    dfs(N - 1, 0, conn, s_dis)

    cnt = 0
    for i in range(N):
        if f_dis[i] <= s_dis[i]:
            cnt += 1

    if cnt > (N - cnt):
        ret = 'Fennec'
    else:
        ret = 'Snuke'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()
Problem p03660 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]", b: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[a[i] - 1].append(b[i] - 1)
        conn[b[i] - 1].append(a[i] - 1)

    def dfs(idx, cur, conn, dis):
        dis[idx] = cur
        for nex in conn[idx]:
            if dis[nex] is None:
                dfs(nex, cur + 1, conn, dis)
        return None

    f_dis = [None] * N
    f_dis[0] = 0
    dfs(0, 0, conn, f_dis)

    s_dis = [None] * N
    s_dis[N - 1] = 0
    dfs(N - 1, 0, conn, s_dis)

    cnt = 0
    for i in range(N):
        if f_dis[i] <= s_dis[i]:
            cnt += 1

    if cnt > (N - cnt):
        ret = 'Fennec'
    else:
        ret = 'Snuke'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]", b: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[a[i] - 1].append(b[i] - 1)
        conn[b[i] - 1].append(a[i] - 1)
    def find_path(idx, target, conn, visited):
        visited[idx] = True
        if idx == target:
            return [target]
        for nex in conn[idx]:
            if not visited[nex]:
                path = find_path(nex, target, conn, visited)
                if path is not None:
                    return [idx] + path
        return None

    visited = [False] * N
    path_to_n = find_path(0, N - 1, conn, visited)
    #print(path_to_n)

    colors = [None] * N
    for i, node in enumerate(path_to_n):
        if i < (len(path_to_n) + 1) / 2:
            colors[node] = True
        else:
            colors[node] = False

    def dfs(idx, conn, colors):
        colors[idx] = True
        for nex in conn[idx]:
            if colors[nex] is None:
                dfs(nex, conn, colors)
        return

    cnt = 0
    dfs(0, conn, colors)
    #print(colors)
    for c in colors:
        if c:
            cnt += 1
    if cnt > (N - cnt):
        ret = 'Fennec'
    else:
        ret = 'Snuke'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()
Problem p02705 (python)

Fixed submission:
import math
print(int(input()) * 2 * math.pi)

Buggy submission (verdict: Runtime Error):
import math
print(r * 2 * math.pi)
Problem p02706 (python)

Fixed submission:
N,M = map(int,input().split())
homeworks = [int(i) for i in input().split()]
print(-1 if sum(homeworks) > N else N - sum(homeworks))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
homeworks = [int(i) for i in input().split()]
print(-1 if sum(homeworks) > N else sum(homeworks) - N))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().splti())
homeworks = [int(i) for i in input().splti()]
print(-1 if sum(homeworks) > N else sum(homeworks) - N))
Problem p02755 (python)

Fixed submission:
a,b = map(int,input().split())
magic = 1
ans = -1

while a >= (magic * 0.08) // 1 and b >= ( magic * 0.1) // 1:
    if a == (magic * 0.08) // 1 and b == ( magic * 0.1) // 1:
        ans = magic
        break
    magic += 1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split)
magic = 0
ans = -1

while a > magic * 0.08 and b > magic * 0.1:
    if magic * 0.08 == a and  magic * 0.1 == b:
        ans = magic * 0.08
        break
    magic +=  1
print(ans)
Problem p02817 (python)

Fixed submission:
s = input().split()
print(s[1]+s[0])

Buggy submission (verdict: Runtime Error):
print('',join(input().split()))
Problem p02886 (python)

Fixed submission:
n = int(input())
data = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans += data[i]*data[j]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
data = [int(i) for i input().split()]
ans = 0
for i in range(n):
  for j in range(i+1,n):
    ans += data[i]*data[j]
print(ans)
Problem p02945 (python)

Fixed submission:
a,b = map(int, input().split())
print(max(a+b,a*b,a-b))

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
print(max(a+b,a*b,a-b)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
print(max(a+b,a*b,a-
Problem p02971 (python)

Fixed submission:
n = int(input())
a_max = 0
data = [int(input()) for i in range(n)]
a_max = max(data)
flag = True if 2 <= data.count(a_max) else False
for i in range(n):
  if data[i] == a_max and not flag:
    tmp = data.pop(i)
    print(max(data))
    data.insert(tmp,0)
    
  else:
  	print(a_max)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_max = 0
data = [int(input()) for i in range(n)]
a_max = max(data)
flag = True if a_max == a_max(data.remove(a_max)) else False
for i in range(n):
  if data[i] == a_max and not flag:
    tmp = data.pop(data[i])
    print(max(data))
    data.append(tmp,0)
    
  else:
  	print(a_max)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_max = 0
data = [int(input()) for i in range(n)]
a_max = max(data)
flag = True if a_max == a_max(data.remove(a_max)) else False
for i in range(n):
  if data[i] == a_max and not flag:
    tmp = data.pop(data[i])
    print(max(data))
    data.append(tmp)
    
  else:
  
  	print(a_max)
Problem p03080 (python)

Fixed submission:
N = int(input())
red_num = 0
blue_num = 0
for i in input():
  if i == 'R':
    red_num += 1
  else:
    blue_num += 1
print('Yes' if red_num > blue_num else 'No')

Buggy submission (verdict: Runtime Error):
N = int(input())
red_num = 0
for i in input():
  if i == 'R':
    red_num += 1
print('Yes' if res > N else 'No')
Problem p03106 (python)

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

t=[]
for i in range(1, min(a,b)+1):
    if a%i == 0 and b%i == 0:
        t.append(i)
t = sorted(t,reverse=True)
print(t[k-1])

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

t=[1]
for i in range(2, int(b/2)):
    if a%i == 0 and b%i == 0:
        t.append(i)
print(t[k-1])

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

t=[1]
for i in range(2,b):
    if a%i==0 and b%i == 0:
        t.append(i)
print(t[k-1])

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if a < b:
    a,b = b,a
t=[1]
for i in range(2,b//2):
    if a%i==0 and b%i == 0:
        t.append(i)
print(t[k-1])
Problem p03110 (python)

Fixed submission:
n = int(input())
jpy = 0
btc = 0
for i in range(n):
    num,cur_t = input().split()
    if cur_t =='JPY':
        jpy += int(num)
    else:
        btc += float(num)
print(jpy+btc*38*10**4)

Buggy submission (verdict: Runtime Error):
N = int(input())
res = 0
while N > 0:
  x,u = map(int, input().split())
  res += x if u == 'JPY' else x*380000
  
  N -= 1
print(res)
Problem p03813 (python)

Fixed submission:
a = int(input())
print('ABC' if 1200 > a else 'ARC')

Buggy submission (verdict: Runtime Error):
a = int(input())
print('ABC' if 1200
Problem p03826 (python)

Fixed submission:
a,b,c,d = map(int, input().split())
if a*b < c*d:
    a,b = c,d
print(a*b)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
print(a*b if a*b > d*c els
Problem p02687 (python)

Fixed submission:
a = input()
if a == "ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
a = input()
if a = "ABC":
    print("ARC")
else:
    print("ABC")
Problem p02801 (python)

Fixed submission:
a = input()
b = chr(ord(a)+1)
print(b)

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

ans = M*N-sum(A)

if ans > K:
    print(-1)
elif ans < 0:
    print(0)
else:
    print(ans)
Problem p02811 (python)

Fixed submission:
K,M = map(int,input().split())
if 500*K >= M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
K,M = map(int,input().split())
if 500*K >= X:
    print("Yes")
else:
    print("No")
Problem p02842 (python)

Fixed submission:
N = int(input())

ans = -1

for i in range(1,N+1):
    if int(i*1.08) == N:
        ans = i

if ans != -1:
    print(ans)
else:
    print(":(")

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

ans = -1

for i in range(1,N+1):
    if int(i*1.08) == N:
        ans = i

if ans =! -1:
    print(ans)
else:
    print(":(")

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

ans = -1

for i in range(1,N+1):
    if int(int(i)*1.08) == N:
        ans = i

if ans =! -1:
    print(ans)
else:
    print(":(")
Problem p02843 (python)

Fixed submission:
X = int(input())
mod = X % 100
q = int(X //100)
sum = 0
ans = 0
if q >= 20:
    ans = 1
else:
    for i in range (0,q+1):
        for j in range (0,q+1-i):
            for k in range (0,q+1-i-j):
                for l in range (0,q+1-i-k-j):
                    for m in range (0,q+1-i-j-k-l):
                        sum = i+(2*j)+(3*k)+(4*l)+(5*m)
                        if sum == mod:
                            ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
X = int(input())
mod = X % 100
q = int(X //100)
sum = 0
ans = 0
if q => 100:
    ans = 1
else:
    for i in range (0,q+1):
        for j in range (0,q+1-i):
            for k in range (0,q+1-i-j):
                for l in range (0,q+1-i-k-j):
                    for m in range (0,q+1-i-j-k-l):
                        sum = i+(2*j)+(3*k)+(4*l)+(5*m)
                        if sum == mod:
                            ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
X = int(input())
mod = X % 100
q = int(X //100)
sum = 0
ans = 0
if q => 20:
    ans = 1
else:
    for i in range (0,q+1):
        for j in range (0,q+1-i):
            for k in range (0,q+1-i-j):
                for l in range (0,q+1-i-k-j):
                    for m in range (0,q+1-i-j-k-l):
                        sum = i+(2*j)+(3*k)+(4*l)+(5*m)
                        if sum == mod:
                            ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
X = int(input())
x = x % 100
sum = 0
for i in range (0,100):
    for j in range (0,50):
        for k in range (0,34):
            for l in range (0,26):
                for m in range (0,20):
                    sum = i+(2*j)+(3*k)+(4*l)+(5*m)
if sum == x:
    print("1")
else:
    print("0")
Problem p02642 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A)

MAXN = max(A)
B = [False]*(MAXN+1)
for c in C.most_common():
    B[c[0]] = True
ans = 0
for i in range(MAXN + 1):
    if B[i]:
        if C[i]==1:
            ans += 1
        B[i::i] = [False]*(MAXN//i)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A).most_common()

MAXN = max(A)
B = [False]*(MAXN+1)
for c in C:
    B[c[0]] = True
ans = 0
for i in range(MAXN + 1):
    if B[i]:
        if C[i]==1:
            ans += 1
        B[i::i] = [False]*(MAXN//i)
print(ans)
Problem p02784 (python)

Fixed submission:
H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A)>=H:print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A)>=H:print("yes")
else:print("No")H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A)>=H:print("yes")
else:print("No")
Problem p02900 (python)

Fixed submission:
import math,sys
sys.setrecursionlimit(1000000)
def mygcd(x,y):
    if x<y:x,y=y,x
    if y==0:return x
    return mygcd(y,x%y)
def is_prime(n):
    if n==1:return True
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:return False
    return True
A,B = map(int,input().split())
gcd = mygcd(A,B)
C = []
for i in range(1,gcd+1):
    if i*i>gcd:break
    if gcd%i==0:
        C.append(i)
        if i!=gcd//i:
            C.append(gcd//i)
cnt = 0
for c in C:
    if is_prime(c):cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
gcd = math.gcd(A,B)
C = []
for i in range(1,gcd+1):
    if i*i>gcd:break
    if gcd%i==0:
        C.append(i)
        if i!=gcd//i:
            C.append(gcd//i)
def is_prime(n):
    if n==1:return True
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:return False
    return True
cnt = 0
for c in C:
    if is_prime(c):cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
def gcd(a,b):
    if a<b : a,b = b,a
    if b==0: return a
    else: return gcd(b, a%b)
C = gcd(A,B)
ans = 0
X = [True]*(C+1)
X[0] = X[1] = False
for i in range(C+1):
    if X[i]:
        X[i::i] = [False]*(C//i)
        if C%i==0: ans+=1
print(ans+1)

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

ans = 0
C = min(A,B)
X = [True]*(C+1)
X[0] = X[1] = False
for i in range(2,C+1):
    if i*i>C:break
    if X[i]:
        X[i::i] = [False]*(C//i)
        if A%i==0 and B%i==0:
            ans+=1
print(ans+1)
Problem p02936 (python)

Fixed submission:
N,Q = map(int,input().split())
T = [0]*(N+1)
V = [0]*(N+1)
for _ in range(N-1):
    a,b = map(int,input().split())
    T[b] = a
for _ in range(Q):
    p,x = map(int,input().split())
    V[p]+=x
for i in range(1,N+1):
    V[i]+=V[T[i]]
print(*V[1:])

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
T = [[] for i in range(N+1)]
V = [0]*(N+1)
for _ in range(N-1):
    a,b = map(int,input().split())
    T[a].append(b)
    T[b].append(a)
for _ in range(Q):
    p,x = map(int,input().split())
    V[p]+=x
def f(v,p):
    global T,V
    for c in T[v]:
        if c==p:continue
        V[c]+=V[v]
        f(c,v)
f(1,0)
print(*V[1:])
Problem p02937 (python)

Fixed submission:
from bisect import bisect
S = input()
T = input()

NS = len(S)
NT = len(T)
alp = {}
for i in range(26):
    alp[chr(97+i)] = i
D = [[] for i in range(26)]
for i in range(NS):
    D[alp[S[i]]].append(i)
inf = float("inf")
for i in range(26):D[i].append(inf)
k = 0
l = -1
ans = -1
for i in range(NT):
    index = alp[T[i]]
    if D[index] == [inf]:break
    b = bisect(D[index],l)
    if D[index][b]==inf:
        k += 1
        l = D[index][0]
    else:
        l = D[index][b]
    if i==NT-1:ans = k*NS+l+1
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
if set(T)-set(S):
    print(-1)
    exit()
ans = 0
for t in T:
    while True:
        if S[ans]==t:break
        ans+=1
    S+=S
print(ans+1)
Problem p03006 (python)

Fixed submission:
from collections import Counter
N = int(input())
X = []
for i in range(N):
    x,y = map(int,input().split())
    X.append((x,y))
kouho = []
for i in range(N):
    for j in range(N):
        if i==j:continue
        kouho.append((X[i][0]-X[j][0],X[i][1]-X[j][1]))
C = Counter(kouho)
if len(C)==0:print(1)
else:print(N-max(C.values()))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
X = []
for i in range(N):
    x,y = map(int,input().split())
    X.append((x,y))
kouho = []
for i in range(N):
    for j in range(N):
        if i==j:continue
        kouho.append((X[i][0]-X[j][0],X[i][1]-X[j][1]))
C = Counter(kouho)
print(N-max(C.values()))
Problem p03014 (python)

Fixed submission:
H,W = map(int,input().split())
S = [input() for i in range(H)]

L = [[0]*W for i in range(H)]
R = [[0]*W for i in range(H)]
U = [[0]*W for i in range(H)]
D = [[0]*W for i in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            if h==0:D[h][w]=1
            else:D[h][w]=D[h-1][w]+1
            if w==0:R[h][w]=1
            else:R[h][w]=R[h][w-1]+1
for h in range(H-1,-1,-1):
    for w in range(W-1,-1,-1):
        if S[h][w]==".":
            if h==H-1:U[h][w]=1
            else:U[h][w]=U[h+1][w]+1
            if w==W-1:L[h][w]=1
            else:L[h][w]=L[h][w+1]+1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,L[h][w]+R[h][w]+U[h][w]+D[h][w]-3)
print(ans)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
ans = [[0 for i in range(W)] for j in range(H)]
def f(h,w,x):
  global H,W,S,ans
  if h<0 or h>=H or w<0 or w>=W or S[h][w]=="#":
    return
  ans[h][w]+=1
  if x==0:
    f(h-1,w,1)
    f(h+1,w,2)
    f(h,w-1,3)
    f(h,w+1,4)
  elif x==1:
    f(h-1,w,1)
  elif x==2:
    f(h+1,w,2)
  elif x==3:
    f(h,w-1,3)
  elif x==4:
    f(h,w+1,4)
for h in range(H):
  for w in range(W):
    if S[h][w]=="#":
      continue
    f(h,w,0)
a = 0
for h in ans:
  a = max(a,max(h))
print(a)
Problem p03047 (python)

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

Buggy submission (verdict: Runtime Error):
N,K = map(int,input())
print(N-K+1)
Problem p03087 (python)

Fixed submission:
N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split()))for i in range(Q)]
rui_count = []
AC_k = S.find('AC')
if AC_k == -1:
    for i in range(Q):
        print(0)
    exit()
for i in range(N):
    if AC_k+1 > i:
        if i == 0:
            rui_count.append(0)
        else:
            rui_count.append(rui_count[i-1])
        continue
    AC_k = S[i:N].find('AC')
    if AC_k == -1:
        rui_count += [rui_count[i-1]+1 for j in range(i,N)]
        break
    AC_k += i
    rui_count.append(rui_count[i-1]+1)
count = []
for i in lr:
    count.append(rui_count[i[1]-1]-rui_count[i[0]-1])
for i in count:
    print(i)

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split()))for i in range(Q)]
rui_count = []
AC_k = S.find('AC')
for i in range(N):
    if AC_k+1 > i:
        if i == 0:
            rui_count.append(0)
        else:
            rui_count.append(rui_count[i-1])
        continue
    AC_k = S[i:N].find('AC')
    if AC_k == -1:
        rui_count += [rui_count[i-1]+1 for j in range(i,N)]
        break
    AC_k += i
    rui_count.append(rui_count[i-1]+1)
count = []
for i in lr:
    count.append(rui_count[i[1]-1]-rui_count[i[0]-1])
for i in count:
    print(i)
Problem p03095 (python)

Fixed submission:
N = int(input())
S = input()
MOD = 10**9+7

alp = 'abcdefghijklmnopqrstuvwxyz'
count_alp = [0 for i in range(26)]
count = 1

for s in S:
    count_alp[alp.find(s)]+=1

for i in count_alp:
    count*= (i+1)
print((count-1)%MOD)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**10)
N = int(input())
S = input()

count = -1

def dfs(index, moji):
    global N,S,count
    if index==N:
        count+=1
        return
    if S[index] in moji:
        dfs(index+1, moji)
    else:
        dfs(index+1, moji)
        dfs(index+1, moji+S[index])

dfs(0,'')
print(count)

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

count = -1

def dfs(index, moji):
    global N,S,count
    if index==N:
        count+=1
        return
    if S[index] in moji:
        dfs(index+1, moji)
    else:
        dfs(index+1, moji)
        dfs(index+1, moji+S[index])

dfs(0,'')
print(count)
Problem p03136 (python)

Fixed submission:
n = int(input())
s = list(map(int,input().split()))
if max(s)<sum(s)-max(s):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
if max(s)<sum(s)-max(s):
  print("Yes")
else:
  print("No")
Problem p03141 (python)

Fixed submission:
n = int(input())
ab = []
x = 0
for i in range(n):
  a,b = map(int,input().split())
  x -= b
  ab.append(a+b)
ab.sort()
ab.reverse()
for i in range(n):
  if i%2==0:
      x+=ab[i]
print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
ab = []
x = 0
for i in range(n):
  a,b = map(int,input().split())
  x -= b
  ab.append(a+b)
ab.sort()
for i in range(raound(n/2)):
  x += ab[i]
print(x)