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

Fixed submission:
n = int(input())
a_list = sorted(map(int, input().split()),reverse=True)

ans = 0
ans += a_list.pop(0)
cnt = 2
times_2 = 0
times_1 = 0
while 1:
  if cnt == n:
    break
  if n - cnt >= 2:
    cnt += 2
    times_2 += 1
  else:
    cnt += 1
    times_1 += 1
      
ind = 0
for i in range(times_2):
  ans += 2 * a_list[i]
  ind += 1
  
for i in range(times_1):
  ans += a_list[ind + i]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = sorted(map(int, input().split()),reverse=True)

if n <= 2:
  a_list.pop(-1)
  print(sum(a_list))
else:
  ans = 0
  ans += a_list.pop(0)
  cnt = 2
  while 1:
    if cnt == n:
      break
    if n - cnt >= 2:
      ans += a_list.pop(0) * 2
      cnt += 2
    else:
      ans += a_list.pop(0) * 1
      cnt += 1
      
print(ans)
Problem p02641 (python)

Fixed submission:
x,n = input().split()
x = int(x)
if int(n) != 0:
  p = list(map(int, input().split()))
else:
  p = []

all_list = [i for i in range(1,101)]
p = reversed(sorted(p))

for i in p:
  all_list.pop(i-1)
  
all_list.insert(0,0)
all_list.insert(0,-1)
all_list.append(101)

if x in all_list:
  ans = x
else:
  abs_ = 1000
  for i in all_list:
    if abs(x - i) < abs_:
      abs_ = abs(x - i)
      ans = i

print(ans)

Buggy submission (verdict: Runtime Error):
x,n = input().split()
x = int(x)
if int(n) != 0:
  p = list(map(int, input().split()))
else:
  p = []

all_list = [i for i in range(1,101)]
p = reversed(sorted(p))

for i in p:
  all_list.pop(i-1)
  
if x in all_list:
  ans = x
else:
  abs_ = 100
  for i in all_list:
    if abs(x - i) < abs_:
      abs_ = abs(x - i)
      ans = i

print(ans)

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

all_list = [i for i in range(1,101)]
p = reversed(sorted(p))

for i in p:
  all_list.pop(i-1)
  
if x in all_list:
  ans = x
else:
  abs_ = 100
  for i in all_list:
    if abs(x - i) < abs_:
      abs_ = abs(x - i)
      ans = i

print(ans)
Problem p02660 (python)

Fixed submission:
def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)

    upper_divisors.reverse()
    return lower_divisors + upper_divisors

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())

ans = []
used_list = []

def solve(n, used_list):
  if n == 1:
    return len(used_list)
  div_list = make_divisors(n)[1:]
  for i in div_list:
    z_kouho = factorization(i)
    if i not in used_list and len(z_kouho) == 1:
      used_list.append(i)
      return solve(int(n/i),used_list)
  
  return len(used_list)
      
print(solve(n, used_list))

Buggy submission (verdict: Runtime Error):
import sympy

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())

ans = []
used_list = []

def solve(n, used_list):
  if n == 1:
    return len(used_list)
  div_list = sympy.divisors(n)[1:]
  for i in div_list:
    z_kouho = factorization(i)
    if i not in used_list and len(z_kouho) == 1:
      used_list.append(i)
      return solve(int(n/i),used_list)
  
  return len(used_list)
      
print(solve(n, used_list))
Problem p02690 (python)

Fixed submission:
X = int(input())

_range = int(pow(X,1/5))
for i in range(-2*_range-1,2*_range+2):
  for j in range(-2*_range-1,2*_range+2):
    if pow(i,5) - pow(j,5) == X:
      ans_a = i
      ans_b = j
      break
      
print(ans_a,ans_b)

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

_range = int(pow(X,1/5))
for i in range(-1*_range-1,_range+2):
  for j in range(-1*_range-1,_range+2):
    if pow(i,5) - pow(j,5) == X:
      ans_a = i
      ans_b = j
      break
      
print(ans_a,ans_b)
Problem p02761 (python)

