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

Fixed submission:
# importing the sys module 
import sys 
  
# the setrecursionlimit function is 
# used to modify the default recursion 
# limit set by python. Using this,  
# we can increase the recursion limit 
# to satisfy our needs 
  
sys.setrecursionlimit(10**6) 
n = int(input())
h = [int(x) for x in input().split()]
memo = [-1]*n

def dp(i):
    if i == 0:
        return 0
    if i < 0:
        return 10**10
    if memo[i] != -1:
        return memo[i]
    if i == 1:
        memo[i] = abs(h[i] - h[i-1])
        return memo[i]
    memo[i] = min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2]))
    return memo[i]

print(dp(n-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(x) for x in input().split()]
memo = [-1]*n

def dp(i):
    if i == 0:
        return 0
    if i < 0:
        return 10**10
    if memo[i] != -1:
        return memo[i]
    if i == 1:
        memo[i] = abs(h[i] - h[i-1])
        return memo[i]
    memo[i] = min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2]))
    return memo[i]

print(dp(n-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(x) for x in input().split()]
memo = [-1]*n

def dp(i):
    if i == 0:
        return 0
    if memo[i] != -1:
        return memo[i]
    if i == 1:
        memo[i] = abs(h[i] - h[i-1])
        return memo[i]
    memo[i] = min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2]))
    return memo[i]

print(dp(n-1))

Buggy submission (verdict: Runtime Error):
INF = 10 ** 9
n = int(input())
h = [int(x) for x in input().split()]
memo = [-1]*n

def dp(i):
    if i == 0:
        return 0
    if i < 0:
        return INF
    if memo[i] != -1:
        return memo[i]
    if i == 1:
        memo[i] = abs(h[i] - h[i-1])
        return memo[i]
    memo[i] = min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2]))
    return memo[i]

print(dp(n-1))
Problem p03029 (python)

Fixed submission:
a,p = map(int,input().split())
print((a*3+p)//2)

Buggy submission (verdict: Runtime Error):
#include <stdio.h>

int main(void){
  int a;
  int p;
  
  scanf("%d",a); scanf("%d",a);
  print("%d", (a*3+p)/2);

  return 0;
}
Problem p03037 (python)

Fixed submission:
n,m = map(int,input().split())
l = []
max = 0
min = n

for i in range(m):
    l += [input().split()]
    if int(l[i][0]) > max:  
        max = int(l[i][0])
    if int(l[i][1]) < min:
        min = int(l[i][1])

if min - max >= 0:
    print(min - max + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = []
max = 0
min = 100001

for i in range(m):
    l += [input()]
    if int(l[i][0]) > max:  
        max = int(l[i][0])
    if int(l[i][2]) < min:
        min = int(l[i][2])
       
if min - max >= 0:
    print(min - max + 1)
else:
    print(0)
Problem p03067 (python)

Fixed submission:
a,b,c = map(int,(input().split()))
if (a <= c <= b) or (b <= c <= a):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int(input().split()))
if (a <= c <= b) or (b <= c <= a):
    print('Yes')
else:
    print('No')
Problem p03068 (python)

Fixed submission:
n = int(input())
s = input()
k = int(input())
l = []
a = ''

for i in range(n):
    l += s[i]

for i in range(n):
    if l[k-1] != l[i]:
        l[i] = '*'

for i in range(n):
    a += ''.join(l[i])
    
print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
l = []

for i in range(n):
    l += s[i]

for i in range(n):
    if l[k-1] != l[i]:
        l[i] = '*'

for i in range(n):
    a += ''.join(l[i])
    
print(a)
Problem p03076 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
l=[a,b,c,d,e]
last=9
for i in range(5):
    if l[i]%10!=0:
        last=min(last,l[i]%10)
        
g=0
if a%10==0 and b%10==0 and c%10==0 and d%10==0 and e%10==0:
    print(sum(l))
else:
    for i in range(5):
        if l[i]%10==0:
            g+=l[i]
        else:
            g+=l[i]+10-l[i]%10
    print(g-10+last)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
l=[a,b,c,d,e]
last=9
for i in range(5):
    if l[i]%10!=0:
        last=min(last,l[i]%10)
        
sum=0
if a%10==0 and b%10==0 and c%10==0 and d%10==0 and e%10==0:
    print(sum(l))
else:
    for i in range(5):
        if l[i]%10==0:
            sum+=l[i]
        else:
            sum+=l[i]+10-l[i]%10
    print(sum-10+last)
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):
b=input()
if b=='A':
    print('T')
