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

Fixed submission:
S, W = map(int,input().split())

if W >= S:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
A = input()

S = 0
lis = [0] * 2019
lis[0] += 1
l = len(A)+1
d = 1

for n in reversed(A):
    S += int(n)*d
    sm = S % 2019
    lis[sm] += 1
    d *= 10

result = 0

for n in lis:
    result += (n*(n-1)/2)


print(int(result))
Problem p02711 (python)

Fixed submission:
N = int(input())

if str(7)in [str(N)[0],str(N)[1],str(N)[2]]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
import itertools as itr

A = {'R':[] ,'G':[] ,'B':[]}
sum = 0

for i in range(N):
    A[S[i]].append(i+1)



for i,j,k in itr.product(A['R'],A['B'],A['G']):
            if not i-j == k-j:
                l = [i,j,k]
                l.sort()
                if not l[1] - l[0] == l[2] - l[1]:
                    sum += 1

print(sum)
Problem p02912 (python)

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

for i in range(len(A)):
    A[i] *= -1

import heapq

heapq.heapify(A)


for _ in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, ((a*(-1))//2)*(-1))


result = -sum(A)
print(result)

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

A.sort(reverse = True)

n = 0
if N > 1:
    while not M == 0:

        while A[0] >= A[1]:
            A[n] //= 2
            M -= 1
            if M == 0:
                break
                
        if M == 0:
            break

        i = 0
        while A[i] < A[i+1]:
            A[i], A[i+1] = A[i+1], A[i]
            i += 1
            if i == N:
                break


else:
    A[0] //= (2**M)


result = sum(A)
print(result)

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

A.sort(reverse = True)

n = 0
if N > 1:
    while not M == 0:

        while A[0] >= A[1]:
            A[n] //= 2
            M -= 1
            if M == 0:
                break
        i = 0
        while A[i] < A[i+1]:
            A[i], A[i+1] = A[i+1], A[i]
            i += 1
            if i == N:
                break 

        if M == 0:
            break

else:
    A[0] //= (2**M)


result = sum(A)
print(result)

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

A.sort(reverse = True)

n = 0
if N > 1:
    while not M == 0:

        while A[0] >= A[1]:
            A[n] //= 2
            M -= 1
            if M == 0:
                break
        i = 0
        while A[i] < A[i+1]:
            A[i], A[i+1] = A[i+1], A[i]
            i += 1

        if M == 0:
            break

else:
    A[0] //= (2**M)


result = sum(A)
print(result)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
dp = [0] * N
for _ in range(M):
    a = int(input())
    dp[a-1] = -1

k = 1000000007


for i in range(N):
    if dp[i] == -1:
        dp[i] = 0
        continue
    if i == 0:
        dp[i] = 1
        continue
    if i == 1:
        dp[i] = dp[i-1] + 1
        continue

    dp[i] = dp[i-1] + dp[i-2]

n = dp[-1] % k

print(n)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
dp = [0] * N
for _ in range(M):
    a = int(input())
    dp[a-1] = -1

k = 1000000007


for i in range(N):
    if dp[i] == -1:
        dp[i] = 0
        continue
    if i == 0:
        dp[i] = 1
        continue
    if i == 1:
        dp[i] = dp[i-1] + 1
        continue

    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= k



print(n)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
dp = [0] * N
for _ in range(M):
    a = int(input())
    dp[a-1] = -1

k = 1000000007


for i in range(N):
    if dp[i] == -1:
        dp[i] = 0
        continue
    if i == 0:
        dp[i] = 1
        continue
    if i == 1:
        dp[i] = dp[i-1] + 1
        continue

    dp[i] = dp[i-1] + dp[i-2]
    dp[i] /= k



print(n)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
dp = [0] * N
for _ in range(M):
    a = int(input())
    dp[a-1] = -1

k = 1000000007

if dp[0] == 0 and dp[1] == 0:
    dp[0] = 1
    dp[1] = 2

if dp[0] == -1 and dp[1] == 0:
    dp[0] = 0
    dp[1] = 1


if dp[0] == 0 and dp[1] == -1:
    dp[0] = 1
    dp[1] = 0


if dp[0] == -1 and dp[1] == -1:
    dp[0] = 0
    dp[1] = 0


for i in range(2, N):
    if dp[i] == -1:
        dp[i] = 0
        continue
    dp[i] = dp[i-1] + dp[i-2]

n = dp[-1] % k

print(n)
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
ch = []
for _ in range(M):
    b, c = map(int, input().split())
    ch.append([c, b])

A.sort()
ch.sort(reverse = True)


n = -1
result = 0
fin = 0
for c, b in ch:
    if fin == 1:
        break

    n += b

    if n >= N:
        for num in A[n-b+1:]:
            if c > num:
                result += c
            else:
                result += num
            fin += 1
        break

    if c < A[n]:
        for i, j in enumerate(A[n-b+1:]):
            if c < j:
                result += c*i + sum(A[n-b+i+1:])
                fin += 1
                break
    else:
        result += b * c


if not fin == 1:
    result += sum(A[n+1:])



print(result)

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

A.sort()
ch.sort(reverse = True)


n = -1
result = 0
fin = 0
for c, b in ch:
    if fin == 1:
        break

    n += b
    if n > N:
        for num in A[n-b+1:]:
            if c > num:
                result += c
            else:
                result += num
            fin += 1
        break
        
    if c < A[n]:
        for i, j in enumerate(A[n-b+1:]):
            if c < j:
                result += c*i + sum(A[n-b+i+1:])
                fin += 1
                break
    else:
        result += b * c


if not fin == 1:
    result += sum(A[n+1:])



print(result)

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

A.sort()
ch.sort(reverse = True)


n = -1
result = 0
fin = 0
for c, b in ch:
    if fin == 1:
        break

    n += b
    if n > N:
        for num in A[n-b+i+1:]:
            if c > num:
                result += c
            else:
                result += num

    if c < A[n]:
        for i, j in enumerate(A[n-b+1:]):
            if c < j:
                result += c*i + sum(A[n-b+i+1:])
                fin += 1
                break
    else:
        result += b * c


if not fin == 1:
    result += sum(A[n+1:])



print(result)

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

A.sort()
ch.sort(reverse = True)


n = -1
result = 0
fin = 0
for c, b in ch:
    if fin == 1:
        break

    n += b
    if c < A[n]:
        for i, j in enumerate(A[n-b+1:]):
            if c < j:
                result += c*i + sum(A[n-b+i+1:])
                fin += 1
                break
    else:
        result += b * c


if not fin == 1:
    result += sum(A[n+1:])



print(result)
Problem p02688 (python)

Fixed submission:
from copy import copy
from functools import reduce
    
class Sunuke:
    def __init__(self):
        self.has_snack = False
    
n_sunuke, n_v_snacks = [int(s) for s in input().split()]
    
all_sunuke = [copy(Sunuke()) for i in range(n_sunuke)]
    
for snack_id in range(n_v_snacks):
    n_snacks = int(input())
    for sunuke_id in (int(s) for s in input().split()):
        all_sunuke[sunuke_id - 1].has_snack = True
    
print(reduce(lambda n,s: n + (0 if s.has_snack else 1), all_sunuke, 0))

Buggy submission (verdict: Runtime Error):
from copy import copy
from functool import reduce

class Sunkune:
	def __init__(self):
  		self.has_snack = False

n_sunuke, n_v_snacks = [int(s) for s in input().split(2)]

all_sunuke = [copy(Sunuke()) for i in range(n_sunuke)]

for snack_id in n_v_snacks:
  	n_snacks = int(input())
    for sunuke_id in (int(s) for s in input().split()):
    	all_sunuke[s - 1].has_snack = True

print(reduce(lambda n,s: n + (0 if s.has_snack else 1), all_sunuke, 0)
Problem p02726 (python)

Fixed submission:
n, x, y = map(int,input().split())
dist = [0] * n
x -= 1
y -= 1
for i in range(n):
  for j in range(i+1, n):
    dist[min(j-i, abs(x-i)+abs(y-j)+1, abs(y-i)+abs(x-j)+1)] += 1
for d in dist[1:]:
  print(d)

Buggy submission (verdict: Runtime Error):
n, x, y = map(int,input().split())
dist = [0] * (n-1)
x -= 1
y -= 1
for i in range(n):
  for j in range(i+1, n):
    if (i <= x and j <= x) or (x <= i <= y and x <= j <= y) or (y <= i and y <= j):
      dist[j-i] += 1
    elif i <= x and y <= j:
      dist[j-i-(y-x)+1] += 1
    elif i <= x and x <= j <= y:
      dist[x-i + min(j-x, y-j+1)] += 1
    else:
      dist[j-y + min(y-j, j-x+1)] += 1
for d in dist:
  print(d)
Problem p02762 (python)

Fixed submission:
from collections import defaultdict
import time
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = []
start = time.time()
group = [0] * n

for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  fr[a].add(b)
  fr[b].add(a)

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl.append((a,b))


g_num = 0
for i in range(n):
    if group[i] != 0:
        continue
    g_num += 1
    unvisited = set({i})
    while len(unvisited) > 0:
        v = unvisited.pop()
        group[v] = g_num
        for w in fr[v]:
            if group[w] > 0 or w in unvisited:
                continue
            unvisited.add(w)

group_size = defaultdict(int)
for x in group:
    group_size[x] += 1

bl_in_group = [0] * n
for a,b in bl:
    if group[a] == group[b]:
        bl_in_group[a] += 1
        bl_in_group[b] += 1

for i in range(n):
    print(group_size[group[i]] - len(fr[i]) - bl_in_group[i] - 1, end=' ')

print()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = defaultdict(set)

for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  fr[a].add(b)
  fr[b].add(a)

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl[a].add(b)
  bl[b].add(a)

def dfs(i, g):
  g.add(i)
  for a in fr[i]:
    if a not in g:
      dfs(a, g)

for i in range(n):
  s = set()
  dfs(i, s)
  for j in bl[i]:
    if j in s:
      s.remove(j)
  print(len(s) - len(fr[i]) - 1, end=' ')
print()
Problem p02769 (python)

Fixed submission:
n,k = map(int,input().split())
mod = 10**9 + 7

fact = [1]
finv = [1]
for i in range(1, 2*n):
    fact.append((fact[i-1] * i) % mod)
    finv.append(pow(fact[i], mod-2, mod))

if n-1 <= k:
    print((fact[2*n-1] * finv[n] * finv[n-1]) % mod)
    exit()

ans = 0
for i in range(k+1):
    ans += fact[n] * finv[n-i] * finv[i] * fact[n-1] * finv[n-1-i] * finv[i]
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
mod = 10**9 + 7

fact = [1]
finv = [1]
for i in range(1, 2*n):
    fact.append((fact[i-1] * i) % mod)
    finv.append(pow(fact[i], mod-2, mod))

if n-1 <= k:
    print((fact[2*n-1] * finv[n] * finv[n-1]) % mod)

ans = 0
for i in range(k+1):
    ans += fact[n] * finv[n-i] * finv[i] * fact[n-1] * finv[n-1-i] * finv[i]
    ans %= mod

print(ans)
Problem p02773 (python)

Fixed submission:
n = int(input())
d = dict()
for i in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1

ans = []
c = max(d.values())
for k, v in d.items():
    if v == c:
        ans += [k]
for x in sorted(ans):
    print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = {}
for i in range(n):
  s = input()
  d[s] = 1 if not s in d else d[s] += 1

ans = []
c = max(d.values())
for k,v in d.items():
  if v == c:
    ans += [k]
for x in sorted(ans):
  print(x)
Problem p02819 (python)

Fixed submission:
x = int(input())
primes = []
n = 2


def is_prime(num):
    for p in primes:
        if num % p == 0:
            return False
        if p * p > num:
            return True
    return True


while True:
    if is_prime(n):
        if n >= x:
            print(n)
            exit()
        else:
            primes.append(n)
    n += 1

Buggy submission (verdict: Runtime Error):
x = int(input())
primes = []
n = 2

def is_prime(num):
  for p in primes:
    if num % p == 0:
      return False
  return True

while true:
  if is_prime(n):
    if n >= x:
      print(n)
      exit()
    else:
      primes.append(n)
  n += 1
Problem p02835 (python)

Fixed submission:
a = list(map(int,input().split()))
if sum(a) >= 22:
  print('bust')
else:
  print('win')

Buggy submission (verdict: Runtime Error):
a = list(int,input().split())
if sum(a) >= 22:
  print('bust')
else:
  print('win')
Problem p02912 (python)

Fixed submission:
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  a[i] = -a[i]
heapq.heapify(a)

for _ in range(m):
  x = heapq.heappop(a)
  x = -1 * (-1 * x // 2)
  heapq.heappush(a, x)
print(-sum(a))

Buggy submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  a[i] = -a[i]
heapq.heapify(a)

for _ in range(m):
  x = heapq.heappop(a)
  x = -1 * (-1 * x // 2)
  heapq.heappush(x, a)
print(-sum(a))
Problem p02916 (python)

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

ans = 0
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        ans += c[a[i]-1]

print(ans + sum(b))

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

ans = 0
for i in range(n-1):
  if a[i] + 1 == a[i+1]:
    ans += c[i]
  
print(ans + sum(b))
Problem p02989 (python)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[int(n/2)] - d[int(n/2)-1])

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

print(d[n/2] - d[n/2-1])
Problem p03012 (python)

Fixed submission:
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break
  else:
    ans = abs(s2-s1)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break
  else:
	ans = abs(s2-s1)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break:
  else:
	ans = abs(s2-s1)

print(ans)
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))

b = [0] * (n + 1)
b[0] = 1
if 1 not in a:
    b[1] = 1
for i in range(2, n + 1):
    if i in a:
        b[i] = 0
    else:
        b[i] = b[i - 1] + b[i - 2]
print(b[n] % 1000000007)

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

Buggy submission (verdict: Runtime Error):
n,m = map(int, input())
a = set()
for i in range(m):
  a.add(int(input()))
  
b = [0]* (n+1)
b[0] = 1
if 1 not in a:
  b[1] = 1
for i in range(2, n+2):
  if i in a:
    b[i] = 0
  else:
    b[i] = b[i-1] + b[i-2]
print(b[n] % 1000000007)
Problem p03072 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
max_h = 0
ans = 0
for a in h:
  if max_h <= a:
    ans += 1
  max_h = max(a, max_h)
  
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
max_h = 0
ans = 0
for a in h:
  if max <= a:
    ans += 1
  max_h = max(a, max_h)
  
print(ans)
Problem p03208 (python)

Fixed submission:
n,k = map(int,input().split())
h = sorted([int(input()) for i in range(n)])
ans = 1000000000
for i in range(n-k+1):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input())
h = [int(input()) for i in range(n)].sort()
ans = 1000000000
for i in range(n-k):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input())
h = [int(input()) for i in range(n)].sort()
ans = 1000000000
for i in range(n-k+1):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input())
h = [int(input()) for i in range(n)].sort()
ans = 1000000000
for i in range(n-k):
  ans = min(ans, h[i+k]-h[i])
