Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
h,w,K = map(int,input().split())
cum = [[0 for _ in range(w+1)]]
for _ in range(h):
  tmp = input()
  add = [0]
  for j in range(w):
    add.append(add[-1]+int(tmp[j]))
  cum.append(add)
for i in range(h):
  for j in range(w):
    cum[i+1][j+1] += cum[i][j+1]
time = [0 for _ in range(h-1)]
def nex(time):
  for d in range(h-1):
    if time[d] == 0:
      time[d] = 1
      return time
    else:
      time[d] = 0
  else:
    return 'over'
can = []
while time != 'over':
  tmp = [0]
  for d in range(h-1):
    if time[d] == 1:
      tmp.append(d+1)
  tmp.append(h)
  #print(tmp,time)
  l = len(tmp) - 1
  ans = l - 1
  now = 0
  att = 1
  for j in range(1,w+1):
    cand = []
    for k in range(l):
      cand.append(cum[tmp[k+1]][j] - cum[tmp[k+1]][now] - cum[tmp[k]][j] + cum[tmp[k]][now])
    #print(cand,now,tmp)
    if max(cand) > K:
      if att == 1:
        break
      now = j - 1
      ans += 1
      att = 1
    else:
      att = 0
  else:
    #print(l-1,ans,time)
    can.append(ans)
  time = nex(time)
  #print(tmp,l-1,ans)
print(min(can))

Fixed submission:
h,w,K = map(int,input().split())
cum = [[0 for _ in range(w+1)]]
for _ in range(h):
  tmp = input()
  add = [0]
  for j in range(w):
    add.append(add[-1]+int(tmp[j]))
  cum.append(add)
for i in range(h):
  for j in range(w):
    cum[i+1][j+1] += cum[i][j+1]
time = [0 for _ in range(h-1)]
def nex(time):
  for d in range(h-1):
    if time[d] == 0:
      time[d] = 1
      return time
    else:
      time[d] = 0
  else:
    return 'over'
can = []
while time != 'over':
  tmp = [0]
  for d in range(h-1):
    if time[d] == 1:
      tmp.append(d+1)
  tmp.append(h)
  #print(tmp,time)
  l = len(tmp) - 1
  ans = l - 1
  now = 0
  att = 1
  for j in range(1,w+1):
    cand = []
    for k in range(l):
      cand.append(cum[tmp[k+1]][j] - cum[tmp[k+1]][now] - cum[tmp[k]][j] + cum[tmp[k]][now])
    #print(cand,now,tmp)
    if max(cand) > K:
      now = j - 1
      ans += 1
      cane = []
      for k in range(l):
        cane.append(cum[tmp[k+1]][j] - cum[tmp[k+1]][now] - cum[tmp[k]][j] + cum[tmp[k]][now])
        #if tmp == [0,1,3]:
          #print(cane,j)
        if max(cane) > K:
          ans += 1
          now = j
    #print(l-1,ans,time)
  else:
    can.append(ans)
  time = nex(time)
  #print(tmp,l-1,ans)
