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

Fixed submission:
c = [[]]*3

for i in range(3):
    c[i] = list(map(int, input().split()))
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    arr = [[0]* 6]*3
    for i in range(3):
        arr[i][0] = c[i][0] - c[i][1]
        arr[i][1] = c[i][0] - c[i][2]
        arr[i][2] = c[i][1] - c[i][0]
        arr[i][3] = c[i][1] - c[i][2]
        arr[i][4] = c[i][2] - c[i][0]
        arr[i][5] = c[i][2] - c[i][1]
    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    for i in range(3):
        arr[i][0] = c[0][i] - c[1][i]
        arr[i][1] = c[0][i] - c[2][i]
        arr[i][2] = c[1][i] - c[0][i]
        arr[i][3] = c[1][i] - c[2][i]
        arr[i][4] = c[2][i] - c[1][i]
        arr[i][5] = c[2][i] - c[0][i]
          

    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    arr = [0]*3
    sum = 0
    for i in range(3):
        arr[0] += c[i][i]
    for i in range(3):
        if i + 1 < 3:
            arr[1] += c[i][i+1]
        else:
            arr[1] += c[i][0]
    for i in range(3):
        if i + 2 < 3:
            arr[2] += c[i][i+2]
        else:
            arr[2] += c[i][i-1]
    
    if arr[0] != arr[1] or arr[0] != arr[2]:
        print("No")
        exit(0)

    print("Yes")
    exit(0)

print("No")

Buggy submission (verdict: Runtime Error):
c = [[]]*3

for i in range(3):
    c[i] = map(int, input().split())
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    arr = [0]* 3
    for i in range(3):
        arr = c[i][0] - c[i][1] - c[i][2]
    
    if arr[0] == arr[1] and arr[0] == arr[2]:
        print("Yes")
        exit(0)

print("No")
Problem p03436 (python)

Fixed submission:
from collections import deque
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]

white = 0

for i in range(H):
    white += s[i].count(".")

q = deque()
q.append((0, 0))

g = [[10**9]*W for i in range(H)]
g[0][0] = 0
for i in range(H*W):
    if len(q) == 0:
        break
    x, y = q.popleft()
    if (x, y) == (H-1, W-1):
        break
    else:
        if x < H-1 and s[x+1][y] == ".":
            if g[x+1][y] == 10**9:
                q.append((x+1, y))
            g[x+1][y] = min(g[x+1][y], g[x][y]+1)
        if y < W-1 and s[x][y+1] == ".":
            if g[x][y+1] == 10**9:
                q.append((x, y+1))
            g[x][y+1] = min(g[x][y+1], g[x][y]+1)
        if x > 0 and s[x-1][y] == ".":
            if g[x-1][y] == 10**9:
                q.append((x-1, y))
            g[x-1][y] = min(g[x-1][y], g[x][y]+1)
        if y > 0 and s[x][y-1] == ".":
            if g[x][y-1] == 10**9:
                q.append((x, y-1))
            g[x][y-1] = min(g[x][y-1], g[x][y]+1)
if g[H-1][W-1] == 10**9:
    print(-1)
else:
    print(white - (g[H-1][W-1]+1))

Buggy submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]

white = 0

for i in range(H):
    white += s[i].count(".")


q = deque()
q.append((0, 0))

g = [[10**9]*W for i in range(H)]
g[0][0] = 0
for i in range(H*W):
    x, y = q.popleft()
    if (x, y) == (H-1, W-1):
        break
    else:
        if x < H-1 and s[x+1][y] == ".":
            if g[x+1][y] == 10**9:
                q.append((x+1, y))
            g[x+1][y] = min(g[x+1][y], g[x][y]+1)
        if y < W-1 and s[x][y+1] == ".":
            if g[x][y+1] == 10**9:
                q.append((x, y+1))
            g[x][y+1] = min(g[x][y+1], g[x][y]+1)
        if x > 0 and s[x-1][y] == ".":
            if g[x-1][y] == 10**9:
                q.append((x-1, y))
            g[x-1][y] = min(g[x-1][y], g[x][y]+1)
        if y > 0 and s[x][y-1] == ".":
            if g[x][y-1] == 10**9:
                q.append((x, y-1))
            g[x][y-1] = min(g[x][y-1], g[x][y]+1)
if g[H-1][W-1] == 10**9:
    print(-1)
else:
    print(white - (g[H-1][W-1]+1))
Problem p03476 (python)