print(ans)
Problem p03221 (python)

Fixed submission:
n,m = map(int, input().split())
py = []
for i in range(m):
  a,b = map(int, input().split())
  py.append([a,b,i])
py.sort()
p = py[0][0]
y = 1
for i in range(m):
  if py[i][0] == p:
    py[i][1] = y
    y += 1
  else:
    py[i][1] = 1
    y = 2
    p = py[i][0]
py = sorted(py, key=lambda x:x[2])
for p,y,i in py:
  print("{:0=6}{:0=6}".format(p,y))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
py = []
for i in rante(m):
  a,b = map(int, input.split())
  py.append([a,b,i])
py.sort()
p = 1
y = 1
for i in range(m):
  if py[i][0] == p:
    py[i][1] = y
    y += 1
  else:
    py[i][1] = 1
    y = 1
    p = py[i][0]
py = sorted(py, key=lambda x:x[2])
for p,y,i in py:
  print("{06}{06}".format(p,y))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
py = []
for i in rante(m):
  a,b = map(int, input.split())
  py.append([a,b,i])
py.sort()
p = 1
y = 1
for i in range(m):
  if py[i][0] == p:
    py[i][1] = y
    y += 1
  else:
    py[i][1] = 1
    y = 1
    p = py[i][0]
py.sort(key=lambda x:x[2])
for p,y,i in py:
  print("{06}{06}".format(p,y))
