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

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

Buggy submission (verdict: Runtime Error):
def get_sum_arr(arr):
    sum_arr = [0]
    N = len(arr)
    for i in range(1,N+1):
        sum_arr.append(sum_arr[i-1] + arr[i-1])
    return sum_arr

def get_max_b(left_time,j,B_sum_arr):
    # [0,1,2,3,4,5]
    while B_sum_arr[j] >= left_time and j > 0:
        j -= 1
    return j
def get_max_book_num(A,B,K):
    A_sum_arr,B_sum_arr = get_sum_arr(A),get_sum_arr(B)
    count,i,j = 0,0,len(B_sum_arr)-1
    for i in range(0,len(A_sum_arr)):
        if K < A_sum_arr[i]:
            break
        else:
            left_time = K - A_sum_arr[i]
            j = get_max_b(left_time,j,B_sum_arr)
        count = max(count,(i+j))
    return count

if __name__ == "__main__":
    N,M,K = list(map(int,input().split()))
    A = list(map(int,input().split()))
     # [0,1,2,3,4,5]
    B = list(map(int,input().split()))
     # [0,1,2,3,4,5]
    print(get_max_book_num(A,B,K))
Problem p02641 (python)

Fixed submission:
if __name__=="__main__":
    X,N = list(map(int,input().split()))
    p = list(map(int,input().split()))
    for i in range(X+1):
        for j in [-1,1]:
            a = X + i*j
            if not (a in p):
                print(a)
                exit(0)

Buggy submission (verdict: Runtime Error):
if __name__=="__main__":
    X,N = list(map(int,input().split(" ")))
    p = list(map(int,input().split(" ")))
    for i in range(X+1):
        for j in [-1,1]:
            a = X + i*j
            if not (a in p):
                print(a)
                exit()
Problem p03469 (python)

Fixed submission:
s = input()
s = s.replace("2017", "2018")
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = '8'
print(s)
Problem p03760 (python)

Fixed submission:
s = input();
t = input();

n = len(s);
for i in range(n) :
	print(s[i], end="");
	if i < len(t) :
		print(t[i], end="");
print("");

Buggy submission (verdict: Runtime Error):
s = input();
t = input();

n = len(s);
for i in range(n) :
	print(s[i], end="");
	print(t[i], end="");
print("");
Problem p03798 (python)

Fixed submission:

def check(s, ans, i) :
    return s[i-1] ^ ans[i-1] ^ ans[i-2] ^ ans[i]

def solve(first, second, s) :
    n = len(s)
    ans = [0] * (n)
    ans[-2] = first;
    ans[-1] = second;



    for i in range(0, n-2) :
        nsame = 0
        nsame ^= s[i-1]
        nsame ^= ans[i-1]
        ans[i] = ans[i-2] ^ nsame
    if check( s, ans, n-2 ) == 0 and check(s, ans, n-1) == 0 :
        ans.append(1)
#    print(ans)
    return ans

N = int(input())
s = input()

data = [0] * N
for i in range(N) :
    data[i] = 1 if s[i] == 'x' else 0
ok = 0

for i in range(2) :
    if ok == 1 :
        break
    for j in range(2) :
        if ok == 1 :
            break
        ans = solve(i, j, data)
        ok = len(ans) - N
if ok == 0 :
    print("-1")
else :
    for i in range(N) :
        print('W' if ans[i] == 1 else 'S', end = "")
    print()

Buggy submission (verdict: Runtime Error):

def check(s, ans, i) :
    return s[i-1] ^ ans[i-2] ^ ans[i]

def solve(first, second, s) :
    n = len(s)
    ans = [0] * (n)
    ans[-2] = first;
    ans[-1] = second;



    for i in range(0, n-2) :
        nsame = 0
        nsame ^= s[i-1]
        nsame ^= ans[i-1]
        ans[i] = ans[i-2] ^ nsame
    if check( s, ans, -2 ) == 0 and check(s, ans, -1) == 0 :
        ans += [1]
