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

Fixed submission:
from collections import Counter

# print('input >>')
N = input()
As = list(map(int,(input().split())))
Q = int(input())
BCs = []
for _ in range(Q):
    BCs.append(tuple(map(int,(input().split()))))

counter = dict(Counter(As))
sum_ = sum(As)

for BC in BCs:
    if not BC[0] in counter:
        counter[BC[0]] = 0
    if not BC[1] in counter:
        counter[BC[1]] = 0
    sa = BC[1] - BC[0]
    sum_ += counter[BC[0]] * sa
    counter[BC[1]] = counter[BC[1]] + counter[BC[0]]
    counter[BC[0]] = 0
    # print(counter)
    print(sum_)

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

# print('input >>')
N = input()
As = list(map(int,(input().split())))
Q = int(input())
BCs = []
for _ in range(Q):
    BCs.append(tuple(map(int,(input().split()))))

counter = dict(Counter(As))
sum_ = sum(As)

for BC in BCs:
    sa = BC[1] - BC[0]
    sum_ += counter[BC[0]] * sa
    if not BC[1] in counter:
        counter[BC[1]] = 0
    counter[BC[1]] = counter[BC[1]] + counter[BC[0]]
    counter[BC[0]] = 0
    # print(counter)
    print(sum_)
Problem p02642 (python)

Fixed submission:
# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

As.sort()
# print(As)

all_nums = [0] * (As[-1] + 1)

for A in As:
    all_nums[A] += 1

dup = 0

for i, num in enumerate(all_nums):
    if num == 0:
        continue
    if num > 1:
        dup += num
    j = 2
    while i * j <= As[-1]:
        all_nums[i*j] = 0
        j += 1
    # print(all_nums)

print(sum(all_nums)-dup)

Buggy submission (verdict: Runtime Error):

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors[1:] + upper_divisors[::-1]

# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

As.sort()
print(As)

warusu = set()
ans = 0

# for x in range(len(As)):
    # print(As)

for A1 in As:
    for A2 in sorted(As, reverse=True):
        if A2 % A1 == 0:
            As.remove(A1)

# print('-----output-----')
print(len(As))

Buggy submission (verdict: Runtime Error):

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors[1:] + upper_divisors[::-1]

# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

As.sort()
print(As)

warusu = set()
ans = 0

# for x in range(len(As)):
    # print(As)

for A1 in As:
    for A2 in sorted(As, reverse=True):
        if A2 % A1 == 0
            As.remove(A1)

# print('-----output-----')
print(len(As))
Problem p02675 (python)

Fixed submission:
# print('input >>')
N = input()
last = int(N[-1])

# print('-----output-----')
if last == 2 or last == 4 or last == 5 or last == 7 or last == 9:
    print('hon')
elif last == 0 or last == 1 or last == 6 or last == 8:
    print('pon')
elif last == 3:
    print('bon')

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

# print('input >>')
N, M = map(int,(input().split()))
ABs = [map(int,(input().split())) for _ in range(M)]

INF = 10 ** 10
ds = [INF] * (N+1)
marks = [0] * (N+1)

nodes = [None] * (N+1)

for AB in ABs:
    A, B = AB
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

    B, A = A, B
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

# print(nodes)

queue = deque([1])
visited = [0] * (N+1)
visited[1] = 1

# d = 0
# ds = [INF] * (N+1)
marks = [0] * (N+1)
parent = 1

while len(queue) > 0:
    p = queue.popleft()
    # print(p)
    # parent, node = p[0], p[1]
    # visited[node] = 1
    # marks[node] = parent
    for n in nodes[p]:
        if visited[n] == 0:
            visited[n] = 1
            marks[n] = p

print('Yes')
for mark in marks[2:]:
    print(mark)

Buggy submission (verdict: Runtime Error):
# print('input >>')
N = input()
last = int(N[-1])

# print('-----output-----')
if last == 2 or last == 4 or last == 5 or last == 7 or last == 9:
    print('hon')
elif last == 0 or last == 1 or last == 6 or last == 8:
    print('pon')
elif last == 3
    print('bon')
Problem p02678 (python)

Fixed submission:
from collections import deque

# print('input >>')
N, M = map(int,(input().split()))
ABs = [map(int,(input().split())) for _ in range(M)]