Problem p03252 (python)

Fixed submission:
s = input()
t = input()
d_s = dict()
d_t = dict()
for i in range(len(s)):
  if not s[i] in d_s:
    d_s[s[i]] = t[i]
  elif d_s[s[i]] != t[i]:
    print('No')
    exit()
  if not t[i] in d_t:
    d_t[t[i]] = s[i]
  elif d_t[t[i]] != s[i]:
    print('No')
    exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
d_s = dict()
d_t = dict()
for i in range(len(s)):
  if not s[i] in d:
    d_s[s[i]] = t[i]
  elif d_s[s[i]] != t[i]:
    print('No')
    exit()
  if not t[i] in d:
    d_t[t[i]] = s[i]
  elif d_t[t[i]] != s[i]:
    print('No')
    exit()
print('Yes')
Problem p03295 (python)

Fixed submission:
n,m = map(int, input().split())
a = []
for i in range(m):
  x,y = map(int, input().split())
  a.append((x,y))
a.sort(key=lambda x:x[1])
ans = 1
l,r = a[0]
for x,y in a[1:]:
  if r <= x:
    ans += 1
    l = x
    r = y

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = []
for i in range(m):
  x,y = map(int, input().split())
  a.append((x,y))
a.sort()
ans = 1
l,r = a[0][]
for x,y in a[1:]:
  if r <= x:
    ans += 1
    r = x
    l = y
  else:
    r = max(r, y)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = []
for i in range(n):
  x,y = map(int, input().split())
  a.append((x,y))
a.sort()
ans = 1
l,r = a[0]
for x,y in a[1:]:
  if r <= x:
    ans += 1
    r = x
    l = y
  else:
    r = max(r, y)
print(ans)
Problem p03327 (python)

Fixed submission:
n = int(input())
if n < 1000:
  print('ABC')
else:
  print('ABD')

Buggy submission (verdict: Runtime Error):
n = int(input().split())
if n < 1000:
  print('ABC')
else:
  print('ABD')
Problem p03426 (python)

Fixed submission:
h,w,d = map(int,input().split())
p = [(0,0)] * (h*w)
c = [0] * (h*w)
for i in range(h):
  a = list(map(int,input().split()))
  for j in range(w):
    p[a[j]-1] = (i,j)

for i in range(d, h*w):
  c[i] = c[i-d] + abs(p[i][0] - p[i-d][0]) + abs(p[i][1] - p[i-d][1])

q = int(input())
ans = 0
for i in range(q):
  l,r = map(int,input().split())
  print(c[r-1] - c[l-1])

Buggy submission (verdict: Runtime Error):
h,w,d = map(int,input().split())
p = [(0,0)] * (h*w)
c = [0] * (h*w)
for i in range(h):
  a = list(map(int,input().split()))
  for j in range(w):
    p[a[j]-1] = (i,j)

