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

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
n = int(input())

edge = [[] for i in range(n)]
ans = [-1] * n
odd = []
even =[]
nums = [[],[],[]]
for i in range(1,n+1):
    nums[i % 3].append(i)

def dfs(x, last = -1, d = 0):
    if d % 2 == 0: even.append(x)
    else: odd.append(x)
    for nxt in edge[x]:
        if nxt == last:continue
        dfs(nxt, x, d + 1)

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

dfs(0)

zerocnt = len(nums[0])

if len(even) <= zerocnt:
    for even_node in even:
        ans[even_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for odd_node in odd:
        ans[odd_node] = rest.pop()

elif len(odd) <= zerocnt:
    for odd_node in odd:
        ans[odd_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for even_node in even:
        ans[even_node] = rest.pop()

# len
# nums[1] >= nums[2] >= nums[0] >= nums[1]-1
else:
    for num in nums[1]:
        ans[even.pop()] = num
    for num in nums[2]:
        ans[odd.pop()] = num
    rest = nums[0]
    for even_node in even:
        ans[even_node] = rest.pop()
    for odd_node in odd:
        ans[odd_node] = rest.pop()

print(*ans)

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

edge = [[] for i in range(n)]
ans = [-1] * n
odd = []
even =[]
nums = [[],[],[]]
for i in range(1,n+1):
    nums[i % 3].append(i)

def dfs(x, last = -1, d = 0):
    if d % 2 == 0: even.append(x)
    else: odd.append(x)
    for nxt in edge[x]:
        if nxt == last:continue
        dfs(nxt, x, d + 1)

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

dfs(0)

zerocnt = len(nums[0])

if len(even) <= zerocnt:
    for even_node in even:
        ans[even_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for odd_node in odd:
        ans[odd_node] = rest.pop()

elif len(odd) <= zerocnt:
    for odd_node in odd:
        ans[odd_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for even_node in even:
        ans[even_node] = rest.pop()

else:
    for num in nums[1]:
        ans[even.pop()] = num
    for num in nums[2]:
        ans[odd.pop()] = num
    rest = nums[0]
    for even_node in even:
        ans[even_node] = rest.pop()
    for odd_node in odd:
        ans[odd_node] = rest.pop()

print(*ans)
Problem p02840 (python)

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

if d == 0:
    if x == 0:print(1)
    else:print(n+1)
    exit(0)

ranges = {}

for k in range(n+1):
    mod = k * x % d
    l = k * x // d + k * (k-1)//2
    r = k * x // d + k * (2*n-k-1)//2
    if mod not in ranges:
        ranges[mod] = []
    ranges[mod].append((l,-1)) 
    ranges[mod].append((r+1, 1))

ans = 0
    
for mod in ranges:
    lrs = ranges[mod]
    lrs.sort()
    cnt = 0
    last = -1
    for x,y in lrs:
        if cnt == 0:last = x
        cnt += y
        if cnt == 0:
            ans += x - last

print(ans)

Buggy submission (verdict: Runtime Error):
n, x, d = map(int, input().split())

ranges = {}

for k in range(n+1):
    mod = k * x % d
    l = k * x // d + k * (k-1)//2
    r = k * x // d + k * (2*n-k-1)//2
    if mod not in ranges:
        ranges[mod] = []
    ranges[mod].append((l,-1)) 
    ranges[mod].append((r+1, 1))

ans = 0
    
for mod in ranges:
    lrs = ranges[mod]
    lrs.sort()
    cnt = 0
    last = -1
    for x,y in lrs:
        if cnt == 0:last = x
        cnt += y
        if cnt == 0:
            ans += x - last

print(ans)
Problem p02850 (python)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

n = int(input())
edge = [[] for i in range(n)]
a = [0] * n
b = [0] * n

color_dict = {}
k = 0

def dfs(x, last = -1, ban_color = -1):
    global k
    color = 1
    for to in edge[x]:
        if to == last:continue
        if color == ban_color:color += 1
        color_dict[(x, to)] = color
        dfs(to, x, color)
        color += 1
    k = max(k, color-1)

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


dfs(0)
print(k)

for i in range(n-1):
    if (a[i], b[i]) in color_dict:
        print(color_dict[(a[i], b[i])])
    else:
        print(color_dict[(b[i], a[i])])

Buggy submission (verdict: Runtime Error):
n = int(input())
edge = [[] for i in range(n)]
a = [0] * n
b = [0] * n

color_dict = {}
k = 0

def dfs(x, last = -1, ban_color = -1):
    global k
    color = 1
    for to in edge[x]:
        if to == last:continue
        if color == ban_color:color += 1
        color_dict[(x, to)] = color
        dfs(to, x, color)
        color += 1
    k = max(k, color-1)

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


dfs(0)
print(k)

for i in range(n-1):
    if (a[i], b[i]) in color_dict:
        print(color_dict[(a[i], b[i])])
    else:
        print(color_dict[(b[i], a[i])])
Problem p02853 (python)

Fixed submission:
x, y = map(int, input().split())
ans = 0
ans += max(0, (4-x)*100000)
ans += max(0, (4-y)*100000)
if x == 1 and y == 1:
	ans += 400000
print(ans)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
ans += max(0, (4-x)*100000)
ans += max(0, (4-y)*100000)
if x == 1 and y == 1:
	ans += 400000
print(ans)
Problem p02913 (python)

Fixed submission:
n = int(input())
s = input()

A = 1234567
MOD = 10000000000000007

def ok(length):
    rolling_hash = 0
    head = pow(A, length, MOD)
    occurence = {}
    for i in range(n):
        rolling_hash = (rolling_hash * A + ord(s[i])) % MOD
        if i - length >= 0:
            rolling_hash = (rolling_hash - head * ord(s[i-length])) % MOD
        if rolling_hash not in occurence:
            occurence[rolling_hash] = []
        occurence[rolling_hash].append(i)

    for key in occurence:
        if occurence[key][-1] - occurence[key][0] >= length:
            return True
    return False

bottom, top = 0, n

while top - bottom > 1:
    mid = (top + bottom) // 2
    if ok(mid):bottom = mid
    else: top = mid

print(bottom)

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

dp = [[-1]*n for _ in range(n)]

def calc(x, y):
    if x >= n or y >= n:return 0
    if dp[x][y] != -1:return dp[x][y]
    if s[x] != s[y]:
        dp[x][y] = 0
        return dp[x][y]
    dp[x][y] = calc(x+1, y+1) + 1
    return dp[x][y]
        
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans = max(ans, min(calc(i, j), j-i))

print(ans)
Problem p02961 (python)

Fixed submission:
K = int(input())
x, y = map(int, input().split())

nowx, nowy = 0, 0
ans = []

def ok():
    global ans, x, y
    ans.append((x, y))
    print(len(ans))
    for (x, y) in ans:
        print(x,y)
    exit(0)
        


while(abs(nowx - x) + abs(nowy - y) >= 2*K):
    if x - nowx >= K:
        nowx += K
    elif nowx - x >= K:
        nowx -= K
    elif y - nowy >= K:
        nowy += K
    else:
        nowy -= K
    ans.append((nowx, nowy))

if (abs(nowx - x) + abs(nowy - y)) % 2 == 1 and K % 2 == 0:
    print(-1)
    exit(0)

    
if (abs(nowx - x) + abs(nowy - y)) == K:ok()
    
if (abs(nowx - x) + abs(nowy - y)) % 2 == 1:
    if abs(nowx+K - x) + abs(nowy - y) < 2*K:nowx += K
    elif abs(nowx-K - x) + abs(nowy - y) < 2*K:nowx -= K
    elif abs(nowx - x) + abs(nowy+K - y) < 2*K:nowy += K
    elif abs(nowx - x) + abs(nowy-K - y) < 2*K:nowy -= K
    ans.append((nowx, nowy))
    
if (abs(nowx - x) + abs(nowy - y)) == K:ok()

rest = K*2 - (abs(nowx-x) + abs(nowy-y))
rest //= 2
xgo, ygo = 1, 1

if nowx != x:
    xgo = (x - nowx) // abs(nowx - x)
if nowy != y:
    ygo = (y - nowy) // abs(nowy - y)

if abs(nowx-x) >= abs(nowy-y):
    nowx += xgo * (K - rest)
    nowy -= ygo * rest
    ans.append((nowx, nowy))
    
else:
    nowy += ygo * (K - rest)
    nowx -= xgo * rest
    ans.append((nowx, nowy))

ok()

Buggy submission (verdict: Runtime Error):
K = int(input())
x, y = map(int, input().split())

nowx, nowy = 0, 0
ans = []

while(abs(nowx - x) + abs(nowy - y) >= 2*K):
    if x - nowx >= K:
        nowx += K
    elif nowx - x >= K:
        nowx -= K
    elif y - nowy >= K:
        nowy += K
    else:
        nowy -= K
    ans.append((nowx, nowy))

if (abs(nowx - x) + abs(nowy - y)) % 2 == 1 and K % 2 == 0:
    print(-1)
    exit(0)

if (abs(nowx - x) + abs(nowy - y)) % 2 == 1:
    if abs(nowx+K - x) + abs(nowy - y) < 2*K:nowx += K
    elif abs(nowx-K - x) + abs(nowy - y) < 2*K:nowx -= K
    elif abs(nowx - x) + abs(nowy+K - y) < 2*K:nowy += K
    elif abs(nowx - x) + abs(nowy-K - y) < 2*K:nowy -= K
    ans.append((nowx, nowy))

rest = K*2 - (abs(nowx-x) + abs(nowy-y))
rest //= 2

xgo = (x - nowx) // abs(nowx - x)
ygo = (y - nowy) // abs(nowy - y)

if abs(nowx-x) >= abs(nowy-y):
    nowx += xgo * (K - rest)
    nowy -= ygo * rest
    ans.append((nowx, nowy))
    
else:
    nowy += ygo * (K - rest)
    nowx -= xgo * rest
    ans.append((nowx, nowy))

ans.append((x, y))

print(len(ans))
for (x, y) in ans:
    print(x,y)
Problem p03039 (python)

Fixed submission:
n, m, k = map(int, input().split())
MOD = (10**9) + 7


S = 0

def stick(n):
    return n * (n+1) // 2

def calc(w, h):
    L = w * (w-1) // 2
    R = L + w * (h-1)
    return (L + R) * h // 2

for i in range(n):
    for j in range(m):
        S += calc(i+1, j+1)
        S += calc(i+1, m-j)
        S += calc(n-i, j+1)
        S += calc(n-i, m-j)
        S -= stick(i)
        S -= stick(j)
        S -= stick(n-i-1)
        S -= stick(m-j-1)
        S %= MOD
        
if S % 2 == 0:S //= 2
else: S = (S + MOD) // 2
S %= MOD
if S < 0:S += MOD

def fact(x):
    res = 1
    for i in range(1, x+1):
        res = res * i % MOD
    return res


def rev(x):
    return pow(x, MOD-2, MOD)

def nCk(n, k):
    return fact(n) * rev(fact(k)) % MOD * rev(fact(n-k)) % MOD

print(S * nCk(n*m-2, k-2) % MOD)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
MOD = 10**9 + 7


S = 0

def stick(n):
    return n * (n+1) // 2

def calc(w, h):
    L = w * (w-1) // 2
    R = L + w * (h-1)
    return (L + R) * h // 2

for i in range(n):
    for j in range(m):
        S += calc(i+1, j+1)
        S += calc(i+1, m-j)
        S += calc(n-i, j+1)
        S += calc(n-i, m-j)
        S -= stick(i)
        S -= stick(j)
        S -= stick(n-i-1)
        S -= stick(m-j-1)
        S %= MOD
if S % 2 == 0:S //= 2
else: S = (S + MOD) // 2
S %= MOD
if S < 0:S += MOD
def fact(x):
    if x == 0:return 1
    else: return x * fact(x-1) % MOD

def rev(x):
    return pow(x, MOD-2, MOD)

def nCk(n, k):
    return fact(n) * rev(fact(k)) % MOD * rev(fact(n-k)) % MOD

print(S * nCk(n+m-2, k-2) % MOD)
Problem p03130 (python)

Fixed submission:
cnt = [0] * 100
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
if max(cnt) == 3:print"NO"
else:print "YES"

Buggy submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
if max(cnt) == 3:print"NO"
else:print "YES"
Problem p03131 (python)

Fixed submission:
k, a, b = map(int, raw_input().split())
res = k+1
if a >= b:
    print(res)
    exit()

k -= a-1
if k >= 0:res = max(res, a + (k / 2) * (b-a))
k -= 1
if k >= 0:res = max(res, a + 1 + (k / 2) * (b-a))
print res

Buggy submission (verdict: Runtime Error):
k, a, b = map(int, raw_input().split())
if a >= b:
    print(res)
    exit()

res = k
k -= a-1
if k >= 0:res = max(res, a + (k / 2) * (b-a))
k -= 1
if k >= 0:res = max(res, a + 1 + (k / 2) * (b-a))
print res
Problem p03146 (python)

Fixed submission:
s = int(input())
ans = 1
nums = set()
while s not in nums:
    ans += 1
    nums.add(s)
    if s % 2 == 0: s //= 2
    else: s = s * 3 + 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = int(input())
ans = 1
nums = set()
while s not in nums:
  ans += 1
  if s % 2 == 0: s // = 2
  else: s = s * 3 + 1
  nums.add(s)
print(ans)
Problem p03308 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
print(max(a)-min(a))
Problem p03309 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i + 1

a.sort()

b = a[n//2]

for i in range(n):
    a[i] = abs(a[i]-b)
print(sum(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i + 1

a.sort()

b = a[n/2]

for i in range(n):
    a[i] = abs(a[i]-b)
print(sum(a))
Problem p03331 (python)

Fixed submission:
n = input()
res = 1<<10
def ds(x):
    return sum(map(int,list(str(x))))

for a in range(1,n):
    b = n - a
    res = min(ds(a) + ds(b), res)

print res

Buggy submission (verdict: Runtime Error):
n = int(input())
res = 0
for a in range(n):
  b = n - a
  res = sum(map(int, str(a))) + sum(map(int, str(b)))
 print(res)
Problem p03627 (python)

Fixed submission:
input()

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < len(a):
      if a[p] == a[p-1]:
              edge.append(a[p])
              p += 2
      else:
              p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]

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

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < a.size():
  if a[p] == a[p-1]:
    edge.append(a[p])
    p += 2
  else:
    p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]

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

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < a.size():
  if a[p] == a[p-1]:
    p += 2
    edge.append(a[p])
  else:
    p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]
Problem p04033 (python)

Fixed submission:
a,b = map(int, raw_input().split())
cnt = b - a + 1
if a > 0:print 'Positive'
elif b < 0:print ['Positive', 'Negative'][cnt%2]
else:print 'Zero'

Buggy submission (verdict: Runtime Error):
    a,b = map(int, raw_input().split())
    cnt = b - a + 1
    if a > 0:print 'Positive'
    elif b < 0:print ['Positive', 'Negative'][cnt%2]
    else:print 'Zero'
Problem p02612 (python)

Fixed submission:
n = input()
if int(n)%1000 == 0:
    print(0)
elif int(n) < 1000:
    print(1000-int(n))
else:
    print(1000-int(n[-3:]))

Buggy submission (verdict: Runtime Error):
n = input()
if int(n)%1000 = 0:
    print(0)
if int(n) < 1000:
    print(1000-int(n))
else:
    print(1000-int(n[-3:]))
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,102)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []
for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif len(al) > 1:
    if abs(al[-1]-x) == abs(al[-2]-x):
        print(al[-2])
    else:
        print(al[-1])
else:
    print(al[-1])

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,101)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []
for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif abs(al[-1]-x) == abs(al[-2]-x):
    print(al[-2])
else:
    print(al[-1])

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,101)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000

for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif abs(al[-1]-x) == abs(al[-2]-x):
    print(al[-2])
else:
    print(al[-1])

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(1,101)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []

for i in p1:
    ans = min(abs(i-x),ans)
    if ans >= abs(i-x):
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif abs(al[-1]-x) == abs(al[-2]-x):
    print(al[-2])
else:
    print(al[-1])
Problem p02677 (python)

Fixed submission:
import math
a,b,h,m = map(int,input().split())

print((a**2+b**2-(2*a*b*math.cos(math.radians(h*30 - m*5.5))))**0.5)

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m = map(int,input().split())
print(a**2+b**2-2*a*b*math.cos(math.radians(h*30 - m*5.5)))**0.5

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m = map(int,input().split())
print((a**2+b**2-2*a*b*math.cos(math.radians(h*30 - m*5.5))))**0.5
Problem p02690 (python)

Fixed submission:
import sys
x = int(input())
a = []
b = []
t = 0
for i in range(-1000,1000):
    t = i**5
    a.append([t,i])
    b.append([t,i])
    
for i in a:
    for j in b:
        if i[0]-j[0] == x:
            print(i[1],j[1])
            sys.exit()

Buggy submission (verdict: Runtime Error):
x = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

temp = prime_factorize(x)
ma = min(temp)
a = 0
b = 0
if x == 1:
    print(0,-1)
else:
    for i in range(ma+1):
        a = ma-i
        b = a-ma
        #print(a,b)
        if a**4+(a**3)*b+(a**2)*(b**2)+a*(b**3)+b**4 == max(temp):
            print(a,b)
            break
Problem p02732 (python)

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))
Problem p02743 (python)

