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

Fixed submission:
# coding:utf-8
#masu = map(float, input().split())
masu = input()
count = 0
for be in masu:
    be_ = int(be)
    if be_==1:
        count+=1

print(count)

Buggy submission (verdict: Runtime Error):
# coding:utf-8
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
default_A = A.copy()
counted = list(map(lambda x:x*0, list(range(10))))

'''
counted2 = [[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7],[0,8],[0,9]]
for a in A:
    counted2[a-1][0] += 1
count2 = 0
for i in range(10):
    if counted2[i][0]>0:
        count2 += 1

iranai = count2-K
min_2 = 1<<15
min_number = []
for i in range(len(counted2)):
    for j in range(len(counted2)-1, i, -1):
        if counted2[j][0] < counted2[j-1][0]:
            counted2[j], counted2[j-1] = counted2[j-1], counted2[j]

for i in range(10):
    if counted2[0][0] == 0:
        counted2.pop(0)

last_min = 0
if iranai > 0:
    for i in range(iranai):
        last_min += counted2[i][0]
    print(last_min)
else:
    print(0)
'''


def BallCount(A):
    global counted
    for a in A:
        counted[a-1] += 1
    count = 0
    for i in range(10):
        if counted[i]>0:
            count+=1
    #print("count ",count, "A ", A)
    counted = [0,0,0,0,0,0,0,0,0,0]
    return count

#print(BallCount(A))
min_ = 1<<15
def func(reciveA):
    change_count = 0
    global default_A
    for i in range(N):
        #print("reciveA[i] ", reciveA[i] , "A[i] " ,default_A[i])
        if reciveA[i]!=default_A[i]:
            change_count += 1

        #print("change count", change_count)
    global min_
    min_ = min(min_, change_count)


def bfs(pos):
    ballcount = BallCount(A)

    if ballcount==K:
        #print("ballcount ",ballcount )
        func(A)
    if pos==N:
        return
    for i in default_A:
        A[pos] = i
        bfs(pos+1)
    
bfs(0)
if min_ == (1<<15):
    print(0)
else:
    print(min_)
Problem p03503 (python)

Fixed submission:
# coding:utf-8
inp = input()
N = int(inp)

eigyo = []

b = []
Ci = []
for i in range(N):
    N_ = list(map(int, input().split()))
    eigyo.append(N_)
    Ci.append(sum(N_))

P = []
for i in range(N):
    P.append(list(map(int, input().split())))


ans = -(1<<30)
a = list(map(lambda x: x*0, list(range(10))))
count = 0

def func():
    #score = 0
    global count
    count += 1
    #print(count, a)
    cc = 0
    if count!=1:
        for i in range(N):
            count_c = 0
            for j,element in enumerate(eigyo[i]):
                if element==a[j] and a[j]==1:
                    count_c += 1
            cc += P[i][count_c]
        global ans
        ans = max(ans, cc)
            
    #ans = max(ans, score)

def dfs(pos):
    if pos==10:
        func()
        return
    a[pos] = 0
    dfs(pos+1)
    a[pos] = 1
    dfs(pos+1)


dfs(0)
print(ans)

Buggy submission (verdict: Runtime Error):
# coding:utf-8
inp = input()
N = int(inp)

eigyo = []

b = []
Ci = []
for i in range(N):
    N_ = list(map(int, input().split()))
    eigyo.append(N_)
    Ci.append(sum(N_))

P = []
for i in range(N):
    P.append(list(map(int, input().split())))


ans = 0
a = list(map(lambda x: x*0, list(range(10))))
count = 0

def func():
    #score = 0
    global count
    count += 1
    #print(count, a)
    cc = 0
    for i in range(N):
        count_c = 0
        for j,element in enumerate(eigyo[N]):
            if element==a[j]:
                count_c += 1
        cc += P[i][count_c]

    global ans
    ans = max(ans, cc)
            
    #ans = max(ans, score)

def dfs(pos):
    if pos==10:
        func()
        return
    a[pos] = 0
    dfs(pos+1)
    a[pos] = 1
    dfs(pos+1)


dfs(0)
print(ans)
Problem p03611 (python)

Fixed submission:
N = int(input())

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

buff = [0 for i in range(10**5)]

for i in range(N):
    buff[A[i]] += 1


ans = 0
# print(buff)
for i in range(N-2):
    ans = max(ans,buff[i]+buff[i+1]+buff[i+2])

ans = max(ans, buff[N-2])
ans = max(ans, buff[N-1])
print(ans)

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

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

