Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

ans = []
x,y,h = MAP()
for i in range(101):
    for j in range(101):
        ans.append((i,j,h+abs(i-x)+abs(j-y)))

for i in range(n-1):
    tmp = []
    x,y,h = MAP()
    for j in range(101):
        for k in range(101):
            if (j,k,h+abs(j-x)+abs(k-y)) in ans:
                tmp.append((j,k,h+abs(j-x)+abs(k-y)))
    ans = tmp

print(*ans[0])

Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = MAP()
    x.append(xx)
    y.append(yy)
    h.append(hh)

kk = h.index(max(h))
k = 0

for i in range(101):
    for j in range(101):
        ass = h[kk] + abs(x[kk]-i) + abs(y[kk]-j)
        for r in range(n):
            if h[r]==0:
                if ass-abs(x[r]-i)-abs(y[r]-j)>0:
                    ass = -1
                    break
            else:
                if ass != abs(x[r]-i)+abs(y[r]-j)+h[r]:
                    ass = -1
                    break
        if ass!=-1:
            print(i,j,ass)
            break

Buggy python submission (verdict: Runtime Error):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

ans = []
x,y,h = MAP()
for i in range(101):
    for j in range(101):
        ans.append((i,j,h+abs(i-x)+abs(j-y)))

for i in range(n-1):
    tmp = []
    x,y,h = MAP()
    for j in range(101):
        for k in range(101):
            if (j,k,h+abs(j-x)+abs(k-y)) in ans:
                tmp.append((j,k,h+abs(j-x)+abs(k-y)))
    ans = tmp

print(*ans[0])

Fixed submission:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = MAP()
    x.append(xx)
    y.append(yy)
    h.append(hh)

kk = h.index(max(h))
k = 0

for i in range(101):
    for j in range(101):
        ass = h[kk] + abs(x[kk]-i) + abs(y[kk]-j)
        for r in range(n):
            if h[r]==0:
                if ass-abs(x[r]-i)-abs(y[r]-j)>0:
                    ass = -1
                    break
            else:
                if ass != abs(x[r]-i)+abs(y[r]-j)+h[r]:
                    ass = -1
                    break
        if ass!=-1:
            print(i,j,ass)
            break
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
k = int(input())

substring = []
for i in range(len(s)):
    for j in range(i,len(s)):
        if not("".join(s[i:j+1]) in substring):
            substring.append("".join(s[i:j+1]))

substring.sort()
print(substring[k-1])

Fixed submission:
s = list(input())
k = int(input())

substring = []
for i in range(len(s)):
    for j in range(i,min(len(s),i+k)):
        if not("".join(s[i:j+1]) in substring):
            substring.append("".join(s[i:j+1]))