Fixed submission:
from decimal import *
a,b,c = map(str,input().split())
r = "0.5"
if Decimal(a)**Decimal(r)+Decimal(b)**Decimal(r) < Decimal(c) **Decimal(r):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m
    
    return f(int(np.sqrt(n) * (1 + 1e-10)))

a,b,c = map(int,input().split())
if int_sqrt2(a)+int_sqrt2(b) < int_sqrt2(c):
    print("Yes")
else:
    print("No")
Problem p02756 (python)

Fixed submission:
from collections import deque

s = list(input())
s = deque(s)
q = int(input())
flag = ''
count = 0
for i in range(q):
    que = list(map(str,input().split()))
    if que[0] == "1":
        count += 1
        if flag == 'one':
          flag = ''
        else:
          flag = 'one'
    else:
        if que[1] == '1':
            if flag == 'one':
                s.append(que[2])
            else:
                s.appendleft(que[2])
        elif que[1] == '2':
            if flag == 'one':
                s.appendleft(que[2])
            else:
                s.append(que[2])
if count % 2 == 0:
  for i in s:
    print(i,end="")
else:
  for i in reversed(s):
    print(i,end="")

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)

comon = c.most_common()
ans = 0
for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
  if (ans-int(a.count(i))) < 0:
    print(0)
  else:
    co = a.count(i)
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))
Problem p02780 (python)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int,input().split()))