Fixed submission:
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

s_list = []
c_list = []

for i in range(M):
  hoge = input().split()
  s_list.append(int(hoge[0]))
  c_list.append(int(hoge[1]))
num = [10] * N

for i in range(len(s_list)):
  if s_list[i] == 1 and c_list[i] == 0 and N!= 1:
    num[s_list[i]-1] = 100
  elif num[s_list[i]-1] == 10:
    num[s_list[i]-1] = c_list[i]
  elif num[s_list[i]-1] != c_list[i]:
    num[s_list[i]-1] = 100
    
if 100 in num:
  print(-1)
elif N == 1 and M == 0:
  print(0)
elif 10 in num:
  for i in range(len(num)):
    if num[i] == 10 and i == 0:
      num[i] = 1
    if num[i] == 10 and i != 0:
      num[i] = 0
  for i in range(len(num)):
    print(num[i], sep="", end="")
else:
  for i in range(len(num)):
    print(num[i], sep="", end="")

Buggy submission (verdict: Runtime Error):
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

s_list = []
c_list = []

for i in range(M):
  hoge = input().split()
  s_list.append(int(hoge[0]))
  c_list.append(int(hoge[1]))
num = [10] * M

for i in range(len(s_list)):
  if s_list[i] == 1 and c_list[i] == 0:
    num[s_list[i]-1] = 100
  elif num[s_list[i]-1] == 10:
    num[s_list[i]-1] = c_list[i]
  elif num[s_list[i]-1] != c_list[i]:
    num[s_list[i]-1] = 100

if 100 in num:
  print(-1)
elif 10 in num:
  for i in range(len(num)):
    if num[i] == 10:
      num[i] = 0
  for i in range(len(num)):
    print(num[i], sep="", end="")
else:
  for i in range(len(num)):
    print(num[i], sep="", end="")
Problem p02802 (python)

Fixed submission:
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

WA = [0] * 105000
AC = [False] * 105000

WAnum = 0
ACnum = 0

for i in range(M):
    hoge = input().split()
    if AC[int(hoge[0])]:
      continue
    if hoge[1] == "AC":
      AC[int(hoge[0])] = True;
      ACnum += 1
      WAnum += WA[int(hoge[0])]
    elif hoge[1] == "WA":
      WA[int(hoge[0])] += 1
      
print(ACnum, WAnum)

Buggy submission (verdict: Runtime Error):
import numpy as np
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

if M != 0:
  A = []
  ACnum = []
  ACkazu = []
  for i in range(M):
    hoge = input().split()
    if hoge[1] == "AC" and hoge[0] not in ACkazu:
      ACnum.append(i)
      ACkazu.append(hoge[0])
      A.append(hoge)
    elif hoge[0] not in ACkazu:
      A.append(hoge)
  pena = 0
  _remove = []
  for i in ACnum:
    i = int(i)
    AC_num = A[i][0]
    for j in range(0,i):
      if A[j][0] == A[i][0]:
        pena += 1
        _remove.append(j)
    _remove.append(i)
  # popでケツから消していく
  for i in reversed(_remove):
    A.pop(i)
  pena += len(A)
  print(len(ACnum), end="")
  print(" ", end="")
  print(pena, end="")
else:
  print(0, end="")
  print(" ", end="")
  print(0, end="")
Problem p02911 (python)

Fixed submission:
import numpy as np
_N, _K, _Q = input().split()
N, K, Q = int(_N), int(_K), int(_Q)
A = []
for i in range(Q):
  A.append(int(input()))

if K > Q:
  for i in range(N):
    print("Yes")
else:
  score = K * np.ones(N) - Q
  for i in A:
    score[i-1] += 1
  for i in score:
    if i > 0:
      print("Yes")
    else:
      print("No")

Buggy submission (verdict: Runtime Error):
_N, _K, _Q = input().split()
N, K, Q = int(_N), int(_K), int(_Q)
A = []
for i in range(Q):
  A.append(int(input()))

if K > Q:
  for i in range(N):
    print("Yes")
