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

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

MOD = 10**9 + 7

dp = [0] * N
prev_i = [-1] * (2 * 10**5 + 1)

dp[0] = 1
prev_i[A[0]] = 0

for i in range(1, N):
  a = A[i]
  if prev_i[a] >= 0:
    if prev_i[a] == i - 1:
      dp[i] = dp[i - 1]
    else:
      dp[i] = dp[i - 1] + dp[prev_i[a]]
  else:
    dp[i] = dp[i - 1]
  prev_i[a] = i
  #print(i, dp, prev_i)

print(dp[-1] % MOD)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

dp = [0] * N
prev_i = [-1] * (10**5 + 1)

dp[0] = 1
prev_i[A[0]] = 0

for i in range(1, N):
  a = A[i]
  if prev_i[a] >= 0:
    if prev_i[a] == i - 1:
      dp[i] = dp[i - 1]
    else:
      dp[i] = dp[i - 1] + dp[prev_i[a]]
  else:
    dp[i] = dp[i - 1]
  prev_i[a] = i
  #print(i, dp, prev_i)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

dp = [0] * N
prev_i = [-1] * (10**5 + 1)

dp[0] = 1
prev_i[A[0]] = 0

for i in range(1, N):
  a = A[i]
  if prev_i[a] != -1:
    if prev_i[a] != i - 1:
      dp[i] = dp[i - 1] + dp[prev_i[a]]
    else:
      dp[i] = dp[i - 1]
  else:
    dp[i] = dp[i - 1]
  prev_i[a] = i
  #print(i, dp, prev_i)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

dp = [0] * N
prev_i = [-1] * (N + 1)

dp[0] = 1
prev_i[A[0]] = 0

for i in range(1, N):
  a = A[i]
  if prev_i[a] != -1:
    if prev_i[a] != i - 1:
      dp[i] = dp[i - 1] + dp[prev_i[a]]
    else:
      dp[i] = dp[i - 1]
  else:
    dp[i] = dp[i - 1]
  prev_i[a] = i
  #print(i, dp, prev_i)

print(dp[-1])
Problem p03105 (python)