elif b=='T':
    prtnt('A')
elif b=='C':
    print('G')
elif b=='G'
    print('C')

Buggy submission (verdict: Runtime Error):
b=input()
if b=='A':
    print('T')
elif b=='T':
    prtnt('A')
elif b=='C':
    print('G')
else:
    print('C')
Problem p02555 (python)

Fixed submission:
S = int(input())
if S == 1:
    print(0)
    exit()
MOD = 10**9 + 7
A = [0] * (S + 1)
A[0] = 1
A[1] = 0
A[2] = 0

cumsum = 1
for i in range(3, len(A)):
    A[i] = cumsum
    cumsum += A[i - 2]
    cumsum %= MOD
print(A[-1])

Buggy submission (verdict: Runtime Error):
S = int(input())
MOD = 10**9 + 7
A = [0] * (S + 1)
A[0] = 1
A[1] = 0
A[2] = 0

cumsum = 1
for i in range(3, len(A)):
    A[i] = cumsum
    cumsum += A[i - 2]
    cumsum %= MOD
print(A[-1])
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a + a**2 + a**3)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

cnt = 0
for i in range(len(S)):
    if S[i] != T[i]:
        cnt += 1
print(cnt)
Problem p02837 (python)

Fixed submission:
from itertools import combinations
import sys

N = int(input())
A = [[] for _ in range(N + 1)]
B = [[] for _ in range(N + 1)]
C = [[] for _ in range(N + 1)]
num_hint = []
# hint_dict = {}
for i in range(1, N + 1):
    num_i = int(input())
    num_hint.append(num_i)
    for j in range(num_i):
        x, y = map(int, input().split())
        A[i].append((x, y))
        if y == 1:
            B[i].append(x)
        if y == 0:
            C[i].append(x)
        # if hint_dict.get(x) is None:
        #     hint_dict[x] = {0: [], 1: []}
        #     hint_dict[x][y].append(i)
        # else:
        #     hint_dict[x][y].append(i)

for i in range(N + 1, 0, -1):
    for combi in combinations(range(1, N + 1), i):
        remain = set(range(1, N + 1)) - set(combi)
        s = set()
        t = set()
        hint_dict = {}
        for j in combi:
            s |= set(B[j])
            t |= set(C[j])
            for x, y in A[j]:
                if hint_dict.get(x) is None:
                    hint_dict[x] = {0: [], 1: []}
                    hint_dict[x][y].append(i)
                else:
                    hint_dict[x][y].append(i)
        good1 = True
        for value in hint_dict.values():
            if len(value[0]) != 0 and len(value[1]) != 0:
                good1 = False
                break
        good2 = True
        if len(s & remain) != 0:
            good2 = False
        good3 = True
        if len(t & set(combi)) != 0:
            good3 = False
        if good1 and good2 and good3:
            print(i)
            sys.exit()
print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = []
for _ in range(N):
    s = list(input())
    s.sort()
    # s = ''.join(s)
    S.append(s)

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(10):
            a = S[i]
            b = S[j]
            if a[k] != b[k]:
                break
        else:
            ans += 1
print(ans)
Problem p02850 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**9)

N = int(input())

ab = []
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    ab.append((a, b))
    graph[a].append(b)

colors = [-1] * (N + 1)
K = 0


def bfs(p_node, p_color):
    global K
    children_node = graph[p_node]
    c_color = 1
    for child_node in children_node:
        if c_color == p_color:
            c_color += 1
        colors[child_node] = c_color
        bfs(child_node, c_color)
        c_color += 1
    K = max(K, c_color - 1)


bfs(1, -1)

print(K)
for a, b in ab:
    print(colors[b])

Buggy submission (verdict: Runtime Error):
import sys

# sys.setrecursionlimit(10**9)

N = int(input())

ab = []
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    ab.append((a, b))
    graph[a].append(b)

colors = [-1] * (N + 1)
K = 0


def bfs(p_node, p_color):
    global K
    children_node = graph[p_node]
    c_color = 1
    for child_node in children_node:
        if c_color == p_color:
            c_color += 1
        colors[child_node] = c_color
        bfs(child_node, c_color)
        c_color += 1
    K = max(K, c_color - 1)


bfs(1, -1)