INF = 10 ** 10
ds = [INF] * (N+1)
marks = [0] * (N+1)

nodes = [None] * (N+1)

for AB in ABs:
    A, B = AB
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

    B, A = A, B
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

# print(nodes)

queue = deque([1])
visited = [0] * (N+1)
visited[1] = 1

# d = 0
# ds = [INF] * (N+1)
marks = [0] * (N+1)
parent = 1

while len(queue) > 0:
    p = queue.popleft()
    # print(p)
    # parent, node = p[0], p[1]
    # visited[node] = 1
    # marks[node] = parent
    for n in nodes[p]:
        if visited[n] == 0:
            visited[n] = 1
            marks[n] = p
            queue.append(n)

print('Yes')
for mark in marks[2:]:
    print(mark)

Buggy submission (verdict: Runtime Error):



# print('input >>')
N, M = map(int,(input().split()))
ABs = [map(int,(input().split())) for _ in range(M)]

INF = 10 ** 10
ds = [0] * (N+1)
marks = [0] * (N+1)

nodes = [None] * (N+1)

for AB in ABs:
    A, B = AB
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

    B, A = A, B
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

# print(nodes)

checked = [0] * (N+1) 

def dfs(cur, parent, children):
    # print(parent, children)
    if checked[parent] == 1:
        return
    checked[parent] = 1
    for child in children:
        # print(parent, cur, ds)
        if marks[child] == 0 or ds[child] < cur:
            marks[child] = parent
            ds[child] = cur
            # print(marks)
        # if not checked[child] == 0:
        dfs(cur+1, child, nodes[child])

dfs(0, 1, nodes[1])

# print('-----output-----')
print('Yes')
for mark in marks[2:]:
    print(mark)

"""
7 7
1 2
2 5
5 7
3 1
7 3
6 1
2 4
"""

Buggy submission (verdict: Runtime Error):



# print('input >>')
N, M = map(int,(input().split()))
ABs = [map(int,(input().split())) for _ in range(M)]

INF = 10 ** 10
ds = [0] * (N+1)
marks = [0] * (N+1)

nodes = [None] * (N+1)

for AB in ABs:
    A, B = AB
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

    B, A = A, B
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

# print(nodes)

checked = [0] * (N+1) 

def dfs(cur, parent, children):
    # print(parent, children)
    if checked[parent] == 1:
        return
    checked[parent] = 1
    for child in children:
        # print(cur, ds)
        if marks[child] == 0 or ds[child] > cur:
            marks[child] = parent
            ds[child] = cur
            # print(marks)
        # if not checked[child] == 0:
        dfs(cur+1, child, nodes[child])

dfs(0, 1, nodes[1])

# print('-----output-----')
print('Yes')
for mark in marks[2:]:
    print(mark)

"""
7 7
1 2
2 5
5 7
3 1
7 3
6 1
2 4
"""
Problem p02702 (python)

Fixed submission:
from collections import Counter

# print('input >>')

S = input()
S = S[::-1] + '0'

mod = 0
mods = [0] * 2019
mods[0] += 1

i_mod = 1

for i in range(len(S)-1):
    # mods[i+1] = (int(S[i+1]) * 10 ** (i+1) + mods[i]) % 2019
    i_mod %= 2019
    mod = (int(S[i]) * i_mod + mod) % 2019
    # print(mod)
    mods[mod]+=1
    i_mod *= 10

# print(mods)

ans = 0

# counter = Counter(mods)

# for n in counter.values():
#     if n > 1:
#         ans += (n * (n-1)) // 2

# print('-----output-----')

for m in mods:
    if m > 1:
        ans += (m * (m-1)) // 2

print(ans)

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

# print('input >>')

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

mods = [0] * (len(S)+1)
mods[0] = int(S[0]) % 2019

for i in range(len(mods)-1-1):
    mods[i+1] = (int(S[i+1]) * 10 ** (i+1) + mods[i]) % 2019

# print(mods)

# ans = 0

# counter = Counter(mods)

# for n in counter.values():
#     if n > 1:
#         ans += (n * (n-1)) // 2

# print('-----output-----')

print(ans)
Problem p02756 (python)

Fixed submission:
from collections import deque