substring.sort()
print(substring[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

total = 0
for i in range(N-1):
  sum_val = sum(A[i+1:N])
  total += A[i]*sum_val
  total %= (10**9+7)
print(total)

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

total = 0
sum_val = sum(A[1:N])
for i in range(N-1):
  total += A[i]*sum_val
  total %= (10**9+7)
  sum_val -= A[i+1]
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(1,2**N):
  bin_line = str(bin(i))
  bin_line = bin_line.replace('0b', '')

  line = []
  if bin_line.count('1') == 3:
    for j in range(len(bin_line)):
      if bin_line[j] == '1':
        line.append(L[N-len(bin_line)+j])
    if len(set(line)) == 3:
      if line[0]+line[1] > line[2] and line[0]+line[2] > line[1] and line[1]+line[2]>line[0]:
        ans += 1
print(ans)

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

ans = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(1,2**N):
  bin_line = str(bin(i))
  bin_line = bin_line.replace('0b', '')

  count = 0
  line = []
  for j in range(len(bin_line)):
    if bin_line[j] == '1':
      count += 1
      line.append(L[N-len(bin_line)+j])
      if count > 4:
        break
  if count == 3 and len(set(line)) == 3:
    if line[0]+line[1] > line[2] and line[0]+line[2] > line[1] and line[1]+line[2]>line[0]:
      ans += 1
print(ans)
    
                 

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

ans = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(1,2**N):
  bin_line = str(bin(i))
  bin_line = bin_line.replace('0b', '')
  if len(bin_line) < N:
    zero = '0'*(N-len(bin_line))
    bin_line = zero + bin_line
  count = 0
  line = []
  for j in range(N):
    if bin_line[j] == '1':
      count += 1
      line.append(L[j])
  if count == 3 and len(set(line)) == 3:
    if line[0]+line[1] > line[2] and line[0]+line[2] > line[1] and line[1]+line[2]>line[0]:
      ans += 1
print(ans)
    
                 

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

ans = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i]:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def find_name(tmp_N, p, keta, alpha):
  if keta == 1:
    for i in range(len(alpha)):
      #print(tmp_N + (i+1))
      if tmp_N + (i+1) == N:
        p.append(i)
        return p
  else:
    for i in range(len(alpha)):
      #print(tmp_N + 26**(keta-1)*i+1, tmp_N + 26**(keta-1)*(i+1))
      if tmp_N + 26**(keta-1)*i+1 <= N <= tmp_N + 26**(keta-1)*(i+1):
        #print(tmp_N + 26**(keta-1)*i+1, tmp_N + 26**(keta-1)*(i+1))
        p.append(i)
        tmp_N = tmp_N + 26**(keta-1)*i
        keta -= 1
        return find_name(tmp_N, p, keta, alpha)
    
# 桁数の確認
keta = 1
while 1:
  tmp_N = 26**(keta-1)
  if tmp_N + 26**(keta-1)+1 <= N <= tmp_N + 26**keta:
    break
  else:
    keta += 1
#print(keta)

tmp_N = 0
if keta == 1:
  tmp_N = 0
else:
  tmp_N = 26**(keta-1)
#print(tmp_N)
p = []
p = find_name(tmp_N, p, keta, alpha)
out = ''
#print(p)
for i in range(len(p)):
  out += alpha[p[i]]
print(out)



Fixed submission:
N = int(input())
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def find_name(tmp_N, p, keta, alpha):
  if keta == 1:
    for i in range(len(alpha)):
      #print(tmp_N + (i+1))
      if tmp_N + (i+1) == N:
        p.append(i)
        return p
  else:
    for i in range(len(alpha)):
      if tmp_N + 26**(keta-1)*i+1 <= N <= tmp_N + 26**(keta-1)*(i+1):
        p.append(i)
        tmp_N = tmp_N + 26**(keta-1)*i
        keta -= 1
        return find_name(tmp_N, p, keta, alpha)
    
# 桁数の確認
keta = 1
tmp_N = 0
while 1:
  if tmp_N + 1 <= N <= tmp_N + 26**keta:
    break
  else:
    keta += 1
    tmp_N += 26**(keta-1)
#print(keta)

p = []
p = find_name(tmp_N, p, keta, alpha)
out = ''
#print(p)
for i in range(len(p)):
  out += alpha[p[i]]
print(out)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

A.sort()
total = 1
flag = 9
for i in range(N-1,-1,-1):
  total *= A[i]
  if total > 10**18:
    flag = 0
    break
  elif min(A) == 0:
    flag = 1
    break
  
if flag == 0:
  print(-1)
elif flag == 1:
  print(0)
else:
  print(total)
    

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

A.sort()
B = list(set(A))

total = 1
flag = 9
for i in range(len(B)):
  total *= B[i]**A.count(B[i])
  if total > 10**18:
    flag = 0
    break
  elif min(A) == 0:
    flag = 1
    break
  
if flag == 0:
  print(-1)
elif flag == 1:
  print(0)
else:
  print(total)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

total = 1
flag = 9
for i in range(N):
  total *= A[i]
  if total > 10**18:
    flag = 0
    break
  elif min(A) == 0:
    flag = 1
    break
if flag == 0:
  print(-1)
elif flag == 1:
  print(0)
else:
  print(total)
    

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

A.sort()
B = list(set(A))

total = 1
flag = 9
for i in range(len(B)):
  total *= B[i]**A.count(B[i])
  if total > 10**18:
    flag = 0
    break
  elif min(A) == 0:
    flag = 1
    break
  
if flag == 0:
  print(-1)
elif flag == 1:
  print(0)
else:
  print(total)
Buggy python submission (verdict: Runtime Error):
import math
R = int(intput())

print(2*math.pi*R)

Fixed submission:
import math

R = (int)(input())
print(2*math.pi*R)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

flag = 1
for i in range(N-1):
  for j in range(i+1,N):
    if A[i] == A[j]:
      flag = 0
      break
  if flag == 0:
    break
if flag == 1:	print('YES')
else:			print('NO')

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

flag = 1
for i in range(N-1):
  if A[i] == A[i+1]:
    flag = 0
    break

if flag == 1:	print('YES')
else:			print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

max_val = 0
max_idx = 0
tmp = 0
for i in range(1,N-K+2):
  if i == 1:
    tmp = sum(p[i-1:i-1+K])
  else:
    tmp = tmp - p[i-2] + p[i-2+K]
  if tmp > max_val:
    max_val = tmp
    max_idx = i

expect = 0.0
for i in range(max_idx, max_idx+K):
  tmp = 0.0
  for j in range(1,p[i-1]+1):
    tmp += j
  expect += tmp/p[i-1]
print(expect)

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

max_val = 0
max_idx = 0
tmp = 0
for i in range(1,N-K+2):
  if i == 1:
    tmp = sum(p[i-1:i-1+K])
  else:
    tmp = tmp - p[i-2] + p[i-2+K]
  if tmp > max_val:
    max_val = tmp
    max_idx = i

p = p[max_idx-1:max_idx-1+K]
p.sort()
prev_tmp = 0.0
expect = 0.0
for i in range(len(p)):
  tmp = 0.0
  if i == 0:
    for j in range(1,p[i]+1):
      tmp += j
    expect += tmp/p[i]
    prev_tmp = tmp
  else:
    tmp = prev_tmp
    for j in range(p[i-1]+1,p[i]+1):
      tmp += j
    expect += tmp/p[i]
    prev_tmp = tmp
print(expect)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

max_val = 0
max_idx = 0
for i in range(1,N-K+2):
  tmp = sum(p[i-1:i-1+K])
  if tmp > max_val:
    max_val = tmp
    max_idx = i

expect = 0.0
for i in range(max_idx, max_idx+K):
  tmp = 0.0
  for j in range(1,p[i-1]+1):
    tmp += j
  expect += tmp/p[i-1]
print(expect)

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

max_val = 0
max_idx = 0
tmp = 0
for i in range(1,N-K+2):
  if i == 1:
    tmp = sum(p[i-1:i-1+K])
  else:
    tmp = tmp - p[i-2] + p[i-2+K]
  if tmp > max_val:
    max_val = tmp
    max_idx = i

p = p[max_idx-1:max_idx-1+K]
p.sort()
prev_tmp = 0.0
expect = 0.0
for i in range(len(p)):
  tmp = 0.0
  if i == 0:
    for j in range(1,p[i]+1):
      tmp += j
    expect += tmp/p[i]
    prev_tmp = tmp
  else:
    tmp = prev_tmp
    for j in range(p[i-1]+1,p[i]+1):
      tmp += j
    expect += tmp/p[i]
    prev_tmp = tmp
print(expect)
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))