#    print(ans)
    return ans

N = int(input())
s = input()

data = [0] * N
for i in range(N) :
    data[i] = 1 if s[i] == 'o' else 0
ok = 0

for i in range(2) :
    if ok == 1 :
        break
    for j in range(2) :
        if ok == 1 :
            break
        ans = solve(i, j, data)
        ok = len(ans) - N
if ok == 0 :
    print("-1")
else :
    for i in range(N) :
        print('S' if ans[i] == 1 else 'W', end = "")
    print()
Problem p02658 (python)

Fixed submission:
#from operator import mul
#from functools import reduce
#cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

if 0 in nums:
        print(0)
        exit()
for num in nums:
    ans *= num
    if ans > 10**18 :
        print(-1)
        exit()
print(ans)

Buggy submission (verdict: Runtime Error):
#from operator import mul
#from functools import reduce
#cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

if 0 in nums:
        print(0)
        exit()
for num in nums:
    ans *= num
    if ans > 10**18 :
        print(-1)
         exit()
print(ans)

Buggy submission (verdict: Runtime Error):
#from operator import mul
#from functools import reduce
cnt = 1000000000000000000
ans =1
N = map(int, input().split())
nums = list(map(int, input().split()))


count  = reduce(mul, nums)
if "0" in N:
        print("0")
for  num in nums
    ans *= num
        if count  > cnt :
        print(-1)

print(count)

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define cnt 1000000000000000000
int main(){
  int N;
  long int A[1000000];
  long long int sum=1;
  scanf("%d", &N);
  for (int i = 0; i <N; i++){
    scanf("%ld",&A[i]);
    sum *= A[i];

  }

  
  if(sum >cnt){
    printf("-1\n");
  }else{
    printf("%lld\n", sum);
  }
  return 0;
}
Problem p02787 (python)

Fixed submission:
def run():
  H, N = map(int, input().split())
  ab_li = [tuple(map(int, input().split())) for n in range(N)]
  dp = [0]*(H+1)
  for i in range(1, H+1):
    new_li = []
    for n in range(N):
      a, b = ab_li[n]
      if a <= i:
        new_li.append(dp[i-a]+b)
      else:
        new_li.append(b)
    dp[i] = min(new_li)
  print(dp[-1])
  
if __name__ == '__main__':
  run()

Buggy submission (verdict: Runtime Error):
def run():
  H, N = map(int, input().split())
  ab_li = [tuple(map(int, input().split())) for n in range(N)]
  dp = [float('inf')]*(H+1)
  for i in range(1, H+1):
    for n in range(N):
      a, b = ab_li[n]
      if i == a:
        dp[i] = min(dp[i], b)
      if (i < a) or (dp[i-a] == float('inf')):
        continue
      dp[i] = min(dp[i], dp[i-a]+b)
  if dp[-1] == float('inf'):
    for h in range(H, 0, -1):
      if dp[h] != float('inf'):
        ans = dp[h]+min(ab_li, key=lambda x:x[1])[1]
        break
  else:
    ans = dp[-1]
  for n in range(N):
    a, b = ab_li[n]
    if a > H:
      ans = min(ans, b)
  print(ans)
  
if __name__ == '__main__':
  run()
Problem p03264 (python)

Fixed submission:
K = int(input())

if K%2 == 0:
  even_num = odd_num = K//2
else:
  even_num = K//2
  odd_num = even_num + 1

print(even_num * odd_num)

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

if K%2 == 0:
  even_num = odd_num = K/2
eles:
  even_num = K/2
  odd_num = even_num + 1

print(even_num * odd_num)
Problem p03274 (python)

Fixed submission:
N, K = map(int, input().split())
x_coordinate = list(map(int, input().split()))
zero_pos = 0
distance = []