else:
  hoge = Q - K + 1
  goods = sorted(set([i for i in A if A.count(i) >= hoge]))
  j = 0
  max_j = len(goods)
  for i in range(1,N+1):
    if i == goods[j]:
      print("Yes")
      if j + 1 == len(goods):
        for k in range(i,N):
          print("No")
        break
      else:
        j += 1
    else:
      print("No")
Problem p02953 (python)

Fixed submission:
N = int(input())
hoge = input().split()
H = []
for i in range(N):
  H.append(int(hoge[i]))

piyo = True
dame = False
if N == 1:
  print("Yes")
else:
  for i in range(0,N-1):
    huga = H[i+1] - H[i]
    # print(huga)
    if huga < -1:
      dame = True
      break
    elif huga == -1:
      if piyo == True:
        H[i] = H[i] - 1
      piyo = True
    elif huga > 0:
      H[i+1] = H[i+1] - 1
      piyo = False
  # print(H)
  for i in range(0,N-1):
    huga = H[i+1] - H[i]
    # print(huga)
    if huga < 0:
      dame = True
      break
  if dame == True:
    print("No")
  else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
if N < 50000
print("No")
Problem p02971 (python)

Fixed submission:
import numpy as np
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

npA = np.array(A)
max_number = max(A)
max_itr = np.where(npA == npA.max())
if len(max_itr[0]) == 1:
  for i in range(N):
    if i != max_itr[0][0]:
      print(max_number)
    else:
      print(sorted(A)[-2])
else:
  for i in range(N):
    print(max_number)

Buggy submission (verdict: Runtime Error):
N = int(input())
hoge = input().split()
A = []
for i in range(N):
  A.append(hoge[i])

max_itr = [i for i, v in enumerate(A) if v == max(A)]
max_number = max(A)
for i in range(N):
  if i not in max_itr:
    print(max_number)
  else:
    print(sorted(A)[-2])
Problem p02994 (python)

Fixed submission:
hoge = input().split()
N = int(hoge[0])
L = int(hoge[1])

if L > 0:
  erase_apple = 0
elif L+N >= 0:
  for i in range(N+1):
    if i + L == 0:
      erase_apple = i
      break
else:
  erase_apple = N-1

if erase_apple == N:
  erase_apple = N-1

apples = []
for i in range(N):
  apples.append(L+i)

apples.pop(erase_apple)
print(sum(apples))

Buggy submission (verdict: Runtime Error):
hoge = input().split()
N = int(hoge[0])
L = int(hoge[1])

if L > 0:
  erase_apple = 0
elif L+N >= 0:
  for i in range(N):
    if i + L == 0:
      erase_apple = i
      break
else:
  erase_apple = N-1

if erase_apple == N:
  erase_apple = N-1

apples = []
for i in range(N):
  apples.append(L+i)

apples.pop(erase_apple)
print(sum(apples))

Buggy submission (verdict: Runtime Error):
hoge = input().split()
N = int(hoge[0])
L = int(hoge[1])

if L > 0:
  print("a")
  erase_apple = 0
elif L+N-1 >= 0:
  for i in range(N):
    if i + L == 0:
      break
else:
  erase_apple = N-1

print(erase_apple)
apples = []
for i in range(N):
  apples.append(L+i)

apples.pop(erase_apple)
print(sum(apples))

Buggy submission (verdict: Runtime Error):
hoge = input().split()
N = int(hoge[0])
L = int(hoge[1])

if L > 0:
  erase_apple = 0
elif L+N >= 0:
  for i in range(N):
    if i + L == 0:
      erase_apple = i
      break
else:
  erase_apple = N-1
  
apples = []
for i in range(N):
  apples.append(L+i)

apples.pop(erase_apple)
print(sum(apples))
Problem p02553 (python)

Fixed submission:
a, b, c, d = list(map(int, input().split()))
# minus minus
if b <= 0 and d <= 0:
    print(a*c)
else:
    ans = max(a*c, a*d, b*c, b*d)
    print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c, d = list(map(int, input().split()))
# minus minus
if b <= 0 and d <= 0:
    ans = a*c