count = 1
if P[1] <= P[0]:
  count+=1
for i in range(2,N):
  if P[i] <= min(P[:i-1]):
    count+=1
print(count)


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

count = 1
if N == 1:
  print(count)
else:
  min = P[0]
  if P[1] <= P[0]:
    count+=1
    min = P[1]

  for i in range(2,N):
    if P[i] <= min:
      count+=1
      min = P[i]
  print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

count = 0
for i in range(N):
  flag = 1
  for j in range(i+1):
    if P[i] > P[j]:
      flag = 0
      break
  if flag == 1:
    count+=1

print(count)


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

count = 1
if N == 1:
  print(count)
else:
  min = P[0]
  if P[1] <= P[0]:
    count+=1
    min = P[1]

  for i in range(2,N):
    if P[i] <= min:
      count+=1
      min = P[i]
  print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

i, j = 0, 1
count = 0
while 1:
  while S[i] == S[j]:
    j += 1
    if j == N:	break
  if j == N:
    count += 1
    break
  elif S[i] != S[j] and j == N-1:
    count += 2
    break
  else:
    count += 1
    i = j
    j += 1
    if j == N:
      count += 1
      break
print(count)

Fixed submission:
N = int(input())
S = input()

i, j = 0, 1
count = 0
if N == 1:
  print(1)
