Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M=[int(x) for x in input().split()]
ans=[0]*N
for n in range(N):
  a,b=[int(x) for x in input().split()]
  ans[a-1]+=1
  ans[b-1]+=1
for a in ans:
  print(a)

Fixed submission:
N,M=[int(x) for x in input().split()]
ans=[0]*N
for m in range(M):
  a,b=[int(x) for x in input().split()]
  ans[a-1]+=1
  ans[b-1]+=1
for a in ans:
  print(a)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().strip().split())
ans = 0
while A != B and B != C and (A % 2) + (B % 2) + (C % 2) == 0:
  A, B, C = (B + C) // 2, (A, C) // 2, (A + B) // 2
  ans += 1
print(ans)

Fixed submission:
A, B, C = map(int, input().strip().split())
ans = 0
while (A != B or B != C) and (A % 2) + (B % 2) + (C % 2) == 0:
  A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2
  ans += 1
if (A % 2) + (B % 2) + (C % 2) == 0 and A == B == C:
  ans = -1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
x=0
ans=0
for s in S:
  if s=='I':
    x+=1
    ans=max(anx,x)
  else:
    x-=1
print(ans)
  

Fixed submission:
N=int(input())
S=input()
x=0
ans=0
for s in S:
  if s=='I':
    x+=1
    ans=max(ans,x)
  else:
    x-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
AopB=input().split()
if AopB[1]=='+':
  print(int(AopB[0]+int(AopB[2])))
else:
  print(int(AopB[0]-int(AopB[2])))


Fixed submission:
AopB=input().split()
if AopB[1]=='+':
  print(int(AopB[0])+int(AopB[2]))