Fixed submission:
A,B,C=map(int,input().split())
print(min(C,B//A))

Buggy submission (verdict: Runtime Error):
root = [i for i in range(N + 1)]
comp_size = [1] * (N+1)
 
def root_find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = root_find(y)
    root[x] = z
    return z

def merge(x, y):
  #print(x, y)
  rx = root_find(x)
  ry = root_find(y)
  sx = comp_size[rx]
  sy = comp_size[ry]
  if rx == ry:
    return 0
  else:
    if sx >= sy:
      root[ry] = rx
      comp_size[rx] = sx + sy
    else:
      root[rx] = ry
      comp_size[ry] = sx + sy
    return sx * sy
Problem p03131 (python)

Fixed submission:
K,A,B=map(int,input().split())
if B-A>=2:
  if K+1>=A:
    K=K-A+1
    print(A+(B-A)*(K//2)+K%2)
  else:
    print(1+K)
else:
  print(1+K)

Buggy submission (verdict: Runtime Error):
aa
Problem p03136 (python)

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

sw=0
for i in range(N):
  if s-L[i]<=L[i]:
    sw=1
    break
print("Yes" if sw==0 else "No")

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

Fixed submission:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

A = []
C = []
for a, b in AB:
  A.append(a)
  C.append(a + b)
#print("C:", C)

C.sort()
C = C[::-1]

print(sum(A) - sum(C[1::2]))

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

S_cnt = [0] * 27
T_cnt = [0] * 27

for s in S:
  S_cnt[ord(s) - ord("A")] += 1
for t in T:
  T_cnt[ord(t) - ord("A")] += 1
#print("S_cnt", *S_cnt)
#print("T_cnt", *T_cnt)

answer = 0
for i in range(27):
  if S_cnt[i]:
    if T_cnt[i] == 0:
      print(-1)
      exit()
    else:
      answer = max(answer, -(-S_cnt[i] // T_cnt[i]))
print(answer)
Problem p03148 (python)

Fixed submission:
from collections import defaultdict

N, K = map(int, input().split())
TD = [list(map(int, input().split())) for _ in range(N)]

TD.sort(key = lambda x: -x[1])
#print(TD)

tmp = [[] for _ in range(N + 1)]
cnt = defaultdict(int)
out_candidate = []
kiso = 0
kind = 0
for i in range(K):
    t, d = TD[i]
    tmp[t].append(d)
    if cnt[t]:
        out_candidate.append([t, d])
    else:
        kind += 1
    kiso += d
    cnt[t] += 1
out_candidate.sort(key = lambda x: -x[1])
#print(tmp)
#print(cnt)
#print(out_candidate)
#print(kiso, kind)

answer = []
answer.append(kiso + kind ** 2)

in_candidate = []
if K < N:
    for i in range(K, N):
        in_candidate.append(TD[i])
in_candidate.sort(key = lambda x: x[1])
#print(in_candidate)

while out_candidate and in_candidate:
    in_t, in_d = in_candidate.pop()
    if cnt[in_t] == 0:
        cnt[in_t] += 1
        out_t, out_d = out_candidate.pop()
        kiso += in_d - out_d
        kind += 1
        answer.append(kiso + kind ** 2)
        
print(max(answer))

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop
from collections import defaultdict

N, K = map(int, input().split())
TD = [list(map(int, input().split())) for _ in range(N)]

DT = [[d, t] for t, d  in TD]
DT.sort(reverse = True)
#print(DT)

h_in = []
cnt = defaultdict(int)

tmp = []
kiso = 0
for d, t in DT:
    if cnt[t] == 0:
        heappush(h_in, [d, t])
        kiso += d
    else:
        tmp.append([d, t])
    cnt[t] += 1

tmp = tmp[::-1]
len_h_in = len(h_in)
if len_h_in < K:
    d = K - len_h_in
    for i in range(d):
        heappush(h_in, tmp[i])
        kiso += tmp[i][0]

kind = 0
for k, v in list(cnt.items()):
    if v:
        kind += 1
#print(kiso, kind)
#print(h_in)
#print(tmp)

answer = kiso + kind ** 2
tmp = tmp[::-1]
while tmp:
    out_d, out_t = tmp.pop()
    in_d, in_t = heappop(h_in)
    
    kiso += out_d - in_d
    cnt[in_t] -= 1
    if cnt[in_t] == 0: kind -= 1
    cnt[out_t] += 1
    if cnt[out_t] == 1: kind += 1
    
    answer = max(answer, kiso + kind ** 2)

print(answer)
Problem p03150 (python)

Fixed submission:
a="keyence"
s=input()
#print(s[:7],s[-7:])
if a==s[:7] or a==s[-7:]:
  print("YES")
else:
  i=0
  sw=0
  while 1:
    if a[i]==s[i]:
      i+=1
    else:
      break
  while 1:
    if a[i]==s[-7+i]:
      i+=1
    else:
      sw=1
      break
    if i==7:
      break
  print("NO" if sw==1 else "YES")

Buggy submission (verdict: Runtime Error):
a=["k","e","y","e","n","c","e"]
s=input()

if a==s[:7] or a==s[-7:]:
  print("YES")
else:
  i=0
  sw=0
  while 1:
    if a[i]==s[i]:
      i+=1
    else:
      break
  while 1:
    if a[i]==s[-7+i]:
      i+=1
    else:
      sw=1
      break
    if i==7:
      break
  print("NO" if sw==1 else "YES")
Problem p03160 (python)

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

c=[0]*N
c[1]=abs(h[1]-h[0])
for i in range(2,N):
  c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]))
print(c[-1])

Buggy submission (verdict: Runtime Error):
# 埋める配列
# dp[x] = 足場0からスタートして足場xに着地するときに足場xまでに払うコストの最小値

# 計算方法
# dp[0] = 0
# dp[x] = min(dp[x - 1] + |h[x] - h[x - 1]|, dp[x - 2] + |h[x] - h[x - 2]|, ... ,  dp[x - K] + |h[x] - h[x - K]|)

# 埋める順番
# xが小さい順

N, K = map(int, input().split())
H = list(map(int, input().split()))
INF = 10 ** 18

dp = [0] * (N + 5)

for i in range(1, N):
    dp[i] = INF
    for j in range(1, K + 1):
        if i - j >= 0: # 脳死
            dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]))

print(dp[N - 1])
Problem p03196 (python)

Fixed submission:
N,P=map(int,input().split())
Q=[0]*(10**6+1)

i=2

if N==1:
  print(P)
  exit()

while 1:
  if P==1 or i>=10**6:
    break
  if P%i==0:
    P//=i
    Q[i]+=1
    i=2
  else:
    i+=1