else:
  while j < N:
    if j < N-1:
      if S[i] == S[j]:
        j += 1
      elif S[i] != S[j]:
        count += 1
        i = j
        j += 1
    elif j == N-1:
      if S[i] == S[j]:
        count += 1
      elif S[i] != S[j]:
        count += 2
      break
  print(count)

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

i, j = 0, 1
count = 0
while 1:
  while S[i] == S[j]:
    j += 1
    if j == N:	break
  if j == N:
    count += 1
    break
  elif S[i] != S[j] and j == N-1:
    count += 2
    break
  else:
    count += 1
    i = j
    j += 1
    if j == N:
      break
print(count)

Fixed submission:
N = int(input())
S = input()

i, j = 0, 1
count = 0
if N == 1:
  print(1)
else:
  while j < N:
    if j < N-1:
      if S[i] == S[j]:
        j += 1
      elif S[i] != S[j]:
        count += 1
        i = j
        j += 1
    elif j == N-1:
      if S[i] == S[j]:
        count += 1
      elif S[i] != S[j]:
        count += 2
      break
  print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N,K,Q = map(int, input().split())
A = []
for i in range(Q):
  tmp = int(input())
  A.append(tmp)

count_A = np.zeros(N)
for i in range(Q):
  count_A[A[i]-1] += 1

point_all = [K]*N
for i in range(N):
  if point_all[i]-(sum(count_A)-count_A[i]) <= 0:
    print('No')
  else:
    print('Yes')
  
               

Fixed submission:
import numpy as np

N,K,Q = map(int, input().split())
A = []
for i in range(Q):
  tmp = int(input())
  A.append(tmp)

count_A = np.zeros(N)
for i in range(Q):
  count_A[A[i]-1] += 1

for i in range(N):
  if K-(Q-count_A[i]) <= 0:
    print('No')
  else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
total = 0
for i in range(1,N+1):
  total += i-1
print(total)

Fixed submission:
N = int(input())
if N == 1:
    print(0)
elif N == 2:
    print(1)