print(K)
for a, b in ab:
    print(colors[b])
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2.0:
    theta = math.atan(_x * 2.0 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2.0 / _x)
    print(90.0 - math.degrees(theta))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2.0:
    theta = math.atan(_x * 2.0 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2.0 / _x)
    print(90.0 - math.degrees(theta))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2.0:
    theta = math.atan(_x * 2.0 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2.0 / _x)
    print(90.0 - math.degrees(theta))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90.0 - math.degrees(theta))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
_x = x / a
if _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))
Problem p02900 (python)

Fixed submission:
from collections import defaultdict

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


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


d = gcd(A, B)
# print(d)


def f(v):
    dic = defaultdict(int)
    if v == 1:
        dic[1] = 1
        return dic
    for i in range(2, v):
        if i * i > v:
            break
        while v % i == 0:
            v //= i
            dic[i] += 1
    if v != 1:
        dic[v] += 1
    dic[1] = 1
    return dic


divisor = f(d)
# print(divisor)
print(len(divisor))

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


def furui(data):
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data


a, b = map(int, input().split())
# a, b = 100000000000000, 1000000000000000
a = make_divisors(a)
a = furui(a)
b = make_divisors(b)
b = furui(b)
print(len(set(a) & set(b)) + 1)
Problem p02924 (python)

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

Buggy submission (verdict: Runtime Error):
from math import log10

n = int(input())
ans = log10(n) + log10(n-1) - log10(2)
print(round(10**ans))
Problem p02936 (python)

Fixed submission:
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N, Q = map(int, input().split())
G = defaultdict(list)
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1  # 0-indexed
    G[a].append(b)
    G[b].append(a)

# print('G', G)

V = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p = p - 1  # 0-indexed
    V[p] += x


def dfs(v, p):
    if p != -1:
        V[v] += V[p]
    for idx in G[v]:
        if idx == p:
            continue
        dfs(idx, v)


dfs(0, -1)

# print('V', V)

print(' '.join(map(str, V)))

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

N, Q = map(int, input().split())
G = defaultdict(list)
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1  # 0-indexed
    G[a].append(b)
    G[b].append(a)

# print('G', G)

V = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p = p - 1  # 0-indexed
    V[p] += x


def dfs(v, p):
    if p != -1:
        V[v] += V[p]
    for idx in G[v]:
        if idx == p:
            continue
        dfs(idx, v)


dfs(0, -1)

# print('V', V)

for v in V:
    print(v)

Buggy submission (verdict: Runtime Error):
def get_subgraph(node):
  subgraph = [node]
  for i, j in edges:
    if node == i:
      subgraph.extend(get_subgraph(j))
  return subgraph

n, q = map(int, input().split())
edges = []
for i in range(n-1):
  e, f = map(int, input().split())
  edges.append((e, f))
edges.reverse()

tasks = []
for i in range(q):
  p, x = map(int, input().split())
  tasks.append((p, x))

counter = list(map(int, list('0'*n)))

subgraphs = [get_subgraph(i) for i in range(n+1, 1, -1)]

for p, x in tasks:
  for i in subgraphs[p-1]:
    counter[i-1] += x
print(' '.join(map(str, counter)))
Problem p02988 (python)

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

cnt = 0
for i in range(n - 2):
    if sorted([p[i], p[i + 1], p[i + 2]])[1] == p[i + 1]:
        cnt += 1
print(cnt)

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

cnt = 0
for i in range(n-2):
    if sorted([p[i], p[i+1], p[i+2])[1] == p[i+1]:
        cnt += 1
print(cnt)
Problem p02993 (python)

Fixed submission:
s = list(map(int, list(input())))
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print('Bad')
        break
else:
    print('Good')

Buggy submission (verdict: Runtime Error):
s = list(map(int, list(input())))
for i in range(s - 1):
    if s[i] == s[i + 1]:
        print('Bad')
    print('Good')
Problem p02994 (python)

Fixed submission:
import numpy as np

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

apple = np.array([L + i - 1 for i in range(1, N + 1)])
abs_apple = np.abs(apple)
idx = abs_apple.argmin()
print(apple.sum() - apple[idx])

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())

r = l + n - 1

if r <= 0:
    eat = r
elif l >= 0:
    eat = l
else:
    eat = 0
print((R + L) * (R - L + 1) / 2 - eat)
Problem p03000 (python)

Fixed submission:
import numpy as np
N, X = map(int, input().split())
L = np.array(list(map(int, input().split())))
L = np.append(0, L)
print(np.count_nonzero(L.cumsum() <= X))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
# n, x = 3, 6
# l = [3, 4, 5]
d = 0
i = 0
for i in range(1, n + 2):
    d = d + l[i - 1]
    if d > x:
        break