ls = []
ans = 0

for i in range(k):
    ans += p[i]
    
max_ans = ans
max_index = 0

for i in range(n-k):
    ans -= p[i]
    ans += p[i+k]
    if max_ans < ans:
        max_ans = ans
        max_index = i+1

ans = 0
for i in range(k):
    pp = p[max_index+i]
    for j in range(pp):
        ans += (1/pp*(j+1))
    
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))

ls = []
ans = 0

for i in range(k):
    ans += p[i]
    
max_ans = ans
max_index = 0

for i in range(n-k):
    ans -= p[i]
    ans += p[i+k]
    if max_ans < ans:
        max_ans = ans
        max_index = i+1

ans = 0
al = []
for i in range(k):
    pp = p[max_index+i]
    if pp = 200000:
        ans += 2000010000.0000002
    else:
        for j in range(pp):
            ans += (1/pp*(j+1))
            al.append(ans)
    
print(ans)
Problem p02801 (python)

Fixed submission:
c = input()
print(chr(ord(c) + 1))

Buggy submission (verdict: Runtime Error):
n,M = map(int,input().split())
ls = []
for i in range(M):
    p,m = map(str,input().split())
    ls.append([p,m])
    
ac = 0
wa = 0
now = ""
p = 0
c = 0
for i in range(M):
    if now == ls[i][0]:
        continue
    if ls[i][0] != ls[i-1][0] and c == 0:
        wa -= p
        p = 0
    if ls[i][1] == "AC":
        now = ls[i][0]
        ac += 1
        c = 1
    elif ls[i][1] == "WA":
        wa += 1
        c = 0
        p += 1
        
print(ac,wa)
Problem p02823 (python)

Fixed submission:
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(b-1,n-a,round((a-1+b-(a-1))/2),round((n-b+a+(n-b))/2)))
Problem p02843 (python)

Fixed submission:
import sys
x=(input())
ls = [101,102,103,104,105]
if int(x) < 100:
    print(0)
else:
    t = int(x[:-2])
    x = int(x)
    c = 0
    while True:
        if x <= 100:
            break
        x -=105
        c += 1

    if x+105 in ls:
        print(1)
    elif c == t:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
import sys
x=(input())
t = int(x[:-2])
x = int(x)
c = 0
while True:
    if x <= 100:
        break
    x -=105
    c += 1

if c == t:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
import sys
x=(input())
n=int(x[:-2])
t=int(x[-2]+x[-1]) 
if n > 10:
    n = 10
ans = 0
p = 0
for i in range(1,n):#0
    for j in range(1,n):#1
        for k in range(1,n):#2
            for l in range(1,n):#3
                for m in range(1,n):#4
                    for o in range(1,n):#5
                        ans += i*0+j*1+k*2+l*3+m*4+o*5
                        if ans == t:
                            print(1)
                            sys.exit()
                            
print(0)