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

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

ans=set()
lm=0
rm=n
for i in range(m):
  l, r = map(int, input().split())
  lm=max(l, lm)
  rm=min(r, rm)
if rm - lm < 0:
  print(0)
else:
  print(rm - lm + 1)

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

ans=set()
l, r = map(int, input().split())
for j in range(l,r+1):
    ans.add(j)

for i in range(m-1):
  l, r = map(int, input().split())
  temp=set()
  lm=min(list(ans))
  rm=min(list(ans))
  for j in range(min(l,lm), min(r,rm)+1):
    temp.add(j)
  ans=temp & ans

print(len(ans))
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to)

n = int(input())
color = [0]*(n+1)
reached = [0]*(n+1)
uv = [[] * (n+1) for i in range(n+1)]
for i in range(n-1):
  u,v,w = map(int,input().split())
  uv[u].append({"to":v, "weight":w})
  uv[v].append({"to":u, "weight":w})
dfs(1)
for i in color[1:]:
  print(i)

Buggy submission (verdict: Runtime Error):
def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to)

n = int(input())
color = [0]*(n+1)
reached = [0]*(n+1)
uv = [[] * (n+1) for i in range(n+1)]
for i in range(n-1):
  u,v,w = map(int,input().split())
  uv[u].append({"to":v, "weight":w})
  uv[v].append({"to":u, "weight":w})
dfs(1)
for i in color[1:]:
  print(i)
Problem p03074 (python)

Fixed submission:
n, k = map(int, input().split())
s = input()
l=list()
s = s.replace("10","1,0")
s = s.replace("01","0,1")

l = [len(i) for i in s.split(",")]
r = 0
ans = 0

if s[0] == "1":
    r = min(k, len(l) - 1)
else:
    r = min(k-1, len(l) - 1)

t = l[r]

for j in range(1, k+1):
    #print(r,j,t,l[r-j],l[r+j])
    if r-j >= 0:
        #print("r-j >= 0:")
        t += l[r-j]
    if r+j < len(l):
        #print("r+j < len(l):")
        t += l[r+j]
ans = t
for i in range(r+2, len(l) ,2):
    for j in range(1, 3):
        if i-j-k >= 0:
            #print("l[i-j-k]", i-j-k, l[i-j-k])
            t -= l[i-j-k]
        if i+j+k-2 < len(l):
            #print("l[i+k+j]", i+j+k-2, l[i+j+k-2])
            t += l[i+j+k-2]
    ans = max(ans, t)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
l=list()
s = s.replace("10","1,0")
s = s.replace("01","0,1")

l = [len(i) for i in s.split(",")]
r = 0
ans = 0

if s[0] == "1":
    r = min(k, len(l) - 1)
else:
    r = k-1

t = l[r]

for j in range(1, k+1):
    #print(r,j,t,l[r-j],l[r+j])
    if r-j >= 0:
        #print("r-j >= 0:")
        t += l[r-j]
    if r+j < len(l):
        #print("r+j < len(l):")
        t += l[r+j]
ans = t
for i in range(r+2, len(l) ,2):
    for j in range(1, 3):
        if i-j-k >= 0:
            #print("l[i-j-k]", i-j-k, l[i-j-k])
            t -= l[i-j-k]
        if i+j+k-2 < len(l):
            #print("l[i+k+j]", i+j+k-2, l[i+j+k-2])
            t += l[i+j+k-2]
    ans = max(ans, t)
print(ans)
Problem p03240 (python)

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

pos = sorted(pos, key=lambda x: x[2])
tx,ty,th = pos[-1]
def solve():
  for cx in range(101):
    for cy in range(101):
      H = th+abs(tx-cx)+abs(ty-cy)
      for x,y,h in pos:
        if h != max(H-abs(x-cx)-abs(y-cy), 0):
          break
      else:
        return(cx,cy,H)

cx,cy,H=solve()
print(cx,cy,H)

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

def solve():
  for cx in range(101):
    for cy in range(101):
      H = h+abs(x-cx)+abs(y-cy)
      if all(h == max(H-abs(x-cx)-abs(y-cy), 0) for x,y,h in pos):
        return(cx,cy,H)