# print('input >>')
S = deque(input())
Q = int(input())
queries = []
for _ in range(Q):
    queries.append(input())

is_reverse = False

for q in queries:
    ql = list(q.split())
    if len(ql) == 1:
        is_reverse = not is_reverse
    else:
        if ql[1] == '1': # 先頭に加える
            if not is_reverse:
                S.appendleft(ql[2])
            else:
                S.append(ql[2])
        else: # 末尾に加える
            if not is_reverse:
                S.append(ql[2])
            else:
                S.appendleft(ql[2])

# print('-----output-----')
if not is_reverse:
    print(''.join(list(S)))
else:
    print(''.join(list(S)[::-1]))

Buggy submission (verdict: Runtime Error):
# print('input >>')
S = input()
Q = int(input())
queries = []
for _ in range(Q):
    queries.append(input())

is_reverse = False

for q in queries:
    ql = list(q.split())
    if len(ql) == 1:
        is_reverse = not is_reverse
    else:
        if ql[1] == '1': # 先頭に加える
            if not is_reverse:
                S = ql[2] + S
            else:
                S = S + ql[2]
        else: # 末尾に加える
            if not is_reverse:
                S = S + ql[2]

            else:
                S = ql[2] + S
    print(S, is_reverse)

# print('-----output-----')
if not is_reverse:
    print(S)
else:
    print(S[::-1])
Problem p02911 (python)

Fixed submission:
import collections

# print('input >>')
N, K, Q = map(int, (input().split()))
points = [K] * N
A = []
for _ in range(Q):
    A.append(int(input()))

Acount = collections.Counter(A)

for answerer, times in Acount.items():
    points[answerer - 1] += times

# print('----------output----------')

for answerer in range(N):
    print('Yes') if points[answerer] > Q else print('No')

Buggy submission (verdict: Runtime Error):
# import collections

print('input >>')
N, K, Q = map(int, (input().split()))
points = [K] * N
A = []
for _ in range(Q):
    A.append(int(input()))

Acount = collections.Counter(A)

for answerer, times in Acount.items():
    points = [p - times for p in points]
    points[answerer - 1] += times

# print('----------output----------')

for answerer in range(N):
    print('Yes') if points[answerer] > 0 else print('No')
Problem p02947 (python)

Fixed submission:
import collections
from scipy.misc import comb

N = int(input())
s = []
for _ in range(N):
    s.append(list(input()))

for i in range(len(s)):
    s[i] = tuple(sorted(s[i]))
    
c = collections.Counter(s)

cnt = 0
for c_ in c.values():
    cnt += comb(c_, 2, exact=True)
    
print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
from scipy.special import comb

N = int(input())
s = []
for _ in range(N):
    s.append(list(input()))

for i in range(len(s)):
    s[i] = tuple(sorted(s[i]))
    
c = collections.Counter(s)

cnt = 0
for c_ in c.values():
    cnt += comb(c_, 2)
    
print(int(cnt))
Problem p02972 (python)

Fixed submission:
import sys

import math

N = int(input())
a = list(map(int,(input().split())))

ball_arr = [0] * N

for i in range(math.floor(N/2), N):
    ball_arr[i] = a[i]
    
# print(ball_arr)

for i in reversed(range(math.floor(N/2))):
    # print(i)
    # print(i+1)
    # print(sum(ball_arr[i-1::i+1]))
    # print(sum(ball_arr[i-1::i+1]) != a[i])
    mul_arr = ball_arr[i::i+1]
    # print(mul_arr)
    if sum(mul_arr) % 2 != a[i]:
        # print((mull_arr.index(0)+1)*i)
        if 0 in mul_arr: 
            ball_arr[(mul_arr.index(0)+1)*i] = 1
        else:
            print(-1)
            sys.exit()
    # print(ball_arr)
    # print('---')
# print(ball_arr)

M = sum(ball_arr)
print(M)
for i, v in enumerate(ball_arr):
    if v == 1:
        print(i+1, end=' ')

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
a = list(map(int,(input().split())))

ball_arr = [0] * N

for i in range(math.ceil(N/2), N):
    ball_arr[i] = a[i]
    
# print(ball_arr)