# minus plus
if b <= 0 and c >= 0:
    ans = b*c
# plus minus
elif 0 <= a and d <= 0:
    ans = a*d
# plus plus
if a >= 0 and c >= 0:
    ans = b*d
print(ans)
Problem p02585 (python)

Fixed submission:
n, k = map(int, input().split())
P = tuple(map(lambda x: int(x)-1, input().split()))
C = tuple(map(int, input().split()))
CC = [[] for _ in range(n)]
for idx, p in enumerate(P):
    CC[idx].append(C[p])
    pp = P[p]
    for _ in range(n):
        CC[idx].append(C[pp])
        pp = P[pp]
        if pp == p:
            break
        
from itertools import accumulate
ans = -2*(10**9)
for cc in CC:
    cca = list(accumulate(cc))
    if cca[-1] <= 0:
        # 1周分のうちの最大値
        if k < len(cc):
            ans = max(ans, max(cca[:k]))
        else:
            ans = max(ans, max(cca))
    else:
        # kk周したほうが良い
        kk, r = divmod(k, len(cc))
        if r == 0:
            ans = max(ans, kk*cca[-1], (kk-1)*cca[-1]+max(cca))
        else:
            ans = max(ans, kk*cca[-1] + max(cca[:r]))
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
P = tuple(map(lambda x: int(x)-1, input().split()))
C = tuple(map(int, input().split()))
CC = [[] for _ in range(n)]
p = P[0]

for idx, p in enumerate(P):
    CC[idx].append(C[p])
    pp = P[p]
    for i in range(n):
        if pp == p:
            break
        CC[idx].append(C[pp])
        pp = P[pp]
        

from itertools import accumulate
ans = -50**15
for cc in CC:
    cca = list(accumulate(cc))
    sc = sum(cc)
    if sc <= 0:
        # 1周分のmax
        ans = max(ans, max(cca))
    else:
        kk, r = divmod(k, len(cc))
        ans = max(ans, kk * sc + max(cca[:r]))
print(ans)
Problem p02642 (python)

Fixed submission:
from collections import Counter
n = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)
A = list(set(A))
ok = [True] * (10**6+1)

for a in A:
    temp = a+a
    while temp < 10**6+1:
        ok[temp] = False
        temp += a

c = 0
for a in A:
    if C[a] == 1 and ok[a] == True:
        c += 1
print(c)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
A = np.sort(A)
c = 0
while len(A) > 0:
    ai = A[0]
    AL = A[1:]
    if ai != AL[0]:
        c += 1
    mask = AL % ai != 0
    A = AL[mask]
    if len(A) == 1:
        c += 1
        break
print(c)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = tuple(map(lambda n: int(n) - 1, input().split()))

costs = [-1] * N
loc = 0

if K <= N:
    for i in range(K):
        loc = A[loc]
    print(loc + 1)

else:
    costs[loc] = 0
    for i in range(1, K):
        loc = A[loc]

        if costs[loc] >= 0:
            break

        costs[loc] = i

    offset = costs[loc]
    loop = i - offset

    K -= i
    K %= loop

    for _ in range(K):
        loc = A[loc]
    print(loc + 1)

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

costs = [-1] * (N + 1)

loc = 1
costs[loc] = 0
for i in range(1, K):
    loc = A[loc - 1]

    if costs[loc] >= 0:
        break

    costs[loc] = i

offset = costs[loc]
loop = i - offset

K -= i
K %= loop

for _ in range(K):
    loc = A[loc - 1]
print(loc)

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

costs = [0] * (N + 1)

loc = 1
for i in range(1, K+1):
    loc = A[loc - 1]

    if costs[loc] > 0:
        break

    costs[loc] = i

offset = costs[loc]
loop = i - offset

K -= i
K %= loop

for _ in range(K):
    loc = A[loc - 1]
print(loc)

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

costs = [0] * (N + 1)

if K <= N:
    for i in range(1, K+1):
        loc = A[loc - 1]
    print(loc)

