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

Fixed submission:
N, K = map(int, input().split())
withSnacks = []
for x in range(K):
	nUmsnakes = int(input())
	snakes = list(map(int, input().split()))
	withSnacks.extend(snakes)
withSnacks = list(set(withSnacks))
count = 0
for x in range(1, N + 1):
	if not x in withSnacks:
		count += 1
 
print(count)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
withSnacks = []
for x in range(K):
  nUmsnakes = int(input)
  snakes = list(map(int, input().split()))
  withSnacks.extend(snakes)
withSnacks = list(set(withSnacks))
count = 0
for x in range(1, x + 1):
  if not x in withSnacks:
    count += 1

print(count)
Problem p02701 (python)

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

print(len(list(set(arr))))

Buggy submission (verdict: Runtime Error):
N = int(input())
items = []
count = 0
for x in range(N):
  thing = input()
  if thing not x in items:
    count += 1
  	items.append(thing)
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
items = []
count = 0
for x in range(N):
  thing = input()
  if thing is not in items:
    count += 1
  items.append(thing)
print(count)
Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce

N, K = [int(n) for n in input().split()]
R = N - K

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    res = over // under
    return res

def calc(i):
    blue = i
    red = i - 1
    a = cmb(K - 1, blue - 1) if K >= blue else 0
    b = cmb(R + 1, red + 1) if R >= red else 0
    return a * b

M = 10**9 + 7
for i in range(1, K + 1):
    print(calc(i) % M)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

N, K = [int(n) for n in input().split()]
R = N - K

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    res = over // under
    return res

def calc(i):
    if i > N//2 + 1:
        return 0
    blue = i
    red = i - 1
    a = cmb(K - 1, blue - 1)
    b = cmb(R + 1, red + 1)
    return a * b

M = 10**9 + 7
for i in range(1, K + 1):
    print(calc(i) % M)

Buggy submission (verdict: Runtime Error):
from scipy import special

N, K = [int(n) for n in input().split()]
R = N - K

def calc(i):
    blue = i
    red = i - 1
    a = special.comb(K - 1, blue - 1, True)
    b = special.comb(R + 1, red + 1, True)
    return a * b

M = 10**9 + 7
for i in range(1, K + 1):
    print(calc(i) % M)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

N, K = [int(n) for n in input().split()]
R = N - K

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    if under == 0:
        return 0
    res = over // under
    return res

def calc(i):
    blue = i
    red = i - 1
    a = cmb(K - 1, blue - 1)
    b = cmb(R + 1, red + 1)
    return a * b