print(i)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
# n, x = 3, 6
# l = [3, 4, 5]
d = 0
for i in range(1, n + 2):
    d = d + l[i - 1]
    if d > x:
        break
print(i)
Problem p03014 (python)

Fixed submission:
import sys
import numpy as np
sys.setrecursionlimit(10**9)
H, W = map(int, input().split())
S = [list('#' * (W + 2))]
for _ in range(H):
    S.append(list('#' + input() + '#'))
S.append(list('#' * (W + 2)))
S = np.array(S)
# print(S)

north = np.zeros_like(S, dtype='int')
for w in range(1, W + 1):
    north[:, w] = north[:, w - 1] + 1
    north[:, w][S[:, w - 1] == '#'] = 0
    north[:, w][S[:, w] == '#'] = 0

south = np.zeros_like(S, dtype='int')
for w in range(W, 0, -1):
    south[:, w] = south[:, w + 1] + 1
    south[:, w][S[:, w + 1] == '#'] = 0
    south[:, w][S[:, w] == '#'] = 0

east = np.zeros_like(S, dtype='int')
for h in range(1, H + 1):
    east[h, :] = east[h - 1, :] + 1
    east[h, :][S[h - 1] == '#'] = 0
    east[h, :][S[h, :] == '#'] = 0

west = np.zeros_like(S, dtype='int')
for h in range(H, 0, -1):
    west[h, :] = west[h + 1, :] + 1
    west[h, :][S[h + 1] == '#'] = 0
    west[h, :][S[h, :] == '#'] = 0
# print(west)

ans = north + south + east + west
print(ans.max() + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W = map(int, input().split())
S = [list('#' * (W + 2))]
for _ in range(H):
    S.append(list('#' + input() + '#'))
S.append(list('#' * (W + 2)))
S = np.array(S)
# print(S)
# print(S.shape)


def f(x, y, dx, dy):
    if S[x + dx, y + dy] == '#':
        return 0
    return f(x + dx, y + dy, dx, dy) + 1


ans = 0
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i, j] != '.':
            continue
        v = 1
        for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            v += f(i, j, dx, dy)
        ans = max(ans, v)
print(ans)
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
cnt = [0]
for i in range(2, len(S) + 1):
    if S[i - 2:i] == 'AC':
        v = cnt[-1] + 1
    else:
        v = cnt[-1]
    cnt.append(v)

# print('cnt', cnt)
for _ in range(Q):
    l, r = map(int, input().split())
    ans = cnt[r - 1] - cnt[l - 1]
    print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc122/tasks/abc122_c
import itertools

N, Q = map(int, input().split())
N = int(N)
S = input()
lr = []
for _ in range(Q):
    l, r = map(int, input().split())
    lr.append((l - 1, r - 1))
locations = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        locations.append(i)
# print(locations)

for l, r in lr:
    subset = list(itertools.filterfalse(lambda x: x < l, locations))
    subset = list(itertools.filterfalse(lambda x: x > r, subset))
    # print(l, r, subset)
    num_substring = len(subset)
    # print('num_substring', num_substring)
    if subset[-1] == r:
        print(num_substring - 1)
    else:
        print(num_substring)
Problem p03106 (python)

Fixed submission:
a, b, k = map(int, input().split())
c = [i for i in range(1, min(a, b) + 1) if a % i == 0 and b % i == 0]
print(c[-k])

Buggy submission (verdict: Runtime Error):
import sys
a, b, k = map(int, input().split())
c = 0
for i in range(min(a, b)):
  if a % i == 0 and b % i == 0:
    c += 1
  if c == k:
    print(a)
    sys.exit(0)
Problem p03160 (python)

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

# dp[i] := 足場iに来るのにかかる最小のコスト
dp = [0 for _ in range(N)]
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    c1 = dp[i - 2] + abs(H[i] - H[i - 2])
    c2 = dp[i - 1] + abs(H[i] - H[i - 1])
    dp[i] = min(c1, c2)
ans = dp[-1]
print(ans)

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

dp = [0] + [-1] * W
for i in range(1, N + 1):
    w, v = map(int, input().split())
    for sum_w in range(W - w, -1, -1):
        if dp[sum_w] >= 0:
            dp[sum_w + w] = max(dp[sum_w + w], dp[sum_w] + v)
    # print(dp)
