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

Fixed submission:
a = input()
l = map(int, raw_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()
    return divisors

def gcd(l):
	l = sorted(l, reverse=True)
	l1 = make_divisors(l[0])
	l2 = make_divisors(l[1])
	l_mix = list(set(l1 + l2))
	l_mix = sorted(l_mix)
	r = 0
	for i in l_mix:
		f = 0
		for j in l:
			if j % i != 0:
				f += 1
			if f > 1:
				break
		if f <= 1:
			r = i
	return r 

print gcd(l)

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

def gcd(l):
	m = max(l)
	r = 0
	for i in range(1, m + 1):
		f = 0
		for j in l:
			if j % i != 0:
				f += 1
			if f > 1:
				break
		if f <= 1:
			r = i
	return r 

print gcd(l)
Problem p03693 (python)

Fixed submission:
a, b, c = map(int, raw_input().split())
if (b * 10 + c) % 4 == 0:
	print "YES"
else:
	print "NO"

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, raw_input().spilt())
if (b * 10 + c) % 4 == 0:
	print "YES"
else:
	print "NO"
Problem p03697 (python)

Fixed submission:
a, b = map(int, raw_input().split())

if a + b >= 10:
	print 'error'
else:
	print a + b

Buggy submission (verdict: Runtime Error):
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

def solve(hp, count):
	q = hp - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(hp, m):
		r = m
	else:
		l = m

if r == 2:
	if solve(hp, 1):
		r = 1

print r
Problem p02909 (python)

Fixed submission:
def solve():
    S = input()
    if S == "Sunny":
        ans = "Cloudy"
    elif S == "Cloudy":
        ans = "Rainy"
    elif S == "Rainy":
        ans = "Sunny"
    
    print(ans)
solve()

Buggy submission (verdict: Runtime Error):
def solve():
    S = input()
    if S == "Sunny":
        ans = "Cloudy"
    elif S == "Cloudy":
        ans = "Rainy"
    elif S == "Rainy":
        ans == "Sunny"
    
    print(ans)
solve()

Buggy submission (verdict: Runtime Error):
def solve():
    S = input()
    if S == "Sunny":
        ans = "Cloudy"
    elif S == "Cloudy":
        ans = "Rainy"
    else S == "Rainy":
        ans == "Sunny"
    
    print(ans)
solve()
Problem p02993 (python)

Fixed submission:
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3] or S[3]==S[4]:
    print("Bad")
else:
    print("Good")
Problem p03503 (python)

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

ans = -1000000000

for i in range(1,1024):
    F0 = [0]*10
    i_temp = i
    for j in range(10):
        F0[j] = i_temp%2
        i_temp = int(i_temp/2)
    
    c = [0]*N
    for j in range(10):
        if F0[j] == 1:
            for k in range(N):
                c[k] += F[k][j]
    
    ans_temp = 0
    for j in range(N):
        ans_temp += P[j][c[j]]
    ans = max(ans, ans_temp)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
F = []
for i in range(N):
    F_temp = list(map(int, input().split()))
    F.append(F_temp)
P = []
for i in range(N):
    P_temp = list(map(int, input().split()))
    P.append(P_temp)

ans = -1000000000

for i in range(1,1024):
    F0 = [0]*10
    i_temp = i
    for j in range(10):
        F0[j] = i_temp%2
        i_temp = int(i_temp/2)
    
    c = [0]*10
    for j in range(10):
        if F0[j] == 1:
            for k in range(N):
                c[k] += F[k][j]
    
    ans_temp = 0
    for j in range(N):
        ans_temp += P[j][c[j]]
    ans = max(ans, ans_temp)

print(ans)
Problem p03076 (python)

Fixed submission:
import math
dish = []
mini = 0
for i in range(5):
    d = input()
    dish.append(d)
for j in dish:
    if j[-1] != '0':
        mini = j
if mini == 0:
    mini = dish[0]