for i in reversed(range(math.ceil(N/2))):
    # print(i+1)
    # print(sum(ball_arr[i-1::i+1]))
    # print(sum(ball_arr[i-1::i+1]) != a[i])
    mul_arr = ball_arr[i-1::i+1]
    if sum(mul_arr) != a[i]:
        # print((mull_arr.index(0)+1)*i)
        ball_arr[(mul_arr.index(0)+1)*i] = 1
    # print(ball_arr)
    # print('---')
# print(ball_arr)

M = sum(ball_arr)
print(M)
for i, v in enumerate(ball_arr):
    if v == 1:
        print(i+1, end=' ')
Problem p02995 (python)

Fixed submission:
import fractions

def lcm(a, b):
    y = a*b / fractions.gcd(a, b)
    return int(y)

A, B, C, D = map(int, input().split())

A -= 1

lcm_cd = lcm(C, D)
a_by_c = A // C
a_by_d = A // D
b_by_c = B // C
b_by_d = B // D
a_by_cd = A // lcm_cd
b_by_cd = B // lcm_cd

toB = B - (b_by_c + b_by_d - b_by_cd)
toA = A - (a_by_c + a_by_d - a_by_cd)

print(toB - toA)

Buggy submission (verdict: Runtime Error):
import math

def lcm(a, b):
    y = a*b / math.gcd(a, b)
    return int(y)

A, B, C, D = map(int, input().split())

A -= 1

lcm_cd = lcm(C, D)
a_by_c = A // C
a_by_d = A // D
b_by_c = B // C
b_by_d = B // D
a_by_cd = A // lcm_cd
b_by_cd = B // lcm_cd

toB = B - (b_by_c + b_by_d - b_by_cd)
toA = A - (a_by_c + a_by_d - a_by_cd)

print(toB - toA)
Problem p03037 (python)

Fixed submission:
def intersect(a, b, c, d):
    if b < c or d < a:
        return -2, -1
    else:
        li = sorted([a, b, c, d])
        return li[1], li[2]
        
N, M = map(int, input().split())
LR = []
for _ in range(M):
    LR.append(tuple(map(int, input().split())))
    
a, b = LR[0]
for lr in LR:
    a, b = intersect(a, b, *lr)
    
ans = b-a+1
print(ans) if a > 0 else print('0')

Buggy submission (verdict: Runtime Error):
def intersect(a, b, c, d):
    if b <= c or d <= a:
        return None
    else:
        li = sorted([a, b, c, d])
        return li[1], li[2]
        
N, M = map(int, input().split())
LR = []
for _ in range(M):
    LR.append(tuple(map(int, input().split())))
    
a, b = LR[0]
for lr in LR:
    a, b = intersect(a, b, *lr)
    
print(b-a + 1)
Problem p03068 (python)

Fixed submission:
N = input()
S = input()
K = int(input())
 
char = S[K-1]
 
for s in S:
    print('*',end='') if s != char else print(s,end='')

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

char = S[K]

for s in S:
    print('*',end='') if s != char else print(s,end='')
Problem p03085 (python)

Fixed submission:
b = input()

if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
else:
  print('C')

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
AC = [0] * N

for i in range(1, len(S)):
    if S[i-1] == 'A' and S[i] == 'C':
        AC[i] = AC[i-1] + 1
    else:
        AC[i] = AC[i-1]


for i in range(Q):
    start, end = map(lambda x:int(x)-1, input().split())
    print(AC[end] - AC[start])
Problem p03110 (python)

Fixed submission:
N = int(input())

ot = 0
for i in range(N):
    x,u = input().split()
    if u == 'JPY':
        ot += int(x)
    if u == 'BTC':
        ot += float(x)*380000
        
print(ot)

Buggy submission (verdict: Runtime Error):
3
100000000 JPY
100.00000000 BTC
0.00000001 BTC
Problem p03136 (python)

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

L.sort()
L.reverse()

if L[0] < sum(L)-L[0]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
10
1 8 10 5 8 12 34 100 11 3
Problem p03251 (python)

Fixed submission:
n,m,x,y = map(int,input().split())
xs = list(map(int,input().split()))
ys = list(map(int,input().split()))

war = True

for z in range(-100,101):
    new_xs = xs + [z]
    new_ys = ys + [z]
    new_xs.sort()
    new_ys.sort()
    if new_xs[-1] == z and new_xs[-2] != z and new_ys[0] == z and x<z<=y:
        war = False
        
