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

Fixed submission:
from collections import deque

N = int(input())
L = [deque([int(i)-1 for i in input().split()]) for i in range(N)]

q = deque(range(N))
d = [0 for i in range(N)]
pairs = [-1 for i in range(N)]
while q:
    a = q.popleft()  # qの左端の選手のindexをpopleft
    if len(L[a]) == 0:
        continue
    b = L[a].popleft()

    if pairs[b] == a:  # bのリクエストがaなら
        d[a] = d[b] = max(d[a], d[b]) + 1
        q.append(a)
        q.append(b)
    else:
        pairs[a] = b
print(max(d) if not any(L) else -1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
N = int(input())

match = [[-1] * (N) for _ in range(N)]
c = 0
for i in range(N):
    for j in range(i+1, N):
        match[i][j] = c
        c += 1


def get_id(i, j):
    if i > j:
        i, j = j, i
    return match[i][j]


start = []
G = {k: [] for k in range(c)}
for i in range(N):
    L = map(int, input().split())
    pid = -1
    for i, l in enumerate(L):
        id = get_id(i, l-1)
        if i == 0:
            start.append(id)
        else:
            G[pid].append(id)
        pid = id

visited = [False]*c
calculated = [False]*c
dp = [-1]*c


def dfs(v):
    if dp[v] >= 0:
        return dp[v]
    visited[v] = True
    dp[v] = 1
    for nxt in G[v]:
        if visited[nxt] is True and calculated[nxt] is False:
            print(-1)
            exit()
        d = dfs(nxt)
        if d >= dp[v]:
            dp[v] = d+1
    calculated[v] = True
    return dp[v]


ans = 0
for i in start:
    res = dfs(i)
    ans = max(ans, res)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
N = int(input())

match = [[-1] * (N) for _ in range(N)]
c = 0
for i in range(N):
    for j in range(i+1, N):
        match[i][j] = c
        c += 1


def get_id(i, j):
    if i > j:
        i, j = j, i
    return match[i][j]


start = []
G = {k: [] for k in range(c)}
for i in range(N):
    L = map(int, input().split())
    pid = -1
    for i, l in enumerate(L):
        id = get_id(i, l-1)
        if i == 0:
            start.append(id)
        else:
            G[pid].append(id)
        pid = id

visited = [False]*c
calculated = [False]*c
dp = [-1]*c


def dfs(v):
    if dp[v] >= 0:
        return dp[v]
    visited[v] = True
    dp[v] = 1
    for nxt in G[v]:
        if visited[nxt] is True and calculated[nxt] is False:
            print(-1)
            exit()
        d = dfs(nxt)
        if d >= dp[v]:
            dp[v] = d+1
    calculated[v] = True
    return dp[v]


ans = 0
for i in start:
    res = dfs(i)
    ans = max(ans, res)
print(ans)
Problem p02955 (python)

Fixed submission:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]


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

    divisors.sort(reverse=True)
    return divisors


lst = make_divisors(sum(A))

for l in lst:
    cnt_m, cnt_p = 0, 0
    ml = sorted([i % l for i in A])
    for m in ml:
        if cnt_m <= K-m:
            cnt_m += m
        else:
            cnt_p += l-m
    if cnt_m <= K and cnt_p <= K:
        print(l)
        exit()
print(1)

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

sA = sum(A)


def trial_division(n):
    # 素因数を格納するリスト
    factor = []
    # 2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    # リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor


lst = sorted(trial_division(sum(A)))

n = len(lst)
for i in range((2 ** n)-1, 0, -1):
    c = 1
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            c *= lst[j]  # フラグが立っていたら bag に果物を詰める

    cnt = 0
    for a in A:
        cnt += min(a % c, c-(a % c))
    if cnt//2 <= K:
        print(c)
        exit()

print(1)
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
a={int(input()) for _ in range(M)}

l=[0]*(N+1)
l[0]=1

for i in range(N):
    c=l[i]%1000000007
    if i>N-2:
        if i not in a:
            l[i+1]+=c
    elif i not in a:
        l[i+1]+=c
        l[i+2]+=c

print(l[N]%1000000007)

Buggy submission (verdict: Runtime Error):

N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]

l=[0]*(N+1)
l[0]=1

for i in range(N):
    c=l[i]%1000000007
    if i<=N-2:
        if i not in a:
            l[i+1]+=c
    elif i not in a:
        l[i+1]+=c
        l[i+2]+=c

print(l[N]%1000000007)

Buggy submission (verdict: Runtime Error):


N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]

