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

Fixed submission:
import numpy as np
from numba import njit

n,k =map(int,input().split())
a= np.array(list(map(int,input().split())))

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)

[print(aa,end=' ') for aa in a]

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

n,k =map(int,input().split())
a= np.array(list(map(int,input().split())))

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)

[print(aa,end=' ') for aa in a]

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

n,k =map(int,input().split())
a= list(map(int,input().split()))
a= np.array(a)

def light(a_list):
    outcome= np.array([0]*(n+1))
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if sum(a) >= n*n:
        break
    a = light(a)

[print(aa,end=' ') for aa in a]

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

n,k =map(int,input().split())
a= list(map(int,input().split()))
a= np.array(a)

@njit
def light(a_list):
    outcome= np.array([0]*(n+1))
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if sum(a) >= n*n:
        break
    a = light(a)

[print(aa,end=' ') for aa in a]
Problem p02683 (python)

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

A=[0]*n
c=[0]*n

for i in range(n):
    A[i] = list(map(int,input().split()))

for i in range(n):
    c[i]= A[i][0]
    A[i] = A[i][1:]

import numpy as np
import sys

a = np.array(A)

ans = np.inf

for s in range(1<<n):
    cost = 0
    d = np.array([0]*m)
    for i in range(n):
        if s>>i&1:
            cost += c[i]
            d += a[i]
    if all(d >= x):
        ans = min(ans,cost)

print(ans if ans != np.inf else '-1')

Buggy submission (verdict: Runtime Error):

n,m,x = map(int,input().split())

A=[0]*n
c=[0]*n

for i in range(n):
    A[i] = list(map(int,input().split()))

for i in range(n):
    c[i]= A[i][0]
    A[i] = A[i][1:]

import numpy as np
import sys

a = np.array(A)

ans = 10**5+1

for s in range(1<<n):
    cost = 0
    d = np.array([0]*m)
    for i in range(n):
        if s>>i&1:
            cost += c[i]
            d += a[i]
    if all(d >= x):
        ans = min(ans,cost)

print(ans if ans != 10**5+1 else '-1')

Buggy submission (verdict: Runtime Error):

n,m,x = map(int,input().split())

A=[0]*n
c=[0]*n

for i in range(n):
    A[i] = list(map(int,input().split()))

for i in range(n):
    c[i]= A[i][0]
    A[i] = A[i][1:]

import numpy as np
import sys

a = np.array(A)

ans = 10**5+1

for s in range(1<<n):
    cost = 0
    d = np.array([0]*m)
    for i in range(n):
        if s>>i&1:
            cost += c[i]
            d += a[i]
    if all(d >= x):
        ans = min(ans,cost)

print(ans if ans != 10**5+1 else '-1')
Problem p02694 (python)

Fixed submission:
x=int(input())

k=100
for i in range(10000):
    if k >= x:
        print(i)
        break
    k= k*1.01 // 1

Buggy submission (verdict: Runtime Error):
k=100
for i in range(10000):
    if k >= x:
        print(i)
        break
    k= k*1.01 // 1
Problem p02741 (python)

Fixed submission:
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k= int(input())
print(a[k-1])

Buggy submission (verdict: Runtime Error):
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k= int(input())
print(a[k+1])
Problem p02743 (python)

Fixed submission:
a,b,c = map(int,input().split())
if (c-a-b)>0 and 4*a*b < (c-a-b)**2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math

a,b,c = map(int,input().split())
if (c-a-b)**2 > 4*((a*b)**2)):
    print('Yes')
else:
    print('No')
Problem p02756 (python)

Fixed submission:
s = list(input())
q = int(input()) #int(input())
inv = 1
query = [input() for _ in range(q)]
bef = []
aft = []


for t in query:
  if t == '1':
    inv *= -1 #s = s[::-1]
  else:
    _, f, c = map(str, t.split())
    if (f =='1' and inv == 1) or (f =='2' and inv == -1):
      # s = c+s
      bef.append(c)
    else:
      # s = s+c
      aft.append(c)

bef.reverse()
bef.extend(s)
bef.extend(aft)