if war:
    print('War')
else:
    print('No War')

Buggy submission (verdict: Runtime Error):
3 2 10 20
8 15 13
16 22
Problem p03262 (python)

Fixed submission:
import fractions as math

N, X = map(int,(input().split()))
x = list(map(int,input().split()))
x.append(X)
x_min = min(x)

x_0 = [x_- x_min for x_ in x]

gcd = x_0[0]
for x_0_ in x_0:
    gcd = math.gcd(gcd,x_0_)

print(gcd)

Buggy submission (verdict: Runtime Error):
import functools
import fractions
N, X = [int(i) for i in input().split()]
X_N = [int(i) for i in input().split()]
list = []
for e in [int(i) for i in input().split()]:
    list.append(abs(e - X))
gcd = functools.reduce(fractions.gcd, list)
print(gcd)

Buggy submission (verdict: Runtime Error):
# PROXY

import functools
import fractions
N, X = [int(i) for i in input().split()]
X_N = [int(i) for i in input().split()]
list = []
for e in [int(i) for i in input().split()]:
    list.append(abs(e - X))
gcd = functools.reduce(fractions.gcd, list)
print(gcd)

Buggy submission (verdict: Runtime Error):
# PROXY

import functools
import math
N, X = [int(i) for i in input().split()]
X_N = [int(i) for i in input().split()]
list = []
for e in [int(i) for i in input().split()]:
    list.append(abs(e - X))
gcd = functools.reduce(math.gcd, list)
print(gcd)

Buggy submission (verdict: Runtime Error):
import math

N, X = map(int,(input().split()))
x = list(map(int,input().split()))
x_min = min(x)

x_0 = [x_- x_min for x_ in x]

gcd = x_0[0]
for x_0_ in x_0:
    gcd = math.gcd(gcd,x_0_)

ans = gcd

if N==1:
    ans = abs(x[0] - X)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int,(input().split()))
x = list(map(int,input().split()))
x_min = min(x)

x_0 = [x_- x_min for x_ in x]

ans = gcd_list(x_0)

if N==1:
    ans = abs(x[0] - X)

print(ans)
Problem p03290 (python)

Fixed submission:
import math

# print('input >>')
D, G = map(int, (input().split()))
pc = []
for _ in range(D):
    p, c = map(int, (input().split()))
    pc.append((p, c))

point = 0
ans = []

def dfs(i, count, point):
    # Gまで到達したかどうか確かめる
    c_ = count
    if point >= G:
        ans.append(count)
        return
    # 途中まで解いてGまで届くかどうか試す
    if point + (i + 1) * 100 * (pc[i][0] - 1) >= G:
        count += math.ceil((G - point) / ((i + 1) * 100))
        ans.append(count)
    # 全部解いてGまで届くかどうか試す
    elif point + (i + 1) * 100 * pc[i][0] + pc[i][1] >= G:
        count += pc[i][0]
        ans.append(count)
    if i == 0:
        return
    # 完全に解く
    dfs(i-1, c_+pc[i][0], point + (i+1)*100 * pc[i][0] + pc[i][1])
    # 完全に解かない
    dfs(i-1, c_, point)

dfs(D-1,0,0)

# print('----------output----------')
print(min(ans))

Buggy submission (verdict: Runtime Error):
import math

# print('input >>')
D, G = map(int, (input().split()))
pc = []
for _ in range(D):
    p, c = map(int, (input().split()))
    pc.append((p, c))

point = 0
ans = []

def dfs(i, count, point):
    # Gまで到達したかどうか確かめる
    if point >= G:
        ans.append(count)
        return
    # 途中まで解いてGまで届くかどうか試す
    if point + (i + 1) * 100 * (pc[i][0] - 1) >= G:
        count += math.ceil((G - point) / ((i + 1) * 100))
        point += math.ceil((G - point) / ((i + 1) * 100)) * (i + 1) * 100
        ans.append(count)
    if i == 0:
        return
    # 完全に解く
    dfs(i-1, count+pc[i][0], point + (i+1)*100 * pc[i][0] + pc[i][1])
    # 完全に解かない
    dfs(i-1, count, point)

dfs(D-1,0,0)