Fixed submission:
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(1,int(math.sqrt(x))):
      if x % (i+1) == 0:
        return False
    return True

table=[0]*50001
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2 - 1]
  
for i in range(Q):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
Q = int(input())
lr = [tuple(map(int, input().split())) for i in range(Q)]


def primes(n):
    ret = []
    A = [i for i in range(2, n+1)]
    k = 0
    s = n**0.5
    while(k < s):
        ret.append(A[0])
        k = A[0]
        A = [x for x in A if x % k]
    ret += A
    return ret


prime = primes(10**5)

table = collections.defaultdict(int)
prime_s = set(prime)
t = [0]*(10**5 + 1)
for i in range(1, 10**5+1):
    if i in prime_s and (i+1)//2 in prime_s:
        t[i] = 1
for i in range(1, 10**5+1):
    t[i] = t[i] + t[i-1]

for l, r in lr:
    print(t[r] - t[l-1])

Buggy submission (verdict: Runtime Error):
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(2,int(math.sqrt(x))):
      if x % i == 0:
        return False
    return True

table=[0]*50000
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2]
for i in range(Q):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(2,int(math.sqrt)):
      if x % i == 0:
        return False
    return True

table=[0]*50000
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2]
for i in range(Q):
  print(ans[i])
Problem p03479 (python)

Fixed submission:
X,Y=map(int,input().split())
d=Y-X
k= Y // X
if k <= 1:
  print(1)
  exit(0)
count=1
while(1):
  if k < 2**count:
    break
  elif k ==2**count:
    count+=1
    break
  else:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
d=Y-X
k= Y // X
if k <= 1:
  print(1)
  exit(0)
count=0
while(1):
  if  <= 2**count:
    break
  else:
    count+=1
print(count+1)
Problem p03495 (python)

Fixed submission:
import collections
N,K=map(int,input().split())
a=list(map(int,input().split()))
table=collections.defaultdict(int)
for i in range(N):
  table[a[i]]+=1
table= list(table.items())
if len(table)<=K:
  print(0)
else:
  ans=0
  table.sort(key =lambda x:x[1])
  for i in range(len(table)-K):
    ans+=table[i][1]
  print(ans)

Buggy submission (verdict: Runtime Error):
import collections
N,K=map(int,input().split())
a=list(map(int,input().split()))
table=collections.defaultdict(int)
for i in range(N):
  table[a[i]]+=1
table= list(table.items())
if len(table)<=K:
  print(0)
else:
  ans=0
  table.sort(key =lambda x:x[1])
  for i in range(N-K):
    ans+=table[i][1]
  print(ans)

Buggy submission (verdict: Runtime Error):
import collections
N,K=map(int,input().split())
a=list(map(int,input().split()))
table=collections.defaultdict(int)
for i in range(N):
  table[a[i]]+=1
ana=0
table= list(table.items())
if len(table)<=K:
  print(0)
else:
  ans=0
  table.sort(key =lambda x:x[1])
  for i in range(N-K):
    ans+=table[i][1]
print(ans)
Problem p03507 (python)