l=[0]*(N+1)
l[0]=1

for i in range(N):
    c=l[i]%1000000007
    if i<=N-2:
        if i not in a:
            l[i+1]+=c
    elif i not in a:
        l[i+1]+=c
        l[i+2]+=c

print(l[N]%1000000007)
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S = input()
 
print(S[:K-1] + S[K-1].lower() + S[K:])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
 
S[K+1] = S[K+1].lower()
 
print(S)

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

S[N+1] = S[N+1].lower()

print(S)
Problem p03053 (python)

Fixed submission:
import numpy as np
import sys
# 距離K以内にxが居ない
# xからの距離を測る

buf = sys.stdin.buffer
R,C = map(int,buf.readline().split())
black = np.zeros((R+2,C+2),dtype=np.bool)
black[1:-1,1:] = (np.frombuffer(buf.read(R*(C+1)),dtype='S1') == b'#').reshape(R,C+1)

INF = 10 ** 9
dist = np.zeros((R,C),dtype=np.int32)
dist[~black[1:-1,1:-1]] = INF

for n in range(1,R):
  np.minimum(dist[n-1]+1,dist[n],out=dist[n])
for n in range(R-2,-1,-1):
  np.minimum(dist[n+1]+1,dist[n],out=dist[n])

for n in range(1,C):
  np.minimum(dist[:,n-1]+1,dist[:,n],out=dist[:,n])
for n in range(C-2,-1,-1):
  np.minimum(dist[:,n+1]+1,dist[:,n],out=dist[:,n])

answer = dist.max()
print(answer)

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


H,W=map(int,input().split())
A=[list(input()) for _ in range(H)]   # (i,j) = A[i][j]
seen = [[False] * W for _ in range(H)] 
queue = collections.deque([])

for i in range(H):
    for j in range(W):
        if A[i][j]=='#':
            queue.append((i,j,0))
            seen[i][j]=True

while queue:
    i,j,k=queue.popleft()
    if i!=0   and seen[i-1][j] == False: 
        queue.append((i-1,j,k+1))
        seen[i-1][j]=True
    if i!=H-1 and seen[i+1][j] == False:
        queue.append((i+1,j,k+1))
        seen[i+1][j]=True
    if j!=0   and seen[i][j-1] == False:
        queue.append((i,j-1,k+1))
        seen[i][j-1]=True
    if j!=W-1 and seen[i][j+1] == False:
        queue.append((i,j+1,k+1))
        seen[i][j+1]=True

print(k)
Problem p03072 (python)

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

max_ = 0
cnt = 0

for h in H:
  if h >= max_:
    cnt += 1
    max_ = h

print(cnt)

Buggy submission (verdict: Runtime Error):
input()
H = list(map(int, input()))

max = 0
cnt = 0

for h in H:
  if h >= max:
    cnt += 1
    max = h

print(cnt)
Problem p03307 (python)

Fixed submission:
import fractions
N = int(input())

print(2*N if N%2==1 else N)

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
print(2 * N / gcd(2,N))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
print(math.gcd(2,N))
Problem p03315 (python)

Fixed submission:
S = input()
print(S.count('+')-S.count('-'))

Buggy submission (verdict: Runtime Error):
S = input()
print(S.count('+')-s.count('-'))
Problem p03329 (python)

Fixed submission:
N=int(input())
dp=[10**7]*3000000
dp[0]=0

pow6=[6**j for j in range(10) if 6**j <= N]
pow9=[9**j for j in range(10) if 9**j <= N]

for i in range(N):
    for p6 in pow6:
        dp[i+p6]=min(dp[i+p6], dp[i]+1)
    for p9 in pow9:
        dp[i+p9]=min(dp[i+p9], dp[i]+1)

print(dp[N])

Buggy submission (verdict: Runtime Error):
N=int(input())
dp=[10**7]*110000
dp[0]=0

pow6=[6**j for j in range(10) if 6**j <= N]
pow9=[9**j for j in range(10) if 9**j <= N]

for i in range(N):
    for p6 in pow6:
        dp[i+p6]=min(dp[i+p6], dp[i]+1)

    for p9 in pow9:
        dp[i+p9]=min(dp[i+p9], dp[i]+1)

print(dp[N])
Problem p03634 (python)

Fixed submission:
from collections import deque

N = int(input())

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

Q, K = map(int, input().split())

visited = [False] * N
visited[K-1] = True

distance = [-1]*N

que = deque([(K, 0)])
while que:
    cur, d = que.popleft()
    distance[cur-1] = d

    for nx, nd in G[cur-1]:
        if visited[nx-1] is False:
            visited[nx-1] = True
            que.append((nx, d+nd))