cx,cy,H=solve()
print(cx,cy,H)

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

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      edge=[]
      for i in range(n):
        x=pos[i][0]
        y=pos[i][1]
        h=pos[i][2]
        H = h+abs(x-cx)+abs(y-cy)
        if h == 0:
          if x == cx+H or x == cx-H or y == cy+H or y == cy-H:
            res.append(H)
        else:
          res.append(H)
      if len(set(res)) ==1:
        return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)

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

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      edge=[]
      for i in range(n):
        x=pos[i][0]
        y=pos[i][1]
        h=pos[i][2]
        H = h+abs(x-cx)+abs(y-cy)
        if h == 0:
          if (x == cx+H or x == cx-H) or (y == cy+H or x == cy-H):
            res.append(H)
        else:
          res.append(H)
      if len(set(res)) ==1:
        return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)
Problem p03274 (python)

Fixed submission:
import bisect
n,k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x,0)

ans=10**12
s=z-k
if s < 0:
  s=0
g=z+1
if g+k >= n:
  g=n-k+1
for i in range(s,g):

  xl=x[i]
  xr=x[i+k-1]
  ans=min(ans,abs(xr)+abs(xr-xl),abs(xl)+abs(xr-xl))
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n,k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x,0)

ans=10**12
s=z-k+1
if s < 0:
  s=0
if z == 0:
  z+=1
for i in range(s,z):
  xl=x[i]
  xr=x[i+k-1]
  ans=min(ans,abs(xr)+abs(xr-xl),abs(xl)+abs(xr-xl))
print(ans)
Problem p03280 (python)

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

print(a * b - a - b + 1)

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

print(a * b - a - b + 1)
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):
from collections import deque

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if (0 <= new_y < h) and (0 <= new_x < w):
        if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
          visited[new_y][new_x] = visited[y][x] + 1
          queue.append([new_y, new_x])
          
h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  t=input()
  maze.append(t)
  w_space += t.count(".")

visited = [[-1]*w for _ in range(h)]

ans = bfs()
if ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)
Problem p03436 (python)

Fixed submission:
from collections import deque

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]

    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if not (0 <= new_y < h) or not (0 <= new_x < w):
        continue

      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        visited[new_y][new_x] = visited[y][x] + 1
        queue.append([new_y, new_x])

h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  t=input()
  maze.append(t)
  w_space += t.count(".")
visited = [[-1]*w for _ in range(h)]

ans = bfs()
if ans and ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)

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

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if (0 <= new_y < h) and (0 <= new_x < w):
        if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
          visited[new_y][new_x] = visited[y][x] + 1
          queue.append([new_y, new_x])
          
h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  t=input()
  maze.append(t)
  w_space += t.count(".")

visited = [[-1]*w for _ in range(h)]

ans = bfs()
if ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  maze.append(input())
  w_space += maze[-1].count(".")

visited = [[-1]*w for _ in range(h)]

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if 0 <= new_y <= h-1 and 0 <= new_x <= w-1:
        if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
          visited[new_y][new_x] = visited[y][x] + 1
          queue.append([new_y, new_x])

ans = bfs()
if ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)
Problem p03474 (python)

Fixed submission:
a, b = map(int, input().split())
s = input()
if s[a] != "-":
  print("No")
else:
  s1, s2 = s[:a], s[a+1:]
  if s1.isdigit() and s2.isdigit():
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = input()
if s[a] != "-":
  print("No")
else:
  s1, s2 = s.split("-")
  if s1.isdigit() and s2.isdigit():
    print("Yes")
  else:
    print("No")
Problem p03556 (python)

Fixed submission:
n = int(input())

for i in range(n, 0, -1):
  j = int(i ** 0.5)
  if int(j) ** 2 == i:
    break
print(i)

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

for i in range(n, 1, -1):
  j = int(i ** 0.5)
  if int(j) ** 2 == i:
    break
print(i)
Problem p03599 (python)

Fixed submission:
a,b,c,d,e,f = map(int, input().split())