else:
    loc = 1
    for i in range(1, K+1):
        loc = A[loc - 1]

        if costs[loc] > 0:
            break

        costs[loc] = i

    offset = costs[loc]
    loop = i - offset

    K -= offset
    K %= loop

    for _ in range(K):
        loc = A[loc - 1]
    print(loc)

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

costs = [0] * (N + 1)

loc = 1
for i in range(1, K+1):
    loc = A[loc - 1]

    if costs[loc] > 0:
        break

    costs[loc] = i

offset = costs[loc]
loop = i - offset

K -= offset
K %= loop

for _ in range(K):
    loc = A[loc - 1]
print(loc)

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

rec = [0] * N
costs = [0] * N

loc = 1
rec[loc-1] = 1

finished = True
for i in range(1, K+1):
    next_loc = A[loc - 1]

    if rec[next_loc - 1] == 1:
        break

    costs[next_loc - 1] = i
    rec[next_loc - 1] = 1
    loc = next_loc

loop_index_cost = costs[next_loc - 1]
loop_cost = i - loop_index_cost

cs = tuple(map(lambda x: x - loop_index_cost, costs))

final_loc = cs.index((K - loop_index_cost) % loop_cost) + 1
print(final_loc)
Problem p02702 (python)

Fixed submission:
S = input()
mod = 2019

cs_mods = {0:1}
cumsum = 0
count = 0
for i, s in enumerate(S[::-1]):
    cumsum = (cumsum + int(s) * pow(10, i, mod)) % mod
    cs_mods.setdefault(cumsum, 0)
    # count += cs_mods[cumsum]
    cs_mods[cumsum] += 1

# count = 0
for k, v in cs_mods.items():
    count += v*(v-1)//2

print(count)

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
for i in range(i, len(S) - 4):
    for j in range(i+4, len(S)):
        if int(S[i:j]) // 2019 == 0:
            count += 1
print(count)
Problem p02741 (python)