Fixed submission:
import sys
N, K = map(int, input().split())
input = sys.stdin.readline
wd = [tuple(map(int, input().split())) for i in range(N)]
wd.sort()
d = 0
dp = [0]*N
l = 0
r = wd[0][0] + wd[0][1]*K
while(r - l > 1):
    tmp = (l+r)//2
    num = 0
    for w, d in wd:
        if w <= tmp:
            num += ((tmp - w) // d) + 1
    if num >= K:
        r = tmp
    else:
        l = tmp

print(r)

Buggy submission (verdict: Runtime Error):
import sys
def main():
  N, K = map(int, input().split())
  input = sys.stdin.readline
  wd = [tuple(map(int, input().split())) for i in range(N)]
  wd.sort()
  d = 0
  dp = [0]*N
  l = 0
  r = wd[0][0] + wd[0][1]*K
  while(r - l > 1):
    tmp = (l+r)//2
    num = 0
    for w, d in wd:
      if w <= tmp:
          num += ((tmp - w) // d) + 1
    if num >= K:
      r = tmp
    else:
      l = tmp
  print(r)
main()
Problem p03523 (python)

Fixed submission:
S=list(input())
A="AKIHABARA"
id=0
for i in range(len(A)):
  if len(S) > i and A[i]==S[i]:
    continue
  else:
    if A[i]=="A":
      S.insert(i,"A")
    else:
      print("NO")
      exit(0)
if "".join(S)==A:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
S=list(input())
A="AKIHABARA"
id=0
for i in range(len(A)):
  if A[i]==S[i]:
    continue
  else:
    if A[i]=="A":
      S.insert("A",i)
    else:
      print("NO")
      exit(0)
if "".join(S)==A:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
S=input()
A="AKIHABARA"
id=0
for i in range(len(A)):
  if A[i]==S[id]:
    id+=1
    continue
  else:
    if A[i]=="A":
      continue
    else:
      print("NO")
      exit(0)
print("YES")
Problem p03524 (python)

Fixed submission:
import collections
S=input()
dic=collections.defaultdict(int)
for i in range(len(S)):
  dic[S[i]]+=1
smax=[0,"d"]
for i in dic:
  if dic[i] > smax[0]:
    smax=[dic[i],i]

if len(dic.values())==1:
  if len(S)==1:
    print("YES")
  else:
    print("NO")
  exit(0)
    
elif len(dic.values())==2:
  if len(S)==2:
    print("YES")
  else:
    print("NO")
  exit(0)
if sum(dic.values()) - smax[0]>= smax[0]:
  if smax[0] - min(dic.values()) <= 1:
    print("YES")
    exit(0)
    
print("NO")

Buggy submission (verdict: Runtime Error):
import collections
S=input()
dic=collections.defaultdict(int)
for i in range(len(S)):
  dic[S[i]]+=1
smax=[0,d]
for i in dic:
  if dic[i] > smax[0]:
    smax=[dic[i],i]
    
if sum(dic.values()) - smax[0]>= smax[0] - 1:
  print("YES")
else:
  print("NO")
Problem p03549 (python)

Fixed submission:
N,M=map(int,input().split())
ans=(M*1900 +(N-M)*100)*(2**M)

print(ans)

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

ans=(M*1900 +(N-M)*100)*(2**M)

print(ans)
Problem p03574 (python)

Fixed submission:
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
for i in range(H):
  ans=["0"]*W
  for j in range(W):
    if s[i][j]=="#":
      ans[j]="#"
      continue
    count=0
    if i > 0:
      if s[i-1][j]=="#":
        count+=1
      if j > 0:
        if s[i-1][j-1]=="#":
          count+=1
      if j < W-1:
        if s[i-1][j+1]=="#":
          count+=1
    if i<H-1:
      if s[i+1][j]=="#":
        count+=1
      if j >0:
        if s[i+1][j-1]=="#":
          count+=1
      if j<W-1:
        if s[i+1][j+1]=="#":
          count+=1
    if j>0:
      if s[i][j-1]=="#":
        count+=1
    if j<W-1:
      if s[i][j+1]=="#":
        count+=1
    ans[j]=str(count)
  print("".join(ans))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
for i in range(H):
  ans=[0]*W
  for i in range(W):
    if s[i][j]=="#":
      ans[j]=="#"
      continue
    count=0
    if i > 0:
      if s[i-1][j]=="#":
        count+=1
      if j > 0:
        if s[i-1][j-1]=="#":
          count+=1
      if j < W-1:
        if s[i-1][j+1]=5"#":
          count+=1
    if i<H-1:
      if s[i+1][j]=="#":
        count+=1
      if j >0:
        if s[i+1][j-1]=="#":
          count+=1
      if j<W-1:
        if s[i+1][j+1]=="#":
          count+=1
    if j>0:
      if s[i][j-1]==”#”:
        count+=1
    if j<W-1:
      if s[i][j+1]=="#":
        count+=1
    ans[j]=count
  print("".join(map(str,ans)))
Problem p03591 (python)

Fixed submission:
s=input()
if s.startswith("YAKI"):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
if s.startwith("YAKI"):
  print("Yes")
else:
  print("No")
Problem p03592 (python)

Fixed submission:
N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if N - 2 * i ==0:
        for j in range(M):
           now += M
    elif (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= M and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        print("No")
        exit(0)
    else:
        now += M

Buggy submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= M and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        break
    else:
        for j in range(M):
            field[i][j] = reverse(field[i][j])
            now = sum(map(sum,field))

print("No")

Buggy submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= N and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        break
    else:
        for j in range(M):
            field[i][j] = reverse(field[i][j])
            now = sum(map(sum,field))

print("No")

Buggy submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= N and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        break
    else:
        for j in range(M):
            field[i][j] = reverse(field[i][j])
            now = sum(map(sum,field))

print("No")
Problem p03599 (python)

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

water = set()
for i in range(F//(100*A) + 1):
    for j in range(F // (100*B) + 1):
        if 100*A * i + 100*j*B <= F:
            water |= {100*A * i + 100*j*B}
        else:
            break

sugar = set()
for i in range(F//C + 1):
    for j in range(F // D + 1):
        if C * i + D*j <= F:
            sugar |= {C * i + D*j}
        else:
            break
ans = [100*A, 0]
for x in water:
    if x == 0:
        continue
    for y in sugar:
        if x + y <= F and y <= (x/100)*E:
            if ans[1]/ans[0] < y / (x+y):
                ans = [x+y, y]

print(ans[0], ans[1])

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

A *= 100
B *= 100
dp = [-1]*(F+1)
dp[A] = 0
dp[B] = 0
for i in range(A, F + 1):
    if A <= i:
        dp[i] = max(dp[i - A], dp[i])
    if B <= i:
        dp[i] = max(dp[i - B], dp[i])
    if C <= i and dp[i-C] >= 0:
        if dp[i-C] + C <= (i-C - dp[i-C]) * (E / 100):
            dp[i] = max(dp[i-C] + C, dp[i])

    if D <= i and dp[i-D] >= 0:
        if dp[i-D] + D <= ((i - D) - dp[i-D]) * (E / 100):
            dp[i] = max(dp[i-D] + D, dp[i])


x = 0
id = 0
for i in range(A, F+1):

    if x <= (dp[i] / (i)):
        x = dp[i] / (i)
        id = i

print(id, dp[id])
Problem p03612 (python)

Fixed submission:
N=int(input())
p=list(map(int,input().split()))
count=0
t=set()
for i in range(N):
  if p[i]==i+1:
    t.add(i)
ans=0
id=0
while(id<N):
  if id in t:
    if id+1 in t:
      id+=1
    ans+=1
  id+=1
  
  
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,input().split()))
count=0
import collections

s=collections.deque()
t=set()
for i in range(N):
  if p[i]==i+1:
    s.append(i)
    t.add(i)
ans=0
id=0
while(id<N):
  if id in t:
    if x+1 in t:
      id+=1
    ans+=1
  id+=1
  
  
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,input().))
count=0
for i in range(N):
  if p[i]==i:
    count+=1
ans=count//2
if count%2==1:
  ans+=1
  
  
print(ans)
Problem p03627 (python)

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


dic = collections.defaultdict(int)

for x in A:
    dic[x] += 1

dic = list(dic.items())
dic = [x for x in dic if x[1] >= 2]
dic = sorted(dic, reverse=True, key=lambda x: x[0])

if len(dic) >= 2:
    if dic[0][1] >= 4:
        print(dic[0][0] * dic[0][0])
    else:
        print(dic[0][0] * dic[1][0])
else:
    print(0)

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

table=collections.defaultdict(int)
for x in A:
  table[x]+=1
table=list(table.items())
table=[table[i][0] for  i in range(N) if table[i][1]>1]
table.append(0)
table.append(0)
table.sort(reverse=True)
print(table[0]*table[1])
Problem p03659 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(1,N+1):
  S[i]=S[i-1]+a[i-1]
  
ans=float("Inf")
for i in range(1,N):
  tmp=abs(S[N]-S[i]*2)
  ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(1,N+1):
  S[i]=S[i-1]+a[i-1]
  
ans=floot("Inf")
for i in range(1,N):
  tmp=abs(S[N]-S[i])
  ans=min(ans,tmp)
print(ans)
Problem p03660 (python)

Fixed submission:
N=int(input())
import collections
import heapq
ab=[tuple(map(int,input().split())) for i in range(N-1)]
G=[set() for i in range(N)]
for a,b in ab:
  a-=1
  b-=1
  G[a].add(b)
  G[b].add(a)
q=collections.deque()

dis=[[-1]*N for i in range(2)]
dis[0][0]=0
q.append(0)
while(q):
  x=q.popleft()
  for y in G[x]:
    if dis[0][y]==-1:
      q.append(y)
      dis[0][y]=dis[0][x]+1
dis[1][N-1]=0
q.append(N-1)
while(q):
  x=q.popleft()
  for y in G[x]:
    if dis[1][y]==-1:
      q.append(y)
      dis[1][y]=dis[1][x]+1

hqF=[(0,0)]
hqS=[(0,N-1)]
colord=[False]*N

while(1):
  if len(hqF)==0:
    print("Snuke")
    exit(0)
  _,x = heapq.heappop(hqF)
  while(colord[x]):
    if hqF:
      _,x = heapq.heappop(hqF)
    else:
      print("Snuke")
      exit(0)
  colord[x]=True
  for y in G[x]:
    if colord[y]==False:
      heapq.heappush(hqF,(dis[1][y],y))

  if len(hqS)==0:
    print("Fennec")
    exit(0)
  _,x = heapq.heappop(hqS)
  while(colord[x]):
    if hqF:
      _,x = heapq.heappop(hqS)
    else:
      print("Fennec")
      exit(0)
  colord[x]=True
  for y in G[x]:
    if colord[y]==False:
      heapq.heappush(hqS,(dis[0][y],y))

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
G = [set() for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)


F = [-1]*N
F[0] = 0
q = collections.deque()
q.append(0)
while(q):
    x = q.popleft()
    for y in G[x]:
        if F[y] < 0:
            F[y] = F[x] + 1
            q.append(y)

S = [-1]*N
S[N-1] = 0
q.append(N-1)
while(q):
    x = q.popleft()
    for y in G[x]:
        if S[y] < 0:
            S[y] = S[x] + 1
            q.append(y)
# print(F)
# print(S)
ans = 0
for i in range(N):
    if F[i] + S[i] == F[-1]:



if ans > N // 2:
    print("Fennec")
else:
    print("Snuke")
Problem p03665 (python)

Fixed submission:
from math import factorial
N,P=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(N):
  if a[i]%2==0:
    even+=1
  else:
    odd+=1
ans=2**even
k=0
if P==0:
  k=0
else:
  k=1
tmp=0
for i in range(k,odd+1,2):
  tmp+=factorial(odd)//factorial(odd-i)//factorial(i)

print(ans*tmp)

Buggy submission (verdict: Runtime Error):
from math import factorial
N,P=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(N):
  if a[i]%2==0:
    even+=1
  else:
    odd+=1
ans=2**even
k=0
if P==0:
  k=odd//2 +1
else:
  k=(odd+1)//2
tmp=0
for i in range(1,k+1):
  tmp+=factorial(odd)//factorial(odd-i)//factorial(i)

print(ans*tmp)
Problem p03666 (python)

Fixed submission:
N, A, B, C, D = map(int, input().split())
if A > B:
    A, B = B, A

flag = False
diff = B-A
d = 0
for i in range(0, N, 2):
    if i > 0:
        d += D-C
    j = N-1 - i
    if diff == d and j % 2 == 0:
        flag == True
        break
    if j == 0:
        break

    k = abs(diff - d) / j
    if (k >= C and k <= D) or (abs(diff-d) >= C and abs(diff-d) <= D and j % 2 == 1):
        flag = True
        break
    k = abs(diff + d) / j
    if (k >= C and k <= D) or (diff+d >= C and diff+d <= D and j % 2 == 1):
        flag = True
        break

if flag:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
if A> B:
  A,B=B,A
if C>D:
  C,B=B,C
if B-A>D*(N-1):
  print("NO")
elif B-A>=C*(N-1):
  print("YES")
else:
  flag=False
  diff=B-A
  d=0
  for i in range(2,N,2):
    d+=D-C
    j= N-1 - i
    if j==0:
      if diff==d:
        flag=True
      break
    k=(diff - d) / j
    if k>=C and k<=D:
      flag=True
    
if flag:
  print("YES")
else:
  print("NO")
Problem p03673 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
b[N//2]=a[0]
for i in range(1,N//2+1):
  b[N//2-i]=a[i*2-1]
  if i != N//2 or N%2==1:
    b[N//2+i]=a[i*2]
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()

flag = True

for x in a:
    if flag:
        b.append(x)
        flag = False
    else:
        b.appendleft(x)
        flag = True
if flag:
    print(*b)
else:
    print(*b[::-1])
Problem p03712 (python)

Fixed submission:
H,W=map(int,input().split())
ans=[[] for i in range(H+2)]
ans[0]=["#"]*(W+2)
ans[H+1]=["#"]*(W+2)
for i in range(1,H+1):
  ans[i]="#"+input()+"#"
for i in range(H+2):
  print("".join(ans[i]))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
ans=[]*(H+2)
ans[0]=["#"]*(W+2)
ans[H+1]=["#"]*(W+2)
for i in range(1,H+1):
  ans[i]="#"+input()+"#"
for i in range(H+2):
  print("".join(ans[i]))