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

Fixed submission:
#import math
#=input()
#=int(input())
a,b=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

print(a*b)

Buggy submission (verdict: Runtime Error):
import collections #はい。
n=int(input()) #はい。
a=[list(map(str,input().split())) for _ in range(n)]
l = []
for i in range(len(a)):
    l += list(a[i][0])
#↑与えられる文字を全てリストにしたかった。技術が無くて回りくどいやり方になってしまったけれど…。

#以下、2回以上出てくる文字を取り出してn//2文字並べ、その文字列を反転させたものを連結させるという方針。
c = collections.Counter(l) #lに含まれる文字の統計
let,num = zip(*c.most_common()) #letは出てくる文字の種類、numはそれらの文字が何個出てくるか。
ll = list(num) #numがtuple型なのでlist型にした。
for j in range(len(ll)):
    ll[j] //= 2
#↑回文に使える文字が何組あるかというリストに置き換えている。
#例) qが3個出てくる。→1組使える。　,　wが4個出てくる。→2組使える。
    
sum = 0
for jj in range(len(ll)):
    sum += ll[jj]
#↑llのリストの数値の和を求めている。
if sum < n//2:
    print(-1) #回文に使える組数がそもそも足りないのでprint(-1)で終了。
else:
    ans = '' #ここからこのansに回文を詰め込んでいく。
    for k in range(len(let)):
        ans += str(let[k]) * ll[k] #回文に使える文字を使える個数詰め込む。
    ans = ans[:n//2] #n//2以降はいらないので捨てる。
    if n % 2 == 0:
        ans += ans[::-1] #文字数が偶数なら反転させたものを連結するだけ。
    else:
        ans += let[-1] + ans[::-1] #文字数が奇数なら適当な文字(ここではletの最後の要素)を加え、反転させたものを連結する。
    print(ans) #表示する。
Problem p02687 (python)

Fixed submission:
#import math
S=input()
#int(input())
#map(int,input().split())
#list(map(int,input().split()))
#[input() for _ in range()]

if S[1] == 'B':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
#import math
S=input()
#int(input())
#map(int,input().split())
#list(map(int,input().split()))
#[input() for _ in range()]

if S[1] == B:
    print('ARC')
else:
    print('ABC')
Problem p02741 (python)

Fixed submission:
K=int(input())

if (K==1)or(K==2)or(K==3)or(K==5)or(K==7)or(K==11)or(K==13)or(K==15)or(K==17)or(K==19)or(K==23)or(K==29)or(K==31):
    print(1)
if (K==4)or(K==6)or(K==9)or(K==10)or(K==14)or(K==21)or(K==22)or(K==25)or(K==26):
    print(2)
if (K==8)or(K==12)or(K==18)or(K==20)or(K==27):
    print(5)
if K==16:
    print(14)
if K==24:
    print(15)
if (K==28)or(K==30):
    print(4)
if K==32:
    print(51)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
 
if (H == 1)or(W == 1):
    sum = 1
elif H % 2 == 0:
    sum = W * H / 2
elif W % 2 == 0:
    sum = (W * (H-1) / 2) + (W / 2)
else:
    sum = (W * (H-1) / 2) + ((W+1) / 2)
 
print(int(sum))
Problem p02742 (python)

Fixed submission:
H,W = map(int,input().split())
 
if (H == 1)or(W == 1):
    sum = 1
elif H % 2 == 0:
    sum = W * H // 2
elif W % 2 == 0:
    sum = (W * (H-1) // 2) + (W // 2)
else:
    sum = (W * (H-1) // 2) + ((W+1) // 2)
 
print(int(sum))

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())

if H < 10**9:
    if H % 2 == 0:
        sum = W * H / 2
    elif W % 2 == 0:
        sum = (W * (H-1) / 2) + (W / 2)
    else:
        sum = (W * (H-1) / 2) + ((W+1) / 2)
else:
    1+1

print(int(sum))
Problem p02765 (python)

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

if N >= 10:
    X = R
else:
    X = R + 100 * (10 - N)

print(X)

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

if N >= 10:
    R' == R
else:
    R' == R + 100 * (10 - N)

print(R')

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

if N >= 10:
    R' = R
else:
    R' = R + 100 * (10 - N)

print(R')
Problem p02660 (python)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



def pop(stack):
	return stack[0],stack[1:]

def push(stack,x):
	stack.append(x)
	s = set(stack)
	p = list(s)
	p.sort()
	return p

n = int(input())
#a = sympy.factorint(n)
a = factorization(n)
ans = 0
if n != 1:
	for i in a:
		t = 1
		k = 1
		while t <= i[1]:
			#print(t,k,i[1])
			ans += 1
			k += 1
			t += k
			#print(t,k,i[1])
	
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy

def pop(stack):
	return stack[0],stack[1:]

def push(stack,x):
	stack.append(x)
	s = set(stack)
	p = list(s)
	p.sort()
	return p
	"""
	for i in range(len(stack)):
		#print(type(stack[i]),type(x))
		if stack[i] < x:
			t = stack[:i+1]
			t.append(x)
			g = t + stack[i+1:]
			return g
		if stack[i] == x:
			return stack
	"""

n = int(input())
a = sympy.factorint(n)
#print(type(a))
stack = []
temp = []
for i in a:
	stack.append(i)
	temp.append(i)
#print(stack)
#print(set(stack))
ans = 0
while 1 < n:
	v, stack = pop(stack)
	#print(v,n,n%v,stack)
	#print(type(v))
	#v_a = factorint(v)
	#aとv_aとの比較
	if n%v == 0:
		ans += 1
		n /= v
		if n <= v: break
		for i in temp:
			#print(i*v)
			stack = push(stack,i*v)
	else:
		continue
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy

def pop(stack):
	return stack[0],stack[1:]

def push(stack,x):
	stack.append(x)
	s = set(stack)
	p = list(s)
	p.sort()
	return p
	"""
	for i in range(len(stack)):
		#print(type(stack[i]),type(x))
		if stack[i] < x:
			t = stack[:i+1]
			t.append(x)
			g = t + stack[i+1:]
			return g
		if stack[i] == x:
			return stack
	"""

n = int(input())
a = sympy.factorint(n)
#print(type(a))
stack = []
temp = []
for i in a:
	stack.append(i)
	temp.append(i)
#print(stack)
#print(set(stack))
ans = 0
while 1 < n:
	v, stack = pop(stack)
	#print(v,n,n%v,stack)
	#print(type(v))
	#v_a = factorint(v)
	#aとv_aとの比較
	if n%v == 0:
		ans += 1
		n /= v
		if n <= v: break
		for i in temp:
			#print(i*v)
			stack = push(stack,i*v)
	else:
		continue
print(ans)
Problem p02573 (python)

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

graph = [[] for i in range(n)]
for i in range(0,m):
    a, b = map(lambda z: int(z) - 1, data2[i])
    graph[a].append(b)
    graph[b].append(a)

size = [0 for i in range(n)]
check = [True for i in range(n)]
for i in range(n):
    if check[i]:
        tmp = 1
        stack = [i]
        check[i] = False
        while stack:
            now = stack.pop()
            size[now] = tmp
            tmp += 1
            for to in graph[now]:
                if check[to]:
                    check[to] = False
                    stack.append(to)
print(max(size))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
data2 = []
for i in range(m):
    data2.append(input().split())


graph = [[] for i in range(n)]
for i in range(m):
    a, b = map(lambda z: int(z) - 1, data2[m])
    graph[a].append(b)
    graph[b].append(a)

print(graph)
size = [0 for i in range(n)]
check = [True for i in range(n)]
for i in range(n):
    if check[i]:
        tmp = 1
        stack = [i]
        check[i] = False
        while stack:
            now = stack.pop()
            size[now] = tmp
            print(size)
            tmp += 1
            for to in graph[now]:
                if check[to]:
                    check[to] = False
                    stack.append(to)
print(max(size))
Problem p02583 (python)

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

res = 0
for t0 in range(0,len(l)-2):
    for t1 in range(t0+1,len(l)-1):
        for t2 in range(t1+1,len(l)):

             if (l[t0] + l[t1] > l[t2] and l[t0] + l[t2] > l[t1] and l[t1] + l[t2] > l[t0] and l[t0]!=l[t1] and l[t1]!=l[t2] and l[t0]!=l[t2]):
                 res += 1

print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
for index in range(n):
    l.append(int(input()))

res = 0
for t0 in range(len(l)-2):
    for t1 in range(t0,len(l)-2):
        for t2 in range(t1, len(l) - 2):
            if(l[t0]!=l[t1] and  l[t1]!=l[t2]  and l[t1]!=l[t2]):
                if(t0+t1>t2 and t0+t2>t1 and t1+t2>t0):
                    res += 1
print(res)
Problem p02600 (python)

Fixed submission:
def ranking(x):
    if(x>=400):
        if(x<600):
            return 8
        elif(x<800):
            return 7
        elif (x < 1000):
            return 6
        elif (x < 1200):
            return 5
        elif (x < 1400):
            return 4
        elif (x < 1600):
            return 3
        elif (x < 1800):
            return 2
        elif (x < 2000):
            return 1
x=int(input())
print(ranking(x))

Buggy submission (verdict: Runtime Error):
def ranking(x):
    if(x>=400):
        if(x<600):
            return 8
        elif(x<800):
            return 7
        elif (x < 1000):
            return 6
        elif (x < 1200):
            return 5
        elif (x < 1400):
            return 4
        elif (x < 1600):
            return 3
        elif (x < 1800):
            return 2
        elif (x < 2000):
            return 1
x=input()
print(ranking(x))

Buggy submission (verdict: Runtime Error):
def ranking(x):
    if(x>=400):
        if(x<600):
            return 8
        elif(x<800):
            return 7
        elif (x < 1000):
            return 6
        elif (x < 1200):
            return 5
        elif (x < 1400):
            return 4
        elif (x < 1600):
            return 3
        elif (x < 1800):
            return 2
        elif (x < 2000):
            return 1
x=input()
ranking(x)
Problem p02632 (python)

Fixed submission:
MOD = 10**9 + 7
MOD_t_MAX = 2*10**6 + 10

fac  = [None] * MOD_t_MAX
finv = [None] * MOD_t_MAX
inv  = [None] * MOD_t_MAX
def MOD_COM_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MOD_t_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
def MOD_COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

def main():
    k = int(input())
    s = input()
    n = len(s)
    MOD_COM_init()
    ans = 0
    a = 1
    b = pow(26, k, MOD)
    for i in range(k+1):
        ans += a * MOD_COM(i + n-1, n-1) * b % MOD
        a *= 25
        b *= inv[26]
        a %= MOD
        b %= MOD
    print(ans % MOD)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
MOD_t_MAX = 10**6 + 10

fac  = [None] * MOD_t_MAX
finv = [None] * MOD_t_MAX
inv  = [None] * MOD_t_MAX
def MOD_COM_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MOD_t_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
def MOD_COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

def main():
    k = int(input())
    s = input()
    n = len(s)
    MOD_COM_init()
    ans = 0
    pow_26 = [None]*(k+1)
    pow_25 = [None]*(k+1)
    pow_26[0] = 1
    pow_25[0] = 1
    for i in range(1, k+1):
        pow_26[i] = pow_26[i-1] * 26 % MOD
        pow_25[i] = pow_25[i-1] * 25 % MOD
    for i in range(k+1):
        x, y = i, k-i
        tmp = 1
        tmp *= pow_25[x] * MOD_COM(x + n-1, n-1)
        tmp *= pow_26[y]
        ans += tmp % MOD
    print(ans % MOD)

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

Fixed submission:
def main():
    n, m = map(int, input().split())
    ans = []
    t = [True]*(n+1)
    l = n//2 - 1
    for i in range(1, n//2):
        if l <= 0:
            break
        if not t[i] or not t[i+l]:
            continue
        ans.append([i, i+l])
        t[i] = False
        t[i+l] = False
        l -= 2
    if n % 2 == 1:
        l = n//2
        for i in range(n//2, n):
            if l <= 0:
                break
            if not t[i] or not t[i+l]:
                continue
            ans.append([i, i+l])
            t[i] = False
            t[i+l] = False
            l -= 2
    else:
        l = n//2 - 2
        for i in range(n//2, n):
            if l <= 0:
                break
            if not t[i] or not t[i+l]:
                continue
            ans.append([i, i+l])
            t[i] = False
            t[i+l] = False
            l -= 2
    for i in range(m):
        print(ans[i][0], ans[i][1])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    t = [True]*n
    s = [True]*(n+1)
    x = 1
    for _ in range(m):
        while not s[x]:
            x += 1
        s[x] = False
        for i in range(1, n+1):
            if t[i] and x+i<n+1 and s[x+i]:
                print(x, x+i)
                t[i] = False
                s[x+i] = False
                break

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

Fixed submission:
def perm(n, r):
    rtn = 1
    for i in range(r):
        rtn *= n-i
    return rtn

def cmb(n, r):
    return perm(n, r) // perm(r, r)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnts = [0]*(2*10**5 + 1)
    for v in a:
        cnts[v] += 1
    buf = 0
    for i in range(2*10**5 + 1):
        if cnts[i] > 0:
            buf += cmb(cnts[i], 2)
    for i in range(n):
        x = a[i]
        if cnts[x] <= 1:
            print(buf)
        else:
            ans = buf
            ans -= cmb(cnts[x], 2)
            print(ans + cmb(cnts[x]-1, 2))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def cmb(n, r):
    if n <= 0 or n < r:
        return 0
    if n == r or r == 0:
        return 1
    if r == 1:
        return n
    return cmb(n-1,r-1) + cmb(n-1,r)
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnts = [0]*(n+1)
    for v in a:
        cnts[v] += 1
    buf = 0
    for i in range(n+1):
        if cnts[i] > 0:
            buf += cmb(cnts[i], 2)
    for i in range(n):
        x = a[i]
        if cnts[x] <= 1:
            print(buf)
        else:
            ans = buf
            ans -= cmb(cnts[x], 2)
            print(ans + cmb(cnts[x]-1, 2))

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

Fixed submission:
def main():
    a_n, b_n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 10**8
    for _ in range(m):
        x, y, c = map(int, input().split())
        x -= 1
        y -= 1
        buf = a[x] + b[y] - c
        if buf < ans:
            ans = buf
    a.sort()
    b.sort()
    if a[0] + b[0] < ans:
        ans = a[0] + b[0]
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    a_n, b_n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 10**8
    for _ in range(m):
        x, y, c = map(int, input().split())
        x -= 1
        y -= 1
        buf = a[x] + b[x] - c
        if buf < ans:
            ans = buf
    a.sort()
    b.sort()
    if a[0] + b[0] < ans:
        ans = a[0] + b[0]
    print(ans)

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

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)

def solve(g, p, index, y, z, k):
    p[index] = k - y - z
    x = 1
    for i in g[index]:
        if p[i] == -1:
            solve(g, p, i, x, y, k)
            y += 1

def main():
    n, k = map(int, input().split())
    graph =[[] for _ in range(n)]
    p = [-1]*n
    for _ in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)
    s = None
    for i in range(n):
        if len(graph[i]) == 1:
            s = i
            break
    if s is None:
        print(k)
        sys.exit()
    solve(graph, p, s, 0, 0, k)
    ans = 1
    for i in p:
        ans *= i
        ans %= 10**9 + 7
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)

def solve(g, p, index, y, z, k):
    p[index] = k - y - z
    x = 1
    for i in g[index]:
        if p[i] == -1:
            solve(g, p, i, x, y, k)
            y += 1

def main():
    n, k = map(int, input().split())
    graph =[[] for _ in range(n)]
    p = [-1]*n
    for _ in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)
    s = None
    for i in range(n):
        if len(graph[i]) == 1:
            s = i
            break
    solve(graph, p, s, 0, 0, k)
    ans = 1
    for i in p:
        ans *= i
        ans %= 10**9 + 7
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def solve(g, p, index, y, z, k):
    p[index] = k - y - z
    x = 1
    for i in g[index]:
        if p[i] == -1:
            solve(g, p, i, x, y, k)
            y += 1

def main():
    n, k = map(int, input().split())
    graph =[[] for _ in range(n)]
    p = [-1]*n
    for _ in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)
    s = None
    for i in range(n):
        if len(graph[i]) == 1:
            s = i
            break
    solve(graph, p, s, 0, 0, k)
    ans = 1
    for i in p:
        ans *= i
        ans %= 10**9 + 7
    print(ans)

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

Fixed submission:
def dist(s, t, g):
    q = [s]
    dists = [-1]*len(g)
    dists[s] = 0
    while len(q) != 0:
        p = []
        for u in q:
            for v in g[u]:
                if dists[v] != -1:
                    continue
                p.append(v)
                dists[v] = dists[u] + 1
        q = p
    return dists[t]

def main():
    n, m = map(int, input().split())
    g = [[] for _ in range(n*3)]
    for _ in range(m):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        g[u].append(v+n)
        g[u+n].append(v+2*n)
        g[u+2*n].append(v)
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    print(dist(s, t, g)//3)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import shortest_path
def main():
    n, m = map(int, input().split())
    g = [[0]*(n*3) for _ in range(n*3)]
    for _ in range(m):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        g[u][v+n] = 1
        g[u+n][v+2*n] = 1
        g[u+2*n][v] = 1
    s, t = map(int, input().split())
    dist = shortest_path(g, indices=s-1, method="D")
    if dist[t-1] == float('inf'):
        print("-1")
    else:
        print(int(dist[t-1])//3)

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

Fixed submission:
import heapq
def main():
    n, k = map(int, input().split())
    v = list(map(int, input().split()))
    ans = 0
    for L_i in range(min(k+1, n)):#左から取る回数
        R_i_max = k - L_i+1
        if n < L_i + R_i_max:
            R_i_max = n - L_i + 1
        for R_i in range(R_i_max):#右から取る回数
            pop_i = k - L_i - R_i
            q = []
            heapq.heapify(q)
            tmp = 0
            for L_j in range(L_i):
                tmp += v[L_j]
                heapq.heappush(q, v[L_j])
            for R_j in range(n-R_i, n):
                tmp += v[R_j]
                heapq.heappush(q, v[R_j])
            for _ in range(pop_i):
                if len(q) == 0:
                    break
                x = heapq.heappop(q)
                if 0 < x:
                    break
                tmp -= x
            if ans < tmp:
                ans = tmp
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import heapq
def main():
    n, k = map(int, input().split())
    v = list(map(int, input().split()))
#    v_cum = [x for x in v]
#    for i in range(1, n):
#        v_cum[i] += v_cum[i-1]
    ans = 0
    for L_i in range(min(k+1, n)):#左から取る回数
        R_i_max = k - L_i+1
        if n < L_i + R_i_max:
            R_i_max = n - L_i + 1
        for R_i in range(R_i_max):#右から取る回数
            pop_i = k - L_i - R_i
            q = []
            heapq.heapify(q)
            tmp = 0
            for L_j in range(L_i):
                tmp += v[L_j]
                heapq.heappush(q, v[L_j])
            for R_j in range(n-R_i, n):
                tmp += v[R_j]
                heapq.heappush(q, v[R_j])
            for _ in range(pop_i):
                if len(q) == 0:
                    break
                x = heapq.heappop(q)
                if 0 < x:
                    break
                tmp -= x
#            print(L_i, R_i, tmp)
            if ans < tmp:
                ans = tmp
    print(ans)

if __name__ == "__main__":
    main()import heapq
def main():
    n, k = map(int, input().split())
    v = list(map(int, input().split()))
#    v_cum = [x for x in v]
#    for i in range(1, n):
#        v_cum[i] += v_cum[i-1]
    ans = 0
    for L_i in range(min(k+1, n)):#左から取る回数
        R_i_max = k - L_i+1
        if n < L_i + R_i_max:
            R_i_max = n - L_i + 1
        for R_i in range(R_i_max):#右から取る回数
            pop_i = k - L_i - R_i
            q = []
            heapq.heapify(q)
            tmp = 0
            for L_j in range(L_i):
                tmp += v[L_j]
                heapq.heappush(q, v[L_j])
            for R_j in range(n-R_i, n):
                tmp += v[R_j]
                heapq.heappush(q, v[R_j])
            for _ in range(pop_i):
                if len(q) == 0:
                    break
                x = heapq.heappop(q)
                if 0 < x:
                    break
                tmp -= x
#            print(L_i, R_i, tmp)
            if ans < tmp:
                ans = tmp
    print(ans)

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

Fixed submission:
from math import sqrt
def main():
    n = int(input())
    ans = 0
    for i in range(1, int(sqrt(n))+1):
        y = n - i
        if y % i == 0 and y != 0 and n//(y//i) == i:
            ans += y // i
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import sqrt
def main():
    n = int(input())
    ans = 0
    for i in range(1, int(sqrt(n))+1):
        y = n - i
        if y % i == 0 and n//(y//i) == i:
            ans += y // i
    print(ans)

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

Fixed submission:
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    ans = 0
    a[0] = a[0]%m
    for i in range(1, n):
        a[i] += a[i-1]
        a[i] %= m
    a.sort()
    target = 0
    cnt = 1
    for i in a:
        if i == target:
            ans += cnt
            cnt += 1
        else:
            target = i
            cnt = 1
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int cmpAsc(const void* a, const void* b){
    int x = *(int*)a, y = *(int*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    lld m;
    scanf("%d %lld", &n, &m);
    lld a[n+1];
    a[0] = 0;
    rep(i, 1, n+1){
        scanf("%lld", &a[i]);
    }
    rep(i, 1, n+1){
        a[i] += a[i-1];
        a[i] %= m;
    }
    qsort(a, n+1, sizeof(lld), cmpAsc);
    int cnt = 1, target = -1;
    lld ans = 0;
    rep(i, 0, n+1){
        if(a[i] == target){
            ans += (lld)cnt;
            cnt++;
        }else{
            target = a[i];
            cnt = 1;
        }
    }
    printf("%lld", ans);

    return 0;
}