print(max(dp))
Problem p03274 (python)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
X = np.array(list(map(int, input().split())))
idx = np.searchsorted(X, 0)
# print('idx', idx)
ans = 10**10
for i in range(N - K + 1):
    l = i
    r = i + K - 1
    d1 = np.abs(X[l]) + np.abs(X[r] - X[l])
    d2 = np.abs(X[r]) + np.abs(X[r] - X[l])
    d = min(d1, d2)
    ans = min(ans, d)
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = ((N - 1) + (K - 1 - 1)) // (K - 1)
print(ans)
Problem p03339 (python)

Fixed submission:
from collections import Counter
N = int(input())
S = list(input())

counter = Counter(S)
E = counter.get('E', 0)
W = counter.get('W', 0)
# print('E W', E, W)

ans = 10**6
e, w = 0, 0
for i in range(N):
    v = w + E - e
    if S[i] == 'E':
        v -= 1
        e += 1
    else:
        w += 1
    # print('v, e, w', v, e, w)
    ans = min(ans, v)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = list(input())

counter = Counter(S)
E = counter.get('E')
W = counter.get('W')
# print('E W', E, W)

ans = 10**6
e, w = 0, 0
for i in range(N):
    v = w + E - e
    if S[i] == 'E':
        v -= 1
        e += 1
    else:
        w += 1
    # print('v, e, w', v, e, w)
    ans = min(ans, v)
print(ans)
Problem p03424 (python)

Fixed submission:
N = int(input())
A = input().split()
for a in A:
  if a == 'Y':
    print('Four')
    exit()
print('Three')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
for a in A:
  if a == 'Y':
    print('Four')
    exit()
print('Three')
Problem p03433 (python)

Fixed submission:
N, A = int(input()), int(input())
for i in range(A + 1):
  if (N - i) % 500 == 0:
    print('Yes')
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
N, A = int(input()), int(input())
for i in range(len(A) + 1):
  if (N - i) % 500 == 0:
    print('Yes')
    exit()
print('No')
Problem p03598 (python)

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

ans = 0
for x in X:
    ans += min(abs(x - K), x) * 2
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = list(map(int, input().split()))
sum_T = sum(T)
M = int(input())
for _ in range(M):
    p, x = map(int, input().split())
    v = sum_T - T[p - 1] + x
    print(v)
Problem p03611 (python)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
counter = np.append(0, np.bincount(A, minlength=10**5 + 10))
# print(counter)
cumsum = counter.cumsum()
# print(cumsum)
# print((cumsum[3:] - cumsum[:-3]))
print((cumsum[3:] - cumsum[:-3]).max())

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
counter = np.bincount(A)
# print(counter)
cumsum = counter.cumsum()
# print(cumsum)
i = min(3, N)
# print('i', i)
print((cumsum[i:] - cumsum[:-i]).max())

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
counter = np.bincount(A)
# print(counter)
cumsum = counter.cumsum()
# print(cumsum)
print((cumsum[3:] - cumsum[:-3]).max())
Problem p03695 (python)

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

cnt1 = 0
for i in range(8):
  v1 = i * 400
  v2 = (i + 1) * 400 - 1
  for j in range(N):
    if v1 <= A[j] and A[j] <= v2:
      cnt1 += 1
      break

cnt2 = 0
for i in range(N):
  if A[i] >= 3200:
    cnt2 += 1

if cnt1 == 0:
  print(1, cnt2)
else:
  print(cnt1, cnt1 + cnt2)

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

cnt1 = 0
for i in range(8):
  v1 = i * 400
  v2 = (i + 1) * 400 - 1
  for j in range(N):
    if v1 <= A[i] <= v2:
      cnt1 += 1
      break

cnt2 = 0
for i in range(N):
  if A[i] >= 3200:
    cnt2 += 1

print(cnt1, cnt2)
Problem p03779 (python)

Fixed submission:
import numpy as np
X = int(input())
arr = np.arange(1, 100000)
arr = arr * (arr + 1) / 2
# print(arr)
# print(arr >= X)
ans = np.nonzero(arr >= X)[0].min() + 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())
arr = np.arange(1, 10)
arr = arr * (arr + 1) / 2
# print(arr)
# print(arr >= X)
ans = np.nonzero(arr >= X)[0].min() + 1
print(ans)
Problem p03827 (python)

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

ans = 0
x = 0
for s in S:
  v = 1 if s == 'I' else -1
  x += v
  ans = max(ans, x)
print(ans)

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

ans = 0
x = 0
for s in S:
  v = 1 if s == 'I' else: 0
  x += v
  ans = max(ans, x)
print(ans)