for k in dish:
    if (k[-1] <= mini[-1]) and k[-1] != '0':
        mini = k
for i in range(5):
    if dish[i] == mini:
        dish.pop(i)
        break
time = 0
for l in range(4):
    dish[l] = math.ceil((int(dish[l]) / 10)) * 10
    time += int(dish[l])
time += int(mini)
print(time)

Buggy submission (verdict: Runtime Error):
import math
dish = []
mini = 0
for i in range(5):
    d = input()
    dish.append(d)
for j in dish:
    if j[-1] != '0':
        mini = j
for k in dish:
    if (k[-1] <= mini[-1]) and k[-1] != '0':
        mini = k
if mini == 0:
    mini = dish[0]
for i in range(5):
    if dish[i] == mini:
        dish.pop(i)
        break
time = 0
for l in range(4):
    dish[l] = math.ceil((int(dish[l]) / 10)) * 10
    time += int(dish[l])
time += int(mini)
print(time)

Buggy submission (verdict: Runtime Error):
import math
dish = []
for i in range(5):
    d = input()
    dish.append(d)
for j in dish:
    if j[-1] != '0':
        mini = j
for k in dish:
    if (k[-1] <= mini[-1]) and k[-1] != '0':
        mini = k
for i in range(5):
    if dish[i] == mini:
        dish.pop(i)
        break
time = 0
for l in range(4):
    dish[l] = math.ceil((int(dish[l]) / 10)) * 10
    time += int(dish[l])
time += int(mini)
print(time)
Problem p03106 (python)

Fixed submission:
a, b, k = map(int, input().split())
num = []
mini = min(a, b)
for i in range(1, mini+1):
    if a % i == 0 and b % i == 0:
        num.append(i)