Fixed submission:
a = [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(a[int(input()) - 1])

Buggy submission (verdict: Runtime Error):
a = [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]
K = int(input())
print(a[K])
Problem p02767 (python)

Fixed submission:
N = int(input())
xlist = list(map(int, input().split()))
p = round(sum(xlist) / N)
s = 0
for x in xlist:
    s += (x-p)**2
print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
xlist = list(map(int, input().split()))
def power(p, xlist):
    s = 0
    for x in xlist:
        s += (x - p)**2
    return s

xmax = max(xlist)
xmin = min(xlist)
powers = []
for p in range(xmin, xmax):
    powers.append(power(p, xlist))
print(min(powers))
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9+7
ans = pow(2, n, mod) - 1

up = 1
bo = 1
for i in range(b):
    up = up*(n-i)%mod
    bo = bo*(i+1)%mod
    if i == a-1:
        acombs = up*pow(bo, mod-2, mod)%mod

bcombs = up*pow(bo, mod-2, mod)%mod

print((ans - acombs - bcombs)%mod)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
counts = [0]*(n+1)
counts[1] = n
mod = 10**9+7
for i in range(2, n+1):
    counts[i] = counts[i-1] * (n-i+1) // i % mod
counts[a] = 0
counts[b] = 0
print(sum(counts))
Problem p02801 (python)

Fixed submission:
print(chr(ord(input())+1))

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

def bfs(maze, h, w, si, sj):
    q = deque([[si, sj]])
    score = [[0] * w for i in range(h)]

    pattern = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    while len(q) > 0:
        i, j = q.popleft()
        for move in pattern:
            ni, nj= i + move[0], j + move[1]
            if ni < 0 or h <= ni or nj < 0 or w <= nj:
                continue
            p = maze[ni][nj]
            if p == '#':
                continue
            if p == '.' and not score[ni][nj]:
                score[ni][nj] = score[i][j] + 1
                q.append([ni, nj])
    return max(sum(score, []))
  
h, w = map(int, input().split())
maze = [input() for i in range(h)]
scores = []
for si  in range(h):
    for sj in range(w):
        memo.append((si, sj))
        if maze[si][sj] == "#":
            continue
        scores.append(bfs(maze, h, w, si, sj))
print(max(scores))

Buggy submission (verdict: Runtime Error):
print(chr(ord(input())+1)
Problem p02811 (python)

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

if 500 * k  >= x:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# 大きさnの順列をすべて生成する
from itertools import permutations
def generate_permutations(n):
    perms = permutations(range(1, n+1), n)
    return [perm for perm in perms]

n = int(input())
ptuple = tuple(map(int, input().split()))
qtuple = tuple(map(int, input().split()))

perms = generate_permutations(n)
a = perms.index(ptuple)
b = perms.index(qtuple)
print(int(math.fabs(a - b)))
Problem p02813 (python)

Fixed submission:
import math

def number(plist):
    a = 1
    memo = []
    while len(plist) > 0:
        p = plist.pop(0)
        memo.append(p)
        num = len(set(range(1, p)) - set(memo))
        a += math.factorial(len(plist)) * num
    return a

n = int(input())
plist = list(map(int, input().split()))
qlist = list(map(int, input().split()))

a = number(plist)
b = number(qlist)
print(int(math.fabs(a - b)))

Buggy submission (verdict: Runtime Error):
# 大きさnの順列をすべて生成する
from itertools import permutations
def generate_permutations(n):
    perms = permutations(range(1, n+1), n)
    return [perm for perm in perms]

n = int(input())
ptuple = tuple(map(int, input().split()))
qtuple = tuple(map(int, input().split()))
 
perms = generate_permutations(n)
a = perms.index(ptuple)
b = perms.index(qtuple)
print(int(math.fabs(a - b)))
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())
vs = a*a*b
rem = vs - x
if rem > x:
    y = 2*x/(a*b)
    theta = math.degrees(math.atan2(b, y))
    print(theta)
else:
    y = 2*rem/(a*a)
    theta = math.degrees(math.atan2(y, a))
    print(theta)

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
vs = a*a*b
rem = vs - x
if rem > x:
    y = 2*x/(a*b)
    theta = math.degrees(math.atan2(b, y))
    print(theta)
else:
    y = 2*rem/(a*a)
    theta = math.degrees(math.atan2(y, a))
    print(theta)
Problem p02936 (python)

Fixed submission:
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x:int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)

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

from collections import deque
st = deque([[0, points[0]]])
result = ['0'] * N
visited = [0] * N
visited[0] = 1
while st:
    idx, count = st.pop()
    result[idx] = str(count)
    for ni in G[idx]:
        if visited[ni] != 1:
            visited[ni] = 1
            st.append([ni, count+points[ni]])

print(" ".join(result))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x:int(x)-1, input().split())
    G[a].append(b)

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

from collections import deque
st = deque([[0, points[0]]])
result = [0] * N
while st:
    idx, count = st.pop()
    result[idx] = str(count)
    for ni in G[idx]:
        st.append([ni, count+points[ni]])

print(" ".join(result))
Problem p03031 (python)

Fixed submission:
N, M = map(int, input().split())
ds = []
for _ in range(M):
    ds.append(tuple(map(int, input().split()))[1::])
    
P = tuple(map(int, input().split()))

# スイッチのon/offについて全探索
oks = 0
for i in range(2**N):
    switch_states = [(i>>j)&1 for j in range(N)]
    # すべての電球について
    for di, d in enumerate(ds):
        # 関連するスイッチがonの個数を数える
        switch_counts = 0
        for s in d:
            switch_counts += switch_states[s-1]
        if switch_counts%2 != P[di]:
            break
    else:
        oks += 1
print(oks)

Buggy submission (verdict: Runtime Error):
def resolve():
n, m = map(int, input().split())
denq = []
for _ in range(m):
    ks = tuple(map(lambda x: int(x)-1, input().split()))
    denq.append(ks[1:])
P = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    kk = [0] * m
    # switch_states = [(i>>j)&1 for j in range(n)]
    for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += (i>>s)&1
        if counts%2 != P[idq]:
            break
    else:
        ans += 1
print(ans)