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

Fixed submission:
N = input()
for i in range(len(N)):
    if N[i] == '7':
        print('Yes')
        break
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input()
for i in range(len(N)):
    if N[i] = '7':
        print('Yes')
        break
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input()
for i in range(N):
    if N[i] = '7':
        print('Yes')
        break
else:
    print('No')
Problem p02712 (python)

Fixed submission:
N = int(input())
FBSum = 0
for i in range(N):
    j = i+1
    if j % 3 != 0 and j % 5 != 0:
        FBSum +=j

print(FBSum)

Buggy submission (verdict: Runtime Error):
N = int(input())
FBSum = 0
for i in N:
    j = i+1
    if j % 3 != 0 and j % 5 != 0:
    FBSum +=j

print(FBSum)
Problem p02577 (python)

Fixed submission:
n=input()


n=str(n)
Sum=0
for i in range(len(n)):
    Sum=Sum+int(n[i])

if Sum%9==0:
    print("Yes")
else:
    print("No")

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


n=str(n)
Sum=0
for i in range(len(n)):
    Sum=Sum+n[i]-"0"

if Sum%9==0:
    print("yes")
else:
    print("no")
Problem p02912 (python)

Fixed submission:
from heapq import heapify,heappush,heappop

N,M = map(int,input().split())
a = list(map(int,input().split()))
a = [(-x, x) for x in a]

heapify(a)

for m in range(M):
  max_ = heappop(a)
  a_ = max_[1]//2
  heappush(a,(-a_,a_))