else:
    print((N * (N-1)) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

S = input()
N = len(S)
ans = np.zeros(N, dtype=np.int)

for i in range(0,N-1):
  j = 0
  while S[i+j] == 'R':
    j += 1
  if j != 0:
    if j % 2 == 0:
      ans[i+j] += 1
    else:
      ans[i+j-1] += 1

for i in range(N-1, 0, -1):
  j = 0
  while S[i-j] == 'L':
    j += 1
  if j != 0:
    if j % 2 == 0:
      ans[i-j] += 1
    else:
      ans[i-j+1] += 1
print(*ans)

Fixed submission:
import numpy as np

S = input()
N = len(S)
ans = np.zeros(N, dtype=np.int)

j = 0
for i in range(0,N-1):
  if j != 0:
    j -= 1
  if j == 0:
    while S[i+j] == 'R':
      j += 1
  if j != 0:
    if j % 2 == 0:
      ans[i+j] += 1
    else:
      ans[i+j-1] += 1

j = 0
for i in range(N-1, 0, -1):
  if j != 0:
    j -= 1
  if j == 0:
    while S[i-j] == 'L':
      j += 1
  if j != 0:
    if j % 2 == 0:
      ans[i-j] += 1
    else:
      ans[i-j+1] += 1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = []
for i in range(N):
  tmp = int(input())
  A.append(tmp)

B = copy.copy(A)
B.sort()

for i in range(N):
  if A[i] == max(B):
    print(B[N-2])
  else:
    print(B[N-1])

Fixed submission:
import copy
N = int(input())
A = []
for i in range(N):
  tmp = int(input())
  A.append(tmp)

B = copy.copy(A)
B.sort()

max_val = max(B)
for i in range(N):
  if A[i] == max_val:
    print(B[N-2])
  else:
    print(B[N-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,X = map(int, input().split())
L = list(map(int, input().split()))

dist = np.zeros(N+1, dtype=int)
for i in range(N):
  dist[i+1] = dist[i] + L[i]

i = 0
count = 0
while dist[i] <= X:
  count += 1
  i += 1
print(count)
"""
dist = 0
count = 1
for i in range(N):
  if dist + L[i] <= X:
    count += 1
    dist += L[i]
print(count)
"""

Fixed submission:
import numpy as np
N,X = map(int, input().split())
L = list(map(int, input().split()))

dist = np.zeros(N+1, dtype=int)
for i in range(N):
  dist[i+1] = dist[i] + L[i]

i = 0
count = 0
while dist[i] <= X:
  count += 1
  i += 1
  if i == N +1:
    break
print(count)
"""
dist = 0
count = 1
for i in range(N):
  if dist + L[i] <= X:
    count += 1
    dist += L[i]
print(count)
"""
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for i in range(M):
  tmp = list(map(int, input().split()))
  BC.append(tmp)

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

j = 0
for i in range(M):
  count = 0
  while A[j] < BC[i][1]:
    A[j] = BC[i][1]			# 値を置き換える
    j += 1
    count += 1
    if count == BC[i][0] or j == N:
      break
print(sum(A))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for i in range(M):
  tmp = list(map(int, input().split()))
  BC.append(tmp)

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

j = 0
for i in range(M):
  count = 0
  while A[j] < BC[i][1]:
    A[j] = BC[i][1]			# 値を置き換える
    j += 1
    count += 1
    if count == BC[i][0] or j == N:
      break
  if j == N:
    break
print(sum(A))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for i in range(M):
  tmp = list(map(int, input().split()))
  BC.append(tmp)

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

j = 0
for i in range(M):
  count = 0
  while A[j] < BC[i][1]:
    A[j] = BC[i][1]			# 値を置き換える
    j += 1
    count += 1
    if count == BC[i][0]:
      break
print(sum(A))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for i in range(M):
  tmp = list(map(int, input().split()))
  BC.append(tmp)

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

j = 0
for i in range(M):
  count = 0
  while A[j] < BC[i][1]:
    A[j] = BC[i][1]			# 値を置き換える
    j += 1
    count += 1
    if count == BC[i][0] or j == N:
      break
  if j == N:
    break
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
h = []
for i in range(N):
  tmp = int(input())
  h.append(tmp)
h.sort()

ans = h[N-1]
for i in range(0, N-K+1):
  tmp = max(h[i:i+K]) - min(h[i:i+K])
  ans = min(ans, tmp)
print(ans)

Fixed submission:
N,K = map(int, input().split())
h = []
for i in range(N):
  tmp = int(input())
  h.append(tmp)
h.sort()

ans = h[N-1]
for i in range(0, N-K+1):
  tmp = h[i+K-1] - h[i]
  ans = min(ans, tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

flag = 1
if S[0] == 'A':
  c_count = 0
  for i in range(1,len(S)):
    if 2 <= i <= len(S)-2:
      if S[i] == 'C':
        c_count += 1
    else:
      if S[i].islower() == False:
        flag = 0
else:
  flag = 0
if c_count == 1 and flag == 1:
  print('AC')
else:
  print('WA')

Fixed submission:
S = input()

flag = 1
c_count = 0
if S[0] == 'A':
  for i in range(1,len(S)):
    if 2 <= i <= len(S)-2:
      if S[i] == 'C':
        c_count += 1
    else:
      if S[i].islower() == False:
        flag = 0
else:
  flag = 0
if c_count == 1 and flag == 1:
  print('AC')
else:
  print('WA')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

# ユークリッドの互除法により最大公約数を求める
ans = 0
val1, val2 = a[0], a[1]
while 1:
  if val1 % val2 == 0:
    ans = a[0]*a[1]/val2
    break
  else:
    tmp = val2
    val2 = val1 % val2
    val1 = tmp

for i in range(2, N):
  val1, val2 = ans, a[i]
  while 1:
    if val1 % val2 == 0:
      ans = ans*a[i]/val2
      break
    else:
      tmp = val2
      val2 = val1 % val2
      val1 = tmp

f_ans = 0
for i in range(N):
  f_ans += (ans-1)%a[i]
print(int(f_ans))
  
      
  

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

# ユークリッドの互除法により最大公約数を求める
ans = 0
val1, val2 = a[0], a[1]
while 1:
  if val1 % val2 == 0:
    ans = a[0]*a[1]//val2
    break
  else:
    tmp = val2
    val2 = val1 % val2
    val1 = tmp

for i in range(2, N):
  val1, val2 = ans, a[i]
  while 1:
    if val1 % val2 == 0:
      ans *= a[i]//val2
      break
    else:
      tmp = val2
      val2 = val1 % val2
      val1 = tmp

f_ans = 0
for i in range(N):
  f_ans += (ans-1)%a[i]
print(int(f_ans))

Buggy python submission (verdict: Runtime Error):

コンテスト時間: 2018-07-21(土) 21:00 ~ 2018-07-21(土) 22:40 (100分)AtCoderホームへ戻る
 トップ
 問題
 質問
 提出
 提出結果
 順位表
 バーチャル順位表
 コードテスト
 解説
コードテスト
言語

ソースコード
)
1
N = int(input())
2
a = list(map(int, input().split()))
3
a.sort(reverse=True)
4
​
5
# ユークリッドの互除法により最大公約数を求める
6
ans = 0
7
val1, val2 = a[0], a[1]
8
while 1:
9
  if val1 % val2 == 0:
10
    ans = a[0]*a[1]/val2
11
    break
12
  else:
13
    tmp = val2
14
    val2 = val1 % val2
15
    val1 = tmp
16
​
17
for i in range(2, N):
18
  val1, val2 = ans, a[i]
19
  while 1:
20
    if val1 % val2 == 0:
21
      ans = ans*a[i]/val2
22
      break
23
    else:
24
      tmp = val2
25
      val2 = val1 % val2
26
      val1 = tmp
27
​
28
f_ans = 0
29
for i in range(N):
30
  f_ans += (ans-1)%a[i]
31
print(int(f_ans))
32
  
33
      
34
  
※ 512 KiB まで
※ ソースコードは「Main.拡張子」で保存されます

  
標準入力
7
994 518 941 851 647 2 581
※ 512 KiB まで

終了コード	0
実行時間	17 ms
メモリ	2964 KB
標準出力
4527

標準エラー出力
FacebookTwitterHatena共有
ルール 用語集
利用規約 プライバシーポリシー 個人情報保護方針 企業情報 よくある質問 お問い合わせ 資料請求
Copyright Since 2012 ©AtCoder Inc. All rights reserved.

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

# ユークリッドの互除法により最大公約数を求める
ans = 0
val1, val2 = a[0], a[1]
while 1:
  if val1 % val2 == 0:
    ans = a[0]*a[1]//val2
    break
  else:
    tmp = val2
    val2 = val1 % val2
    val1 = tmp

for i in range(2, N):
  val1, val2 = ans, a[i]
  while 1:
    if val1 % val2 == 0:
      ans *= a[i]//val2
      break
    else:
      tmp = val2
      val2 = val1 % val2
      val1 = tmp

f_ans = 0
for i in range(N):
  f_ans += (ans-1)%a[i]
print(int(f_ans))