for i in range(1, K+1):
    print(calc(i) % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

N, K = [int(n) for n in input().split()]
R = N - K

def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    res = over // under
    return res

def calc(i):
    blue = i
    red = i - 1
    a = cmb(K - 1, blue - 1)
    b = cmb(R + 1, red + 1)
    return a * b

for i in range(1, K+1):
    print(calc(i) % (10**9 + 7))
Problem p02820 (python)

Fixed submission:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
check = [0]*N
ans = 0
for i in range(N):
    if i < K or T[i] != T[i-K] or not check[i-K]:
        ans += P if T[i] == 'r' else R if T[i] == 's' else S
        check[i] = 1
print(ans)

Buggy submission (verdict: Runtime Error):

def solve(N,K,R,S,P,T):
    check = [0]*N
    ans = 0
    for i in range(N):
        if i < K or T[i] != T[i-K] or not check[i-K]:
            ans += P if T[i] == 'r' else R if T[i] == 's' else S
            check[i] = 1
    print(ans)

def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()
    solve()

if __name__ == "__main__":
    main()
Problem p02897 (python)

Fixed submission:
import math
N = int(input())

print(math.ceil(N/2)/N)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
l = list(map(int, input().split()))
ans = [1 if i >= K else 0 for i in l]
print(sum(ans))

Buggy submission (verdict: Runtime Error):
import math
print(math.ceil(int(input()) // 2) / int(input()))
Problem p03011 (python)

Fixed submission:
print(sum(sorted(list(map(int, input().split())))[:2]))

Buggy submission (verdict: Runtime Error):
print(sum(sorted(input().split())[:2]))
Problem p03104 (python)

Fixed submission:
def F(N):
    if ((N+1) // 2) % 2 == 0:
        bit = 0
    else:
        bit = 1
    if N % 2 == 0:
        return bit ^ N
    else:
        return bit

A, B = map(int, input().split())
ans = F(A-1) ^ F(B)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B = map(int, input().split())
l = max(len(bin(A)[2:]), len(bin(B)[2:]))
arr = np.zeros(l)
ans = 0
for i in range(A, B+1):
    c = np.array(list(map(int, bin(i)[2:])))
    arr[l-len(c):] += c
arr = np.flip(arr % 2)
for i in range(l):
    if arr[i] != 0:
        ans += 2 ** i
print(ans)
Problem p02689 (python)

Fixed submission:
N,M= list(map(int, input().split())) 
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
ans = [1]*N

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

for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] < H[b]:
        ans[a]=0
    elif H[a] > H[b]:
        ans[b]=0
    else:
        ans[a]=0
        ans[b]=0
        
print(ans.count(1))

Buggy submission (verdict: Runtime Error):
N,M= list(map(int, input().split())) 
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M

for i in range(M):
    A[i], B[i]= map(int, input().split())
    
ans = []*N
for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] < H[b]:
        ans[a]=1
    elif H[a] > H[b]:
        ans[b]=1
    else:
        ans[a]=0
        ans[b]=0
print(ans.count(1))
Problem p02711 (python)

Fixed submission:
n= input()

if ("7" in n):
  print("Yes")
else:
  print("No")

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

if 7 in n:
  print("Yes")
else:
  print("No")
Problem p02725 (python)

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

S = [0]*(N)

for i in range(N):
      
    if i==N-1:
        S[i] = K + A[0] -A[i]
    else:
        S[i] = A[i+1] - A[i]

Smax = S.index(max(S))

ans = sum(S)-S[Smax]
print(ans)

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

S = [0]*(N+1)

for i in range(N):
    if i==N:
        S[i+1] = A[i] - K + A[0]
    else:
        S[i+1] = A[i+1] - A[i]

Smax = S.index(max(S))

ans = sum(S)-S[Smax]
print(ans)
Problem p02685 (python)

Fixed submission:
#左からn個目でendが特定の色の場合に
N,M,K = list(map(int,input().split()))

def xgcd(a, b):
  x0, y0, x1, y1 = 1, 0, 0, 1
  while b != 0:
    q, a, b = a // b, b, a % b
    x0, x1 = x1, x0 - q * x1
    y0, y1 = y1, y0 - q * y1
  return a, x0, y0
def modinv(a, m):
  g, x, y = xgcd(a, m)
  if g != 1:
    raise Exception('modular inverse does not exist')
  else:
    return x % m
def combination(n, k, mod=1e9+7) -> int:
  ret = 1
  for i in range(1, k+1):
    ret = (ret * (n-k+i) * modinv(i, mod))%mod
  return int(ret)

def pow(base, exponent, mod=1e9+7) -> int:
  if exponent == 0:
    return 1
  if exponent > 1:
    d,m = divmod(exponent, 2)
    return (base**m * pow(base, d, mod)**2 ) % mod
  else:
    return base

m = 998244353
res = 0
B = 1
if M != 1:
  mi = modinv(M-1,m)
  A = M * pow(M-1,N-1,m)
  for k in range(K+1):
    if k>0:
      B = (B*(N-k)*modinv(k,m))%m
    res = (res+ A*B)%m
    A = (A*mi)%m
  print (res)
else:
  if K == N-1:
    
    print(1)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
#左からn個目でendが特定の色の場合に
N,M,K = list(map(int,input().split()))

def xgcd(a, b):
  x0, y0, x1, y1 = 1, 0, 0, 1
  while b != 0:
    q, a, b = a // b, b, a % b
    x0, x1 = x1, x0 - q * x1
    y0, y1 = y1, y0 - q * y1
  return a, x0, y0
def modinv(a, m):
  g, x, y = xgcd(a, m)
  if g != 1:
    raise Exception('modular inverse does not exist')
  else:
    return x % m
def combination(n, k, mod=1e9+7) -> int:
  ret = 1
  for i in range(1, k+1):
    ret = (ret * (n-k+i) * modinv(i, mod))%mod
  return int(ret)

def pow(base, exponent, mod=1e9+7) -> int:
  if exponent == 0:
    return 1
  if exponent > 1:
    d,m = divmod(exponent, 2)
    return (base**m * pow(base, d, mod)**2 ) % mod
  else:
    return base

m = 998244353
res = 0
B = 1
mi = modinv(M-1,m)
A = M * pow(M-1,N-1,m)
for k in range(K+1):
  if k>0:
    B = B*(N-k)//k 
  res = (res+ A*B)%m
  A = (A*mi)%m
print (res)
Problem p02689 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N,M = list(map(int,input().split()))
H = list(map(int,input().split()))

# 展望台から行ける展望台の高さを格納しておく
from collections import defaultdict
d = defaultdict(int)
for i in range(M):
  A,B = list(map(int,input().split()))
  A -= 1
  B -= 1
  if d[A] < H[B]:
    d[A] = H[B]
  if d[B] < H[A]:
    d[B] = H[A]
cnt = 0
for idx,h in enumerate(H):
  if d[idx] == 0 or h > d[idx]:
    cnt += 1
else:
  print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M = list(map(int,input().split()))
H = list(map(int,input().split()))

# 展望台から行ける展望台の高さを格納しておく
from collections import defaultdict
d = defaultdict(int)
for i in range(M):
  A,B = list(map(int,input().split()))
  A -= 1
  B -= 1
  if d[A] < H[B]:
    d[A] = H[B]:
  if d[B] < H[A]:
    d[B] = H[A]
cnt = 0
for idx,h in enumerate(H):
  if d[idx] == 0 or h < d[idx]:
    cnt += 1
else:
  print(cnt)
Problem p02736 (python)

Fixed submission:
N = int(input())
S = input()
a = [int(s)-1 for s in S]


from collections import defaultdict

r = 1
d = defaultdict(int)
while 2**r  <= N:
  for i in range(1,N):
    if i*(2**r) <= N:
      d[i*(2**r)] += 1
    else:
      break
  r+=1

def calc(list_of_int):
  # 1と0で構成されているとする
  length = len(list_of_int)
  res = list_of_int[0]
  
  keisu = 0
  for i,r in zip(list_of_int[1:], range(N-1)):
    keisu += d[N-r-1]-d[r+1]
    res = (res + ((2 if keisu>0 else 1)*i) )% 2
  return res

if 1 in a:
  print(calc(a))
else:
  print(calc(list(map(lambda x:x//2,a)))*2)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
a = [int(S[i]) for i in range(N)]

from collections import Counter

b = [abs(a[i+1]-a[i]) for i in range(N-1)]
c = Counter(b)
if c[1] == 0 and c[2]==1 and (b[0] ==2 or b[-1] ==2):
  print(2)
elif c[1] == 0 and c[0]==1 and (b[0] ==0 or a[-1] ==0):
  print(2)
else:
  if N == 2:
    print(abs(a[0]-a[1]))
  else:
    a = [abs(a[i+1]-a[i]) for i in range(N-1)]
    cd = Counter(a[1:-1])
    cde = Counter(a[0:1] + a[-1:])
    if ((cd[1] * 2) + cde[1])%2 ==1:
      print(1)
    else:
      print(0)
print(cde)
Problem p02773 (python)

Fixed submission:
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  d[input()] += 1

max_cnt = max(d.values())
for v in sorted([key for key,value in d.items() if value == max_cnt]):
  print(v)

Buggy submission (verdict: Runtime Error):
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  d[input()] += 1

max_cnt = max(d.value())
for v in sorted([key for key,value in d.items() if value == max_cnt]):
  print(v)
Problem p02891 (python)

Fixed submission:
string = input()
K = int(input())
from collections import defaultdict
if len(set(string)) ==1:
    print(K*len(string)//2)
else:
    if(string[0]==string[-1]):
        ## 両端が同じ文字なら…
        start = string[0]
        startFlag = True
        cnt = defaultdict(int)
        length = 0
        
        for char in string:
            #print(char,start,length)
            if char == start:
                length +=1
                
            else:
                if startFlag:
                    startlen = length
                    startFlag = False
                cnt[length] +=1
                start = char
                length = 1
        else:
            ## 両端をカウントしない
            cnt[startlen] -= 1
            cnt[startlen +length] += 1
        print(sum([(key//2)*value*K for key,value in cnt.items()])-(startlen+length)//2+startlen//2+length//2)
    else:
        ## 両端が同じ文字なら…
        start = string[0]
        cnt = defaultdict(int)
        length = 0
        for char in string:
            #print(char,start,length)
            if char == start:
                length +=1
                
            else:
                cnt[length] +=1
                start = char
                length = 1
        else:
            ## 両端をカウントしない
            cnt[length] += 1
        print(sum([(key//2)*value*K for key,value in cnt.items()]))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
if len(set(string)) ==1:
    print(K*len(string)//2)
else:
    if(string[0]==string[-1]):
        ## 両端が同じ文字なら…
        start = string[0]
        startFlag = True
        cnt = defaultdict(int)
        length = 0
        
        for char in string:
            #print(char,start,length)
            if char == start:
                length +=1
                
            else:
                if startFlag:
                    startlen = length
                    startFlag = False
                cnt[length] +=1
                start = char
                length = 1
        else:
            ## 両端をカウントしない
            cnt[startlen] -= 1
            cnt[startlen +length] += 1
        print(sum([(key//2)*value*K for key,value in cnt.items()])-(startlen+length)//2+startlen//2+length//2)
    else:
        ## 両端が同じ文字なら…
        start = string[0]
        cnt = defaultdict(int)
        length = 0
        for char in string:
            #print(char,start,length)
            if char == start:
                length +=1
                
            else:
                cnt[length] +=1
                start = char
                length = 1
        else:
            ## 両端をカウントしない
            cnt[length] += 1
        print(sum([(key//2)*value*K for key,value in cnt.items()]))
Problem p02984 (python)

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

# A[0]は0と1の間に振ったものなので、
a = 0
for i in range(N//2):
  a +=  A[2*i] - A[2*i+1]

a0 = (a + A[-1]) //2

for i in A:
  print(a0*2,end=" ")
  a0 = i - a0

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

import numpy as np
from numpy.linalg import solve
N = int(input())
A = np.array(list(map(int,input().split())))


x = np.roll(np.eye(N),1)
x[0,0]=0
x[N-1,0]=1
x += np.eye(N)
x /= 2


Q, R = linalg.qr(x)
t = np.dot(Q.T, A)
x = linalg.solve(R, t)

print(" ".join( list(map(str,list(map(int,x).tolist())))))

Buggy submission (verdict: Runtime Error):
import numpy as np
from numpy.linalg import solve
N = int(input())
A = np.array(list(map(int,input().split())))


x = np.roll(np.eye(N),1)
x[0,0]=0
x[N-1,0]=1
x += np.eye(N)
x /= 2


print(" ".join( list(map(str,list(map(int,solve(x,A).tolist()))))))

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


N = int(input())
A = np.array(list(map(int,input().split())))


x = np.roll(np.eye(N),1)
x[0,0]=0
x[N-1,0]=1
x += np.eye(N)
x /= 2

print(" ".join( list(map(str,list(map(int,np.dot(np.linalg.inv(x),A).tolist()))))))
Problem p03017 (python)

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

if "##" in s[A-1:max(C,D)]:
  print("No")
  quit()
st,e=0,0

for spl in s.split("##"):
  e += (len(spl)+2)
  if st <A<max(C,D)<=e:
    break
  st+= (len(spl)+2)

if "..." in s[B-2:min(C,D)+1] or B<C<D:
  print("Yes")
else:
  print("No")

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

if "##" in s[A-1:C]+" "+s[B-1:D]:
  print("NO")
  quit()
st,e=0,0
for spl in s.split("##"):
  e += len(spl)
  if st <A<max(C,D)<end:
    break
  st+= len(spl)

if "..." in s[st:e]:
  print("YES")
elif D<C:
  print("NO")
else:
  print("YES")
Problem p03018 (python)

Fixed submission:
s=input()
s=s.replace("BC","D").replace("B","C")
l=[i for i in s.split("C") if len(i) !=0]
cnt=0

for line in l:
  dcnt =0 
  for ch in reversed(line):
    if ch == "D":
      dcnt+=1
    else:
      cnt+=dcnt

print(cnt)

Buggy submission (verdict: Runtime Error):
s=input()
s.replace("BC","D").replace("B","C")
l=[i for i in split("C") if len(i) !=0]
cnt=0
for line in l:
  dcnt =0 
  for ch in reversed(line):
    if ch = "D":
      dcnt+=1
    else:
      cnt+=dcnt

print(cnt)
Problem p03038 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N,M =  list(map(int,input().split()))
A = sorted(list(map(int,input().split())))
q = [tuple(map(int,input().split())) for i in range(M)]
q.sort(key= lambda x:-x[1])
#print(q)  

mask = []
for num,cost in q:
  mask += [cost]*num
  
  if len(mask) >=N:
    break
  if A[len(mask)-1] >= cost:
    break
    
res = 0
for idx,cost in enumerate(mask):
  if idx >= N:
    break
  if cost > A[idx]:
    res += cost
  else:
    break
else:
  idx+=1
    
for i in range(idx,len(A)):
  #print(i)
  res += A[i]
  
print(res)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M =  list(map(int,input().split()))
A = sorted(list(map(int,input().split())))
q = [tuple(map(int,input().split())) for i in range(M)]
q.sort(key= lambda x:-x[1])
#print(q)  

mask = []
for num,cost in q:
  mask += [cost]*num
  if A[len(mask)-1] >= cost:
    break
    
res = 0
for idx,cost in enumerate(mask):
  if cost > A[idx]:
    res += cost
  else:
    break
else:
  idx+=1
    
for i in range(idx,len(A)):
  #print(i)
  res += A[i]
  
print(res)
Problem p03104 (python)

Fixed submission:
import math
A,B = list(map(int,input().split()))
s =""
if B == 0:
    print(0)
else:
    for i in range(int(math.log2(B))+1):
        if i == 0:
            a =0
            for j in range(A,4*(divmod(A,4)[0]+1)):
                #print(divmod(j,2)[1])
                a += divmod(j,2)[1]
            for j in range(4*(divmod(B,4)[0]),B+1):
                #print(divmod(j,2)[1])
                a += divmod(j,2)[1]
            s = str(divmod(a,2)[1])
        else:
            # int(divmod(16/16 ,2)[1])
            s = str(divmod((2**i-divmod(A,2**i)[1]) * int(divmod(A/2**i ,2)[1])+(divmod(B,2**i)[1]+1) * int(divmod(B/2**i ,2)[1]),2)[1]) + s
    print(int(s,2))

Buggy submission (verdict: Runtime Error):
import math
A,B = list(map(int,input().split()))
s =""
for i in range(int(math.log2(B))+1):
    if i == 0:
        a =0
        for j in range(A,4*(divmod(A,4)[0]+1)):
            #print(divmod(j,2)[1])
            a += divmod(j,2)[1]
        for j in range(4*(divmod(B,4)[0]),B+1):
            #print(divmod(j,2)[1])
            a += divmod(j,2)[1]
        s = str(divmod(a,2)[1])
    else:
        # int(divmod(16/16 ,2)[1])
        s = str(divmod((2**i-divmod(A,2**i)[1]) * int(divmod(A/2**i ,2)[1])+(divmod(B,2**i)[1]+1) * int(divmod(B/2**i ,2)[1]),2)[1]) + s
print(int(s,2))

Buggy submission (verdict: Runtime Error):
import math
A,B = list(map(int,input().split()))
s =""
for i in range(int(math.log2(B))+1):
    if i == 0:
        a =0
        for j in range(A,4*(divmod(A,4)[0]+1)):
            #print(divmod(j,2)[1])
            a += divmod(j,2)[1]
        for j in range(4*(divmod(B,4)[0]),B+1):
            #print(divmod(j,2)[1])
            a += divmod(j,2)[1]
        s = str(divmod(a,2)[1])
    else:
        # int(divmod(16/16 ,2)[1])
        s = str(divmod((2**i-divmod(A,2**i)[1]) * int(divmod(A/2**i ,2)[1])+(divmod(B,2**i)[1]+1) * int(divmod(B/2**i ,2)[1]),2)[1]) + s
print(int(s,2))

Buggy submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))
s =""
for i in range(int(math.log2(B))+1):
    if i == 0:
        a =0
        for j in range(A,4*(divmod(A,4)[0]+1)):
            #print(divmod(j,2)[1])
            a += divmod(j,2)[1]
        for j in range(4*(divmod(B,4)[0]),B+1):
            #print(divmod(j,2)[1])
            a += divmod(j,2)[1]
        s = str(divmod(a,2)[1])
    else:
        # int(divmod(16/16 ,2)[1])
        s = str(divmod((2**i-divmod(A,2**i)[1]) * int(divmod(A/2**i ,2)[1])+(divmod(B,2**i)[1]+1) * int(divmod(B/2**i ,2)[1]),2)[1]) + s
print(int(s,2))
Problem p03127 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
a = A[0]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

for i in A:
    a = gcd(a,i)
print(a)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int,input().split()))
a = A[0]
for i in A:
    a = math.gcd(a,i)
print(a)
Problem p03775 (python)

Fixed submission:
n=int(input())
import math
for i in range (int(math.sqrt(n)),0,-1):
  if n%i==0:
    print(max(len(str(i)),len(str(n//i))))
    quit()

Buggy submission (verdict: Runtime Error):
n=int(input())
import math
for i in range (math.sqrt(n),0,-1):
  if n%i==0:
    print(max(len(str(i)),len(str(n//i))))
    quit()
Problem p02661 (python)

Fixed submission:
n = int(input())
a = [0 for _ in range(n)]
b = a[:]
for i in range(n):
    a[i],b[i] = map(int,input().split())
a.sort()
b.sort()

ans = 0
if n % 2 == 0:
    l = a[n//2-1] + a[n//2]
    h = b[n//2-1] + b[n//2]

    ans += h - l + 1
else:
    l = a[n//2]
    h = b[n//2]

    ans += h - l + 1



print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [0 for _ in range(n)]
b = a[:]
for i in range(n):
    a[i],b[i] = map(int,input().split())
a.sort()
b.aort()

ans = 0
if n % 2 == 0:
    l = a[n//2-1] + a[n//2]
    h = b[n//2-1] + b[n//2]

    ans += h - l + 1
else:
    l = a[n//2]
    h = b[n//2]

    ans += h - l + 1



print(ans)
Problem p02793 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

'''def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)'''


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
ans=0
m=int(10**9+7)
g=1
l=1
'''
for x in a:
  if l%x!=0:
    g=gcd(l,x)
    l=l*x//g
'''
l=lcm(*a)

for x in a:
  ans+=l//x

print(ans%m)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline


n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
ans=0
m=int(10**9+7)
g=1
l=1
y=0

for x in a:
  if y!=x and l%x!=0:
    g=gcd(l,x)
  y=x

l=lcm(*a)

for x in a:
  ans+=(l//x)%m

print(ans%m)
Problem p02833 (python)

Fixed submission:
n=int(input())
if n%2==1 or n==0 or n==1:
  print(0)
else:
  l=n//2
  k=0
  while l>=5:
    l/=5
    k+=1
  c=0
  for i in range(1,k+1):
    c+=n//(2*5**i)
  print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==1:
  print(0)
else:
  l=n//2
  k=0
  while l>=5:
    l/=5
    k+=1
  #print(k)
  c=0
  for i in range(1,k+1):
    c+=n//(2*5**i)
  print(c
Problem p02881 (python)

Fixed submission:
n=int(input())
a=[]
ans=1e12
l=int(n**0.5)+2
for i in range(1,l):
  if n%i==0 and i not in a:
    a.append(i)
    a.append(n//i)
    ans=min(ans,(i+n//i-2))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=()
ans=1e12
l=int(n**0.5)+2
for i in range(1,l):
  if i in a:
    continue
  elif n%i==0:
    a.append(i)
    a.append(n//i)
    ans=min(ans,(i+n//i-2))
print(ans)
Problem p02912 (python)

Fixed submission:
import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(m):
  x=heapq.heappop(a)
  x=((x*(-1))//2)*(-1)
  heapq.heappush(a,x)










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

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=0
for i in range(m+1):
  a.sort(reverse=1)
  print(a)
  x=a[0]//2
  a[0]=x
print(sum(a))