ans=0
for a_ in a:
  ans+=a_[1]
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
for m in range(M):
  max_=max(a[:2])
  a.remove(max_)
  if max_//2<a[0]:
    a.insert(1,max_//2)
  else:
    a.insert(0,max_//2)
print(sum(a))
Problem p03036 (python)

Fixed submission:
r,d,x_2000=map(int,input().split())
x_i = x_2000
for i in range(10):
  x_ii = r*x_i-d
  x_i = x_ii
  print(x_ii)

Buggy submission (verdict: Runtime Error):
r,d,x_2000=map(int,input().split())
x_i = x_2000
for i in range(10):
  x_ii = r*x_i-D
  x_i = x_ii
  print(x_ii)
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=list(str(input()))
k-=1
if s[k]=="A":
  s[k]="a"
elif s[k]=="B":
  s[k]="b"
elif s[k]=="C":
  s[k]="c"

print("".join(s))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=str(input())
k-=1
if s[k]=="A":
  s[k]="a"
elif s[k]=="B":
  s[k]="b"
elif s[k]=="C":
  s[k]="c"

print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=str(input())
k-=1
if s[k]=="A":
  s[k]="a"
elif s[k]=="B":
  s[k]="b"
elif s[k]=="C":
  s[k]="c"
else
print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=str(input())
if s[k]=="A":
  s[k]="a"
elif s[k]=="B":
  s[k]="b"
elif s[k]=="C":
  s[k]="c"
print(s)
Problem p03107 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(S: str):
    stack = []
    N = len(S)
    for i, s in enumerate(S):
        if i == 0:
            stack.append(s)
        else:
            if len(stack) == 0:
                stack.append(s)
            else:
                if s != stack[-1]:
                    tmp = stack.pop()
                else:
                    stack.append(s)
    print(N - len(stack))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = str(input())
    solve(S)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
S = str(input())
stack = []
N = len(S)
for i, s in enumerate(S):
  if i == 0:
    stack.append(s)
    else:
      if len(stack) == 0:
        stack.append(s)
        else:
          if s != stack[-1]:
            tmp = stack.pop()
            else:
              stack.append(s)
print(N - len(stack))
Problem p03242 (python)

Fixed submission:
n = str(input()).replace("1","q").replace("9","1").replace("q","9")
print(n)

Buggy submission (verdict: Runtime Error):
n = str(input())
for i, s in enumerate(n):
  if s == "1":
    n[i] = "9"
  elif s == "9":
    n[i] = "1"

print(int(n))
Problem p02595 (python)

Fixed submission:
nd = input().split()
N = int(nd[0])
D = int(nd[1])
D = D**2

ans = 0

for i in range(N):
    ls = input().split()
    x = int(ls[0])
    y = int(ls[1])
    d = x**2 + y**2
    if d <= D :
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
nd = input().split()
N = int(nd[0])
D = int(nd[1])

ans = 0

for i in range(N-1):
    xy = input().split()
    x = int(xy [2*i])
    y = int(xy [2*i+1])
    d = x**2 + y**2
    if d < D:
        ans += 1

print(ans)
Problem p02676 (python)

Fixed submission:
num = int(input())
word = input()

for i in range(num):
    print(word[i],end="")
    if i+1 >= len(word):
        break

if len(word) > num:
    print("...")

Buggy submission (verdict: Runtime Error):
num = int(input())
word = input()

for i in range(num):
    print(word[i],end="")
    if i >= len(word):
        break

if len(word) > num:
    print("...")

Buggy submission (verdict: Runtime Error):
num = int(input())
word = input()

for i in range(num):
    print(word[i],end="")

if len(word) > num:
    print("...")
Problem p02729 (python)

Fixed submission:
nm = input().split()
n = int(nm[0])
m = int(nm[1])

ans = 0

n1 = n*(n-1)/2

n2 = m*(m-1)/2

ans = int(n1 + n2)

print(ans)

Buggy submission (verdict: Runtime Error):
nm = input()
n = int(nm[0])
m = int(nm[1])

ans = 0

n1 = n*(n-1)/2

n2 = m*(m-1)/2

ans = n1 + n2

print(ans)
Problem p02773 (python)

Fixed submission:
from collections import defaultdict
import collections
N=int(input())
ss = []
for i in range(N):
  ss.append(input())
#d = defaultdict(lambda: 0)
c = collections.Counter(ss)
d_=c.most_common()
mx = d_[0][1]
d_.sort()
#print(d_)
m=len(d_)
for i in range(m):
  if d_[i][1] == mx:
    print(d_[i][0])
  else:
    pass

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import collections
N=int(input())
ss = []
for i in range(N):
  ss.append(input())
ss.sort()
#d = defaultdict(lambda: 0)
c = collections.Counter(ss)
d_=c.most_common()
mx = d_[0][1]
for i in range(N):
  if d_[i][1] == mx:
    print(d_[i][0])
  else:
    break
Problem p02970 (python)

Fixed submission:
import math
n,d=map(int,input().split())
k=math.ceil(n/(2*d+1))
print(k)

Buggy submission (verdict: Runtime Error):
import math
n,d=map(int,input())
k=math.ceil(n/(2*d))
print(k)
Problem p03042 (python)

Fixed submission:
def check(M_1, M_2):
    M_1 = int(M_1)
    M_2 = int(M_2)
    MM = M_1 * 10 + M_2
    if 1 <= MM <= 12:
        return True
    else:
        return False


S = input()
ans = [0, 0]
if check(S[0], S[1]):
    ans[0] += 1
if check(S[2], S[3]):
    ans[1] += 1

if ans == [0, 0]:
    print("NA")
elif ans == [0, 1]:
    print("YYMM")
elif ans == [1, 0]:
    print("MMYY")
elif ans == [1, 1]:
    print("AMBIGUOUS")

Buggy submission (verdict: Runtime Error):
S = input()
ans = [0, 0]
if check(S[0], S[1]):
    ans[0] += 1
if check(S[2], S[3]):
    ans[1] += 1

if ans == [0, 0]:
    print("NA")
elif ans == [0, 1]:
    print("YYMM")
elif ans == [1, 0]:
    print("MMYY")
elif ans == [1, 1]:
    print("AMBIGIOUS")
Problem p02623 (python)

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

a_sum = [0]
b_sum = [0]
cnt = 0
best_b = m
confirm = ()

for i in a:
    a_sum.append(i + a_sum[-1])

for i in b:
    b_sum.append(i + b_sum[-1])

for a_idx in range(n + 1):
    if a_sum[a_idx] > k:
        break
    for b_idx in reversed(range(best_b + 1)):
        if b_sum[b_idx] + a_sum[a_idx] <= k:
            # if cnt < a_idx + b_idx:
            cnt = max(cnt, a_idx + b_idx)
            best_b = b_idx
            break

print(cnt)

Buggy submission (verdict: Runtime Error):
# f = open('test.txt')
f = open('b11.txt')
n, m, k = map(int, f.readline().split())
a = list(map(int, f.readline().split()))
b = list(map(int, f.readline().split()))

a_sum = [0]
b_sum = [0]
cnt = 0
best_b = m
confirm = ()

for i in a:
    a_sum.append(i + a_sum[-1])

for i in b:
    b_sum.append(i + b_sum[-1])

for a_idx in range(n + 1):
    if a_sum[a_idx] > k:
        break
    for b_idx in reversed(range(best_b + 1)):
        if b_sum[b_idx] + a_sum[a_idx] <= k:
            # if cnt < a_idx + b_idx:
            cnt = max(cnt, a_idx + b_idx)
            best_b = b_idx
            break

print(cnt)
Problem p02594 (python)

Fixed submission:
if int(input()) >= 30:
    print('Yes')
else:
    print('No')

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

import copy
value = copy.deepcopy(arr)
piece = [1 for i in range(N)]
left = K+N-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

import math
print(round(round(max(value)*10)/10))
Problem p02597 (python)

Fixed submission:
N = int(input())
l = input()
arr = []
for i in range(N):
    arr.append(l[i])

c = 0
left = 0
right = N-1

T = False
for i in arr:
    if i == 'R':
        T = True
if T == False:
    print(c)
else:
    T = False
    for i in arr:
        if i == 'W':
            T = True
    if T == False:
        print(c)
    else:
        while True:
            while True:
                if arr[left] == 'R':
                    left += 1
                else:
                    break
            while True:
                if arr[right] == 'W':
                    right -= 1
                else:
                    break
            arr[left] = 'R'
            arr[right] = 'W'
            if left >= right:
                break
            else:
                c += 1
        print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = input()
arr = []
for i in range(N):
    arr.append(l[i])

c = 0
left = 0
right = N-1
while True:
    while True:
        if arr[left] == 'R':
            left += 1
        else:
            break
    while True:
        if arr[right] == 'W':
            right -= 1
        else:
            break
    arr[left] = 'R'
    arr[right] = 'W'
    if left >= right:
        break
    else:
        c += 1

print(c)
Problem p02688 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
s=[[0] * k for i in range(n)]
for i in range(k):
  input()
  l=list(map(int, input().split()))
  for j in range(len(l)):
    s[l[j]-1][i]=1

r=0
for i in range(n):
  if sum(s[i])==0:
    r=r+1
print(r)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
s=[[0] * k for i in range(n)]
for i in range(k):
  input()
  l=list(map(int, input().split()))
  for j in range(len(l)):
    s[l[j]-1][i]=1

r=0
for i in range(k):
  if sum(s[i])==0:
    r=r+1
print(r)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
num_list = list(input().split())
a = Decimal(num_list[0])
b = Decimal(num_list[1])

print(int(a*b))

Buggy submission (verdict: Runtime Error):
um_list = list(input().split())
a = int(num_list[0])
b = int(float(num_list[1])*100)

print((a*b)//100)

Buggy submission (verdict: Runtime Error):
num_list = map(input().split())
a = int(num_list[0])
b = float(num_list[1])
print(int(a*b))
Problem p02836 (python)

Fixed submission:
S=str(input())

count = 0

l=[]

l = list(S)

a = len(l)

b = a - 1

for i in range(a):
    if l[i] != l[b-i]:
        count = count + 1

count = count/2

print(int(count))

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

count = 0

l=[]

l = list(S)

a = len(l)

b = a - 1

for i in range(a):
    if l[i] != l[b-i]:
        count = count + 1

count = count/2

print(int(count))

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

count = 0

l = list(S)

a = len(S)

b = a - 1

for i in a:
    if l(i) != l(b-i):
        count = count + 1

count = count/2

print(count)
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if w >= s:
  print('unsafe')
else:
  print('safe')

Buggy submission (verdict: Runtime Error):
try:
  s,w=map(int,input().split())
  if(w>=s):
    print("unsafe")
   else:
    print("safe")
except:
  pass
Problem p02623 (python)

Fixed submission:
n,m,k = map(int, input().split())
ln = list(map(int, input().split()))
lm = list(map(int, input().split()))

def csum(l,ll):
    s = 0
    res = [0] * ll
    for i in range(ll):
        s += l[i]
        res[i] = s
    return res

csln = csum(ln,n)
cslm = csum(lm,m)

import numpy as np

lk = [k] + [k-x for x in csln if k-x >=0]
res = np.searchsorted(np.array(cslm), np.array(lk), side='right')
rmax = 0
for i,j in zip(range(len(lk)+1), res):
    rmax = max(rmax, i+j)
print(rmax)

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

def csum(l,ll):
    s = 0
    res = [0] * ll
    for i in range(ll):
        s += l[i]
        res[i] = s
    return res

csln = csum(ln,n)
cslm = csum(lm,m)

import numpy as np

lk = [k-x for x in csln if k-x >=0]
res = np.searchsorted(np.array(cslm), np.array(lk), side='right').
rmax = 0
for i,j in zip(range(1,len(lk)+1), res):
    rmax = max(rmax, i+j)
print(int(rmax))
Problem p02629 (python)

Fixed submission:
n = int(input())
d = {k:v for k,v in zip(range(26),'abcdefghijklmnopqrstuvwxyz')}
i = 1
while n > 26**i:
    n -= 26**i
    i += 1
res = ''
n -= 1
for j in range(i-1,-1,-1):
    jn, n = divmod(n, 26**j)
    res += d[jn]
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = {k:v for k,v in zip(range(26),'abcdefghijklmnopqrstuvwxyz')}
i = 1
while n > 26**i:
    n -= 26**i
    i += 1
res = ''
for j in range(i-1,-1,-1):
    jn, n = divmod(n, 26**j)
    if j >0:
        res += d[jn]
    else:
        res += d[jn-1]
print(res)
Problem p03012 (python)

Fixed submission:
import numpy as np

N = int(raw_input())
W = map(int, raw_input().split())

total = sum(W)

ans = total

total_r = total
total_l = 0
for i in range(N):
        total_r = total_r - W[i]
        total_l = total_l + W[i]
        ans_temp = np.abs(total_r - total_l)
        if ans > ans_temp:
                ans = ans_temp

print ans

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

N = int(raw_input())
W = map(int, raw_input().split())

total = sum(W)

ans = total

for i in range(N):
	total = total - W[i]
    if ans < np.abs(total):
      ans = int(np.abs(total))
      
print ans
Problem p02829 (python)

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

for i in range(3):
    if((i+1 != a) and (i+1 != b)):
        c = i+1
    
print(c)

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

#min_indexlist = [a_list.index(min(a_list))]

min_indexlist = []

m = min(a_list)

#print(m)

#ここがおかしい
"""
for i in range(len(a_list)):
    if( a_list[i] == m+1):
        m = a_list[i]
        min_indexlist.append(i)
"""


f = False

for i in range(len(a_list)):

    if(f==False):
        if(a_list[i] == 1):
            min_indexlist.append(i)
            f = True

    if(f==True):
        if( a_list[i] == m+1):
            m = a_list[i]
            min_indexlist.append(i)
            
if(len(min_indexlist)==0):
    min_indexlist.append(1)



#print(min_indexlist)

#砕いたレンガの後のリスト
crash_list = []
for i in range(len(min_indexlist)):
    crash_list.append(a_list[min_indexlist[i]])

#print(crash_list)

#砕いたレンガの数
crash = n - len(min_indexlist)


frag=True

for i in range(len(crash_list)):
    if(crash_list[i] != i+1):
        frag = False


if(frag == True):
    print(crash)
elif(frag == False):
    print(-1)

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

min_indexlist = []

m = min(a_list)


f = False

for i in range(len(a_list)):

    if(f==False):
        if(a_list[i] == 1):
            min_indexlist.append(i)
            f = True

    if(f==True):
        if( a_list[i] == m+1):
            m = a_list[i]
            min_indexlist.append(i)
            
if(len(min_indexlist)==0):
    min_indexlist.append(1)


#砕いたレンガの後のリスト
crash_list = []
for i in range(len(min_indexlist)):
    crash_list.append(a_list[min_indexlist[i]])

#print(crash_list)

#砕いたレンガの数
crash = n - len(min_indexlist)


frag=True

for i in range(len(crash_list)):
    if(crash_list[i] != i+1):
        frag = False


if(frag == True):
    print(crash)
elif(frag == False):
    print(-1)
Problem p02831 (python)

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

min = a * b / fractions.gcd(a, b)

print(int(min))

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

min = a * b / gcd(a, b)

print(min)
Problem p02623 (python)

Fixed submission:
import bisect

n, m, k = map(int, input().split())
a = [0] + [int(x) for x in input().split()]
b = [0]
for x in input().split():
    b.append(b[-1] + int(x))

res = 0
a_ = 0
for i in range(n+1):
    a_ += a[i]
    if a_ > k:
        break
    b_max = k - a_
    b_num = bisect.bisect(b, b_max) - 1
    res = max(res, i + b_num)

print(res)

Buggy submission (verdict: Runtime Error):
import bisect

n, m, k = map(int, input().split())
a, b = [0], [0]
for i, (a_, b_) in enumerate(zip(input().split(), input().split())):
    a.append(a[i] + int(a_))
    b.append(b[i] + int(b_))

res = 0
a_ = 0
for i in range(n+1):
    if a[i] > k:
        break
    j = bisect.bisect(b, k-a[i]) - 1
    res = max(res, i+j)

print(res)
Problem p02759 (python)

Fixed submission:
print((int(input())+1)//2)

Buggy submission (verdict: Runtime Error):
print((int(input)+1)//2)
Problem p02779 (python)

Fixed submission:
n = int(input())
a = set(input().split())

print('YES' if len(a) == n else 'NO')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = set(input().split())

print('YES' if len(s) == n else 'NO')
Problem p02912 (python)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)

for i in range(m):
    tmp = (heapq.heappop(a) * (-1)) // 2
    heapq.heappush(a, tmp * (-1))

print(sum(a) * (-1))

Buggy submission (verdict: Runtime Error):
import heapq

n, m = map(int, input().split())
a = map(int, input().split())
a = map(lambda x: -x, a)
heapq.heapify(a)

for i in range(m):
    tmp = -heapq.heappop(a) // 2
    heapq.heappush(a, -tmp)

print(-sum(a))
Problem p02990 (python)

Fixed submission:
import math

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

if n == k:
    print(1)
    for i in range(k-1):
        print(0)
elif k == 1:
    print(combinations(n-k+1, 1) % 1000000007)
else:
    for i in range(k-1):
        if i + 1 > n-k+1:
            print(0)
        else:
            print((combinations(n-k+1, i+1) * combinations(k-1, i)) % 1000000007)
    else:
        if k > n-k+1:
            print(0)
        else:
            print((combinations(n-k+1, k)) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

if n == k:
    print(1)
    for i in range(k-1):
        print(0)
elif k == 1:
    print(combinations(n-k+1, 1) % 1000000007)
else:
    for i in range(k-1):
        print((combinations(n-k+1, i+1) * (i+1)) % 1000000007)
    else:
        print((combinations(n-k+1, k)) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

if k == 1:
    print(combinations(n-k+1, 1) % 1000000007)
else:
    for i in range(k-1):
        print((combinations(n-k+1, i+1) * (i+1)) % 1000000007)
    else:
        print((combinations(n-k+1, k)) % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

def combinations(p, q):
    return math.factorial(p) // (math.factorial(p - q) * math.factorial(q))

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

for i in range(k-1):
    print((combinations(n-k+1, i+1) * (i+1)) % 1000000007)
else:
    print((combinations(n-k+1, k)) % 1000000007)
Problem p03208 (python)

Fixed submission:
n, k = map(int, input().split())
h = sorted([int(input()) for i in range(n)])

res = h[k-1] - h[0]
for i in range(k, n):
    tmp = h[i] - h[i-k+1]
    res = min(res, tmp)

print(res)

Buggy submission (verdict: Runtime Error):
5 3
5
7
5
7
7
Problem p03723 (python)

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

if a%2==0 and b%2==0 and c%2==0 and a==b==c:
    print(-1)
else:
    res = 0
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        else:
            a, b, c = b//2+c//2, a//2+c//2, a//2+b//2
            res += 1
    print(res)

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

if a%2==0 and b%2==0 and c%2==0 and a==b==c:
    print(-1)
else:
    res = 0
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        else:
            a, b, c = b//2+c//2, a//2+c//2, a//2+b//2
            res += 1

print(res)
Problem p02725 (python)

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

X = 0
space = 0
idx = 0
A.append(A[0]+K)
for j in range(0,len(A)-1):
    X=0
    X = A[j+1] - A[j]
    if space < X:
        space = X
        idx = j
    
print(A[idx] + K - A[idx+1] )

Buggy submission (verdict: Runtime Error):
def around(K,A):
    N2 = A.pop(0)
    A.append(N2+K)
    return A

K,N = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

X = 0
X_min = 1000000000
for j in range(0,len(A)):
    X=
    X = A[len(A)-1] - A[0]
    if X_min > X:
        X_min = X
    A=around(K,A)
    
print(X_min)
Problem p02629 (python)

Fixed submission:
import string
N = int(input())
alphabet = list(string.ascii_lowercase)

n = N
idxs = []
while n > 0:
    n -= 1
    idxs.append(n%26)
    n //= 26

ans = ''
for i in idxs[::-1]:
    ans += alphabet[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import string
N = int(input())
alphabet = list(string.ascii_lowercase)
for i in range(1,11+1):
    if 27**i >= N: break
I = i

ans = ''
n = N
for i in range(I, 0, -1):
    ans += alphabet[n//(26**i)-1]
    n -= (26**i)
if n%26 > 0:
    ans += alphabet[n%26-1]
print(ans)
Problem p02689 (python)

Fixed submission:
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
h = {}
ans = 0
for row in AB:
    if row[0] in h:
        h[row[0]].append(row[1])
    else:
        h[row[0]] = [row[1]]
    if row[1] in h:
        h[row[1]].append(row[0])
    else:
        h[row[1]] = [row[0]]
ans += sum([1 for i in range(1, N+1) if i not in h.keys()])
for hidx, otherh in h.items():
    if H[hidx-1] > max([H[idx-1] for idx in otherh]):
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
h = {}
ans = 0
for row in AB:
    if row[0] in h:
        h[row[0]].append(row[1])
    else:
        h[row[0]] = [row[1]]
    if row[1] in h:
        h[row[1]].append(row[0])
    else:
        h[row[1]] = [row[0]]
ans += sum([1 for i in range(1, N+1) if i not in h.keys()])
for hidx, otherh in h.items():
    if H[hidx-1] > max([H[idx-1] for idx in otherh]):
        ans += 1
print(ans)
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if S <= W:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0

for n in range(3, len(S)):
    for i in range(len(S)-n):
        ans += 1 if int(S[i:i+n+1]) % 2019 == 0 else 0

print(ans)
Problem p02933 (python)

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

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

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

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

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

print(input() if a => 3200 else 'red')

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

print(input() if a => 3200, else 'red')