for i in range(Q):
    x, y = map(int, input().split())
    print(distance[x-1]+distance[y-1])

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

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

Q, K = map(int, input().split())

visited = [False] * N
visited[K-1] = True

distance = [-1]*N


def dfs(v, p, d):  # 現在の頂点v, vの親p, 現在の距離d
    distance[v-1] = d
    for i, c in G[v-1]:
        if visited[i-1] is False:
            if i == p:
                continue
            dfs(i, v, d+c)
    return


dfs(K, -1, 0)

for i in range(Q):
    x, y = map(int, input().split())
    print(distance[x-1]+distance[y-1])
Problem p02572 (python)

Fixed submission:
import math
import itertools
import sys
n = int(input())
a = list(map(int, input().split()))
ans = 0
all = 0
for i in a:
    all += i
for i in a:
    all -= i
    ans += i*all
    if(ans > 10**9+7):
        ans %= 10**9+7
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import itertools
import sys
n = int(input())
a = list(map(int, input().split()))
ans = 0
all = 0
for i in a:
    all += i
for i in a:
    all -= i
    ans += i*all
    if(ans > 10**9+7):
        ans %= 10**9+7
print(ans)
Problem p02689 (python)

Fixed submission:
import sys
import math

n, m = map(int, input().split())
h = list(map(int, input().split()))
ma = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    ma[a - 1] = max(ma[a-1],h[b - 1])
    ma[b - 1] = max(ma[b-1] ,h[a - 1])
cnt = 0
for i in range(n):
    if h[i] > ma[i]:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [True] * n
lis = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    lis[a - 1] = max(lis[a - 1], h[b - 1])
    lis[b - 1] = max(lis[b - 1], h[a - 1])
ans = 0
if lis[i] < h [i]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [True] * n
lis = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    lis[a - 1] = max(lis[a - 1], h[b - 1])
    lis[b - 1] = max(lis[b - 1], h[a - 1])
ans = 0
if lis[i] > h [i]:
    ans += 1
print(ans)
Problem p02987 (python)

Fixed submission:
a = str(input())
b=list(set(a))

if len(b) == 2:
  count = 0
  for i in range(1,4):
    if a[i] == a[0]:
      count +=1
  if count ==1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from collections import deque
 
N, M = map(int, input().split())
 
vec = [[] for _ in range(N)]
for _ in range(M) :
    u, v = map(int, input().split())
    vec[u-1].append(v-1)
 
S, T = map(int, input().split())
S, T = S - 1, T - 1
 
visited = [[False] * N for _ in range(3)]
visited[0][S] = True
queue = deque([(S, 0)])
 
while queue :
    #print(queue)
    q, cost = queue.popleft()
    #print(q,cost)
    #print("vec[q] =",vec[q])
    p = (cost + 1) % 3
    for i in vec[q] :
        if p == 0 and i == T :
            
            print((cost + 1) // 3)
            exit()
        if not visited[p][i] :
            visited[p][i] = True
            #print(visited)
            #print(i)
            queue.append((i, cost + 1))
 
print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
 
N, M = map(int, input().split())
 
vec = [[] for _ in range(N)]
for _ in range(M) :
    u, v = map(int, input().split())
    vec[u-1].append(v-1)
 
S, T = map(int, input().split())
S, T = S - 1, T - 1
 
visited = [[False] * N for _ in range(3)]
visited[0][S] = True
queue = deque([(S, 0)])
 
while queue :
    #print(queue)
    q, cost = queue.popleft()
    #print(q,cost)
    #print("vec[q] =",vec[q])
    p = (cost + 1) % 3
    for i in vec[q] :
        if p == 0 and i == T :
            
            print((cost + 1) // 3)
            exit()
        if not visited[p][i] :
            visited[p][i] = True
            #print(visited)
            #print(i)
            queue.append((i, cost + 1))
 
print(-1)
Problem p02989 (python)

Fixed submission:
N = int(input())
ds = input().split()
ds = [int(i) for i in ds]
ds.sort()
#print(ds)
#if ds[int(N/2)] == ds[int(N/2)+1]:
#  print("0")
#else:
print(ds[int(N/2)]-ds[int(N/2)-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
ds = input().split()
ds = [int(i) for i in ds]
ds.sort()
#print(ds)
#if ds[int(N/2)] == ds[int(N/2)+1]:
#  print("0")
#else:
print(ds[int(N/2)+1]-ds[int(N/2)])

Buggy submission (verdict: Runtime Error):
N = int(input())
ds = input().split()
ds = [int(i) for i in ds]
ds.sort()
#print(ds)
if ds[int(N/2)] == ds[int(N/2)+1]:
  print("0")
else:
  print("1")
Problem p03011 (python)

Fixed submission:
x = input().split()
sum1 = int(x[0]) + int(x[1])
sum2 = int(x[1]) + int(x[2])
sum3 = int(x[0]) + int(x[2])
print(min(sum1, sum2, sum3))

Buggy submission (verdict: Runtime Error):
print(hello)
Problem p03012 (python)

Fixed submission:
y = input()
y = input().split()
y = [ int(x) for x in y]
sum_go = []
sum_back = []
for i in range(1, len(y)):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
#print(sum_go)
#print(sum_back)
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))

Buggy submission (verdict: Runtime Error):
y = input()
y = input().split()
y = [ int(x) for x in y]
sum_go = []
sum_back = []
for i in range(1, num):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))