buff = [0 for i in range(10)]

for i in range(N):
    buff[A[i]] += 1


ans = 0
# print(buff)
for i in range(N-2):
    ans = max(ans,buff[i]+buff[i+1]+buff[i+2])

print(ans)
Problem p03721 (python)

Fixed submission:
amax = 100000
cnt = [0 for i in range(amax+1)]


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

for i in range(N):
    a, b = list(map(int, input().split()))
    cnt[a] += b


for ans in range(1, amax+1):
    if K <= cnt[ans]:
        print(ans)
        break
    K -= cnt[ans]

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

buff = []
a = []
ans = 0
b = 0
for i in range(N):
    _a, _b = list(map(int, input().split()))
    b += _b
    a.append((_a, _b))
    # if b >= K and ans == 0:
    #     ans = _a
    # buff += [_a]*_b


a = a.sort()

for i in range(N):
    buff += [a[i][0]] * a[i][1]

# buff = sorted(buff)
print(buff[K-1])

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
__max = 10**5+1
buff = [0 for i in range(__max)]
a = []
ans = 0
b = 0
for i in range(N):
    _a, _b = list(map(int, input().split()))
    buff[_a] = _b


for i in range(1,__max+1):

    if K <= buff[i]:
        print(i)
        exit()

    K -= buff[i]

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
__max = 10**5+1
buff = [0 for i in range(__max)]
a = []
ans = 0
b = 0
for i in range(N):
    _a, _b = list(map(int, input().split()))
    buff[_a] = _b


for i in range(1,__max+1):

    if K <= buff[i]:
        print(i)
        exit()

    K -= buff[i]
Problem p03761 (python)

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

alfa = [chr(i) for i in range(97,97+26)]
counter = [1000000 for i in range(26)]

for s in S:
    for i in range(26):
        counter[i] = min(s.count(alfa[i]), counter[i])

ans = ''
for i in range(26):
    for j in range(counter[i]):
        ans += alfa[i]

print(ans)

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

S = sorted(S)
_list = []
ans = list(S.pop(1))
# print(S)
for e in range(len(S)):
    buff = ans.copy()
    buff2 = []
    for n in range(len(S[e])):

        # print(e, n, S[e])
        for a in range(len(buff)):
            if S[e][n] == buff[a]:
                buff2.append(buff[a])
                buff[a] = '00000000'

    # print(buff2)
    ans = buff2.copy()


ans = sorted(ans)
ans = ''.join(ans)

print(ans)
Problem p03816 (python)

Fixed submission:
from collections import defaultdict

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

d = defaultdict(int)

for i in range(N):
    d[A[i]] += 1

def func(v):
    if v < 3:
        return v
    a = v//3 + v%3

    return func(a)

ans = 0
se = 0
dd = [0 for i in range(3)]
for k, v in d.items():
    value = v // 3 + (v % 3)
    value = func(v)
    # dd[value] += 1
    if value % 3 == 0 or value % 3 == 1:
        ans += 1
    else:
        se += 1