# print('----------output----------')
print(min(ans))
Problem p02885 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a - a*b >= 0:
  print(a-2*b)
else
  print("0")
Problem p02553 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
'''
if a>b:
  x=a
else:
  x=b
if c>d:
  y=c
else:
  y=d
print(x*y)
'''
print(max(a*c,a*d,b*c,b*d))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,(input().split())
x,y=0,0
if a>b:
    x=a
else:
    x=b
if c>d:
    y=c
else:
    y=d
print(x*y)
Problem p02639 (python)

Fixed submission:
arr = [int(x) for x in input().split()]
for i, a in enumerate(arr, 1):
    if a == 0:
        print(i)

Buggy submission (verdict: Runtime Error):
arr = [int(x) for x in input().split()]
for i, a in enumerate(arr, 1):
    if a == 0:
        return i
Problem p02553 (python)

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

ans = []

ans.append(a * c)
ans.append(b * c)
ans.append(a * d)
ans.append(b * d)

print(max(ans))

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

if a >= 0 and c >= 0:
    ans = b * d
elif  b < 0 and d < 0:
    ans = a * c
elif a >= 0 and d <= 0:
    if a == 0 or b == 0 or c == 0 or d == 0:
        ans = 0
    else:
        ans = a * d
elif b <= 0 and c >= 0:
    if a == 0 or b == 0 or c == 0 or d == 0:
        ans = 0
    else:
        ans = b * c
        
print(ans)

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

if a > 0 and c > 0:
    ans = b * d
elif  b < 0 and d < 0:
    ans = a * c
elif a >= 0 and d <= 0:
    ans = a * d
elif b <= 0 and c >= 0:
    ans = b * c

    
print(ans)

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

if a >= 0 and c >= 0:
    ans = b * d
elif  b <= 0 and d <= 0:
    ans = a * c
elif a >= 0 and d <= 0:
    ans = a * d
elif b <= 0 and c >= 0:
    ans = b * c

    
print(ans)
Problem p02612 (python)

Fixed submission:
N = input()


ans = int(N[-3:])

ans = 1000 - ans

if ans == 1000:
    print(0)
else:
    print(ans)

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

ans = int(N[1:4])

ans = 1000 - ans

if ans == 1000:
    print(0)
else:
    print(ans)
Problem p02741 (python)

Fixed submission:

K = int(input())


S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(S[K-1])

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


h = 0
w = 0
w1 = w2 = 0
if W % 2 == 1:#横が奇数
    w = int(W /2) + 1
    if H % 2 == 1:#縦が奇数
        h = int(H / 2) + 1
        w1 = h * w
        w2 = (w-1) * (h-1)
        print(w1 + w2)
    else:#縦が偶数
        h = int(H / 2)
        w1 = w * h
        w2 = (w-1) * h
        print(w1 + w2)
        
        
else:#横が偶数
    w = int(W / 2)
    print(w * H)
Problem p02995 (python)

Fixed submission:
import math

A, B, C ,D = map(int, input().split())


C_multiple = B // C - A // C
D_multiple = B // D - A // D 

if A % C == 0:
    C_multiple += 1
if A % D == 0:
    D_multiple += 1
        

CD_gcd = C * D // math.gcd(C,D) 
CD_multiple = B // CD_gcd - A// CD_gcd 
if A % CD_gcd == 0:
    CD_multiple += 1



ans = ( B - A + 1 ) - (C_multiple + D_multiple - CD_multiple)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

A, B, C ,D = map(int, input().split())


C_multiple = B // C - A // C
D_multiple = B // D - A // D 

if A % C == 0:
    C_multiple += 1
if A % D == 0:
    D_multiple += 1
        

CD_gcd = C * D / math.gcd(C,D) 
CD_multiple = B // CD_gcd - A// CD_gcd 
if A % CD_gcd == 0:
    CD_multiple += 1
***
print(C_multiple)
print(D_multiple)
print(CD_gcd)
print(CD_multiple)
***
ans = ( B - A + 1 ) - (C_multiple + D_multiple - CD_multiple)
print(int(ans))
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

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

N, Q = map(int, input().split())

S = input()

ac = np.zeros(N-1)

for i in range(Q):
	l, r = map(int, input().split())
    print(S.count('AC'))
	#print(int(sum(ac[l-1:r-2])))