per = 0.0
ans = salt = w = s = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f + 1, 100 * b):
        w = i + j
        if w > f: break
        for k in range(0, f + 1, c):
            if w + k > f: break
            for l in range(0, f + 1, d):
                w = i + j
                s = k + l
                if w + s > f: break
                if s <= (w // 100) * e:
                    if 0 < s + w <= f:
                        if per < s / (s + w):
                            per = s / (s + w)
                            ans = w + s
                            salt = s
if ans == 0:
    print(100*a,0)
else:
    print(ans,salt)

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

dp=[-1]*(f + 1)
dp[0]=0
for i in range(f+1):
  if dp[i] == -1:
    continue
  for j in [a, b]:
    water = i + 100*j
    if water > f:
      continue
    dp[water] = 0
    salt_max = water * e / 100
    dd = int(salt_max - dp[i])
    dp_s = [0] * (dd + 1)
    dp_s[0] = 1
    for pp in range(dd + 1):
      if dp_s[pp] == 0:
        continue
      for k in [c, d]:
        if pp+k > dd:
          continue
        dp_s[pp+k] = 1
    sm = 0
    for index,dp_i in enumerate(dp_s):
      if dp_i != 0:
        sm = index
    if water + sm + dp[i] <= f:
      dp[water] = max(dp[water], sm + dp[i])

for i in range(f+1):
  if dp[i] > 0:
    ans = i
print(dp[ans] + ans, dp[ans])

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

dp=[-1]*(f + 1)
dp[0]=0
for i in range(f+1):
  if dp[i] == -1:
    continue
  for j in [a, b]:
    water = i + 100*j
    if water > f:
      continue
    dp[water] = 0
    salt_max = water * e / 100
    dd = int(salt_max - dp[i] + 1)
    dp_s = [0] * dd
    dp_s[0]=1
    for pp in range(dd):
      if dp_s[pp] == 0:
        continue
      for k in [c, d]:
        if pp+k >= dd:
          continue
        dp_s[pp+k] = 1
    sm = 0
    for index,dp_i in enumerate(dp_s):
      if dp_i != 0:
        sm = index
    if water + sm + dp[i] <= f:
      dp[water] = max(dp[water], sm + dp[i])

for i in range(f+1):
  if dp[i] > 0:
    ans = i
print(dp[ans] + ans, dp[ans])
Problem p03695 (python)

Fixed submission:
n = int(input())

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

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  else:
    c[8] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = sum(c)
print(cmin, cmax)

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

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

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  else:
    c[8] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = min(sum(c))
print(cmin, cmax)

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

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

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  elif t >= 8:
    c[t] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = min(sum(c[:-1]) + c[8], 8)
print(cmin, cmax)
Problem p03795 (python)

Fixed submission:
x = int(input())

print(800 * x - 200 * (x//15))

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

input(x - 200 * (x//15))
Problem p03853 (python)

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

for i in range(n):
  s = input()
  print(s)
  print(s)

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

for i in range(m):
  s = input()
  print(s)
  print(s)
Problem p03943 (python)

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

s = sum([a,b,c])
m = max(a,b,c)

if m == (s - m):
  print("Yes")
else:
  print("No")

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

if (a+b+c) % 3 == 0:P
  print("Yes")
else:
  print("No")
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

print((a + b)*h//2)

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

print((a + b)*h//2)
Problem p02658 (python)

Fixed submission:
N=int(input())
 
A=list(map(int,input().split()))
 
if 0 in A:
    print(0)
else:
    result=1
    for a in A:
        result=result*a
        if result>10**18:
            result=-1
            break
    print(result)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
sum=1
f=0
f2=0
if 0 in a:
        f2=1
for a in A:
	sum=sum*a
	if (sum>10**18):
		sum=-1
                break
if f2==1: 
	print(0)
else:
	print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
sum=1
f=0
f2=0
for i in range(1,n):
	a=(input())
	if  (a==0): 
		f2=1
	sum=sum*a
	if (sum>10**18):
		sum=-1
                break
}
if f2==1: 
	print(0)
else:
	print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
sum=1
f=0
f2=0
for i in range(0,n):
	a=int(input())
	if  (a==0): 
		f2=1
	sum=sum*a
	if (sum>1000000000000000000):
		f=1;
}
if (f2==1): 
	print("0\n")
else if(f==1):
	print("-1\n")
else:
	print(sum)
	print("\n")

Buggy submission (verdict: Runtime Error):
n=input()
sum=1
f=0
f2=0
for i in range(0,n):
	a=input()
	if  (a==0): 
		f2=1
	sum=sum*a
	if (sum>1000000000000000000):
		f=1;
}
if (f2==1): 
	print("0\n")
else if(f==1):
	print("-1\n")
else:
	print(sum)
	print("\n")

Buggy submission (verdict: Runtime Error):
n=input()
sum=1
f=0
f2=0
for i in range(0,n):
	a=input()
	if  (a==0): 
		f2=1
	sum*=a
	if (sum>1000000000000000000):
		f=1;
}
if (f2==1): 
	print("0\n")
else if(f==1):
	print("-1\n")
else:
	print(sum)
	print("\n")

Buggy submission (verdict: Runtime Error):
n=input()
sum=1
f=0
f2=0
for i in range(1,n):
	a=input()
	if (a==0): 
		f2=1
	sum*=a
	if (sum>1000000000000000000):
		f=1;
}
if(f2==1): 
	print("0\n")
else if(f==1):
	print("-1\n")
else:
	print(sum)
	print("\n")

Buggy submission (verdict: Runtime Error):
n=(input())
		a=0
		sum=1
		f=0
		f2=0
		for i in range(1,n):
			a=(input())
			if(a==0): 
				f2=1
			sum*=a
			if (sum>1000000000000000000):
				f=1;
		}
		if(f2==1): 
			print("0\n")
		else if(f==1):
			print("-1\n")
		else:
			print(sum)
			print("\n")

Buggy submission (verdict: Runtime Error):
n=ll(input())
		a=0
		sum=1
		f=0
		f2=0
		for i in range(1,n):
			a=ll(input())
			if(a==0): 
				f2=1
			sum*=a
			if (sum>1000000000000000000):
				f=1;
		}
		if(f2==1): 
			print("0\n")
		else if(f==1):
			print("-1\n")
		else:
			print(sum)
			print("\n")