while True:
  try:
    if x_coordinate[zero_pos] >= 0:
      break
    else:
      zero_pos += 1
  except:
    zero_pos = N - 1
    break

for i in range(zero_pos - K, zero_pos + 1):
  if (i >= 0) and (i + K - 1 < N):
    start_pos = x_coordinate[i]
    end_pos = x_coordinate[i + K - 1]
    if start_pos*end_pos >= 0:
      if abs(start_pos) > abs(end_pos):
        distance.append(abs(start_pos))
      else:
        distance.append(abs(end_pos))
    else:
      if abs(start_pos) >= abs(end_pos):
        total = abs(start_pos) + 2*abs(end_pos)
        distance.append(total)
      else:
        total = 2*abs(start_pos) + abs(end_pos)
        distance.append(total)
      
print(min(distance))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
x_coordinate = list(map(int, input().split()))
zero_pos = 0
distance = []

while True:
  if x_coordinate[zero_pos] >= 0:
    break
  else:
    zero_pos += 1

for i in range(zero_pos - K, zero_pos + 1):
  if (i >= 0) and (i + K - 1 < N):
    start_pos = x_coordinate[i]
    end_pos = x_coordinate[i + K - 1]
    if start_pos*end_pos >= 0:
      if abs(start_pos) >= abs(end_pos):
        distance.append(abs(start_pos))
      else:
        distance.append(abs(end_pos))
    else:
      if abs(start_pos) >= abs(end_pos):
        total = abs(start_pos) + 2*abs(end_pos)
        distance.append(total)
      else:
        total = 2*abs(start_pos) + abs(end_pos)
        distance.append(total)
      
print(min(distance))
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())
if N%500 <= A:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
if N%500 =< A:
  print("Yes")
else:
  print("No")
Problem p03469 (python)

Fixed submission:
S = input().split("/")
S[0] = "2018"
print("/".join(S))

Buggy submission (verdict: Runtime Error):
S = input().split("/")
S[0] = "2018"
print(S.join("/"))
Problem p03470 (python)

Fixed submission:
N = int(input())
a_list = []
for i in range(N):
  a_list.append(input())
a_set = set(a_list)
print(len(a_set))

Buggy submission (verdict: Runtime Error):
N = int(imput())
a_list = []
for i in range(N):
  a_list.append(input())
a_set = set(a_list)
print(len(a_set))
Problem p03944 (python)

Fixed submission:
W, H, N = map(int, input().split())
a_list =[] 
for i in range(N):
  a_list.append(list(map(int, input().split())))
a1_list = [i[0] for i in a_list if i[2] == 1 ]
a2_list = [i[0] for i in a_list if i[2] == 2 ]
a3_list = [i[1] for i in a_list if i[2] == 3 ]
a4_list = [i[1] for i in a_list if i[2] == 4 ]
if a1_list == []:
  a1_max = 0
else:
  a1_max = max(a1_list)
if a2_list == []:
  a2_min = W
else:
  a2_min = min(a2_list)
if a3_list ==[]:
  a3_max = 0
else:
  a3_max = max(a3_list)
if a4_list == []:
  a4_min = H
else:
  a4_min = min(a4_list)
S = (a2_min - a1_max)*(a4_min - a3_max)
if (a2_min - a1_max) >= 0 and (a4_min - a3_max) >= 0:
  print(S)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
W, H, N = map(int, input().split())
a_list =[] 
for i in range(N):
  a_list.append(list(map(int, input().split())))
a1_list = [i[0] for i in a_list if i[2] == 1 ]
a2_list = [i[0] for i in a_list if i[2] == 2 ]
a3_list = [i[1] for i in a_list if i[2] == 3 ]
a4_list = [i[1] for i in a_list if i[2] == 4 ]
if a1_list == []:
  a1_max = 0
else:
  a1_max = max(a1_list)
if a2_list == []:
  a2_min = W
else:
  a2_min = min(a2_list)
if a3_list ==[]:
  a3_max = 0