print(ans + ((se//2)*2))

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

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

d = defaultdict(int)

for i in range(N):
    d[A[i]] += 1

ans = 0
se = 0
dd = [0 for i in range(3)]
for k, v in d.items():
    value = v // 3 + (v % 3)
    dd[value] += 1
    if value % 3 == 0 or value % 3 == 1:
        ans += 1
    else:
        se += 1

print(ans + ((se//2)*2))
Problem p03844 (python)

Fixed submission:
a,p,b = input().split()
a = int(a)
b = int(b)
if p == '+':
  print(a+b)
else:
  print(a-b)

Buggy submission (verdict: Runtime Error):
a,p,b = list(map(int, input().split()))
if p == '+':
  print(a+b)
else:
  print(a-b)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()


# 最初(N//2)**2にしていた、それぞれの場合の数ではなくなってしまう
print((2**(N // 2))%(10**9+7))
Problem p03846 (python)

Fixed submission:
N = int(input())
if N == 1:
    print(1)
    exit()
A = list(map(int, input().split()))
A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()


# 最初(N//2)**2にしていた、それぞれの場合の数ではなくなってしまう
print((2**(N // 2))%(10**9+7))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()


# 最初(N//2)**2にしていた、それぞれの場合の数ではなくなってしまう
print((2**(N // 2))%(10**9+7))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()



print((2**(N // 2))%(10**9+7))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()



print(((N // 2)**2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
# print(A)
if A.count(0) > 1:
    print(0)
    exit()

A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()



print(((N // 2)**2)%(10**9+7))
Problem p02675 (python)

Fixed submission:
a = int(input())
a %= 10

if a==0 or a==1 or a==6 or a==8:
  print("pon")
elif a==3:
  print("bon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
N=int(input())
n=N%10
if n==2 or n==4 or n==5 or n==7 or n==9:
    ptint('hon')
elif n==3
    print('bon')
else:
    print('pon')

Buggy submission (verdict: Runtime Error):
N=int(input())
n=N%10
if n==2,4,5,7,9:
    ptint('hon')
elif n==0,1,6,8:
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
N=int(input())
n=N%10
if n=2,4,5,7,9:
    print('hon')
elif n=0,1,6,8:
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
>>> for N in range(1:1000):
>>> if N%10==2,4,5,7,9:
    print("hon")
>>> elif N%10==0,1,6,8:
    print("pon")
>>> else:
    print("bon")
Problem p02705 (python)

Fixed submission:
import math
r=int(input())
print(2*r*math.pi)

Buggy submission (verdict: Runtime Error):
import math
R=int(input())
print(2*math.pi*r)

Buggy submission (verdict: Runtime Error):
1<=R<=100
π=float(input(3.14))
Circle_Pond=2*R*π
print(Circle_Pond)

Buggy submission (verdict: Runtime Error):
1<=R<=100
Circle_Pond=R*2*3.14
print(Circle_Pond)
Problem p02690 (python)

Fixed submission:
x = int(input())

cands = [(i**5,i) for i in range(-500,500)]

for a,i in cands:
  for b,j in cands:
    if a-b == x:
      print(i,j)
      exit()

Buggy submission (verdict: Runtime Error):
x = int(input())
for i in range(2,x+1):
  if x%i==0:
    a = 0
    b = a-i
    break
while a**5 -b**5 != x:
  a+= 1
  b+= 1
print(a,b)
Problem p02721 (python)

Fixed submission:
n,k,c= map(int,input().split())
s = input()
i = 0

def func(s,k,c):
  i = 0
  res = []
  while 1:
    if s[i] == 'o':
      res.append(i)
      if len(res)== k:
        break
      i += c
    i+= 1
  return res
ans1 = func(s,k,c)
ans2 = func(s[::-1],k,c)
ans2 = [n-a-1 for a in ans2]
ans2 = ans2[::-1]

for i in range(k):
  if ans1[i]==ans2[i]:
    print(ans1[i]+1)

Buggy submission (verdict: Runtime Error):
n,k,c= map(int,input().split())
s = input()
i = 0

def func(s,k,c):
  i = 0
  res = []
  while 1:
    if s[i] == 'o':
      res.append(i)
      if len(ans1)== k:
        break
      i += c
  return res
ans1 = set(func(s,k,c))
ans2 = set(func(s[::-1],k,c))

ans = list(ans1.intersection(ans2))
for a in ans:
  print(a)
Problem p02747 (python)

Fixed submission:
S = input()
hi = ['hi','hihi','hihihi','hihihihi','hihihihihi']
print('Yes'if S in hi else 'No')

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
graph = {i:[] for i in range(n)}
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  graph[a].append(b)
  graph[b].append(a)
  
one = n//3 + bool(n%3)
two = n//3 + bool(n%3>1)
three = n//3
nums = [three+1,one,two]
perms = [0 for i in range(n)]



def dfs(i,n):
  global nums
  perms[i] = (nums[n]-1)*3 + n
  nums[n] -= 1 
  for node in graph[i]:
    if perms[node] == 0:
      next_n = (3-n)%3
      if nums[next_n] == 0:
        dfs(node,0)
      else:
        dfs(node,next_n)


for i in range(n):
  dfs(i,1)
  if sum(perms) == n*(n+1)//2:
    break
  perms = [0 for _ in range(n)]
  nums = [three+1,one,two]
print(*perms)
Problem p02756 (python)

Fixed submission:
from collections import deque

s = deque(input())
reverse = 0
q = int(input())

for _ in range(q):
  query = input()
  if query == '1':
    reverse = 1 - reverse
  else:
    _,f,c = query.split()
    if f == '1':
      if reverse:
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if reverse:
        s.appendleft(c)
      else:
        s.append(c)
        
  
if reverse:
  s.reverse()

print(''.join(s))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque

s = deque(input())
reverse = 0
q = int(input())

for _ in range(q):
  query = input()
  if query == '1':
    reverse = 1 - reverse
  else:
    _,f,c = query.split()
    if f == '1':
      if reverse:
        s.appendleft(c)
      else:
        s.append(c)
    else:
      if reverse:
        s.append(c)
      else:
        s.appendleft(c)
if not  reverse:
  s.reverse()

print(''.join(s))
Problem p02787 (python)

Fixed submission:
h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [float('inf') for _ in range(h+max(skills,key=lambda x:x[1])[1] + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==float('inf'):
    continue
  for damage,mp in skills:
    if i+damage >= len(dp):
      continue
    if dp[i+damage] > dp[i] + mp:
      dp[i+damage] = dp[i]+mp
ans = min(filter(lambda x :x>0,dp[h:]))
print(ans)
#print(dp)

Buggy submission (verdict: Runtime Error):
h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [-1 for _ in range(h+max(skills) + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==-1:
    continue
  for damage,mp in skill:
    if dp[i+mp] < dp[i] + damage:
      dp[i+mp] = dp[i]+damage
print(min(dp[h:]))

Buggy submission (verdict: Runtime Error):
h,n = map(int,input().split())
lst = []
for _ in range(n):
  a,b = map(int,input().split())
  lst.append((a/b,a,b))
lst.sort()

_,a,b = lst[-1]

mp  = (h//a) * b
h -= h//a * a
lst.sort(key = lambda x:x[2])
for i in lst:
  if lst[i][1] >=h:
    mp += lst[i][2]
    break
print(mp)
Problem p02801 (python)

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

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
maze = []
pad = ' ' * (W+2)
maze.append(pad)
for i in range(H):
  m = input()
  maze.append(' ' + m + ' ')
maze.append(pad)
  
def bfs(maze, x,y, score):
    queue = [(x,y,0)]
    visited = {}
    while queue:
      x,y,s = queue.pop(0)
      if maze[x][y] != '.':
        continue
      visited[(x,y)] = s
      if (x+1,y) not in visited:
        queue.append((x+1,y,s+1))
      if (x-1,y) not in visited:
        queue.append((x-1,y,s+1))
      if (x,y+1) not in visited:
        queue.append((x,y+1,s+1))
      if (x,y-1) not in visited:
        queue.append((x,y-1,s+1))
    return max(visited.values())
  
ans = -1
for h in range(1,H+1):
  for w in range(1,W+1):
    now = maze[h][w]
    if now == '#':
      continue
    if maze[h-1][w] == maze[h+1][w] == maze[h][w-1] == maze[h][w+1] == '.':
      continue
    a = bfs(maze,h,w,0)
    if a > ans:
      ans = a
print(ans)
Problem p02813 (python)

Fixed submission:
n = int(input())
p = ''.join(input().split())
q = ''.join(input().split())

from itertools import permutations

all = list(permutations(list(map(str,range(1,n+1))), n))
all = list(map(lambda x: ''.join(x), all))
all.sort()
print(abs(all.index(p) - all.index(q)))

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

from itertools import permutations

lst = permutations(range(1,n+1))
lst.sort()
print(abs(lst.index(P) - lst.index(Q)))
Problem p02837 (python)

Fixed submission:
n = int(input())

def func(x):
  res = []
  for i in range(n):
    res.append(x%2)
    x //= 2
  return res

test = {}
for i in range(n):
  A = int(input())
  test[i+1] = []
  for a in range(A):
    x,y = map(int,input().split())
    test[i+1].append((x,y))

ans = 0
for i in range(2**n):
  people = func(i)
  for i in range(n):
    if people[i]:
      for x,y in test[i+1]:
        if people[x-1] == y:
          continue
        else:
          break
      else:
        continue
      break
  else:
    ans = max(sum(people),ans)
print(ans)

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

def func(x):
  res = []
  for i in range(n):
    res.append(x%2)
    x //= 2
  return res

test = {}
for i in range(n):
  A = int(input())
  test[i+1] = []
  for a in range(A):
    x,y = map(int,input().split())
    test[i].append((x,y))

ans = 0
for i in range(2**n):
  people = func(i)
  for i in range(n):
    if people[i]:
      for x,y in test[i+1]:
        if people[x-1] == y:
          continue
        else:
          break
      else:
        continue
      break
  else:
    ans = max(sum(people),ans)
print(ans)
Problem p02861 (python)

Fixed submission:
import math
n = int(input())
points = []
for i in range(n):
  x,y = map(int,input().split())
  points.append((x,y))

def distance(p1,p2):
  ans = (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2
  return math.sqrt(ans)

amount = 0
for i in range(len(points)):
  for j in range(len(points)):
    if i == j:
      continue
    amount += distance(points[i],points[j])
print(amount/n)

Buggy submission (verdict: Runtime Error):
n = int(input())
pos = []
for _ in range(n):
  x,y = map(int,input().split())
  pos.append((x,y))

import math
def distance(p1,p2):
  x1,y1 = p1
  x2,y2 = p2
  return math.sprt((x1-x2)**2 + (y1-y2)**2)
  
ans = 0
for i in range(n):
  for j in range(n):
    ans += distance(pos[i],pos[j])
print(ans/n)
Problem p02887 (python)

Fixed submission:
n = int(input())
s = input()

ans = 0
for i in range(1,n):
  if s[i] != s[i-1]:
    ans += 1
    
print(ans+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

ans = 0
for i in range(1,s):
  if s[i] != s[i-1]:
    ans += 1
    
print(ans)
Problem p02900 (python)

Fixed submission:
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)
import fractions

a,b = map(int,input().split())
#c = Euclid(a,b) if a > b else Euclid(b,a)
c = fractions.gcd(a,b)

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
  
if c == 1:
  print(1)
else:
  print(len(factorization(c))+1)

Buggy submission (verdict: Runtime Error):
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)

a,b = map(int,input().split())
c = Euclid(a,b) if a > b else Euclid(b,a)

def soinsu(a):
  for i in range(2,a+1):
    if a % i == 0:
      return i
    
ans = []
while 1:
  s = soinsu(c)
  c = int(c/s)
  ans.append(s)
  if c==1:
    break
print(len(set(ans)) + 1)
Problem p02923 (python)

Fixed submission:
n = int(input())
H = list(map(int,input().split()))[::-1]

ans = [0 for i in range(n)]

for i in range(1,n):
  if H[i-1] <= H[i]:
    ans[i] = ans[i-1]+1
  else:
    ans[i] = 0
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())[::-1]
H = list(map(int,input().split()))

ans = [0 for i in range(n)]

for i in range(1,n):
  if H[i] < H[i+1]:
    ans[i] = ans[i]+1
  else:
    ans[i] = 0
print(max(ans))
Problem p02952 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
  if len(str(i)) %2:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
ans = 0
for i in range(1,n+1):
  if len(str(i)) %2:
    ans += 1
print(ans)
Problem p02969 (python)

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

Buggy submission (verdict: Runtime Error):
r = int(input())
return 3 * r ** 2
Problem p02982 (python)

Fixed submission:
n,d = map(int,input().split())
points = []
for _ in range(n):
  X = tuple(map(int,input().split()))
  points.append(X)
  
ans = 0

import math
def distance(x,y):
  dis = 0
  for i in range(d):
    dis += (x[i]-y[i])**2
  return math.sqrt(dis)

for i in range(n-1):
  for j in range(i+1,n):
    dis = distance(points[i],points[j])
    if dis == int(dis):
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,d = map(int,input().split())
points = []
for _ in range(n):
  X = tuple(map(int,input().split()))
  points.append(X)
  
ans = 0

import math
def distance(x,y):
  dis = 0
  for i in range(d):
    dis += (x[i]-y[i])**2
  return math.sqrt(dis)

for i in range(n-1):
  for j in range(i+1,n):
    dis = distance(X[i],X[j])
    if dis == int(dis):
      ans += 1
print(ans)
Problem p02983 (python)

Fixed submission:
l,r = map(int,input().split())

cand = []
for i in range(l,r+1):
  cand.append(i%2019)
  if len(cand) == 2020*2:
    break
    
ans = float('inf')
for i in range(len(cand)):
  for j in range(len(cand)):
    if i==j:
      continue
    ans = min(ans, (cand[i]*cand[j])%2019)
    if ans ==0:
      break
  else:
    continue
  break
print(ans)

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

D.sort()
print(D[n//2] -D[n//2-1])
Problem p02995 (python)

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

lcm = c*d//fractions.gcd(c,d)
ansa = a - a//c - a//d + a//lcm
ansb = b - b//c - b//d + b//lcm

print(ansb-ansa)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
from fractions import gcd
cd_gcd = gcd(c,d)
lcm= c*d // ab_gcd
divs = lcm//c + lcm//d - 1

ans = 0
ans += int((b-a)/lcm)*divs
for i in range(a % lcm, b%lcm+lcm+1):
  if not i % c or not i % d:
    ans += 1
print(b-a - ans)