print(''.join(bef[::inv]))

Buggy submission (verdict: Runtime Error):
import sys
s = sys.stdin.readlines()

s = s[0]
q = int(s[1]) #int(input())
inv = 1

for t in s[2:q]:
  # t = input()
  if t[0] == '1':
    inv *= -1 #s = s[::-1]
  else:
    _, f, c = map(str, t.split())
    if (f =='1' and inv == 1) or (f =='2' and inv == -1):
      s = c+s
    else:
      s = s+c

print(s[::inv])

Buggy submission (verdict: Runtime Error):
import sys
s = sys.stdin.readlines()

s = s[0]
q = int(s[1]) #int(input())
inv = 1

for t in s[2:q+1]:
  # t = input()
  if t[0] == '1':
    inv *= -1 #s = s[::-1]
  else:
    _, f, c = map(str, t.split())
    if (f =='1' and inv == 1) or (f =='2' and inv == -1):
      s = c+s
    else:
      s = s+c

print(s[::inv])
Problem p02767 (python)

Fixed submission:
n=int(input())
import numpy as np
npi = np.array(list(map(int,input().split())))
if npi.mean()%1>0.5:
  p=npi.mean()//1 +1
else:
  p=npi.mean()//1
print(int(np.sum((npi-p)**2)))

Buggy submission (verdict: Runtime Error):
n=int(input())
import numpy as np
npi = np.array(list(map(int,input().split())))
if npi.mean()%1>0.5:
  p=npi.mean()//1 +1
else:
  p=npi.mean()//1
print(int(np.sum((npi-p)**2)))
Problem p02802 (python)

Fixed submission:
n, m = map(int,input().split())
ac = [0]*(n+1)
wa = [0]*(n+1)

for i in range(m):
    p, s = map(str, input().split())
    p= int(p)
    if s == 'AC':
        ac[p] = 1
    elif ac[p] == 0:
        wa[p] += 1

wa_sum = 0
for w, a in zip(wa, ac):
    wa_sum += w*a
print(sum(ac), wa_sum)

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

n, m = map(int,input().split())
ac = [0]*(n+1)
ac = np.array(ac)
wa = [0]*(n+1)
wa = np.array(wa)

for i in range(m):
    p, s = map(str, input().split())
    p= int(p)
    if s == 'AC':
        ac[p] = 1
    elif ac[p] == 0:
        wa[p] += 1

wa= wa*ac
print(sum(ac), sum(wa))
Problem p02817 (python)

Fixed submission:
s,t=map(str,input().split())
# t=input()

print(t+s, sep="")

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

print(t+s, sep="")
Problem p02866 (python)

Fixed submission:

import collections

n = int(input())

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

waru = 998244353

c = collections.Counter(d)

ans =1

cmax =max(c.keys())
if d[0] != 0:
    print(0)
else:
    for i in range(1,cmax+1):
        if d[i] == 0:
            ans = 0
            break
        ans *= c[i-1]** c[i]

    print(ans % waru)

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

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

waru = 998244353

c = collections.Counter(d)

ans =1

cmax =max(c.keys())
if d[0] != 0:
    print(0)
else:
    for i in range(1,cmax+1):
        ans *= c[i-1]** c[i]

print(ans % waru)
Problem p02900 (python)

Fixed submission:
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

a, b = map(int, input().split())
import fractions
print(len(set(prime_decomposition(fractions.gcd(a,b))))+1)

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

ans = [1]

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
 
cflist = cf(a,b)
 
import fractions
import itertools
 
for i in cflist:
        ans.append(i)
        for j in itertools.combinations(ans, 2):
                if 1 == fractions.gcd(j[0],j[1]):
            		pass
                else:
                        ans.pop()
                        break
 
print(len(ans))

Buggy submission (verdict: Runtime Error):
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
 
cflist = cf(a,b)
 
import fractions
import itertools
 
for i in cflist:
        ans.append(i)
        for j in itertools.combinations(ans, 2):
                if 1 == fractions.gcd(j[0],j[1]):
            		pass
                else:
                        ans.pop()
                        break
 