else:
  a3_max = max(a3_list)
if a4_list == []:
  a4_min = H
else:
  a4_min = min(a4_list)
S = (a2_min - a1_max)*(a4_min - a3_max)
if (a2_min - a1_max) >= 0 and (a4_min - a3_max) >= 0):
  print(S)
else:
  print(0)
Problem p04048 (python)

Fixed submission:
def run():
  N, X = map(int, input().split())
  y = N-X
  ans = N
  while True:
    y, X = max(y, X), min(y, X)
    a = y//X
    b = y%X
    ans += a*X*2
    if b == 0:
      break
    y, X = X, b
  print(ans-X)
  
  
if __name__ == '__main__':
  run()

Buggy submission (verdict: Runtime Error):
def run():
  N, X = map(int, input().split())
  y = N-X
  ans = y+X
  while True:
    a = y//X
    ans += a*X*2
    if y%X == 0:
      break
    y, X = max(X, a), min(X, a)
  print(ans-X)
  
  
if __name__ == '__main__':
  run()

Buggy submission (verdict: Runtime Error):
def run():
  N, X = map(int, input().split())
  y = N-X
  ans = y+X
  while True:
    a = y//X
    ans += a*X*2
    if y%X == 0:
      break
    y, X = X, a
  print(ans-X)
  
  
if __name__ == '__main__':
  run()
Problem p02576 (python)

Fixed submission:
import math
n,x,t = map(int,input().split())
c = t*math.ceil(n/x)
print(c)

Buggy submission (verdict: Runtime Error):
num = input()
le = len(num)
sum=0
for i in range(le):
  sum += int(num[i])
if sum%9==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
num = input()
le = len(num)
sum=0
for i in range(le):
  sum += int(num[i])
if sum%==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x = input()
le = len(x)
sum = 0
for i in range(le):
  sum+=int(x[i])
print(sum)
Problem p02630 (python)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
q = int(input())
change_list = [list(map(int, input().split())) for _ in range(q)]

cnt = [0] * 10**6
tot = sum(a_list)

for i in range(n):
    cnt[a_list[i]] += 1
#print(cnt)

for j in range(q):
    tot += cnt[change_list[j][0]] * (change_list[j][1]-change_list[j][0])
    cnt[change_list[j][1]] += cnt[change_list[j][0]]
    cnt[change_list[j][0]] = 0
    print(tot)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
q = int(input())
change_list = [list(map(int, input().split())) for _ in range(q)]

cnt = [0] * 10**5
tot = sum(a_list)

for i in range(n):
    cnt[a_list[i]] += 1
#print(cnt)

for j in range(q):
    tot += cnt[change_list[j][0]] * (change_list[j][1]-change_list[j][0])
    cnt[change_list[j][1]] += cnt[change_list[j][0]]
    cnt[change_list[j][0]] = 0
    print(tot)
Problem p02718 (python)

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

all_vote = sum(A)

cnt = 0

for a in A:
    #if a >= all_vote / (4*m):
    if a * 4 * m >= all_vote:   #小数になる可能性をなくした
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

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

all_vote = sum(A)

cnt = 0

for a in A:
        if a * 4 * m >= all_vote
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

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

all_vote = sum(A)

cnt = 0

for a in A:
        if a * 4 * m >= all_vote    #小数になる可能性をなくした
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

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

all_vote = sum(A)

cnt = 0

for a in A:
    #if a >= all_vote / (4*m):
    if a * 4 * m >= all_vote    #小数になる可能性をなくした
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')
Problem p02767 (python)

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

ans_list = [0] * (max(x_list)+1)

for j in range(1, max(x_list)+1):
    ans = 0
    for i in range(0, n):
        ans += (x_list[i] - j) ** 2
    ans_list[j] = ans

ans_list.remove(0)
print(min(ans_list))