for i in range(d, h*w):
  c[i] = c[i-d] + abs(p[i][0] - p[i-d][0]) + abs(p[i][1] - p[i-d][1])

q = int(input())
ans = 0
for i in range(q):
  l,r = map(int,input().split())
  ans += c[r] - c[l]
print(ans)
Problem p03805 (python)

Fixed submission:
import itertools
n,m = map(int,input().split())
e = [[False]*n for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  e[a-1][b-1] = True
  e[b-1][a-1] = True

ans = 0
l = [i for i in range(1,n)]
for p in itertools.permutations(l):
  p = [0] + list(p)
  reach = 1
  for i in range(n-1):
    if not e[p[i]][p[i+1]]:
      reach = 0
      break
  ans += reach

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import itertools

n,m = map(int,input().split())
e = [[False]*n for _ in range(n)]

for _ in range(m):
  a,b = map(int,input().split())
  e[a-1][b-1] = True
  e[b-1][a-1] = True

ans = 0
l = [i for i in range(1,n)]
for p in itertools.permutations(l):
  p = [0] + p
  reach = 1
  for i in range(n-1):
    if not e[p[i]][p[i+1]]:
      reach = 0
      break
  ans += reach

print(ans)
Problem p02676 (python)

Fixed submission:
import numpy,math

n = int(input())
s = str(input())

if(len(s) <= n):
    print(s)
else:
    print(s[:n] + "...")

Buggy submission (verdict: Runtime Error):
import numpy,math

n = int(input())
s = str(input())

if(len(s) <= n):
    print(s)
else:
    print(s[:n+1 + "..."])
Problem p02693 (python)

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

# main
result = "NG"
for i in range(args[0], args[1] + 1):
    if i % a == 0:
        result = "OK"

# /main

print(result)

Buggy submission (verdict: Runtime Error):
import itertools

x = list(map(int, input().split()))
y = []

for i in range(x[2]):
    y.append(list(map(int, input().split())))

for i in range(len(y)):
    y[i][0] -= 1
    y[i][1] -= 1

def get_score(arr: list):
    score = 0
    for yy in y:
        if arr[yy[1]] - arr[yy[0]] == yy[2]:
            score += yy[3]
    return score

scores = []
for t in itertools.combinations_with_replacement(range(1, 11), x[0]):
    isError = False
    for i in range(x[0] -1):
        if t[i] > t[i+1]:
            isError = True
    if isError == True:
        continue
    scores.append(get_score(t))

print(max(scores))
Problem p02779 (python)

Fixed submission:
def main():
    n = int(input())
    print("YES" if n == len(set(map(int, input().split()))) else "NO")
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n = int(input())
    print("Yes" if n == len(set(map(int, input().split()))) else "No")
Problem p02831 (python)

Fixed submission:
import fractions as math

def main():
    x, y = map(int, input().split())
    print(x*y // math.gcd(x,y))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    x, y = map(int, input().split())
    print(x*y // math.gcd(x,y))

if __name__ == '__main__':
    main()
Problem p03250 (python)

Fixed submission:
def main():
    a=sorted(map(int,input().split()))
    print(a[2]*10+a[0]+a[1])
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
n,m,X,Y=sorted(map(int,input().split()))
x=max([X],max(map(int,input().split())))
y=min([Y],min(map(int,input().split())))
print("No War" if x<y else "War")