#print(Q[:20])
#print(list(map(lambda x: x//N,Q)))
Q=list(map(lambda x: x//N,Q))

ans=1
for i,q in enumerate(Q):
  if q:
    ans*=i**q
print(ans)

Buggy submission (verdict: Runtime Error):
N,P=map(int,input().split())
Q=[0]*(10**6+1)

i=2

while 1:
  if P==1:
    break
  if P%i==0:
    P//=i
    Q[i]+=1
    i=2
  else:
    i+=1
#print(Q[:20])
#print(list(map(lambda x: x//N,Q)))
Q=list(map(lambda x: x//N,Q))

ans=1
for i,q in enumerate(Q):
  if q:
    ans*=i**q
print(ans)
Problem p03239 (python)

Fixed submission:
N,T=map(int,input().split())
min_c = 10**10
for i in range(N):
    c,t=map(int,input().split())
    if t<=T:
        min_c=min(min_c,c)
print("TLE" if min_c==10**10 else min_c)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = int(input())
c_min = -1

for i in range(N):
    c = int(input())
    t = int(input())
    if t <= T:
        if c_min == -1:
            c_min = c
        else:
            if c < c_min:
                c_min = c
if c_min == -1:
    print("TLE")
else:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = int(input())
c_min = -1

for i in range(N):
    c = int(input())
    t = int(input())
    if t <= T:
        if c_min == -1:
            c_min = c
        else:
            if c < c_min:
                c_min = c
if c_min == -1:
    print("TLE")
else:
    print(c)
Problem p03243 (python)

Fixed submission:
print(-(-int(input())//111)*111)

Buggy submission (verdict: Runtime Error):
print(int(input()/111)*111)
Problem p03274 (python)

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

tmp=10**10
for i in range(N-K+1):
  if x[i]*x[i+K-1]<0:
    tmp=min(tmp,min(abs(x[i]),abs(x[i+K-1]))*2+max(abs(x[i]),abs(x[i+K-1])))
  else:
    tmp=min(tmp,max(abs(x[i]),abs(x[i+K-1])))
print(tmp)

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

answer = []
for i in range(N):
  if i + K > N:
    break
  Y = X[i:i+K]
  if Y[0] > 0:
    answer.append(Y[-1])
  elif Y[-1] < 0:
    answer.append(-Y[0])
  else:
    answer.append(min(Y[0]*(-2)+Y[-1], Y[-1]*2-Y[0]))

print(min(answer)
Problem p03280 (python)

Fixed submission:
A,B=map(int,input().split())
print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
# 二次元累積和
# A[i1, j1] から A[i2, j2] までの長方形の積算値は
# Acum[i2 + 1][j2 + 1] - Acum[i1][j2 + 1] - Acum[i2 + 1][j1] + Acum[i1][j1]
def two_dim_accumulate(a) -> list:
  h, w = len(a), len(a[0])
  acum = [[0 for _ in range(w + 1)] for _ in range(h + 1)]
  for i in range(h):
    for j in range(w):
      acum[i + 1][j + 1] = a[i][j]
  for i in range(1, h + 1):
    for j in range(1, w + 1):
      acum[i][j] += acum[i][j - 1]
  for j in range(1, w + 1):
    for i in range(1, h + 1):
      acum[i][j] += acum[i - 1][j]
  return acum

Acum = two_dim_accumulate(A)
#for a in Acum:
#  print(a)

Buggy submission (verdict: Runtime Error):
# 二次元累積和
# A[i1, j1] から A[i2, j2] までの長方形の積算値は
# Acum[i2 + 1][j2 + 1] - Acum[i1][j2 + 1] - Acum[i2 + 1][j1] + Acum[i1][j1]
def two_dim_accumulate(a) -> list:
  h, w = len(a), len(a[0])
  acum = [[0 for _ in range(h + 1)] for _ in range(w + 1)]
  for i in range(h):
    for j in range(w):
      acum[i + 1][j + 1] = a[i][j]
  for i in range(1, h + 1):
    for j in range(1, w + 1):
      acum[i][j] += acum[i][j - 1]
  for j in range(1, w + 1):
    for i in range(1, h + 1):
      acum[i][j] += acum[i - 1][j]
  return acum

Acum = two_dim_accumulate(A)
Acum[q][q] - Acum[p - 1][q] - Acum[q][p - 1] + Acum[p - 1][p - 1]
Problem p03292 (python)

Fixed submission:
A,B,C=map(int,input().split())
print(max(A,B,C)-min(A,B,C))

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
print(max(A,B,C)-min(A,B,C)
Problem p03360 (python)

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

print(sum(a)-max(a)+max(a)*(2**k))

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

print(sum(a,b,c)-max(a,b,c)+max(a,b,c)*(2**k))
Problem p03385 (python)

Fixed submission:
S="".join(sorted(list(input())))
print("Yes" if S == "abc" else "No")

Buggy submission (verdict: Runtime Error):
S=list(input())
print("YES" if a in S and b in S and c in S else "NO")

Buggy submission (verdict: Runtime Error):
S=input()
print("YES" if a in S and b in S and c in S else "NO")
Problem p03407 (python)

Fixed submission:
A,B,C=map(int,input().split())
print("Yes" if A+B>=C else "No")

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
printf("Yes" if A+B>=C else "No")
Problem p03434 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]

for i in range(1,N,2):
  a[i] *= -1
print(sum(a))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input()))
print(sum(a[::2])-sum(a[1::2]))
Problem p03488 (python)

Fixed submission:
S = input()
X, Y = map(int, input().split())

SIZE = 10 ** 4

M = [0] if S[0] == "T" else []
for i in range(1, len(S)):
  if S[i] != S[i-1]:
    M.append(i)
M.append(len(S))
M = [0] + M
#print("M:", M)

L = []
for i in range(1, len(M)):
  L.append(M[i] - M[i - 1])
#print("L:", L)

for i in range(3, len(L), 2):
  L[i] += L[i - 2]
L = [0] + L
#print("L:", L)

x = 1 << SIZE
y = 1 << SIZE
#print("x:", bin(x)[2::])
#print("y:", bin(y)[2::])

for i in range(1, len(L), 2):
  dist = L[i]
  dirc = L[i - 1]
  #print("dist, dirc:", dist, dirc)
  if i == 1:
    x = x << dist
  else:
    if dirc % 2 == 0:
      x = (x << dist) | (x >> dist)
    else:
      y = (y << dist) | (y >> dist)
      
if (x >> SIZE + X) & 1 == 1 and (y >> SIZE + Y) & 1 == 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
X, Y = map(int, input().split())

def run_length(s) -> list:
    res = [[s[0], 1]]
    for i in range(1, len(s)):
        if res[-1][0] == s[i]:
            res[-1][1] += 1
        else:
            res.append([s[i], 1])
    return res

RL = run_length(S)
if RL[0][0] == 'T':
    RL = [['F', 0]] + RL

SIZE = len(S)
nx = 1 << SIZE
ny = 1 << SIZE

x_flag = 1
for i in range(0, len(RL), 2):
    s, l = RL[i]
    if i == 0:
        nx = nx << l
    else:
        x_flag = (x_flag + RL[i - 1][1]) % 2
        if x_flag:
            nx = (nx << l) | (nx >> l)
        else:
            ny = (ny << l) | (ny >> l)

if ((nx >> (SIZE + X)) & 1) & ((ny >> (SIZE + Y)) & 1):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
X, Y = map(int, input().split())

T = [0] if S[0] == "T" else []
for i in range(1, len(S)):
  if S[i] != S[i-1]:
    T.append(i)
T.append(len(S))
#print("T:", T)

U = [T[0]]
for i in range(1, len(T)):
  U.append(T[i] - T[i-1])
#print("U:", U)

sum_T = 0
DX, DY = [], []
for i in range(len(U)):
  if i % 2:
    sum_T += U[i]
  else:
    if sum_T % 2 == 0:
      DX.append(U[i])
    else:
      DY.append(U[i])
#print("DX, DY:", DX, DY)

SX, SY = sum(DX), sum(DY)

ax = 1 << SX + DX[0]
for i in range(1, len(DX)):
  ax |= (ax << DX[i]) | (ax >> DX[i])
#print("ax:", bin(ax))
if SX + X < len(bin(ax)[2:]):
  #print((bin(ax)[2:])[::-1][SX + X])
  #print("O:", SX + DX[0])
  aax = int((bin(ax)[2:])[::-1][SX + X])
else:
  aax = 0

ay = 1 << SY
for i in range(0, len(DY)):
  ay |= (ay << DY[i]) | (ay >> DY[i])
#print("ay:", bin(ay))
if SY + Y < len(bin(ay)[2:]):
  #print((bin(ay)[2:])[::-1][SY + Y])
  #print("O:", SY)
  aay = int((bin(ay)[2:])[::-1][SY + Y])
else:
  aay = 0

print("Yes" if aax * aay else "No")
Problem p03502 (python)

Fixed submission:
N=int(input())
F=sum(map(int,list(str(N))))

ans="Yes"
if N%F:
  ans="No"
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
F=sum(list(str(N)))

ans="Yes"
if N%F:
  ans="No"
print(ans)
Problem p03523 (python)

Fixed submission:
S=input()

T=["AKIHABARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA"]
T+=["AKIHABR","AKIHBAR","KIHABAR","AKIHBRA","KIHABRA","KIHBARA"]
T+=["KIHABR","KIHBAR","KIHBRA","AKIHBR","KIHBR"]
#print(T)

print("YES" if S in T else "NO")

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

T=["AKIHABARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA"]
T+=["AKIHABR","AKIHBAR","KIHABAR","AKIHBRA","KIHABRA","KIHBARA"]
T+=["KIHABR","KIHBAR","KIHBRA","AKIHBR","KIHBR"]
#print(T)

prin("YES" if S in T else "NO")
Problem p03546 (python)

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

for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j]=min(c[i][j],c[i][k]+c[k][j])
#print(c)

ans=0
for i in range(H):
  A=list(map(int,input().split()))
  for j in A:
    if j>=0:
      ans+=c[j][1]
print(ans)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
c=[]
for i in range(10):
  c.append(list(map(int,input().split())))

for i in range(10):
  for j in range(10):
    for k in range(10):
      c[i][j]=min(c[i][j],c[i][k]+c[k][j])
#print(c)

ans=0
for i in range(H):
  A=list(map(int,input()))
  for j in A:
    if A[i][j]!=-1:
      ans+=c[A[i][j]][1]
print(ans)
Problem p03559 (python)

Fixed submission:
import bisect as bi

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

a.sort()
c.sort()
#print(a)
#print(c)

ans=0
for i in b:
  ans+=bi.bisect_left(a,i)*(N-bi.bisect_right(c,i))
print(ans)

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

bc=[0]*N
ii=0
for i in range(N):
  while c[ii]<=b[i] and ii<N:
    ii+=1
    if ii==N:
      break
  bc[i]=N-ii
#print(bc)
for i in range(N-2,-1,-1):
  bc[i]+=bc[i+1]
#print(bc)

ab=[0]*N
ii=0
for i in range(N):
  while b[ii]<=a[i] and ii <N:
    ii+=1
    if ii==N:
      break
  ab[i]=bc[ii] if ii<N else 0
print(sum(ab))
Problem p03576 (python)

Fixed submission:
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort()
#print("XY:", XY)

answer = []
for i in range(N):
  for k in range(K, N + 1):
    if i + k - 1 >= N:
      break
    dx = XY[i + k - 1][0] - XY[i][0]
    Y = []
    for x, y in XY[i: i + k]:
      Y.append(y)
    Y.sort()
    lenY = len(Y)
    for j in range(k):
      if j + K - 1 == lenY:
        break
      dy = Y[j + K - 1] - Y[j]
      answer.append(dx * dy)

print(min(answer))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

answer = []
for i in range(N):
  for j in range(i + 1, N):
    x1, x2 = min(XY[i][0], XY[j][0]), max(XY[i][0], XY[j][0])
    y1, y2 = min(XY[i][1], XY[j][1]), max(XY[i][1], XY[j][1])
    
    cnt = 0
    for n in range(N):
      x3, y3 = XY[n]
      if x1 <= x3 <= x2 and y1 <= y3 <= y2:
        cnt += 1
    if cnt == K:
      answer.append((x2 - x1) * (y2 - y1))
print(min(answer))
Problem p03583 (python)

Fixed submission:
N = int(input())

for h in range(1, 3501):
  for n in range(h, 3501):
    if (4 * h * n - N * n - h * N) == 0:
      continue
    w = (N * h * n) / (4 * h * n - N * n - h * N)
    if w.is_integer() and 1 <= w < 3501:
      print(h, n, int(w))
      exit()

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

for h in range(1, 3501):
  if 1 / h < 4 / N:
    for n in range(1, h + 1):
      if 1 / h + 1 / n < 4 / N:
        w = 1 / (4 / N - 1 / h - 1 / n)
        if w.is_integer() w > 0:
          print(h, n, int(w))
          exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
  
for h in range(1, 3501):
  if 1 / h < 4 / N:
    for n in range(1, h):
      w = 1 / (4 / N - 1 / h - 1 / n)
      if w > 3500:
        break
      if w.is_integer():
        print(h, n, int(w))
        exit()
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F = map(int,input().split())

water = [0] * (F//100 + 1)
water[0] = 1
for i in range(F//100 + 1):
  if water[i]:
    if i + A < F//100 + 1: water[i+A] = 1
    if i + B < F//100 + 1: water[i+B] = 1
water[0] = 0
#print(water)

suger = [0] * (F + 1)
suger[0] = 1
for i in range(F + 1):
  if suger[i]:
    if i + C < F + 1: suger[i+C] = 1
    if i + D < F + 1: suger[i+D] = 1
#print(suger)

max_sol = -1
answer = [0, 0]
for i in range(len(water)):
  if water[i] == 0:
    continue
  #print(i)
  for j in range(len(suger)):
    if suger[j] and i*100 + j <= F and j / (i*100 + j) <= E / (100 + E):
        if max_sol < 100 * j / (i*100 + j):
          max_sol = 100 * j / (i*100 + j)
          answer = [i*100 + j, j]
print(*answer)

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

water=[0]*3001
if 100*A<3001: water[100*A]=100*A
if 100*B<3001: water[100*B]=100*B
for i in range(3001):
  if water[i]>0:
    if i+100*A<3001: water[i+100*A]=i+100*A
    if i+100*B<3001: water[i+100*B]=i+100*B
for i in range(1,3001):
  if water[i]==0:
    water[i]=water[i-1]
#print(water)

suger=[0]*3001
suger[C]=C
suger[D]=D
for i in range(3001):
  if suger[i]>0:
    if i+C<3001: suger[i+C]=i+C
    if i+D<3001: suger[i+D]=i+D
for i in range(1,3001):
  if suger[i]==0:
    suger[i]=suger[i-1]
#print(suger)

tmp=0
for i in water:
  w=i
  s=suger[w//100*E]
  if w+s<=F and w+s>0:
    if s/(w+s)*100>tmp:
      tmp=s/(w+s)*100
      mw=w
      ms=s
print(mw+ms,ms)

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

water=[0]*3001
water[100*A]=100*A
water[100*B]=100*B
for i in range(3001):
  if water[i]>0:
    if i+100*A<3001: water[i+100*A]=i+100*A
    if i+100*B<3001: water[i+100*B]=i+100*B
for i in range(1,3001):
  if water[i]==0:
    water[i]=water[i-1]
#print(water)

suger=[0]*3001
suger[C]=C
suger[D]=D
for i in range(3001):
  if suger[i]>0:
    if i+C<3001: suger[i+C]=i+C
    if i+D<3001: suger[i+D]=i+D
for i in range(1,3001):
  if suger[i]==0:
    suger[i]=suger[i-1]
#print(suger)

tmp=0
for i in water:
  w=i
  s=suger[w//100*E]
  if w+s<=F and w+s>0:
    if s/(w+s)*100>tmp:
      tmp=s/(w+s)*100
      mw=w
      ms=s
print(mw+ms,ms)
Problem p03633 (python)

Fixed submission:
N=int(input())
T=[int(input()) for _ in range(N)]
T=list(set(T))
N=len(T)
#print(T)

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

ans=T[0]
for i in range(N):
  #print(ans)
  ans=ans*T[i]//gcd(ans,T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
T=[int(input()) for _ in range(N)]
T=list(set(T))
#print(T)

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

ans=T[0]
for i in range(N):
  #print(ans)
  ans=ans*T[i]//gcd(ans,T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
T=[int(input()) for _ in range(N)]
T=list(set(T))
print(T)

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

ans=T[0]
for i in range(N):
  #print(ans)
  ans=ans*T[i]//gcd(ans,T[i])
print(ans)
Problem p03673 (python)

Fixed submission:
import collections

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

B=collections.deque([])
for i in range(N):
  if i%2==0:
    B.append(A[i])
  else:
    B.appendleft(A[i])
#print(B)
B=list(B)
#print(B)
if N%2==1:
  B=B[::-1]

print(" ".join(map(str,B)))

Buggy submission (verdict: Runtime Error):
import collections

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

B=collections.deque([])
for i,a in enumerate(A):
  if i%2==0:
    B.append(a)
  else:
    B.appendleft(a)
if N%2==1:
  B=B[::-1]

print(" ".join(map(str,B)))