Problem p02584 (python)

Fixed submission:
X, K, D = map(int, input().split())

if abs(K*D) > abs(X):
    A = X//D
    A %= 2
    if K % 2 == A:
        print(X%D)
    else:
        print(D-X%D)
else:
    print(abs(X)-abs(K*D))

Buggy submission (verdict: Runtime Error):
import bisect

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

cnt = 0
L = list(set(L))
L = sorted(L)


if N >= 3:
    for i in range(len(L)-2):
        for j in range(i+1, len(L)-1):
            ind = bisect.bisect_left(L, L[i]+L[j])
            cnt += max(0, ind-j)
    print(cnt)

else:
    print(0)
Problem p02618 (python)

Fixed submission:
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

max_c = 0
index_c = 0

for i, C in enumerate(c):
    if C > max_c:
        index_c = i
        max_c = C

for d in range(D):
    print(index_c+1)

Buggy submission (verdict: Runtime Error):
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

v = 0
last = [-1 for _ in range(26)]

for d in range(D):
    last[t[d]-1] = d
    v += s[d][t[d]-1]
    for j in range(26):
        v -= c[j]*(d-last[j])
    print(v)
Problem p02619 (python)

Fixed submission:
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

v = 0
last = [-1 for _ in range(26)]

for d in range(D):
    last[t[d]-1] = d
    v += s[d][t[d]-1]
    for j in range(26):
        v -= c[j]*(d-last[j])
    print(v)

Buggy submission (verdict: Runtime Error):
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

v = 0
last = [0 for _ in range(26)]

for i in range(D):
    last[t[i]-1] = i+1
    v += s[i][t[i]-1]
    for j in range(26):
        v -= c[j]*(d-last[j])
    print(v)
Problem p02684 (python)

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

ans=[]
judge={}
j=0 #A進み
while A[j] not in judge.keys() or judge[A[j]]!=2:
    ans.append(A[j])
    if A[j] not in judge.keys():
        judge[A[j]]=0
    judge[A[j]]+=1
    j=A[j]-1

st=ans.index(A[j])

if st<K:
    ans=ans[st:]
    K-=st
    l=len(ans)
    #print(ans)
    print(ans[K%l-1])
else:
    print(ans[K-1])

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

ans=[]
judge={}
j=0 #A進み
while A[j] not in judge.keys() or judge[A[j]]!=2:
    ans.append(A[j])
    if A[j] not in judge.keys():
        judge[A[j]]=0
    judge[A[j]]+=1
    j=A[j]-1

st=ans.index(A[j])
ans=ans[st:]
if st<K:
    K-=st
    l=len(ans)
    #print(ans)
    print(ans[K%l-1])
else:
    print(ans[st])

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

ans=[]
judge={}
j=0 #A進み
while judge[A[j]]!=2:
    ans.append(A[j])
    if A[j] not in judge.keys():
        judge[A[j]]=0
    judge[A[j]]+=1
    j=A[j]-1
