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

Fixed submission:
roman = "abcdefghijklmnopqrstuvwxyz"
num_to_roman = {}
for i in range(26):
  num_to_roman[i] = roman[i]

n = int(input())
ans = []
while(n):
  n-=1
  ans.insert(0,num_to_roman[n%26])
  n = n//26
  
ans_str = ''.join(ans)
print(ans_str)

Buggy submission (verdict: Runtime Error):
roman = "abcdefghijklmnopqrstuvwxyz"
num_to_roman = {}
for i in range(26):
  num_to_roman[i+1] = roman[i]

n = int(input())
ans = []
while(n):
  ans.insert(0, num_to_roman[n%26])
  n = n//26
  
ans_str = ''.join(ans)
print(ans_str)
Problem p02725 (python)

Fixed submission:
k, n = map(int,input().split())
length = list(map(int,input().split()))
length.append(k+length[0])
distance =[]
for i in range(n):
  distance.append(length[i+1]-length[i])
print(k-max(distance))

Buggy submission (verdict: Runtime Error):
k, n = map(int,input().split())
length = list(map(int,input().split()))
distance =[]
for i in range(n):
  distance.append(length[i+1]-length[i])
distance.append(k-length[n-1])
print(k-max(distance))

Buggy submission (verdict: Runtime Error):
k, n = map(int,input().split())
length = list(map(int,input.split())
distance =[]
for i in range(n-1):
  diatance.append(lenght[i+1]-lenght[i])
distance.append(k-length[n-1])
print(k-max(distance))

Buggy submission (verdict: Runtime Error):
k, n = map(int,input().split())
length = list(map(int,input.split())
distance =[]
for i in range(n):
  diatance.append(lenght[i+1]-lenght[i])
distance.append(k-length[n-1])
print(k-max(distance))
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
 
forbidden = []
for i in range(m):
  forbidden.append(int(input()))
forbidden = set(forbidden) 
ans = [0]*(n+1)
ans[0] = 1
if 1 not in forbidden:
  ans[1] = 1
for i in range(2,n+1):
  if i not in forbidden:
    ans[i] += ans[i - 1] + ans[i - 2]
    ans[i] %= 1000000007
print(ans[-1])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
 
forbidden = []
for i in range(m):
  forbidden.append(int(input()))
forbidden = set(forbidden) 
ans = [0]*n
ans[0] = 1
if 1 not in forbidden:
  ans[1] = 1
for i in range(2,n):
  if i not in forbidden:
    ans[i] += ans[i - 1] + ans[i - 2]
    ans[i] %= 1000000007
print(ans[-1])

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

forbidden = []
for i in range(m):
  forbidden.append(int(input()))

ans = [1, 1]
if 1 in forbidden:
  ans[-1] = 0
for i in range(2,n+1):
  if i in forbbidden:
    ans.append(0)
  else:
    ans.append(ans[-1]+[ans[-2]])
  if ans[-1] == 0 and ans[-2] == 0:
    print(0)
  if i == n:
    print(ans[-1])
Problem p03053 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
s = [input() for i in range(h)]

d = [[h+w for j in range(w)] for i in range(h)]
que = deque()

#黒だったらスタートキューに入れる
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
        que.append((i, j))
        d[i][j] = 0

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


while que:
    p = que.popleft()
    # 黒にする4方向をループ
    for i in range(4):
        nx = p[1] + dx[i]
        ny = p[0] + dy[i]

        if (0<=nx<w) and (0<=ny<h) and (d[ny][nx]==h+w):
            que.append((ny, nx))
            d[ny][nx] = d[p[0]][p[1]] + 1

res = max(map(max, d))
print(res)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
sys.setrecursionlimit(100000000)
 
h,w=map(int, input().split())  
s=[list(input()) for i in range(h)]
v=[]
def bfs():
    d = [[float("inf")] * w for i in range(h)]
    que = deque([])
    #黒だったらスタートキューに入れる
    for i in range(h):
        for j in range(w):
            if s[i][j]=='#':
                que.append((i, j))
                d[i][j]=0
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    
    
    while que:
        p = que.popleft()
         # 黒にする4方向をループ
        for i in range(4):
            ny = p[0] + dx[i]
            nx = p[1] + dy[i]
 
            if 0<=nx<w and 0<=ny<h and d[nx][ny] == float("inf"):
                que.append((ny, nx))
                d[nx][ny] = d[p[0]][p[1]] + 1
                
    for i in range(h):
        v.append(max(d[i]))
    return max(v)
res=bfs()
print(res)
Problem p03055 (python)

Fixed submission:
import queue
n = int(input())

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
q = queue.Queue()
q.put(a)
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a]:
        if (v[b] == 0 and len(tree[b]) > 1):
            q.put(b)
            v[b] = 1

s = a
q = queue.Queue()
q.put([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a[0]]:
        if (v[b] == 0 and len(tree[b]) > 1):
            q.put([b, a[1] + 1])
            v[b] = 1

if n <= 3:
    l = n
else:
	l = a[1] + 2

if l%3 == 2:
    print("Second")
else:
    print("First")

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

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
q = queue.Queue()
q.put(a)
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a]:
        if (v[b] == 0 and len(tree[b]) != 1):
            q.put(b)
            v[b] = 1

s = a
q = queue.Queue()
q.put([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a[0]]:
        if (v[b] == 0 and len(tree[b]) != 1):
            q.put([b, a[1] + 1])
            v[b] = 1

if n <= 3:
    l = n
elif:
    l = a[1] + 2
if l%3 == 2:
    print("Second")
else:
    print("First")

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

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
q = queue.Queue()
q.put(a)
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a]:
        if (v[b] == 0 and len(tree[b]) != 1):
            q.put(b)
            v[b] = 1

s = a
q = queue.Queue()
q.put([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a[0]]:
        if (v[b] == 0 and len(tree[b]) != 1):
            q.put([b, a[1] + 1])
            v[b] = 1

if n <= 3:
  l = n
elif:
	l = a[1] + 2
if l%3 == 2:
    print("Second")
else:
    print("First")
Problem p03295 (python)

Fixed submission:
n, m = map(int, input().split())
e = []
for i in range(m):
  e.append(list(map(int, input().split())))

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
e = []
for i in range(m):
  e.append(list(map(int, input, split())))

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
kouho = set([i + 1 for i in range(N)])
hazure = set()
for i in range(M):
    a, b = map(int, input().split())
    Ha = H[a]
    Hb = H[b]
    if Ha >= Hb:
        hazure.add(b)
    if Ha <= Hb:
        hazure.add(a)
ans = kouho - hazure
print(len(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
kouho = [i + 1 for i in range(N)]
for i in range(M):
    a, b = map(int, input(),split())
    if H[a] > H[b] and b in kouho:
        kouho.remove(b)
    elif H[a] < H[b] and a in kouho:
        kouho.remove(a)
    elif H[a] == H[b]:
        if a in kouho:
            kouho.remove(a)
        if b in kouho:
            kouho.remove(b)
print(len(kouho))
Problem p02933 (python)

Fixed submission:
def resolve():
    a = int(input())
    s = input()

    if a >= 3200:
        print(s)
    else:
        print('red')
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
 
def resolve():
    def dfs(num, p=-1):
        for i in to[num]:
            if p == i:
                continue
            ns[i] += ns[num]
            dfs(i, num)
 
    n, q = map(int, input().split())
 
    to = [[] for _ in range(n)]
 
    for _ in range(n-1):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
 
    ns = [0 for _ in range(n)]
    for _ in range(q):
        p, x = map(int, input().split())
        p -= 1
        ns[p] += x
 
    dfs(0)
    print(*ns)
resolve()
Problem p03286 (python)

Fixed submission:
n=int(input())
flg = 0
if n < 0:
    n *= -1
    flg = 1
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    try:
        if l[-i] == 2:
            l[-i] = 0
            if i == len(l):
                l.insert(0,1)
            else:
                l[-(i+1)]+=1
        if i%2==flg and l[-i]==1:
            if i == len(l):
                l.insert(0,1)
            else:
                l[-(i+1)]+=1
    except:
        pass
s = ''.join([str(x) for x in l])
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    if l[-i] == 2:
        l[-i] = 0
        if i == len(l):
            l.insert(0,1)
        else:
            l[-(i+1)]+=1
    if i%2==0 and l[-i]==1:
        if i == len(l):
            l.insert(0,1)
        else:
            l[-(i+1)]+=1
s = ''.join([str(x) for x in l])
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    if l[-i] == 2:
        l[-i] = 0
        try:
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
    if i%2==0 and l[-i]==1:
        try: 
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
s = ''.join([str(x) for x in l])
print(s)

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

n=int(input())
l=list(map(int,str(bin(n))[2:]))
for i in range(1,len(l)+3): 
    if l[-i] == 2: #2のとき繰上げ
        l[-i] = 0
        try:
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
    if i%2==0 and l[-i]==1: #-2^nが-2のとき01→11に変換
        try: 
            l[-(i+1)]+=1
        except:
            l.insert(0,1)
s = ''.join([str(x) for x in l])
print(s)
Problem p02676 (python)

Fixed submission:
K=int(input())
S=list(input())
if len(S)>K:
  answer=[]
  for i in range(K):
    answer.append(S[i])
  answer.append('...')
  s=''
  for i in range(len(answer)):
    s+=answer[i]
  print(s)
else:
  g=''
  for i in range(len(S)):
    g+=S[i]
  print(g)

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())
answer=[]
for i in range(K):
  answer.append(S[i])
  
answer.append('...')
s=''
for i in range(len(answer)):
  s+=answer[i]
  
print(s)
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
result = [1]*N
for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

for a, b in zip(A, B):
    if H[a-1] <= H[b-1]:
        result[a-1] = 0

for a, b in zip(B, A):
    if H[a-1] <= H[b-1]:
        result[a-1] = 0

print(result.count(1))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
result = [0]*M
for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

for a, b in zip(A, B):
    if H[a-1] < H[b-1]:
        result[a-1] = 1

for a, b in zip(A, B):
    if H[a-1] > H[b-1]:
        result[b-1] = 1

C =A+B
D = N - len(set(C))
print(result.count(1)+D)
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
C = N // (A + B) * A + N % (A + B)
D = N // (A + B) * A + A
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N % (A + B) > A:
    print(D)
else:
    print(C)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
F = A + B
C = N // F
D = N % C
E = A * C
if A == 0:
  print(0)
elif B == 0:
  if A > N:
    print(A - N)
  else:
    print(N)
elif C == 0:
  if N < A:
    print(N)
  else:
    print(A)
else:
  if D < A:
    print(E + D)
  else:
    print(E + A)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
F = A + B
C = N // F
D = N % C
E = A * C
if A == 0:
  print(0)
elif B == 0:
  print(A)
elif C == 0:
  if N < A:
    print(N)
  else:
    print(A)
else:
  if D < A:
    print(E + D)
  else:
    print(E + A)
Problem p02831 (python)

Fixed submission:
A, B = map(int, input().split())
from fractions import gcd
 
print(A * B // gcd(A, B))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
from fractions import gcd
 
print(A * B // gcd(A, B)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
from fraction import gcd
 
print(A * B // gcd(A, B))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
import math

print(A * B // math.gcd(A, B))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
import math
C = math.gcd(A, B)
print(A * B // C)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
import math
C = math.gcd(A, B)
print(A * B // C)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
import math
C = math.gcd(A, B)
print(A * B // C)
Problem p03209 (python)

Fixed submission:
N,X = map(int,input().split())
def lb(N):
    if N != 0:
        return 2*lb(N-1)+3
    else:
        return 1
def pn(N):
    if N != 0:
        return 2*pn(N-1)+1
    else:
        return 1
def B(N,X):
    if X == 0:
        return 0
    elif N == 0:
      	return 1
    elif lb(N-1)+1 >= X:
        return B(N-1,X-1)
    else:
        return pn(N-1)+1+B(N-1,X-lb(N-1)-2)
print(B(N,X))

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
def lb(N):
    if N != 0:
        return 2*lb(N-1)+3
    else:
        return 1
def pn(N):
    if N != 0:
        return 2*pn(N-1)+1
    else:
        return 1
def B(N,X):
    if X == 0:
        return 0
    elif lb(N-1)+1 >= X:
        return B(N-1,X-1)
    else:
        return pn(N-1)+1+B(N-1,X-lb(N-1)-2)
print(B(N,X))
Problem p02623 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

N = a[0]
M = a[1]
K = a[2]

count = 0 #読んだ冊数を記録
count_time = 0 #読んだ時間を記録
a = [0]
b = [0]

for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break 
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

N = a[0]
M = a[1]
K = a[2]

count = 0 #読んだ冊数を記録
count_time = 0 #読んだ時間を記録
a = [0]
b = [0]

for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break 
    while b[j] < K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

N = a[0]
M = a[1]
K = a[2]

count = 0 #読んだ冊数を記録
count_time = 0 #読んだ時間を記録

if K<A[0] or K<B[0]:
    pass
 
else:
    while K > count_time:
        if len(A)!=0 and len(B)!=0:
            if A[0] >= B[0]:
                count_time += B[0]
                count += 1
                B.pop(0)

            if A[0] < B[0]:
                count += 1
                count_time += A[0]
                A.pop(0)

        elif len(A)==0 and len(B)!=0:
            count += 1
            count_time += B[0]
            B.pop(0)

        elif len(B)==0 and len(A)!=0:
            count += 1
            count_time += A[0]
            A.pop(0)

        else:
            count += 1
            break

print(count)
Problem p02860 (python)

Fixed submission:
t = int(input())
s = input()
if(s[0:t//2]==s[t//2:t]):
   print("Yes")
else:
   print("No")

Buggy submission (verdict: Runtime Error):
t = int(input())
s = input()
if(s[0:t//2]==s[t//2:t]:
   print("Yes")
else:
   print("No")
Problem p02725 (python)

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

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

Buggy submission (verdict: Runtime Error):
k,n=map(int,input().split())
a=list(map(int,input().split()))
if a[-1]-a[0]<=(k-a[-1])+a[0]:
    print(a[-1]-a[0])
else:
    for i in range(n-1):
        if a[-1]-a[i]>(k-a[-1])+a[i]:
            start=i
        else:
            break
print(((k-a[-1])+a[start])+(a[-1]-a[start+1]))
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)

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

ball=""
cnt=0

for i in range(n//(a+b)+1):
    ball+="b"*a
    ball+="r"*b
for i in range(n):
    if ball[i]=="b":
        cnt+=1
print(cnt)
Problem p02831 (python)

Fixed submission:
def gcd(m,n):
	x=max(m,n)
	y=min(m,n)
	if x%y==0:
		return y
	else:
		while x%y!=0:
			z=x%y
			x=y
			y=z
		else:
			return z

def lcm(m,n):
	return int(m*n/gcd(m,n))
	
	
a,b=map(int,input().split())
print(lcm(a,b))

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

print(a*b//math.gcd(a,b))
Problem p02897 (python)

Fixed submission:
x = int(input())
f = x // 2
print((x-f)/x)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in n:
  if i%2==1:
    ans+=1
print(ans/n)
Problem p02915 (python)

Fixed submission:
n=int(input())
print(n**3)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().split()))
ans = b[0]
for i in range(len(b)-1):
  ans.append(min(b[i], b[i+1]))
ans += b[-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().split()))
ans = b[0]
for i in range(len(b)-1):
  ans.append(min(b[i], b[i+1]))
  ans += b[-1]
print(ans)
Problem p02933 (python)

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

if a>=3200:
  print(s)
else:
  print("red")

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

if a >=　3200:
  print(s)
else:
  print("red")
Problem p03011 (python)

Fixed submission:
p,q,r=map(int,input().split())
print(min(p+q,q+r,r+p))

Buggy submission (verdict: Runtime Error):
p,q,r=map(int,input().split())
print(min(p+q,q+r,r+p)
Problem p03041 (python)

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

s[k-1] = s[k-1].lower()

print(''.join(s))

Buggy submission (verdict: Runtime Error):
n,k=int(input())
s=input()
str.lower(s[k])
print(s)
Problem p03075 (python)

Fixed submission:
a,b,c,d,e,k=[int(input()) for i in range(6)]
print("Yay!" if e-a<=k else ":(")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k=[int(input()) for i in range(5)]
print("Yay!" if e-a<=k else ":(")
Problem p03315 (python)

Fixed submission:
s=input()
print(s.count("+")-s.count("-"))

Buggy submission (verdict: Runtime Error):
s=input()
ams=0

for i in s:
  if s[i]==+:
    ans+=1
  else:
    ans-=1
    
print(ans)
Problem p03631 (python)

Fixed submission:
a,b,c=input()
print("Yes" if a==c else "No")

Buggy submission (verdict: Runtime Error):
n=int(input())
print("Yes" if n[0]==n[2] else "No")
Problem p02819 (python)

Fixed submission:
def Eratosthenes(n):
    li = [i for i in range(2,n+1)]
    judge = [True for i in range(n+1)]
    ans = []
 
    for i in range(2,n+1):
        if judge[i] == True:
            for j in range(i*2,n+1,i):
                judge[j] = False
            ans.append(i)
    return ans
 
x = int(input())
l = Eratosthenes(10 ** 6)
for i in l:
    if i >= x:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
from sympy import sieve
 
def Eratosthenes(n):
    li = [i for i in range(2,n+1)]
    judge = [True for i in range(n+1)]
    ans = []
 
    for i in range(2,n+1):
        if judge[i] == True:
            for j in range(i*2,n+1,i):
                judge[j] = False
            ans.append(i)
    return ans
 
x = int(input())
l = Eratosthenes(10 ** 6)
for i in l:
    if i >= x:
        print(i)
        exit()
Problem p03038 (python)

Fixed submission:
N,M = (int(i) for i in input().split())
A = sorted([int(i) for i in input().split()])
e,p = [(0,0)],0
for k, v in sorted([[int(i) for i in input().split()] for i in range(M)], key=lambda x: -x[1]):
    e.append((e[p][0]+k,v))
    p+=1

p = 1
for i in range(min(e[-1][0],len(A))):
    B,C = e[p]
    if A[i]<C:
        A[i]=C
    else:
        break
    if i == B-1:
        p+=1
print(sum(A))

Buggy submission (verdict: Runtime Error):
import itertools
N,M = (int(i) for i in input().split())
A = sorted([int(i) for i in input().split()])
accum = list(itertools.accumulate(A))
e = []
for k, v in sorted([[int(i) for i in input().split()] for i in range(M)], key=lambda x: -x[1]):
    e.append((k,v))
i = 0
for B,C in e:
    for _ in range(B):
        if A[i] < C:
            A[i] = C
            i+=1
        else:
            print(sum(A))
            exit()
print(sum(A))
Problem p03775 (python)

Fixed submission:
n = int(input())

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()
    return divisors

l = make_divisors(n)
#print(l)

A = l[len(l)//2]
B = l[len(l)//2-1]

print( max( len(str(A)), len(str(B)) ) )

Buggy submission (verdict: Runtime Error):
import heapq

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A = prime_factorize(n)
heapq.heapify(A)

while len(A) > 2:
    a = heapq.heappop(A)
    b = heapq.heappop(A)
    heapq.heappush(A, a * b)

print(max((len(str(max(A)))), len(str(min(A)))) )
Problem p02598 (python)

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

max_a = max(A)
min_a = 0

while abs(max_a - min_a) > 1:
    cnt = 0
    target_length = (max_a + min_a)//2
    for a in A:
        cut_num = (a + target_length - 1)//target_length
        cnt += cut_num - 1
    if cnt > k:
        min_a = target_length
    else:
        if target_length - min_a == 1:
            print(target_length)
            exit()
        max_a = target_length

print(max_a)

Buggy submission (verdict: Runtime Error):
import math

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

ceil = math.ceil

max_a = max(a)
target_length = max_a//2 + 1
min_a = 0




while True:
    cnt = 0
    for a in A:
        cut_num = (a + target_length - 1)//target_length
        cnt += cut_num
    if cnt > k:
        min_a = target_length
        target_length = (target_length + max_a)//2
    else:
        if target_length - min_a == 1:
            print(target_length)
            exit()
        max_a = target_length
        target_length = (target_length + min_a)//2
Problem p02627 (python)

Fixed submission:
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    a = input()[:-1]

    if ord('a') <= ord(a) <= ord('z'):
        print('a')
    else:
        print('A')
        

main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    a = input()

    if ord('a') <= ord(a) <= ord('z'):
        print('a')
    else:
        print('A')
        

main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    a = input()

    if ord('a') <= ord(a) <= ord('z'):
        print('a')
    else:
        print('A')
        

main()