print(len(ans))

Buggy submission (verdict: Runtime Error):
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
 
cflist = cf(a,b)
 
import fractions
import itertools
 
for i in cflist:
        ans.append(i)
        for j in itertools.combinations(ans, 2):
                if 1 == fractions.gcd(j[0],j[1]):
            		pass
                else:
                        ans.pop()
                        break
 
print(len(ans))

Buggy submission (verdict: Runtime Error):
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

cflist = cf(a,b)

import fractions
import itertools

for i in cflist:
        ans.append(i)
        for j in itertools.combinations(ans, 2):
                if 1 == fractions.gcd(j[0],j[1]):
                else:
                        ans.pop()
                        break

print(len(ans))
Problem p02918 (python)

Fixed submission:
import re

n,k= map(int,(input().split()))
b= input()
LRn=len(re.findall('LR',b))
RLn=len(re.findall('RL',b))

if min(LRn,RLn)>=k:
    ans=k*2
elif min(LRn,RLn)<=k and max(LRn,RLn)>=k:
    ans=k+min(LRn,RLn)
else:
    ans=LRn+RLn

a= list(b)
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        ans +=1

print(ans)

Buggy submission (verdict: Runtime Error):
n,k= map(int,(input().split()))
b= input()
LRn=len(re.findall('LR',b))
RLn=len(re.findall('RL',b))

if min(LRn,RLn)>=k:
    ans=k*2
elif min(LRn,RLn)<=k and max(LRn,RLn)>=k:
    ans=k+min(LRn,RLn)
else:
    ans=LRn+RLn

a= list(b)
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        ans +=1

print(ans)
Problem p02945 (python)

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

print(max(a+b,a*b,a-b))

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

print(max(a+b,a*b,a-B))
Problem p02952 (python)

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

print(kekka)

Buggy submission (verdict: Runtime Error):
N = int(input())
kekka = 0
for i in range(1:N+1):
    if len(str(i)) % 2 == 1:
        kekka += 1

print(kekka)

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

Fixed submission:
n = int(input())

def dfs(s):
    if int(s)>n:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s+c)
    return ret

print(dfs('0'))

Buggy submission (verdict: Runtime Error):
def dfs(s):
    if int(s)>n:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s+c)
    return ret

print(dfs('0'))
Problem p03280 (python)

Fixed submission:
a,b=map(int,input().split())
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
print((int(input())-1) * (int(input())-1))
Problem p03352 (python)

Fixed submission:
N = int(input())
ans=1
for i in range(1,32):
    for j in range(2,10):
        if i**j <= N:
            ans = max(ans,i**j)
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans=1
for i in range(1:32):
    for j in range(1:10):
        if i**j <= N:
            ans = max(ans,i**j)
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(1:32):
    for j in range(1:10):
        if i**j <= N:
            ans = max(ans,i**j)
print(ans)
Problem p03424 (python)

Fixed submission:
_=input()
print('Three' if len(set(map(str, input().split())))==3 else 'Four')

Buggy submission (verdict: Runtime Error):
_=input()
print('Three' if len(set(map(int, input().split())))==3 else 'Four')

Buggy submission (verdict: Runtime Error):
_=input()
print('Three' if set(map(int, input().split()))==3 else 'Four')
Problem p03456 (python)

Fixed submission:
a= int(input().replace(" ",""))

print("Yes" if a == int(a**.5)**2 else "No")

Buggy submission (verdict: Runtime Error):
a= int(intpu().replace(" ",""))

print("Yes" if a == int(a**.5)**2 else "No")
Problem p03502 (python)

Fixed submission:
n=input()
print('Yes' if int(n)%sum(map(int,n))==0 else 'No')

Buggy submission (verdict: Runtime Error):
n=int(input())
print('Yes' if n%sum(map(int,n))==0 else 'No')
Problem p03544 (python)

Fixed submission:
N = int(input())

a =[0]*87
a[0] = 2
a[1] = 1

for i in range(2,87):
    a[i]=a[i-2]+a[i-1]