Buggy submission (verdict: Runtime Error):
n = int(input())
x_list = list(map(int,input().split()))
#print(x_list)
#print(sum(x_list))
#(len(x_list))

#p = sum(x_list) // (len(x_list))
#p = (min(x_list) + max(x_list)) // 2
#print(p)

ans_list = [0] * (max(x_list)+1)

for j in range(1, max(x_list)+1):
    ans = 0
    for i in range(0, n):
        ans += (x_list[i] - j) ** 2
        #print(ans)
    ans_list[j] = ans

ans_list.remove(0)
print(min(ans_list))
#print(ans)n = int(input())
x_list = list(map(int,input().split()))
#print(x_list)
#print(sum(x_list))
#(len(x_list))

#p = sum(x_list) // (len(x_list))
#p = (min(x_list) + max(x_list)) // 2
#print(p)

ans_list = [0] * (max(x_list)+1)

for j in range(1, max(x_list)+1):
    ans = 0
    for i in range(0, n):
        ans += (x_list[i] - j) ** 2
        #print(ans)
    ans_list[j] = ans

ans_list.remove(0)
print(min(ans_list))
#print(ans)
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()
cnt = s.count('R')*s.count('G')*s.count('B')
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] != s[j]:
            if 2*j-i > n-1:
                break
            if s[2*j-i] not in(s[i],s[j]):
                cnt -= 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
cnt = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] != s[j]:
            if (s[i]+s[j]).count('R') == 0:
                cnt += s[j+1:n].count('R')
                if s[j+i] == 'R' and j-i > n-j:
                    cnt -= 1
            elif (s[i]+s[j]).count('G') == 0:
                cnt += s[j+1:n].count('G')
                if s[j+i] == 'G' and j-i > n-j:
                    cnt -= 1
            else:
                cnt += s[j+1:n].count('B')
                if s[j+i] == 'B' and j-i > n-j:
                    cnt -= 1
print(cnt)
Problem p02899 (python)

Fixed submission:
j = 1
a = 0
i = 0
N = 0


#N = int(input()) for _ in range(1)
A = [int(input()) for _ in range(1)]
#N=int(input())
mylist = [0]*A[0]

h = [int(x) for x in input().split()]

for i in range(A[0]):
    mylist[h[i]-1]=i+1
print(*mylist)

Buggy submission (verdict: Runtime Error):
j = 0
a = 0
i = 0
mylist = []
for i in range(N):
    mylist.insert(i, 0)
N=int(input())
h = [int(x) for x in input().split()]
   
for i in range(N):
    mylist[h[i]-1]=i+1
    
print(*mylist)
Problem p02573 (python)

Fixed submission:
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

import numpy as np
n, m = map(int, input().split( ))

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for i in range(m):
    x,y=map(int,input().split(' '))
    unite(x-1,y-1)

# print(par)
print(-min(par))

Buggy submission (verdict: Runtime Error):
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

import numpy as np
n, m = map(int, input().split( ))

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for i in range(m):
    x,y=map(int,input().split(' '))
    unite(x,y)

# print(par)
print(-min(par))
Problem p02993 (python)

Fixed submission:
line=list(input())

for i in range(3):
    if line[i]==line[i+1]:
        print('Bad')
        break
    if i==2:
        print('Good')

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

for i in range(3):
    if line(i)==line(i+1):
        print('Bad')
        break
    if i==2:
        print('Good')
Problem p02997 (python)

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

m=(n-2)*(n-1)//2

if m<k:
    print(-1)
else:
    l=m-k
    line=[]
    for i in range(n-1):
        line.append((1,i+2))
    
    counter=0
    for j in range(2,n):
        if counter==l:
            break
        for i in range(j+1,n+1):
            line.append((j,i))
            counter+=1
            if counter==l:
                break
        if counter==l:
            break
    print(len(line))
    for i in range(len(line)):
        print(str(line[i][0])+' '+str(line[i][1]))

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

m=(n-2)*(n-1)//2