ans.append(A[j])

st=ans.index(A[j])
ans=ans[st:-1]
K-=st
l=len(ans)
#print(ans)
print(ans[K%l-1])
Problem p02702 (python)

Fixed submission:
S=input()

N=len(S)
count=0
tot=[0]*2019
S=S[::-1]
base=0
#print(S)
for i,s in enumerate(S):
    base+=int(s)*pow(10,i,2019)
    base%=2019
    #tot[base]+=1
    #print(base)
    if base==0:
        count+=1
    count+=tot[base]
    #print(tot[base],i,base)
    tot[base]+=1
#print(tot)    

print(count)

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

li=list(range(N+1))
count=0

#print(li)
for i in range(M,N+2):
    small=(i*(i-1))//2
    large=small+li[-i]*i
    count+=large-small+1

print(count%(pow(10,9)+7))
Problem p02706 (python)

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

homework=0

for a in A:
    homework+=a

if N>=homework:
    print(N-homework)
else:
    print(-1)

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

homework=0

for a in A:
    homework+=a

if N>hemework:
    print(N-homework)
else:
    print(-1)
Problem p02727 (python)

Fixed submission:
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r,reverse=True)
answer=p[:X]+q[:Y]
sum=0
answer=sorted(answer)
i=0

while i<=min(X+Y-1,C-1) and answer[i]<r[i]:
    answer[i]=r[i]
    i+=1

for a in answer:
    sum+=a

print(sum)

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

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r,reverse=True)
answer=p[:X]+q[:Y]
sum=0
answer=sorted(answer,reverse=True)
i=0

while answer[-i-1]<r[i]:
    answer[-i-1]=r[i]
    i+=1

for a in answer:
    sum+=a

print(sum)
Problem p02761 (python)

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

answer=[]

if N==1:
    for j in range(10):
        a=0
        for i in range(M):
            if int(str(j)[sc[i][0]-1])==sc[i][1]:
                a+=1
            else:
                break
        if a==M:
            answer.append(j)
else:
    for j in range(10**(N-1),10**N):
        a=0
        for i in range(M):
            if int(str(j)[sc[i][0]-1])==sc[i][1]:
                a+=1
            else:
                break
        if a==M:
            answer.append(j)
if len(answer)>=1:
    print(min(answer))
    #print(answer)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(M)]

answer=[]

if N==1:
    for j in range(10):
        for i in range(M):
            if int(str(j)[sc[i][0]-1])==sc[i][1]:
                a+=1
            else:
                break
        if a==M:
            answer.append(j)
else:
    for j in range(10**(N-1),10**N):
        a=0
        for i in range(M):
            if int(str(j)[sc[i][0]-1])==sc[i][1]:
                a+=1
            else:
                break
        if a==M:
            answer.append(j)
if len(answer)>=1:
    print(min(answer))
    #print(answer)
else:
    print(-1)
Problem p02768 (python)

Fixed submission:
import math
n,a,b=map(int,input().split())

count=0
mod=1000000007

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
        x%=mod
        y%=mod
    return x*pow(y,mod-2,mod)%mod

count+=pow(2,n,mod)
#print(count)
count-=1
count-=C(n,a)
#print(count)
count-=C(n,b)

print(max(0,(count)%mod))

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

count=0
mod=10**9+7

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
    return x/y

count+=pow(2,n,mod)
#print(count)
count-=1
count-=C(n,a)
#print(count)
count-=C(n,b)

print(int(count%mod))
Problem p02796 (python)

Fixed submission:
from operator import itemgetter

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

for xl in XL:
    xl.append(xl[0]+xl[1])

XL.sort(key=itemgetter(2))
#print(XL)
count=0
j=0

for i in range(1,N):
    if XL[j][2]>XL[i][0]-XL[i][1]:
        count+=1
    else:
        j=i

print(N-count)

Buggy submission (verdict: Runtime Error):
N=int(input())
XL=[list(map(int,input().split())) for _ in range(N)]

count=0
base=[]

for i in range(N):
    sumple=list(range(XL[i][0]-XL[i][1]+1,XL[i][0]+XL[i][1]))
    for j in range(len(sumple)):
        if sumple[j] in base:
            count+=1
            break
        else:
            if j == len(sumple)-1:
                for k in range(len(sumple)):
                    base.append(sumple[k])

#print(base)
print(N-count)