print(min(can))
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
num = [1 for _ in range(n)]
pre = [i for i in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  num[a] += 1
  num[b] += 1
  A = [a]
  B = [b]
  la = 1
  lb = 1
  while a != pre[a]:
    a = pre[a]
    A.append(a)
    la += 1
  while b != pre[b]:
    b = pre[b]
    B.append(b)
    lb += 1
  #print(a,b)
  if a != b:
    if la > lb:
      pre[b] = a
      for aa in A:
        pre[aa] = a
      for bb in B:
        pre[bb] = a
    else:
      pre[a] = b
      for aa in B:
        pre[aa] = b
      for bb in B:
        pre[bb] = b
root = []
cnt = [0 for _ in range(n)]
for i in range(n):
  I = int(i)
  while I != pre[I]:
    I = pre[I]
  root.append(I)
  cnt[I] += 1
#print(pre)
#print(root)
#print(cnt)
ans = []
for i in range(n):
  ans.append(cnt[root[i]]-num[i])
#print(ans)
for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if root[a] == root[b]:
    ans[a] -= 1
    ans[b] -= 1
print(' '.join(map(str,ans)))

Fixed submission:
n = int(input())
print((n+1)//2)
Buggy python submission (verdict: Runtime Error):
s = input()
l = len(input())
print('x'*l)

Fixed submission:
l = len(input())
print('x'*l)
Buggy python submission (verdict: Time Limit Exceeded):
n,d,a = map(int,input().split())
event = []
for i in range(n):
  x,h = map(int,input().split())
  h = (h-1)//a + 1
  event.append([x,0,i,h])
for i in range(n):
  tmp = event[i][0] + 2 * d
  event.append([tmp,1,i,0])
event.sort()
#print(event)
use = [0 for _ in range(n)]
now = 0
ans = 0
for j in range(2*n):
  x,d,i,h = event[j]
  if d == 0:
    if h <= now:
      pass
    else:
      h -= now
      now += h
      use[i] = h
      ans += h
  else:
    now -= use[i]
  #print(x,d,i,ans,now)
print(ans)

Fixed submission:
n,d,a = map(int,input().split())
raw = []
event = []
for i in range(n):
  x,h = map(int,input().split())
  event.append([x,0,i,h])
for i in range(n):
  tmp = event[i][0] + 2 * d
  event.append([tmp,1,i])
event.sort()
#print(event)
use = [0 for _ in range(n)]
now = 0
ans = 0
for j in range(2*n):
  x,d,i = event[j][:3]
  if d == 0:
    h = event[j][3]
    if h <= now * a:
      pass
    else:
      h -= now * a
      tmp = (h-1)//a+1
      now += tmp
      use[i] = tmp
      ans += tmp
  else:
    now -= use[i]
  #print(x,d,i,ans,now)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,d,a = map(int,input().split())
raw = []
event = []
for i in range(n):
  x,h = map(int,input().split())
  event.append([x,0,i,h])
for i in range(n):
  tmp = event[i][0] + 2 * d
  event.append([tmp,1,i])
event.sort()
#print(event)
use = [0 for _ in range(n)]
now = 0
ans = 0
for j in range(2*n):
  x,d,i = event[j][:3]
  if d == 0:
    h = event[j][3]
    if h <= now * a:
      pass
    else:
      h -= now * a
      tmp = (h-1)//a+1
      now += tmp
      use[i] = tmp
      ans += tmp
  else:
    now -= use[i]
  #print(x,d,i,ans,now)
print(ans)

Fixed submission:
n,d,a = map(int,input().split())
raw = []
event = []
for i in range(n):
  x,h = map(int,input().split())
  event.append([x,0,i,h])
for i in range(n):
  tmp = event[i][0] + 2 * d
  event.append([tmp,1,i])
event.sort()
#print(event)
use = [0 for _ in range(n)]
now = 0
ans = 0
for j in range(2*n):
  x,d,i = event[j][:3]
  if d == 0:
    h = event[j][3]
    if h <= now * a:
      pass
    else:
      h -= now * a
      tmp = (h-1)//a+1
      now += tmp
      use[i] = tmp
      ans += tmp
  else:
    now -= use[i]
  #print(x,d,i,ans,now)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
lcm = a[0]
for i in range(1,n):
  big,sml = lcm,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  lcm *= a[i] // big
ans = 0
mod = 10 ** 9 + 7
for i in range(n):
  tmp = lcm // a[i]
  tmp %= mod
  ans += tmp
  ans %= mod
print(ans)
#print(lcm)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7
lcm = a[0]
for i in range(1,n):
  big,sml = lcm,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  lcm *= a[i] // big
ans = 0
def inv(x):
  y = 1
  while x != 1:
    y *= mod // x + 1
    y %= mod
    x -= mod % x
  return y
#print(inv(5))
for i in range(n):
  ans += inv(a[i])
  ans %= mod
#print(ans)
ans *= lcm
ans %= mod
print(ans)
#print(lcm)
#print(1000000*999999*999998%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
lcm = a[0]
for i in range(1,n):
  big,sml = lcm,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  lcm *= a[i] // big
ans = 0
mod = 10 ** 9 + 7
for i in range(n):
  tmp = lcm // a[i]
  tmp %= mod
  ans += tmp
  ans %= mod
print(ans)
#print(lcm)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7
lcm = a[0]
for i in range(1,n):
  big,sml = lcm,a[i]
  while sml != 0:
    big,sml = sml,big%sml
  lcm *= a[i] // big
ans = 0
def inv(x):
  y = 1
  while x != 1:
    y *= mod // x + 1
    y %= mod
    x -= mod % x
  return y
#print(inv(5))
for i in range(n):
  ans += inv(a[i])
  ans %= mod
#print(ans)
ans *= lcm
ans %= mod
print(ans)
#print(lcm)
#print(1000000*999999*999998%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
mod = 10 ** 9 + 7
ans = 1
for _ in range(n):
  ans *= 2
cef = [ans//2]
for i in range(n-1):
  tmp = cef[-1] + ans // 4
  tmp %= mod
  cef.append(tmp)
son = 0
for i in range(n):
  son += cef[i] * a[i]
  son %= mod
ans *= son
ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
mod = 10 ** 9 + 7
ans = 1
for _ in range(2*n-2):
  ans *= 2
  ans %= mod
cef = [i+2 for i in range(n)]
for i in range(n):
  a[i] *= cef[i]
ans *= sum(a)
ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
mod = 10 ** 9 + 7
ans = 1
for _ in range(n):
  ans *= 2
cef = [ans//2]
for i in range(n-1):
  tmp = cef[-1] + ans // 4
  tmp %= mod
  cef.append(tmp)
son = 0
for i in range(n):
  son += cef[i] * a[i]
  son %= mod
ans *= son
ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
mod = 10 ** 9 + 7
ans = 1
for _ in range(2*n-2):
  ans *= 2
  ans %= mod
cef = [i+2 for i in range(n)]
for i in range(n):
  a[i] *= cef[i]
ans *= sum(a)
ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
scale = 62
#scale = 5
z0 = [0 for _ in range(scale)]
for x in a:
  for d in range(scale):
    if x % 2 == 1:
      z0[d] += 1
    x //= 2
ans = 0
for d in range(scale):
  ans += z0[d] * (n-z0[d]) * 2**d
mod = 10**9+7
ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
  tmp = bin(a[i])[2:]
  tmp = '0' * (64-len(tmp)) + tmp
  b.append(tmp)
ans = 0
bit = 1
mod = 10 ** 9 + 7
for k in range(64):
  z1 = 0
  for i in range(n):
    if b[i][-k-1] == '1':
      z1 += 1
  add = z1 * (n-z1) * bit
  add %= mod
  ans += add
  ans %= mod
  bit *= 2
  bit %= mod
  #print(z1,add,ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#11:44
n = int(input())
a = list(map(int,input().split()))
scale = 62
#scale = 5
z0 = [0 for _ in range(scale)]
for x in a:
  for d in range(scale):
    if x % 2 == 1:
      z0[d] += 1
    x //= 2
ans = 0
for d in range(scale):
  ans += z0[d] * (n-z0[d]) * 2**d
mod = 10**9+7
ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
  tmp = bin(a[i])[2:]
  tmp = '0' * (64-len(tmp)) + tmp
  b.append(tmp)
ans = 0
bit = 1
mod = 10 ** 9 + 7
for k in range(64):
  z1 = 0
  for i in range(n):
    if b[i][-k-1] == '1':
      z1 += 1
  add = z1 * (n-z1) * bit
  add %= mod
  ans += add
  ans %= mod
  bit *= 2
  bit %= mod
  #print(z1,add,ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#16:25
n,t = map(int,input().split())
wv = []
for _ in range(n):
  wv.append(list(map(int,input().split())))
wv.sort(key=lambda x:x[0])
now = [0 for _ in range(t+1)]
for i in range(n):
  w,v = wv[i]
  last = now
  now = []
  for f in range(t):
    if f >= w:
      now.append(max(last[f-w]+v,last[f]))
    else:
      now.append(last[f])
  now.append(max(last[-2]+v,last[-1]))
print(now[-1])

Fixed submission:
n,t = map(int,input().split())
now = [0 for _ in range(t+1)]
wv = []
for _ in range(n):
  wv.append(list(map(int,input().split())))
wv.sort(key=lambda x:x[0])
for i in range(n):
  w,v = wv[i]
  last = now
  now = []
  for f in range(t):
    if f - w >= 0:
      now.append(max(last[f],last[f-w]+v))
    else:
      now.append(last[f])
  now.append(max(last[-2]+v,last[-1]))
  #print(now)
print(now[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,t = map(int,input().split())
now = [0 for _ in range(t+1)]
wv = []
for _ in range(n):
  wv.append(list(map(int,input().split())))
wv.sort(key=lambda x:x[0])
for i in range(n):
  w,v = wv[i]
  last = now
  now = []
  for f in range(t):
    if f - w >= 0:
      now.append(max(last[f],last[f-w]+v))
    else:
      now.append(last[f])
  now.append(max(last[-2]+v,last[-1]))
  #print(now)
print(now[-1])

Fixed submission:
n,t = map(int,input().split())
now = [0 for _ in range(t+1)]
wv = []
for _ in range(n):
  wv.append(list(map(int,input().split())))
wv.sort(key=lambda x:x[0])
for i in range(n):
  w,v = wv[i]
  last = now
  now = []
  for f in range(t):
    if f - w >= 0:
      now.append(max(last[f],last[f-w]+v))
    else:
      now.append(last[f])
  now.append(max(last[-2]+v,last[-1]))
  #print(now)
print(now[-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
raw = []
for _ in range(n):
  raw.append(list(map(int,input().split())))
raw.sort(key= lambda x: x[1])
EF = []
for i in range(n):
  EF.append(raw[i][1])
SL1 = [raw[0][0]]
for i in range(1,n):
  SL1.append(max(SL1[-1],raw[i][0]))
SL2 = [raw[-1][0]]
for i in range(1,n):
  SL2.append(max(SL2[-1],raw[n-i-1][0]))
SL2.reverse()
#print(EF)
#print(SL1)
#print(SL2)
can = []
for i in range(n-1):
  if EF[0] - SL1[i] + 1 > 0 and EF[i+1] - SL2[i+1] + 1 > 0:
    tmp = (EF[0]-SL1[i]+1) + (EF[i+1]-SL2[i+1]+1)
    can.append(tmp)
#print(can)
print(max(can))

Fixed submission:
n = int(input())
raw = []
for _ in range(n):
  raw.append(list(map(int,input().split())))
raw.sort(key= lambda x: x[1])
EF = []
for i in range(n):
  EF.append(raw[i][1])
SL1 = [raw[0][0]]
for i in range(1,n):
  SL1.append(max(SL1[-1],raw[i][0]))
SL2 = [raw[-1][0]]
for i in range(1,n):
  SL2.append(max(SL2[-1],raw[n-i-1][0]))
SL2.reverse()
#print(EF)
#print(SL1)
#print(SL2)
can = []
for i in range(n-1):
  tmp = max(EF[0]-SL1[i]+1,0) + max(EF[i+1]-SL2[i+1]+1,0)
  can.append(tmp)
#print(can)
ans1 = max(can)
xlen = []
xl = []
xr = []
for i in range(n):
  xlen.append(raw[i][1] - raw[i][0] + 1)
  xl.append(raw[i][0])
  xr.append(raw[i][1])
#print(max(xl))
ans2 = max(xlen) + max(0,min(xr)-max(xl)+1)
print(max(ans1,ans2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
for r in range(n-1,-1,-1):
  m = r
  for l in range(n):
    if l == m and m + 1 < r:
      m += 1
    while True:
      if a[l] + a[m-1] > a[r] and l < m-1:
        m -= 1
      else:
        break
    if l < m < r:
      ans += r - m
      #print(l,m,r)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
for r in range(n-1,-1,-1):
  m = r
  for l in range(n):
    if l == m and m + 1 < r:
      m += 1
    else:
      while True:
        if a[l] + a[m-1] > a[r] and l < m-1:
          m -= 1
        else:
          break
    if l < m < r:
      ans += r - m
      #print(l,m,r)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
l = len(s)
s = s * 3
dp = [0,0]
check = []
for i in range(3*l-1):
  if s[i+1] != s[i]:
    dp.append(dp[-1])
  else:
    dp.append(dp[-2]+1)
  if (i+2) % l == 0:
    check.append(dp[-1])
if k % 2 == 0:
  ans = check[1] + (k-2) // 2 * (check[2]-check[0])
else:
  ans = check[0] + (k-1) // 2 * (check[2]-check[0])
print(ans)

Fixed submission:
s = input()
k = int(input())
l = len(s)
s = s * 3
dp = [0,0]
check = []
for i in range(3*l-1):
  if s[i+1] != s[i]:
    dp.append(dp[-1])
  else:
    dp.append(dp[-2]+1)
  if (i+2) % l == 0:
    check.append(dp[-1])
if l == 1:
  ans =  k // 2
elif k % 2 == 0:
  ans = check[1] + (k-2) // 2 * (check[2]-check[0])
else:
  ans = check[0] + (k-1) // 2 * (check[2]-check[0])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
raw = []
for i in range(n):
  raw.append(s[i:])
raw.sort()
#print(raw)
if all( raw[i-1][0] != raw[i][0] for i in range(1,n)):
  ans = 0
else:
  ans = 1
  for i in range(1,n):
    one = raw[i-1]
    two = raw[i]
    lone = len(one)
    ltwo = len(two)
    stop = min(lone,ltwo,abs(lone-ltwo))
    if ans > stop:
      pass
    else:
      for i in range(ans,stop):
        if one[i] == two[i]:
          ans += 1
print(ans)

Fixed submission:
s = input()
if s == 'Sunny':
  print('Cloudy')
elif s == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
Buggy python submission (verdict: Runtime Error):
#16:07
n = int(input())
raw = []
for _ in range(n):
  raw.append(list(map(lambda x: int(x)-1, input().split())))
cnt = [0 for _ in range(n)]
tmp = [0 for _ in range(n)]
now = [i for i in range(n)]
ans = 0
while now:
  ans += 1
  last = now
  now = []
  for x in last:
    tmp[x] = 0
  for x in last:
    try:
      y = raw[x][cnt[x]]
      if tmp[x] == tmp[y] == 0 and x == raw[y][cnt[y]]:
        cnt[x] += 1
        cnt[y] += 1
        tmp[x] = 1
        tmp[y] = 1
        now.append(x)
        now.append(y)
    except:
      pass
  #print(now)
if cnt == [n-1 for _ in range(n)]:
  print(ans-1)
else:
  print(-1)

Fixed submission:
a = input()
b = input()
ans = 0
for i in range(3):
  if a[i] == b[i]:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
#dummy
#16:07
n = int(input())
raw = []
for _ in range(n):
  raw.append(list(map(lambda x: int(x)-1, input().split())))
cnt = [0 for _ in range(n)]
now = [i for i in range(n)]
ans = 0
while now:
  ans += 1
  last = now
  now = []
  tmp = [0 for _ in range(n)]
  for x in last:
    if cnt[x] < n-1:
      y = raw[x][cnt[x]]
      if tmp[x] == tmp[y] == 0 and x == raw[y][cnt[y]]:
        cnt[x] += 1
        cnt[y] += 1
        tmp[x] = 1
        tmp[y] = 1
        now.append(x)
        now.append(y)
  #print(now)
  if n > 500 and cnt[0] == 10:
    break
if cnt == [n-1 for _ in range(n)]:
  print(ans-1)
else:
  print(-1)

Fixed submission:
a = input()
b = input()
ans = 0
for i in range(3):
  if a[i] == b[i]:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
xy = []
for _ in range(n):
  xy.append(list(map(int,input().split())))
can = []
for i in range(n):
  now = [0,0]
  xp = [0,0]
  xm = [0,0]
  X = - xy[i][1] + 0.00000000000001
  Y = xy[i][0]
  for j in range(n):
    x,y = xy[j]
    if x * X + y * Y > 0:
      now[0] += x
      now[1] += y
    elif x * X + y * Y == 0:
      if x == 0:
        if y > 0:
          xp[0] += x
          xp[1] += y
        else:
          xm[0] += x
          xm[1] += y
      elif x > 0:
        xp[0] += x
        xp[1] += y
      else:
        xm[0] += x
        xm[1] += y
  xp[0] += now[0]
  xp[1] += now[1]
  xm[0] += now[0]
  xm[1] += now[1]
  use = max(xp[0]**2+xp[1]**2,xm[0]**2+xm[1]**2)
  can.append(use)
print(max(can)**.5)

Fixed submission:
a = input()
b = input()
ans = 0
for i in range(3):
  if a[i] == b[i]:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
#解説解法
n = int(input())
xp = []
xm = []
yp = []
ym = []
for _ in range(n):
  x,y = map(int,input().split())
  if x == 0:
    if y == 0:
      n -= 1
    elif y > 0:
      yp.append([0,x,y])
    else:
      ym.append([0,x,y])
  elif x > 0:
    xp.append([y/x,x,y])
  else:
    xm.append([y/x,x,y])
xp.sort()
xm.sort()
xy = xp + yp + xm + ym
can = []
for i in range(-n,0):
  for j in range(i+1,i+n+1):
    X = 0
    Y = 0
    for k in range(i,j):
      x,y = xy[k][1],xy[k][2]
      X += x
      Y += y
    can.append(X**2+Y**2)
print(max(can)**.5)

Fixed submission:
#解説解法
n = int(input())
xp = []
xm = []
yp = []
ym = []
for _ in range(n):
  x,y = map(int,input().split())
  if x == 0:
    if y == 0:
      n -= 1
    elif y > 0:
      yp.append([0,x,y])
    else:
      ym.append([0,x,y])
  elif x > 0:
    xp.append([y/x,x,y])
  else:
    xm.append([y/x,x,y])
xp.sort()
xm.sort()
xy = xp + yp + xm + ym
can = []
for i in range(-n,0):
  for j in range(i+1,i+n+1):
    X = 0
    Y = 0
    for k in range(i,j):
      x,y = xy[k][1],xy[k][2]
      X += x
      Y += y
    can.append(X**2+Y**2)
if n == 0:
  print(0)
else:
  print(max(can)**.5)
Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int,input().split()))
inv = 0
for i in range(n):
  inv += 1 / a[i]
print( 1 / inv )

Fixed submission:
n = int(input())
s = list(map(int,input().split()))
t = 0
for i in range(n):
  t += 1 / s[i]
print( 1 / t )
Buggy python submission (verdict: Time Limit Exceeded):
#親ー子の順に書かれてるか否かめっちゃ重要なのになあ
n,q = map(int,input().split())
peer = [[] for _ in range(n)]
for i in range(n-1):
  a,b = (map(int,input().split()))
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
mom = [-1 for _ in range(n)]
mom[0] = 'luca'
child = [[] for _ in range(n)]
now = [0]
while now != []:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if mom[y] == -1:
        now.append(y)
        mom[y] = x
        child[x].append(y)
#print(peer)
#print(mom)
#print(child)
pq = [0 for _ in range(n)]
for i in range(q):
  p,x = map(int,input().split())
  p -= 1
  pq[p] += x
now = [0]
ans = pq
while now != []:
  last = now
  now = []
  for x in last:
    for y in child[x]:
      ans[y] += ans[x]
    now += child[x]
print(' '.join(list(map(str,ans))))

Fixed submission:
#親ー子の順に書かれてるか否かめっちゃ重要なのになあ
n,q = map(int,input().split())

peer = [[] for _ in range(n)]
for i in range(n-1):
  a,b = (map(int,input().split()))
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)

pq = [0 for _ in range(n)]
for i in range(q):
  p,x = map(int,input().split())
  p -= 1
  pq[p] += x

now = [0]
ans = pq
now = [0]
mom = [0 for _ in range(n)]
mom[0] = 1
while now != []:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if mom[y] == 0:
        now.append(y)
        mom[y] = 1
        ans[y] += ans[x]

print(' '.join(list(map(str,ans))))

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
child = [[] for _ in range(n)]
now = [0]
while now != []:
  last = now
  l = len(last)
  now = []
  for i in range(l):
    child[last[i]] = peer[last[i]]
    now += peer[last[i]]
    p = peer[last[i]]
    ll = len(p)
    for ii in range(ll):
      peer[p[ii]].remove(last[i])
mom = ['?' for _ in range(n)]
for i in range(n):
  for x in child[i]:
    mom[x] = i
cnt = [0 for _ in range(n)]
for _ in range(q):
  p,x = map(int,input().split())
  p -= 1
  cnt[p] += x
#print(peer)
#print(child)
#print(mom)
#print(cnt)
ans = cnt
now = [0]
while now != []:
  last = now
  l = len(last)
  now = []
  for i in range(l):
    now += child[last[i]]
    try:
      ans[last[i]] += ans[mom[last[i]]]
    except:
      pass
print(' '.join(list(map(str,ans))))

Fixed submission:
#親ー子の順に書かれてるか否かめっちゃ重要なのになあ
n,q = map(int,input().split())

peer = [[] for _ in range(n)]
for i in range(n-1):
  a,b = (map(int,input().split()))
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)

pq = [0 for _ in range(n)]
for i in range(q):
  p,x = map(int,input().split())
  p -= 1
  pq[p] += x

now = [0]
ans = pq
now = [0]
mom = [0 for _ in range(n)]
mom[0] = 1
while now != []:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if mom[y] == 0:
        now.append(y)
        mom[y] = 1
        ans[y] += ans[x]

print(' '.join(list(map(str,ans))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
flag = 1
for i in range(1,n):
  if h[i] < h[i-1]:
    flag = 0
    break
  if h[i] > h[i-1]:
    h[i] -= 1
if flag == 1:
  print('Yes')
else:
  prinr('No')

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
h.append(0)
flag = 1
for i in range(n):
  if h[i] < h[i-1]:
    flag = 0
    break
  elif h[i] == h[i-1]:
    pass
  else:
    h[i] -= 1
if flag == 1:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
#10:30
s = input()
n = len(s)
now = [1,0,0,0,0,0,0,0,0,0,0,0,0]
for i in range(n):
  last = now
  now = [0 for _ in range(13)]
  here = s[i]
  if here == '?':
    for k in range(10):
      for j in range(13):
        now[(10*j+k)%13] += last[j]
  else:
    k = int(here)
    for j in range(13):
      now[(10*j+k)%13] += last[j]
  for j in range(13):
    now[j] %= 10**9+7
print(now[5])

Fixed submission:
#10:30
s = input()
n = len(s)
now = [1,0,0,0,0,0,0,0,0,0,0,0,0]
for i in range(n):
  last = now
  now = [0 for _ in range(13)]
  here = s[i]
  if here == '?':
    for k in range(10):
      for j in range(13):
        now[(10*j+k)%13] += last[j]
  else:
    k = int(here)
    for j in range(13):
      now[(10*j+k)%13] += last[j]
  for j in range(13):
    now[j] %= 10**9+7
print(now[5])
Buggy python submission (verdict: Runtime Error):
s = int(input())
print(0,0,10**9,1,s%(10**9),s//(10**9)

Fixed submission:
s = int(input())
print(0,0,10**9,1,10**9-(s-1)%(10**9)-1,(s-1)//(10**9)+1)