print(a[N] )

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

a =[0]*86
a[0] = 2
a[1] = 1

for i in range(2,86):
    a[i]=a[i-2]+a[i-1]

print(a[N] )
Problem p03609 (python)

Fixed submission:
print(max(0,eval(input().replace(" ","-"))))

Buggy submission (verdict: Runtime Error):
print(max(o,eval(input().replace(" ","-"))))
Problem p03635 (python)

Fixed submission:
a,b = map(int,input().split())
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
print((int(input())-1)*(int(input()-1))
Problem p03651 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

def gcdd(*numbers):
    return reduce(gcd, numbers)

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

agcd = gcdd(*a)

if max(a) >= k and k%agcd ==0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
from fractions import gcd

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

agcd = gcd(*a)

if max(a) > k and k%agcd ==0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')
Problem p03658 (python)

Fixed submission:
n, k = map(int,input().split())
print(sum(sorted(list(map(int,input().split())),reverse=True)[0:k]))

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
print(sum(sorted(list(map(int,input().split())).reverse=True)[0:k]))
Problem p03673 (python)

Fixed submission:
n=int(input())
a= list(map(int,input().split()))
if n%2 ==1:
    ans = a[::-2]+a[1::2]
else:
    ans = a[::-2]+a[0::2]
print(*ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a= list(map(int,input().split()))
print(*a[::-2],*a[n%2::2])

Buggy submission (verdict: Runtime Error):
n=int(input())
a= list(map(int,input().split()))
print(*a[::-2],*a[n%2::2])

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[N%2::2])

Buggy submission (verdict: Runtime Error):
n=int(input())
a= list(map(int,input().split()))
print(*a[::-2],*a[n%2::2])

Buggy submission (verdict: Runtime Error):
n=int(input())
a= list(map(int,input().split()))
print(*a[::-2],*a[n%2::2])

Buggy submission (verdict: Runtime Error):
n=int(input())
a= list(map(int,input().split()))
print(*a[::-2],*a[n%2::2])

Buggy submission (verdict: Runtime Error):
n=int(input())
a= list(map(int,input().split()))
print(*a[::-2],*a[a%2::2])
Problem p03760 (python)

Fixed submission:
o = list(input())
e = list(input())+[""]

for x,y in zip(o,e):
  print(x+y,end="")

Buggy submission (verdict: Runtime Error):
o = input()
e = input()+[""]

for x,y in zip(o,e):
  print(x+y,end="")
Problem p04030 (python)

Fixed submission:
s = input()
ans=[]
for i in range(len(s)):
    if s[i]=='B' and len(ans)!=0:
        ans.pop()
    elif s[i]=='B' and len(ans)==0:
        continue
    else:
        ans.append(s[i])

print(''.join(ans))

Buggy submission (verdict: Runtime Error):
s = input()
ans=[]
for i in range(len(s)):
    if s[i]=='B':
        ans.pop()
    else:
        ans.append(s[i])
print(''.join(ans))
Problem p04043 (python)

Fixed submission:
a = list(map(int, input().split()))
print('YES' if list(sorted(a)) == [5,5,7] else 'NO')

Buggy submission (verdict: Runtime Error):
P = 10**9+7
fac = [1]
ifac = [1]
ff = 1
for i in range(1,200001):
  ff *= i
  ff %= p
  fac.append(ff)
  ifac.append(pow(ff, p-2, p))
def ncr(n, r, p): 
  return (fac[n] * ifac[r] % p * ifac[n-r] % p)

h,w,a,b = map(int,input().split())
s = 0
nC = b-1
kC = 0
nD = w-b-1+h-1
kD = h-1
for i in range(h-a):
  C = ncr(nC, kC, P)
  D = ncr(nD, kD, P)
  s = (s + C * D) % P
  nC += 1
  kC += 1
  kD -= 1
  nD -= 1
print(s)
Problem p04046 (python)

Fixed submission:
from math import comb
h,w,a,b = map(int,input().split())
s = 0
nC = b-1
kC = 0
nD = w-b-1+h-1
kD = h-1
p = 1000000007
fac = [1]
ff = 1
for i in range(1,200001):
  ff *= i
  ff %= p
  fac.append(ff)
def ncr(n, r, p): 
  return (fac[n] * pow(fac[r], p-2, p) % p * pow(fac[n-r], p-2, p) % p);

for i in range(h-a):
  C = ncr(nC, kC, 1000000007)
  D = ncr(nD, kD, 1000000007)
  s = (s + C * D) % 1000000007
  nC += 1
  kC += 1
  kD -= 1
  nD -= 1
print(s)

Buggy submission (verdict: Runtime Error):
P = 10**9+7
fac = [1]
ifac = [1]
ff = 1
for i in range(1,200001):
  ff *= i
  ff %= p
  fac.append(ff)
  ifac.append(pow(ff, p-2, p))
def ncr(n, r, p): 
  return (fac[n] * ifac[r] % p * ifac[n-r] % p);

h,w,a,b = map(int,input().split())
s = 0
nC = b-1
kC = 0
nD = w-b-1+h-1
kD = h-1
for i in range(h-a):
  C = ncr(nC, kC, P)
  D = ncr(nD, kD, P)
  s = (s + C * D) % P
  nC += 1
  kC += 1
  kD -= 1
  nD -= 1
print(s)
Problem p02694 (python)

Fixed submission:
import math
a=int(input())
t=100
sum=0
while(t<a):
	t=math.floor(t*101/100)
	sum=sum+1
print(sum)

Buggy submission (verdict: Runtime Error):
a=int(input())
t=100
sum=0
while(t<a):
	t=math.floor(t*101/100)
	sum=sum+1
print(sum)

Buggy submission (verdict: Runtime Error):
a=int(input())
t=100
sum=0
while(t<a):
	t=floor(t*101/100)
	sum=sum+1
print(sum)

Buggy submission (verdict: Runtime Error):
a=int(input())
t=100
sum=0
while(t<a):
	t=floor(t*101/100)
    sum=sum+1
print(sum)

Buggy submission (verdict: Runtime Error):
a=int(input())
t=100
sum=0
while(t<a):
	t=t*101/100
    sum=sum+1
print(sum)

Buggy submission (verdict: Runtime Error):
a=input()
t=100
sum=0
while(t<a):
	t=t*101/100
    sum=sum+1
print(sum)
Problem p02541 (python)

Fixed submission:
def euclid(x, y):
    c0, c1 = x, y
    a0, a1 = 1, 0
    b0, b1 = 0, 1
 
    while c1 != 0:
        m = c0 % c1
        q = c0 // c1
 
        c0, c1 = c1, m
        a0, a1 = a1, (a0 - q * a1)
        b0, b1 = b1, (b0 - q * b1)
 
    return a0, b0

n=int(input())
n*=2
soinsu=[]

num=n
for i in range(2,max(10,n)):
    if(i*i>n):
        if(num!=1):
            soinsu.append([num,1])
        break
    if(num%i!=0):
        continue
    cnt=0
    while(num%i==0):
        cnt+=1
        num//=i
    soinsu.append([i,cnt])

kazu=len(soinsu)
#print(soinsu,kazu)


ans=[]
for i in range(2**(kazu-1)):
    a=1
    for j in range(kazu):
        if((i&1<<j)!=0):
            a*=soinsu[j][0]**soinsu[j][1]
    b=n//a
    c,d=euclid(a,b)
    if(c*d==0):
        c+=b
        d+=a
    ans.append(max(a*c,b*d))
    #print(a,b,c,d)


if(kazu==1):
    print(min(ans)-2)
else:
    print(min(ans)-1)

Buggy submission (verdict: Runtime Error):
def euclid(x, y):
    c0, c1 = x, y
    a0, a1 = 1, 0
    b0, b1 = 0, 1
 
    while c1 != 0:
        m = c0 % c1
        q = c0 // c1
 
        c0, c1 = c1, m
        a0, a1 = a1, (a0 - q * a1)
        b0, b1 = b1, (b0 - q * b1)
 
    return a0, b0

n=int(input())
n*=2
soinsu=[]

num=n
for i in range(2,n):
    if(i*i>n):
        if(num!=1):
            soinsu.append([num,1])
        break
    if(num%i!=0):
        continue
    cnt=0
    while(num%i==0):
        cnt+=1
        num//=i
    soinsu.append([i,cnt])

kazu=len(soinsu)


ans=[]
for i in range(2**(kazu-1)):
    a=1
    for j in range(kazu):
        if((i&1<<j)!=0):
            a*=soinsu[j][0]**soinsu[j][1]
    b=n//a
    c,d=euclid(a,b)
    if(c*d==0):
        c+=b
        d+=a
    ans.append(max(a*c,b*d))

print(min(ans)-1)
Problem p03160 (python)

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

costs = [0] * N
costs[0] = 0
costs[1] = abs(h[1] - h[0])
for i in range(2,N):
  tmp1 = costs[i-2] + abs(h[i] - h[i-2])
  tmp2 = costs[i-1] + abs(h[i] - h[i-1])
  costs[i] = min(tmp1,tmp2)
print(costs[N-1])

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

costs = [0] * N
for i in range(1,N):
  _h = h[i]
  s = 0
  if i > K:
    s = i-K
  mn = float('inf')
  for a,b in zip(costs[s:i],h[s:i]):
    cur = a + abs(_h-b)
    if cur < mn:
      mn = cur
 
  costs[i] = mn
print(costs[-1])

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

costs = [0] * N
for i in range(1,N):
  s = max(i-K, 0)
  mn = float('inf')
  for a,b in zip(costs[s:i],h[s:i]):
    cur = a + abs(h[i]-b)
    mn = min(mn,cur)
 
  costs[i] = mn
print(costs[-1])
Problem p02582 (python)

Fixed submission:
s = input()
ans = 0
if "R" in s:
    ans = 1
if "RR" in s:
    ans = 2
if "RRR" in s:
    ans = 3
print(ans)

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

if s in "R":
    ans = 1
if s in "RR":
    ans = 2
if s in "RRR":
    ans = 3
print(ans)
Problem p02748 (python)

Fixed submission:
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
XYC = [list(map(int, input().split())) for _ in range(m)]

mn = min(A) + min(B)

for x, y, c in XYC:
    mn = min(mn, A[x - 1] + B[y - 1] - c)
print(mn)

Buggy submission (verdict: Runtime Error):
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
XYC = [list(map(int, input().split())) for _ in range(m)]

mn = min(A) + min(B)

for x, y, c in XYC:
    mn = min(mn, A[x - 1] + B[x - 1] - c)
print(mn)
Problem p02761 (python)

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

if n == 1:
    t = 0
else:
    t = 10 ** (n - 1)

for i in range(t, 10 ** n):
    j = str(i)
    f = 0
    for s, c in sc:
        if j[s - 1] != str(c):
            break
        f += 1
    if f == m:
        print(i)
        exit()
print(-1)

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

for i in range(10 ** (n - 1) - 1, 10 ** n):
    j = str(i)
    f = 0
    for s, c in sc:
        if j[s - 1] != str(c):
            break
        f += 1
    if f == m:
        print(i)
        exit()
print(-1)
Problem p02780 (python)

Fixed submission:
from itertools import accumulate
import numpy as np

n, k = map(int, input().split())
p = np.array(list(map(int, input().split())), dtype=np.int64)

p = (1 + p) / 2
p = [0] + list(accumulate(p))
ans = 0
for i in range(n - k + 1):
    ans = max(ans, p[i + k] - p[i])
print(ans)

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

n, k = map(int, input().split())
p = np.array(list(map(int, input().split())), dtype="i8")
p = np.cumsum((1 + p) / 2)
print((p[k:] - p[:n - k]).max())

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

n, k = map(int, input().split())
p = np.array(list(map(int, input().split())), dtype=np.int64)

p = (1 + p) / 2
p = [0] + list(accumulate(p))
ans = 0
for i in range(k):
    ans = max(ans, p[i + k] - p[i])
print(ans)