Buggy submission (verdict: Runtime Error):
y = input()
y = input().split()
y = [ int(x) for x in y]
sum_go = []
sum_back = []
for i in range(0, num):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))

Buggy submission (verdict: Runtime Error):
y = input()
y = input().split()
y = [ int(x) for x in y]
sum_go = []
sum_back = []
for i in range(1, num):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))

Buggy submission (verdict: Runtime Error):
input()
y = input().split()
y = [ int(x) for x in y]
sum_go = []
sum_back = []
for i in range(1, num):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))

Buggy submission (verdict: Runtime Error):
y = input().split()
y = [ int(x) for x in y]
y = y[1:]
sum_go = []
sum_back = []
for i in range(1, num):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))
Problem p02627 (python)

Fixed submission:
a = input()
if a.islower():
  print("a")
else:
  print("A")

Buggy submission (verdict: Runtime Error):
n = int(input()) 
a = [0 for i in range(15)]
alf = "abcdefghijklmnopqrstuvwxyz" 
hasStarted = False
hasFound = False
for j in range(14, -1, -1):
	rem = n // (26**j)
	if rem == 0:
		continue
	else:
		a[j] = rem
		n -= rem*(26**j)
a.reverse()
res = ""
for c in a:
	if hasStarted:
		if c == 0:
			res += "z"
		else:
			res += alf[c-1]
	else:
		if c != 0:
			res += alf[c-1]
			hasStarted = True

print(res)
Problem p02712 (python)

Fixed submission:
n = int(input())
a = [0]*n
for i in range(1, n+1):
  if i % 3 == 0 or i % 5 == 0:
    pass
  else:
    a[i-1] = i