num.sort()
num.reverse()
print(num[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
if k == 1:
    print(1)
else:
    num = []
    mini = min(a, b)
    for i in range(1, mini):
        if mini % i == 0:
            num.append(i)
    num.sort()
    print(num[k-1])

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

num = []
mini = min(a, b)
for i in range(1, mini):
    if mini % i == 0:
        num.append(i)
num.sort()
print(num[k-1])
Problem p02952 (python)

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

Buggy submission (verdict: Runtime Error):
N = input()
count = 0
for i in range(N):
  if len(str(i+1)) % 2 == 1:
    count += 1
print(count)
Problem p02953 (python)

Fixed submission:
import numpy as np
N = int(input())
H = list(map(int, input().split()))

max = 0
for i in range(N):
  if max < H[i]:
    max = H[i]
  if max - H[i] >= 2:
    print("No")
    exit(0)
print("Yes")

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
H=np.array(list(map(int,input().split())))
diffH = np.diff(H)
if np.any(diffH <= -2):
  print("No")
  exit(0)

if np.any((diffH[range(N-2)] + diffH[range(1, N-1)]) <= -2):
  print("No")
  exit(0)
 
print("Yes")

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
H=np.array(list(map(int,input().split())))
diffH = np.diff(H)
if np.any(np.diff(H) <= -2):
  print("No")
  exit(0)
if np.any((diffH[range(N-2)] + diffH[range(1, N-1)]) <= -2):
  print("No")
  exit(0)
 
print("Yes")

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
H=np.array(list(map(int,input().split())))
diffH = np.diff(H)
if np.any((diffH[range(N-2)] + diffH[range(1, N-1)]) <= -2):
  print("No")
 
print("Yes")

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
H=np.array(list(map(int,input().split())))
diffH = np.diff(H)
if np.any((diffH[range(N-1)] + diffH[range(1, N)]) <= -2):
  print("No")
 
print("Yes")

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N = int(input())
H = np.array(list(map(int, input().split())))
if all(np.diff(H) >= 0):
  print("Yes")
  
for i in range(N):
  h = H.copy()
  h[i] = h[i] - 1
  if all(np.diff(h) >= 0):
    print("Yes")
 
print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
 
N = int(input())
H = np.array(list(map(int, input().split())))
if all(np.diff(H) >= 0):
  print("Yes")
  sys.exit()
  
for i in range(N):
  h = H.copy()
  h[i] = h[i] - 1
  if all(np.diff(h) >= 0):
    print("Yes")
    sys.exit()
 
print("No")
Problem p02953 (python)

Fixed submission:
N = input()
H_list = list(map(int, input().split()))
H_edit_list = [10**10]

for h in list(reversed(H_list)):
    if h - H_edit_list[-1] > 0:
        H_edit_list.append(h - 1)
    else:
        H_edit_list.append(h)
    if H_edit_list[-2] < H_edit_list[-1]:
        print('No')
        exit()

print('Yes')

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

prev_H = [H_list[0], H_list[1]]

for index, h in enumerate(H_list[2:], 2):
    if h - prev_H[0] < 0:
        H_list[index - 1] -= 1
    prev_H[0] = H_list[index - 1]
    prev_H[1] = H_list[index - 2]
    if prev_H[0] < prev_H[1]:
        print('No')
        exit()

print('Yes')
Problem p02888 (python)

Fixed submission:
import bisect
n=int(input())
List = [int(i) for i in input().split()]
List2=sorted(List)
ans = 0

for i in range(0,n-1): #aにたいし
  for j in range(i+1,n):
    #print(i,j)
    tmp1 = List2[i]
    tmp2 = List2[j]
    
    a=bisect.bisect_left(List2,tmp1+tmp2)
    ans += a -j-1
    #print(a,List2,tmp1,tmp2,j,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
List = [int(i) for i in input().split()]
List2=sorted(List)
ans = 0

for i in range(1,n-1): #aにたいし
  for j in range(i,n):
    tmp1 = List[i]
    tmp2 = List[j]
    
    ans += 4- bisect.bisect_right(List2,tmp1+tmp2)
    
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
List = [int(i) for i in input().split()]
List2=sorted(List)
import numpy as np
A=np.asarray(List2)
ans = 0

for i in range(1,n-1): #aにたいし
  for j in range(i,n):
    tmp1 = List[i]
    tmp2 = List[j]
    ans += np.count_nonzero(A-tmp1-tmp2>0)
    
print(ans)
Problem p02924 (python)

Fixed submission:
N = int(input())

ans = N*(N-1)//2

print(ans)

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

P = list(range(1,N+1))
M = P[1:]
M.append(1)

ans = 0
for i in range(N):
  ans += P[i]%M[i]
  
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())

P = np.arange(1,N+1)
M = np.arange(2,N+1)
M = np.append(M,[1])

ans = np.sum(P%M)

print(ans)

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

P = list(range(1,N+1))
M = P[1:]
M.append(1)

ans = 0
for i in range(N):
  ans += P[i]%M[i]
  
print(ans)
Problem p02936 (python)

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

N, Q = map(int, input().split())
AB = [[0]*2 for i in range(N-1)]
for i in range(N-1):
  AB[i] = list(map(int, input().split()))
C = [0]*N
g = list([] for i in range(N+1))
for i in range(Q):
  p, x = map(int, input().split())
  C[p-1] += x

for i,j in AB:
  g[i].append(j)
  g[j].append(i)
 
def BTS(a, b):
  for i in g[a]:
    if i == b:
      continue
    C[i-1] += C[a-1]
    BTS(i,a)
    
BTS(1,-1)
 
print(*C)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
AB = [[0]*2 for i in range(N-1)]
for i in range(N-1):
  AB[i] = list(map(int, input().split()))
C = [0]*N
g = list([] for i in range(N+1))
for i in range(Q):
  p, x = map(int, input().split())
  C[p-1] += x

for i,j in AB:
  g[i].append(j)
  g[j].append(i)
 
def BTS(a, b):
  for i in g[a]:
    if i == b:
      continue
    C[i-1] += C[a-1]
    BTS(i,i)
    
BTS(1,-1)
 
print(*C)
Problem p02947 (python)

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

import collections
import math

c = collections.Counter(S)
ans = 0
for i in c.values():
    if i == 1:
      continue
    else:
      ans += i*(i-1)//2
print(int(ans))

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

import collections
import math

c = collections.Counter(S)
ans = 0
for i in c.values():
    if i == 1:
      continue
    else:
      ans += math.factorial(i)/math.factorial(2)
print(int(ans))

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

import collections
import math

c = collections.Counter(S)
ans = 0
for i in c.values():
    ans += math.factorial(i)/math.factorial(2)
print(int(ans))
Problem p02963 (python)

Fixed submission:
S = int(input())

A = 10**9
C = S//A
B = S%A

if B!=0:
  C += 1
  B = A - B

ANS = [0, 0, A, 1, B, C]
print(*ANS)

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

A = 10**9
C = S//A
Bt = S%A

if Bt!=0:
  C += 1
  B = A - Bt

ANS = [0, 0, A, 1, B, C]
print(*ANS)
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

maxA = max(A)
max_in = A.index(max(A))
ANS = [maxA]*N
ANS[max_in] = max(A[:max_in]+A[max_in+1:])

for i in ANS:
    print(i)

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

ANS = []
for i in range(N):
  Alist = A[:i]+A[i+1:]
  ANS.append(max(Alist))

for i in ANS:
    print(i)
Problem p02973 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

import bisect
from collections import deque

temp = deque()
temp.appendleft(A[0])
for i in range(1,N):
  if temp[0] >= A[i]:
    temp.appendleft(A[i])
  else:
    temp[bisect.bisect_left(temp,A[i])-1] = A[i]
print(len(temp))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [map(int, input()) for i in range(N)]

count = 0
temp = []
tempin = []
for i in range(N):
  if i in tempin:
    continue
  temp.append(A[i])
  for j in range(i+1, N):
    if j in tempin:
      continue
    elif temp[-1] < A[j]:
      temp.append(A[j])
      tempin.append(j)
  else:
    print(tempin)
    count += 1

print(count)
Problem p02988 (python)

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

c = 0
for i in range(N-2):
  if P[i] < P[i+1] <= P[i+2]:
    c += 1
  elif P[i+2] < P[i+1] <= P[i]:
    c += 1
  
print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = [map(int, input().split())]

c = 0
for i in range(N-2):
  if P[i] < P[i+1] <= P[i+2]:
    c += 1
  elif P[i+2] < P[i+1] <= P[i]:
    c += 1
  else:
    pass
  
print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = [map(int, input.split())]

c = 0
for i in range(N-2):
  if P[i] < P[i+1] <= P[i+2]:
    c += 1
  elif P[i+2] < P[i+1] <= P[i]:
    c += 1
  else:
    pass
  
print(c)
Problem p02995 (python)

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

import fractions
ccount = ((B//C*C)-((A-1)//C*C +C))//C +1
dcount = ((B//D*D)-((A-1)//D*D +D))//D +1
lcm = (C * D) // fractions.gcd(C, D)
cdcount = ((B//lcm*lcm)-((A-1)//lcm*lcm +lcm))//lcm +1
count = B - A + 1 - ccount - dcount + cdcount
print(int(count))

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
import math
ccount = ((B//C*C)-((A-1)//C*C +C))/C +1
dcount = ((B//D*D)-((A-1)//D*D +D))/D +1
lcm = (C * D) // math.gcd(C, D)
cdcount = ((B//lcm*lcm)-((A-1)//lcm*lcm +lcm))/lcm +1
count = B-A+1-ccount - dcount +cdcount
print(int(count))
Problem p03000 (python)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))

D = 0
count = 0
for i in range(N):
  D = D + L[i]
  count += 1
  if D > X :
    print(count)
    exit()
print(count+1)

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

D = 0
count = 0
for i in range(N+1):
  D = D + L[i]
  count += 1
  if D > X :
    print(count)
    break
Problem p03014 (python)

Fixed submission:
import numpy as np
H,W = map(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
  S[i] = list(input())
S = np.array(S)
S = np.where(S=="#",0,1)

l = np.zeros((H,W))
l[:,-1] = S[:,-1]
r = np.zeros((H,W))
r[:,0] = S[:,0]
u = np.zeros((H,W))
u[-1] = S[-1]
d = np.zeros((H,W))
d[0] = S[0]

for i in range(W-2,-1,-1):
  l[:,i] = (l[:,i+1]+1)*S[:,i]
for i in range(1,W):
  r[:,i] = (r[:,i-1]+1)*S[:,i]
for i in range(H-2,-1,-1):
  u[i] = (u[i+1]+1)*S[i]
for i in range(1,H):
  d[i] = (d[i-1]+1)*S[i]

print(int(np.max(l+r+u+d-3)))

Buggy submission (verdict: Runtime Error):
import numpy as np
H,W = mmap(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
  S[i] = list(input())
S = np.array(S)
S = np.where(S=="#",0,1)

l = np.zeros((H,W))
l[:,-1] = S[:,-1]
r = np.zeros((H,W))
r[:,0] = S[:,0]
u = np.zeros((H,W))
u[-1] = S[-1]
d = np.zeros((H,W))
d[0] = S[0]

for i in range(W-2,-1,-1):
  l[:,i] = (l[:,i+1]+1)*S[:,i]
for i in range(1,W):
  r[:,i] = (r[:,i-1]+1)*S[:,i]
for i in range(H-2,-1,-1):
  u[i] = (u[i+1]+1)*S[i]
for i in range(1,H):
  d[i] = (d[i-1]+1)*S[i]

print(int(np.max(l+r+u+d-3)))

Buggy submission (verdict: Runtime Error):
import numpy as np
H,W = mmap(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
  S[i] = [input().split()]
S = np.array(S)
S = np.where(S=="#",0,1)

l = np.zeros((H,W))
l[:,-1] = S[:,-1]
r = np.zeros((H,W))
r[:,0] = S[:,0]
u = np.zeros((H,W))
u[-1] = S[-1]
d = np.zeros((H,W))
d[0] = S[0]

for i in range(W-2,-1,-1):
  l[:,i] = (l[:,i+1]+1)*S[:,i]
for i in range(1,W):
  r[:,i] = (r[:,i-1]+1)*S[:,i]
for i in range(H-2,-1,-1):
  u[i] = (u[i+1]+1)*S[i]
for i in range(1,H):
  d[i] = (d[i-1]+1)*S[i]

print(int(np.max(l+r+u+d-3)))
Problem p03031 (python)

Fixed submission:
N, M = map(int, input().split())
KS = [[] for i in range(M)]
for i in range(M):
  KS[i]= list(map(int, input().split()))
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
  sl = []
  for j in range(N):
    if (i>>j)&1:
      sl.append(j+1)
  for j in range(M):
    if len(set(KS[j][1:])&set(sl))%2 ==P[j]:
      continue
    else:
      break
  else:
    ans += 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
KS = []*M
for i in range(M):
  KS[i]= list(map(int, input().split()))
P = list(map(int, input().split()))

ans = 0
for i in range(N**2):
  sl = []
  for j in range(N):
    if (i>>j)&1:
      sl.append(j+1)
  for j in range(M):
    if len(set(KS[j][1:])&set(sl))%2 ==P[j]:
      continue
    else:
      break
  else:
    ans += 1
    
print(ans)
Problem p03032 (python)

Fixed submission:
from collections import deque
N, K = map(int,input().split())
V = list(map(int,input().split()))

ans = []
for i in range(min(N,K)+1):
  for j in range(min(N,K)+1-i):
    Vc = deque(V.copy())
    cal = deque([0])
    for k in range(i):
      cal.append(Vc.popleft())
    for l in range(j):
      cal.append(Vc.pop())
    cal = deque(sorted(cal))
    for m in range(K-i-j):
      if cal[0] < 0:
        cal.popleft()
      else:
        break
    ans.append(sum(cal))

print(max(ans))

Buggy submission (verdict: Runtime Error):
from collections import deque
N, K = map(int,input().split())
V = list(map(int,input().split()))

V = deque(V)
ans = []
for i in range(min(N,K)):
  for j in range(min(N,K)-i):
    Vc = V.copy()
    cal = deque([0])
    for k in range(i):
      cal.append(Vc.popleft())
    for l in range(j):
      cal.append(Vc.pop())
    cal = deque(sorted(cal))
    for m in range(K-i-j):
      if cal[0] < 0:
        cal.popleft()
      else:
        break
    ans.append(sum(cal))

print(max(ans))

Buggy submission (verdict: Runtime Error):
from collections import deque
N, K = map(int,input().split())
V = list(map(int,input().split()))

V = deque(V)

ans = []
for i in range(min(N,K)):
  for j in range(min(N,K)-i):
    Vc = V.copy()
    cal = deque([])
    for k in range(i):
      cal.append(Vc.popleft())
    for l in range(j):
      cal.append(Vc.pop())
    cal = sorted(cal)
    for m in range(K-i-j):
      if cal[0] < 0:
        cal.popleft()
      else:
        break
    ans.append(sum(cal))

print(max(ans))
Problem p03037 (python)

Fixed submission:
N, M = map(int, input().split())
L = [0 for i in range(M)]
R = [0 for i in range(M)]
for i in range(M):
  L[i], R[i] = map(int, input().split())
  
ans = min(R)-(max(L)-1)

print(max(ans,0))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = []*M
R = []*M
for i in range(M):
  L[i], R[i] = map(int, input().split())
  
ans = min(R)-(max(L)-1)

print(ans)
Problem p03043 (python)

Fixed submission:
N, K = map(int,input().split())
ans = 0
for i in range(1, N+1):
  k = i
  c = 0
  while K > k:
    k = k*2
    c += 1
  p = (1/N)*((1/2)**c)
  ans += p
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
ans = 0
for i in range(1, N+1):
  if K%i == 0:
    p = i * (1/n)*(1/2)**(K//i)
  else:
    p = i * (1/n)*(1/2)**(K//i+1)
  ans += p
print(ans)
Problem p03078 (python)

Fixed submission:
X,Y,Z,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
C = sorted(C, reverse = True)

ans = []

for i in range(min(K,X)):
  for j in range(min(K//(i+1),Y)):
    for k in range(min(K//(i+1)//(j+1),Z)):
      ans.append(A[i]+B[j]+C[k])
    
ans = sorted(ans, reverse=True)

for i in range(K):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
C = sorted(C, reverse = True)

ans = []

for i in range(min(K,X)):
  for j in range(min(K//i,Y)):
    for k in range(min(K//i//j,Z)):
      ans.append(A[i]+B[j]+C[k])
    
ans = sorted(ans, reverse=True)

for i in range(K):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
C = sorted(C, reverse = True)

ans = []

for i in range(min(K,X)):
  for j in range(min(K,Y)):
    for k in range(min(K,Z)):
    ans.append(A[i]+B[j]+C[k])
    
ans = sorted(ans, reverse=True)

for i in range(K):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

#A = sorted(A,reverse=True)
#B = sorted(B,reverse=True)
C = sorted(C,reverse=True)

AB=[]

for i in range(X):
  for j in range(Y):
    AB.append(A[i]+B[j])
    
ans = []

ABl = len(AB)
for i in rnage(ABl):
  for j in range(K):
    ans.append(AB[i]+C[j])

ans = sorted(ans, reverse=True)

for i in range(K):
  print(ans[i])