else:
  print(int(AopB[0])-int(AopB[2]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def adjust(a, b, va, vb):
  if a == 0 and b == 0:
    return va, vb
  if vb == 1:
    return a, b
  while a / b != va / vb:
    if a / b < va / vb:
      a += 1
    elif a / b > va / vb:
      b += 1
  return a, b

t = 0
a = 0
for n in range(N):
  ti, ai = [int(x) for x in input().split()]
  if ti < ai:
    t, a = adjust(t, a, ti, ai)
  else:
    a, t = adjust(a, t, ai, ti)

print(t + a)

Fixed submission:
N = int(input())

def adjust(a, b, va, vb):
  r = max(a // va, b // vb)
  if va * r < a or vb * r < b:
    r += 1
  
  return va * r, vb * r

t, a = [int(x) for x in input().split()]
for n in range(N - 1):
  ti, ai = [int(x) for x in input().split()]
  t, a = adjust(t, a, ti, ai)

print(t + a)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    import numpy as np
    sys.setrecursionlimit(10**6)
    s = input().strip()
    N = len(s)
    d = np.ones(N+1, dtype=int) * -10**5
    d[0] = 0
    for i, si in enumerate(s, start=1):
        d[i//2+i%2:i+1] = np.maximum(d[i//2+i%2-1:i] - (si == 'p'), d[i//2+i%2:i+1] + (si == 'g'))
        # print('i={}, si={}'.format(i, si), d)
    print(max(d[N//2+N%2:]))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    import numpy as np
    sys.setrecursionlimit(10**6)
    s = input().strip()
    N = len(s)
    p = sum([1 if si == 'p' else 0 for si in s])
    print(N//2-p)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    import numpy as np
    sys.setrecursionlimit(10**6)
    s = input().strip()
    N = len(s)
    d = np.ones(N+1, dtype=int) * -10**5
    d[0] = 0
    for i, si in enumerate(s, start=1):
        d[1:i+1] = np.maximum(d[:i] - (si == 'p'), d[1:i+1] + (si == 'g'))
        # print('i={}, si={}'.format(i, si), d)
    print(max(d[N//2+N%2:]))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    import numpy as np
    sys.setrecursionlimit(10**6)
    s = input().strip()
    N = len(s)
    p = sum([1 if si == 'p' else 0 for si in s])
    print(N//2-p)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
s = input()
n = len(s)
ans = 0
for i in range(1<<(n-1)):
    t = ''
    for j in range(n-1):
        t += s[j]
        if (i >> j) & 1:
            t += '+'
    else:
        t += s[n-1]
    ans += eval(t)
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
s = input().strip()
n = len(s)
ans = 0
for i in range(1<<(n-1)):
    t = ''
    for j in range(n-1):
        t += s[j]
        if (i >> j) & 1:
            t += '+'
    else:
        t += s[n-1]
    ans += eval(t)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, A = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
# mat = {}
def dp(i, x):
  if i == N:
    if len(x) and sum(x) == A * len(x):
      return 1
    else:
      return 0
  elif len(x) and (i, sum(x)/len(x)) in mat:
    return mat[(i, sum(x)/len(x))]
  ret = dp(i + 1, x) + dp(i + 1, x + [X[i]])
  # if len(x):
    # mat[i, sum(x)/len(x)] = ret
  return ret

print(dp(0, []))

Fixed submission:
N, A = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
mat = {}
def dp(i: int, x: list) -> int:
  sumx = sum(x)
  lenx = len(x)
  if i == N:
    if lenx and sumx == A * lenx:
      return 1
    else:
      return 0
  if (i, sumx, lenx) in mat:
    return mat[(i, sumx, lenx)]
  ret = dp(i + 1, x[:]) + dp(i + 1, x[:] + [X[i]])
  mat[(i, sumx, lenx)] = ret
  return ret

print(dp(0, []))
Buggy python submission (verdict: Runtime Error):
print(sum([x for x in range(1,int(input().split())+1)]))

Fixed submission:
print(sum([x for x in range(1,int(input())+1)]))
Buggy python submission (verdict: Runtime Error):
ABC=iuput()
if ABC.count('5')==2 and ABC.count('7')==1:
  print('YES')
else:
  print('NO')

Fixed submission:
ABC=input()
if ABC.count('5')==2 and ABC.count('7')==1:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
N,L=[int(x) for x i input().split()]
s=[]
for _ in range(N):
  s.append(input())
s.sort()
print("".join(s))

Fixed submission:
N,L=[int(x) for x in input().split()]
s=[]
for _ in range(N):
  s.append(input())
s.sort()
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
gf = uf.all_group_members()
ans = 0
for i in gf.values():
    #print(i)
    ans = max(ans, len(i))
print(ans)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
if m == 0:
    print(1)
    exit()
uf = UnionFind(n)
ans = 0
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    ans = max(ans, uf.size(a-1))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

bef = 1
for i in range(k):
    bef *= a[i]
for i in range(k, n):
    val = bef // a[i-k] * a[i]
    if val > bef:
        print('Yes')
    else:
        print('No')
    bef = val


Fixed submission:
n, k = map(int, input().split())
a = [int(_) for _ in input().split()]
bef = 0
for i in range(k, n):
    val = a[i]
    bef = a[i-k]
    if val > bef:
        print('Yes')
    else:
        print('No')
    bef = val
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

arr = [0] * 101
for i in p:
    arr[i] = 1

ans, cnt = 0, 0
for i in range(x, -1, -1):
    if arr[i] == 0:
        ans = i
        break
    else:
        cnt += 1

if cnt == x:
    cnt = 10000

#print(arr)
#print(cnt)

cnt2 = 0
for i in range(x, 102):
    if arr[i] == 0:
        if cnt2 < cnt:
            ans = i
        break
    else:
        cnt2 += 1

print(ans)

Fixed submission:
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

arr = [0] * 1000
for i in p:
    arr[i] = 1

ans1 = 0
for i in range(x, -1, -1):
    if arr[i] == 0:
        ans1 = i
        break

# print(arr)

ans2 = 0
for i in range(x, 102):
    if arr[i] == 0:
        ans2 = i
        break

if abs(ans1 - x) <= abs(x - ans2):
    print(ans1)
else:
    print(ans2)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

def check(arr, val):
    for i in arr:
        if not i == val:
            return False
    return True

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

for _ in range(k):
    aa = [0] * n
    for i in range(n):
        aa[max(0, i-a[i])] += 1
        r = i+a[i]+1
        if r < n:
            aa[r] -= 1
    for i in range(1, n):
        aa[i] += aa[i-1]
    a = aa.copy()
    if check(a, n):
        break

for i in a:
    print(i, end=' ')
print()

Fixed submission:
import copy

def check(arr, val):
    for i in arr:
        if not i == val:
            return False
    return True

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

for _ in range(k):
    aa = [0] * n
    for i in range(n):
        aa[max(0, i-a[i])] += 1
        r = i+a[i]+1
        if r < n:
            aa[r] -= 1
    for i in range(1, n):
        aa[i] += aa[i-1]
    a = aa.copy()
    if check(a, n):
        break

for i in a:
    print(i, end=' ')
print()
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = [int(_) for _ in input().split()]
a = [0] + a

rep_check = 0
now = 1
place = []

if now == a[1]:
    print(1)
    exit()

while now not in place:
    place.append(now)
    now = a[now]
    rep_check += 1
    if rep_check == k:
        print(now)
        exit()

rep_start = 0
for i in enumerate(place):
    if i[1] == now:
        rep_start = i[0]
        break

k -= rep_start
rep_cnt = len(place) - rep_start

place = place[rep_start:]
k %= rep_cnt
print(place[k])

Fixed submission:
n, k = map(int, input().split())
a = [int(_) for _ in input().split()]
a = [0] + a

rep_check = 0
now = 1
place = dict()
place2 = []

if now == a[1]:
    print(1)
    exit()

while now not in place:
    place[now] = 1
    place2.append(now)
    now = a[now]
    rep_check += 1
    if rep_check == k:
        print(now)
        exit()

rep_start = 0
for i in enumerate(place):
    if i[1] == now:
        rep_start = i[0]
        break

k -= rep_start
rep_cnt = len(place) - rep_start

place2 = place2[rep_start:]
k %= rep_cnt
print(place2[k])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = [0] * (n+1)
a = [0] * k
for i in range(k):
    d = int(input())
    aa = [int(_) for _ in input().split()]
    a[i] = aa

for i in range(k):
    l = len(a[i])
    for j in range(l):
        s[a[i][j]] += 1

ans = 0
for i in range(1, k+1):
    if s[i] == 0:
        ans += 1
print(ans)

Fixed submission:
n, k = map(int, input().split())
s = [0] * (n+1)
a = [0] * k
for i in range(k):
    d = int(input())
    aa = [int(_) for _ in input().split()]
    a[i] = aa

for i in range(k):
    l = len(a[i])
    for j in range(l):
        s[a[i][j]] += 1

ans = 0
for i in range(1, n+1):
    if s[i] == 0:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n, m, q = map(int, input().split())
abcd = [0] * q
for i in range(q):
    a, b, c, d = map(int, input().split())
    abcd[i] = [a, b, c, d]

lis = []
for i in range(m):
    for j in range(n):
        lis.append(i+1)
pat = list(itertools.combinations(lis, n))

ans = 0
for l in pat:
    cnt = 0
    for i in range(q):
        if l[abcd[i][1]-1] - l[abcd[i][0]-1] == abcd[i][2]:
            cnt += abcd[i][3]
    ans = max(ans, cnt)
print(ans)

Fixed submission:
import itertools

n, m, q = map(int, input().split())
abcd = [0] * q
for i in range(q):
    a, b, c, d = map(int, input().split())
    abcd[i] = [a, b, c, d]

pat = list(itertools.combinations_with_replacement(range(1, m+1), n))

ans = 0
for l in pat:
    cnt = 0
    for i in range(q):
        if l[abcd[i][1]-1] - l[abcd[i][0]-1] == abcd[i][2]:
            cnt += abcd[i][3]
    ans = max(ans, cnt)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9+7

def start(a):
    num = 0
    for i in range(1, a):
        num += i
    return num

def end(m, b):
    num = 0
    for i in range(n, n-b, -1):
        num += i
    return num

n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
    s = start(i)
    e = end(n, i)
    cnt = e-s+1
    ans = ans + cnt
    ans %= MOD
print(ans)

Fixed submission:
MOD = 10**9+7


def end(b):
    num = 0
    for i in range(n, n-b, -1):
        num += i
    return num

n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
    s = (i-1) * i // 2
    e = (2*n-i+1) * i // 2
    #print(s, e)
    cnt = e-s+1
    ans = ans + cnt
    ans %= MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
length = len(s)
que = [[''] * 3 for i in range(q)]
for i in range(q):
    c = input()
    if c[0] == '1':
        que[i][0] = 1
    else:
        n, f, c = map(str, c.split())
        que[i][0], que[i][1], que[i][2] = int(n), int(f), c
for com in que:
    if com[0] == 1:
        s = s[::-1]
    else:
        if com[1] == 1:
            li = [com[2], s]
            s = ''.join(li)
        else:
            tmp = s
            li = [s, com[2]]
            s = ''.join(li)
print(s)

Fixed submission:
s = input()
q = int(input())
length = len(s)
que = [[''] * 3 for i in range(q)]
for i in range(q):
    c = input()
    if c[0] == '1':
        que[i][0] = 1
    else:
        n, f, c = map(str, c.split())
        que[i][0], que[i][1], que[i][2] = int(n), int(f), c

rev_cnt = 0
left = [''] * 200000
right = [''] * 200000
left_cnt = 0
right_cnt = 0
for com in que:
    if com[0] == 1:
        rev_cnt += 1
        left, right = right, left
        left_cnt, right_cnt = right_cnt, left_cnt
    else:
        if com[1] == 1:
            left[left_cnt] = com[2]
            left_cnt += 1
        else:
            right[right_cnt] = com[2]
            right_cnt += 1

l = list(reversed(left[0:left_cnt]))
if rev_cnt % 2 == 0:
    center = list(s)
else:
    center = list(reversed(list(s)))
ans = l + center + right[0:right_cnt]
for c in ans:
    print(c, end='')
print()

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
length = len(s)
que = [[''] * 3 for i in range(q)]
for i in range(q):
    c = input()
    if c[0] == '1':
        que[i][0] = 1
    else:
        n, f, c = map(str, c.split())
        que[i][0], que[i][1], que[i][2] = int(n), int(f), c
for com in que:
    if com[0] == 1:
        s = s[::-1]
    else:
        if com[1] == 1:
            s = com[2] + s
        else:
            s += com[2]
print(s)

Fixed submission:
s = input()
q = int(input())
length = len(s)
que = [[''] * 3 for i in range(q)]
for i in range(q):
    c = input()
    if c[0] == '1':
        que[i][0] = 1
    else:
        n, f, c = map(str, c.split())
        que[i][0], que[i][1], que[i][2] = int(n), int(f), c

rev_cnt = 0
left = [''] * 200000
right = [''] * 200000
left_cnt = 0
right_cnt = 0
for com in que:
    if com[0] == 1:
        rev_cnt += 1
        left, right = right, left
        left_cnt, right_cnt = right_cnt, left_cnt
    else:
        if com[1] == 1:
            left[left_cnt] = com[2]
            left_cnt += 1
        else:
            right[right_cnt] = com[2]
            right_cnt += 1

l = list(reversed(left[0:left_cnt]))
if rev_cnt % 2 == 0:
    center = list(s)
else:
    center = list(reversed(list(s)))
ans = l + center + right[0:right_cnt]
for c in ans:
    print(c, end='')
print()
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = []
for i in range(m):
    s, c = map(int, input().split())
    sc.append((s, c))

ans = [-1] * n

if n == 1:
    for i in range(m):
        if sc[i][1] == 0:
            print(-1)
            exit()
        if ans[0] != sc[i][1] and ans[0] != -1:
            print(-1)
            exit()
        ans[0] = sc[i][1]
    print(sc[0][1])
    exit()

for i in range(m):
    if ans[sc[i][0]-1] != sc[i][1] and ans[sc[i][0]-1] != -1:
        print(-1)
        exit()
    if sc[i][0] == 1 and sc[i][1] == 0:
        print(-1)
        exit()
    ans[sc[i][0]-1] = sc[i][1]

if ans[0] == -1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

for i in ans:
    print(i, end="")
print()


Fixed submission:
n, m = map(int, input().split())
sc = []
for i in range(m):
    s, c = map(int, input().split())
    sc.append((s, c))

ans = [-1] * n

if m == 0:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
    exit()

if n == 1 and m == 1:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(0)
        exit()

if n == 1:
    for i in range(m):
        if sc[i][1] == 0:
            print(-1)
            exit()
        if ans[0] != sc[i][1] and ans[0] != -1:
            print(-1)
            exit()
        ans[0] = sc[i][1]
    print(sc[0][1])
    exit()

for i in range(m):
    if ans[sc[i][0]-1] != sc[i][1] and ans[sc[i][0]-1] != -1:
        print(-1)
        exit()
    if sc[i][0] == 1 and sc[i][1] == 0:
        print(-1)
        exit()
    ans[sc[i][0]-1] = sc[i][1]

if ans[0] == -1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

for i in ans:
    print(i, end="")
print()
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = 0

def base_10_to_n(x, n):
    if int(x / n):
        return base_10_to_n(int(x / n), n) + str(X % n)
    return str(x % n)

print(len(str(base_10_to_n(n, k))))

Fixed submission:
n, k = map(int, input().split())
ans = 0

def Base_10_to_n(X, n):
    if (int(X / n)):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)

print(len(str(Base_10_to_n(n, k))))
Buggy python submission (verdict: Time Limit Exceeded):
def kitaichi(a):
    sum = ((1+a)*a/2)/a
    return sum

n, k = map(int, input().split())
p = [int(_) for _ in input().split()]

ans = 0
ans_index = 0
for i in range(0, n-k+1):
    val = 0
    for j in range(k):
        val += p[i+j]
    if val > ans:
        ans = val
        ans_index = i

sum = 0
for i in range(ans_index, ans_index+k):
    sum += kitaichi(p[i])

print(sum)

Fixed submission:
def kitaichi(a):
    return ((1+a)*a/2)/a

n, k = map(int, input().split())
p = [int(_) for _ in input().split()]
dp = [0] * n
dp[0] = p[0]
cnt = 1

maxi = 0
idx = 0

for i in range(1, n):
    if cnt < k:
        dp[i] = p[i] + dp[i-1]
        cnt += 1
    else:
        dp[i] = p[i] + dp[i-1] - p[i-k]
    if maxi < dp[i]:
        maxi = dp[i]
        idx = i

ans = 0
for i in range(idx-k+1, idx+1):
    ans += kitaichi(p[i])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def kitaichi(a):
    sum = 0
    for i in range(a):
        sum += i+1
    return sum / a

n, k = map(int, input().split())
p = [int(_) for _ in input().split()]

ans = 0
ans_index = 0
for i in range(0, n-k+1):
    val = 0
    for j in range(k):
        val += p[i+j]
    if val > ans:
        ans = val
        ans_index = i

sum = 0
for i in range(ans_index, ans_index+k):
    sum += kitaichi(p[i])

print(sum)

Fixed submission:
def kitaichi(a):
    return ((1+a)*a/2)/a

n, k = map(int, input().split())
p = [int(_) for _ in input().split()]
dp = [0] * n
dp[0] = p[0]
cnt = 1

maxi = 0
idx = 0

for i in range(1, n):
    if cnt < k:
        dp[i] = p[i] + dp[i-1]
        cnt += 1
    else:
        dp[i] = p[i] + dp[i-1] - p[i-k]
    if maxi < dp[i]:
        maxi = dp[i]
        idx = i

ans = 0
for i in range(idx-k+1, idx+1):
    ans += kitaichi(p[i])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def kitaichi(a):
    sum = 0
    for i in range(a):
        sum += i+1
    return sum / a

n, k = map(int, input().split())
p = [int(_) for _ in input().split()]
lis = [0] * n

for i in range(n):
    lis[i] = kitaichi(p[i])

val = 0
ans = 0

for i in range(0, n-k+1):
    val = 0
    for j in range(k):
        val += lis[i+j]
    ans = max(ans, val)

print(ans)

Fixed submission:
def kitaichi(a):
    return ((1+a)*a/2)/a

n, k = map(int, input().split())
p = [int(_) for _ in input().split()]
dp = [0] * n
dp[0] = p[0]
cnt = 1

maxi = 0
idx = 0

for i in range(1, n):
    if cnt < k:
        dp[i] = p[i] + dp[i-1]
        cnt += 1
    else:
        dp[i] = p[i] + dp[i-1] - p[i-k]
    if maxi < dp[i]:
        maxi = dp[i]
        idx = i

ans = 0
for i in range(idx-k+1, idx+1):
    ans += kitaichi(p[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
s = int(input())
num = [[0 for i in range(10)] for j in range(10)]

ans = 0

for _ in range(n):
    i = _ + 1
    if i < 10:
        num[i][i] += 1
    elif i % 10 != 0:
        moji = str(i)
        num[int(moji[0])][int(moji[len(moji)-1])] += 1
    else:
        pass

for i in range(1, 10):
    for j in range(1, 10):
        ans += num[i][j] * num[j][i]

print(ans)

Fixed submission:
n = int(input())
num = [[0 for i in range(10)] for j in range(10)]

ans = 0

for _ in range(n):
    i = _ + 1
    if i < 10:
        num[i][i] += 1
    elif i % 10 != 0:
        moji = str(i)
        num[int(moji[0])][int(moji[len(moji)-1])] += 1
    else:
        pass

for i in range(1, 10):
    for j in range(1, 10):
        ans += num[i][j] * num[j][i]

print(ans)

Buggy python submission (verdict: Runtime Error):
s = int(input())
num = [[0 for i in range(10)] for j in range(10)]

ans = 0

for _ in range(n):
    i = _ + 1
    if i < 10:
        num[i][i] += 1
    elif i % 10 != 0:
        moji = str(i)
        num[int(moji[0])][int(moji[len(moji)-1])] += 1
    else:
        pass

for i in range(1, 10):
    for j in range(1, 10):
        ans += num[i][j] * num[j][i]

for i in num:
    for j in i:
        print(j, " ", end="")
    print()

print(ans)

Fixed submission:
n = int(input())
num = [[0 for i in range(10)] for j in range(10)]

ans = 0

for _ in range(n):
    i = _ + 1
    if i < 10:
        num[i][i] += 1
    elif i % 10 != 0:
        moji = str(i)
        num[int(moji[0])][int(moji[len(moji)-1])] += 1
    else:
        pass

for i in range(1, 10):
    for j in range(1, 10):
        ans += num[i][j] * num[j][i]

print(ans)