print(sum(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [0]*n
for i in range(1, n+1):
  if i % 3 == 0 or i % 5 == 0:
    pass
  else:
    a[i] = i
print(sum(a))
Problem p02723 (python)

Fixed submission:
s = input()

if s[2]==s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
#500-1000, 5-5

x = int(input())
fiveHundred = x//500
x -= fiveHundred*500
fives = x//5
print(fiveHundred*1000+fives*5)
Problem p02598 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[16]:


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


# In[49]:


low = 0
high = max(A)
def ok(x):
    cnt = 0
    for a in A:
        cnt += (a//x)
        if a%x == 0:
            cnt -= 1
    return cnt <= K
 
while high-low > 1:
    mid = (high+low)//2
    if ok(mid):
        high = mid
    else:
        low = mid
print(high)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[16]:


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


# In[23]:


max(A)
cnt


# In[41]:


cnt = 0
low = 0
high = max(A)
ans = max(A)
old = int(high)
mycount = 0
while low < high:
    mid = (high+low)/2
    cnt = sum([(x-0.001)//mid for x in A])
    if cnt <= K:
        high = mid
        ans = min(ans, int(-(-mid//1)))
    else:
        low = mid
    if int(mid) == old:
        mycount += 1
    if mycount == 100:
        break
    old = int(mid)
print(ans)


# In[ ]:
Problem p02959 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[26]:


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


# In[28]:


ans = 0
for i in range(N):
    ans += min(A[i], B[i])
    B[i] = max(B[i]-A[i], 0)
    ans += min(A[i+1], B[i])
    A[i+1] = max(A[i+1]-B[i], 0)
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[26]:


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


# In[27]:


ans = 0
for i in range(N):
    ans += min(A[i], B[i])
    B[i] = max(B[i]-A[i])


# In[ ]:
Problem p03208 (python)

Fixed submission:

# coding: utf-8

# In[3]:


import numpy as np


# In[38]:


n,k = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))


# In[43]:


h = np.array(h)
sorted_h = np.sort(h)
print(min(sorted_h[k-1:] - sorted_h[:-k+1]))

Buggy submission (verdict: Runtime Error):

# coding: utf-8

# In[3]:


import numpy as np


# In[19]:


n,k = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))


# In[20]:


h = np.array(h)


# In[21]:


sorted_h = np.sort(h)


# In[22]:


print(min(sorted_h[k-1:] - sorted_h[:k]))
Problem p03209 (python)

Fixed submission:

# coding: utf-8

# In[103]:


n,x = map(int, input().split())


# In[104]:


def p(n):
    return 2 ** (n+1) - 1
def b(n):
    return 2 ** (n+1) - 2
def l(n):
    return 2 ** (n+2) - 3


# In[109]:


def func(i, x):
    if x == 0:
        return 0
    elif x <= l(i-1) + 1:
        return func(i-1, x-1)
    elif x == l(i-1) + 2:
        return p(i-1) + 1
    elif x <= 2 * l(i-1) + 2:
        return p(i-1) + 1 + func(i-1, x - l(i-1) - 2)
    else:
        return 2 * p(i-1) + 1


# In[110]:


print(func(n,x))

Buggy submission (verdict: Runtime Error):

# coding: utf-8

# In[54]:


n,x = map(int, input().split())


# In[42]:


def p(n):
    return 2 ** (n+1) - 1
def b(n):
    return 2 ** (n+1) - 2
def l(n):
    return 2 ** (n+2) - 3


# In[56]:


def func(i,x):
    if x <= l(i):
        if i == 0:
            if x == 1:
                return 1
            else:
                return 0
        else:
            if x <= 2**(i+1) - 2:
                return func(i-1, x-1)
            else:
                return p(i-1) + 1 + func(i-1, x-(2**(i+1)-2)-1,)


# In[57]:


print(func(n,x))

Buggy submission (verdict: Runtime Error):

# coding: utf-8

# In[1]:


n,x = map(int, input().split())


# In[5]:


def p(n):
    return 2 ** (n+1) - 1
def b(n):
    return 2 ** (n+1) - 2
def l(n):
    return 2 ** (n+2) - 3


# In[30]:


def func(i,x):
    if x > l(i):
        print("error")
    else:
        if i == 0:
            if x == 1:
                return 1
            else:
                return 0
        else:
            if x <= 2**(i+1) - 2:
                return func(i-1, x-1)
            else:
                return p(i-1) + 1 + func(i-1, x-(2**(i+1)-2)-1,)


# In[34]:


print(func(n,x))
Problem p02578 (python)

Fixed submission:
#中身の数
n = int(input())
#リスト
a = list(map(int,input().split()))
#合計
p = 0
#前が使った土
q = 0

for i in range(n-1):
  #前の人との差
  e = a[i+1]-a[i]
  if e > 0:
    if e > q:
      q = 0
    else:
      q = q-e
  else:
    q = q-e
  p += q
  
print(p)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
p = 0
q = 0
for i in range(n-1):
  e = a[i+1]-a[i]
  if e > 0:
    q = 0
  else:
    if p-q > e:
      q -= e
    else:
      q -= e
      e = q
print(s)
Problem p02595 (python)

Fixed submission:
n,d = map(int,input().split())
num = 0
for i in range(n):
  x,y = map(int,input().split())
  if (x**2 + y**2) <= d**2:
    num += 1
  else:
    num += 0
print(num)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
ans = 0
for i in range(n):
  x, y = map(int, input().split())
  if (x**2+y**2) <= D**2:
    ans +=1
  else:
    ans +=0

print(ans)
Problem p02596 (python)

Fixed submission:
k = int(input())
a = 0
for i in range(k):
  a = (a*10+7)%k
  if a == 0:
    print(i+1)
    quit()
print(-1)

Buggy submission (verdict: Runtime Error):
k = int(input())
a = 0
for i in range(k):
  a = (a*10+7)%k
  if a == 0:
    print(i+1)
    brake
print(-1)

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

if a%2 == 0:
  print(-1)
else:
  ans = 1
  div = 0
  
  for i in range(10**6):
    div += 7*10**i
    if a%div == 0:
      break
    else:
      ans +=1

print(ans)
Problem p02597 (python)

Fixed submission:
n = int(input())
c = input()
d = c.count('R')
e = c[:d].count('R')
print(d-e)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = input()
d = c.count(w)
e = c.count(w)[:d]
print(d-e)