if m<k:
    print(-1)
else:
    l=m-k
    line=[]
    for i in range(n-1):
        line.append((1,i+2))
    
    counter=0
    for j in range(2,n):
        for i in range(n-j):
            line.append((j,i+j))
            counter+=1
            if counter==l:
                break
        if counter==l:
            break

print(len(line))
for i in range(len(line)):
    print(str(line[i][0])+' '+str(line[i][1]))

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

m=(n-2)*(n-1)//2

if m<k:
    print(-1)
else:
    l=m-k
    line=[]
    for i in range(n-1):
        line.append((1,i+2))
    
    counter=0
    for j in range(2,n):
        for i in range(n-j):
            line.append((j,i+j))
            counter+=1
            if counter==l:
                break
        if counter==l:
            break

print(len(line))
for i in range(len(line)):
    print(str(line[i][0])+' '+str(line[i][1]))

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

m=(n-2)*(n-1)//2

if m<k:
    print(-1)
else:
    l=m-k
    line=[]
    for i in range(n-1):
        line.append((1,i+2))
    
    counter=0
    for j in range(2,n)
        for i in range(n-j):
            line.append((j,i+j)):
            counter+=1
            if counter==l:
                break
        if counter==l:
            break

print(len(line))
for i in range(len(line)):
    print(str(line[i][0])+' '+str(line[i][1]))
Problem p03037 (python)

Fixed submission:
n,m=map(int,input().split( ))

L=[]
R=[]
for i in range(m):
    l,r=map(int,input().split( ))
    L.append(l)
    R.append(r)

print(max(min(R)-max(L)+1,0))

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

L=[]
R=[]
for i in range(m):
    l,r=map(int,input().split( ))
    L.append(l)
    R.append(r)

print(max(min(R)-max(L)+1,0))

Buggy submission (verdict: Runtime Error):

n,m=map(int,input().split( ))
line=list(map(int,input().split( )))s


L=[]
R=[]
for i in range(m):
    l,r=map(int,input().split( ))
    L.append(l)
    R.append(r)

print(max(min(R)-max(L)+1,0))

Buggy submission (verdict: Runtime Error):

n,m=map(int,input().split( ))
line=list(map(int,input().split( )))s


L=[]
R=[]
for i in range(m):
    l,r=map(int,input().split( ))
    L.append(l)
    R.append(r)

print(max(min(R)-max(L)+1,0)
Problem p03050 (python)

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

n=int(input())
l=[]
# print(make_divisors(n))
md=make_divisors(n)
if 1 in md:
    md.remove(1)
for i in md:
    k=i-1
    if n//k==n%k:
        # print(k+1,n//k,n%k)
        l.append(k)
# print(l)
print(sum(l))

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.append(n)
    # divisors.sort()
    return divisors

n=int(input())
l=[]
# print(make_divisors(n))
for i in make_divisors(n):
    k=i-1
    if n//k==n%k:
        # print(k+1,n//k,n%k)
        l.append(k)
# print(l)
print(sum(l))

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.append(n)
    # divisors.sort()
    return divisors

n=int(input())
l=[]
# print(make_divisors(n))
for i in make_divisors(n):
    k=i-1
    if n//k==n%k:
        # print(k+1,n//k,n%k)
        l.append(k)
# print(l)
print(sum(l))

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.append(n)
    # divisors.sort()
    return divisors

n=int(input())
l=[]
# print(make_divisors(n))
for i in make_divisors(n):
    k=i-1
    if n//k==n%k:
        # print(k+1,n//k,n%k)
        l.append(k)
# print(l)
print(sum(l))

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.append(n)
    # divisors.sort()
    return divisors

n=int(input())
l=[]
# print(make_divisors(n))
for i in make_divisors(n):
    k=i-1
    if n//k==n%k:
        # print(k+1,n//k,n%k)
        l.append(k)
# print(l)
print(sum(l))