Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = [int(i) for i in input().split(' ')]
total = [a_list[0]]
counter = 0

for a in a_list[1:]:
    total.append(total[-1] + a)
    
if total[0]==0:
    total = map(lambda n: n-int(total[1]/abs(total[1])), total)
for i in range(1,n):    
    if total[i-1]<0 and total[i]<=0:
        counter += abs(total[i])+1
        total[i:] = list(map(lambda n: n-(total[i])+1, total[i:]))
    elif total[i-1]>0 and total[i]>=0:
        counter += abs(total[i])+1
        total[i:] = list(map(lambda n: n-(total[i])-1, total[i:]))
    else:
        continue

print(counter)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split(' ')]
_a = [-1*i for i in a]

def func(l):
    _ans = 0
    product = 0
    for i in range(n):
        product += l[i]
        if i%2 == 0:
            if product<=0:
                _ans += abs(product) + 1
                product = 1
        elif i%2 == 1:
            if product>=0:
                _ans += abs(product) + 1
                product = -1
    return _ans

ans = min(func(a), func(_a))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(i) for i in input().split(' ')]
total = [a_list[0]]
counter = 0

for a in a_list[1:]:
    total.append(total[-1] + a)
    
if total[0]==0:
    total = list(map(lambda n: n-int(total[1]/abs(total[1])), total))
for i in range(1,n):    
    if total[i-1]<0 and total[i]<=0:
        counter += abs(total[i])+1
        total[i:] = list(map(lambda n: n-(total[i])+1, total[i:]))
    elif total[i-1]>0 and total[i]>=0:
        counter += abs(total[i])+1
        total[i:] = list(map(lambda n: n-(total[i])-1, total[i:]))
    else:
        continue

print(counter)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split(' ')]
_a = [-1*i for i in a]

def func(l):
    _ans = 0
    product = 0
    for i in range(n):
        product += l[i]
        if i%2 == 0:
            if product<=0:
                _ans += abs(product) + 1
                product = 1
        elif i%2 == 1:
            if product>=0:
                _ans += abs(product) + 1
                product = -1
    return _ans

ans = min(func(a), func(_a))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
 
n, m = [int(i) for i in input().split(' ')]
x_list = [int(i) for i in input().split(' ')]
y_list = [int(i) for i in input().split(' ')]
 
total = 0
for x1, x2 in combinations(x_list, 2):
    for y1, y2 in combinations(y_list,2):
        total += (x2-x1)*(y2-y1)
        
print(int(total % (10**9+7)))

Fixed submission:
n, m = [int(i) for i in input().split(' ')]
x_list = [int(i) for i in input().split(' ')]
y_list = [int(i) for i in input().split(' ')]

x_res = 0
for i in range(n):
    x_res += (i-(n-i-1))*x_list[i]
y_res = 0
for j in range(m):
    y_res += (j-(m-j-1))*y_list[j]
print((x_res*y_res) % (10**9+7))
Buggy python submission (verdict: Runtime Error):
arg = input().split(' ')
a = arg[0]
b = arg[1]'

if a=='D':
    b = 'D' if b=='H' else 'H'
    
print(b)

Fixed submission:
arg = input().split(' ')
a = arg[0]
b = arg[1]

if a=='D':
    b = 'D' if b=='H' else 'H'
    
print(b)

Buggy python submission (verdict: Runtime Error):
x = abs(int(input()))
total = 0
for i in range(x+1):
    total += i
    if total >= x:
        print(i)
        break

Fixed submission:
arg = input().split(' ')
a = arg[0]
b = arg[1]

if a=='D':
    b = 'D' if b=='H' else 'H'
    
print(b)
Buggy python submission (verdict: Runtime Error):
d={}
N,K=map(int,raw_input().split())

for i in xrange(N):
    a,b=map(int,raw_input().split())
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
#    td={}
#    cnt=0
#    print d
#    for key in sorted(d):
#        print key
#        if cnt<=K:
#            td[key]=d[key]
#        else:
#            break
#    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print aa

    


Fixed submission:
A,B,C = map(int, raw_input().split())

if A <= C and B >= C:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import collections

d={}
N,K=map(int,raw_input().split())

for i in xrange(N):
    a,b=map(int,raw_input().split())
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
    td={}
    cnt=0
#    print d
    for key in sorted(d):
#        print key
        if cnt<=K:
            td[key]=d[key]
        else:
            break
    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print aa


Fixed submission:

d={}
N,K=map(int,raw_input().split())

for i in xrange(N):
    a,b=map(int,raw_input().split())
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
#    td={}
#    cnt=0
#    print d
#    for key in sorted(d):
#        print key
#        if cnt<=K:
#            td[key]=d[key]
#        else:
#            break
#    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print aa
Buggy python submission (verdict: Time Limit Exceeded):
def recClr(v,d,c):
    if clr[v-1]==0:
        clr[v-1]=c
#        print "recClr",v,d,c
    if d>0:
        if v in ab:
            for b in ab[v]:
                recClr(b,d-1,c)


N,M=map(int,raw_input().split())
ab={}
for i in xrange(M):
    a,b=map(int,raw_input().split())
    if a in ab:
        ab[a].append(b)
    else:
        ab[a]=[b]
    if b in ab:
        ab[b].append(a)
    else:
        ab[b]=[a]
#print ab


clr=[0]*N

Q=input()
op=[]
for i in xrange(Q):
    v,d,c=map(int,raw_input().split())
    op.append((v,d,c))
op.reverse()
for v,d,c in op:
    recClr(v,d,c)
#print clr   

for i in clr:
    print i


Fixed submission:
def recClr(v,d,c):
#    print "recClr",v,d,c
    if visited[v-1] >= d:
        return
    else:
        visited[v-1]=d
    if clr[v-1]==0:
        clr[v-1]=c
    if d>0:
        if v in ab:
            for b in ab[v]:
                recClr(b,d-1,c)


N,M=map(int,raw_input().split())
ab={}
for i in xrange(M):
    a,b=map(int,raw_input().split())
    if a in ab:
        ab[a].append(b)
    else:
        ab[a]=[b]
    if b in ab:
        ab[b].append(a)
    else:
        ab[b]=[a]
#print ab


clr=[0]*N
visited=[-1]*N

Q=input()
op=[]
for i in xrange(Q):
    v,d,c=map(int,raw_input().split())
    op.append((v,d,c))
op.reverse()
for v,d,c in op:
    recClr(v,d,c)
#print clr   

for i in clr:
    print i
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

x = input()
y=[]
y=x.split(" ")
N=int(y[0])
M=int(y[1])

z=[]
for i in range(M):
	temp1=input()
	temp2=temp1.split(" ")
	for j in temp2:
		j=int(j)
		z.append(j)

dict={}
for i in range(N):
	i+=1
	dict[i]=0

for i in z:
	dict[i]=dict[i]+1

for i in range(N):
	i+=1
	print(dict[i])
	

Fixed submission:
# -*- coding: utf-8 -*-
x=input()
y=[]
y=x.split(" ")

if int(y[2])>=int(y[0]) and int(y[2])<=int(y[1]):
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = list(map(int, input().split(' ')))
L = np.zeros(N).astype(int)
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(N):
    tot += L[i]
    if tot >= K:
        break
print(i+1)

Fixed submission:
import numpy as np

L = np.zeros(10**5).astype(int)
N, K = list(map(int, input().split(' ')))
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(10**5):
    tot += L[i]
    if tot >= K:
        print(i+1)
        break

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = list(map(int, input().split(' ')))
L = np.zeros(N).astype(int)
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(N):
    tot += L[i]
    if tot >= K:
        print(i+1)
        break

Fixed submission:
import numpy as np

L = np.zeros(10**5).astype(int)
N, K = list(map(int, input().split(' ')))
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(10**5):
    tot += L[i]
    if tot >= K:
        print(i+1)
        break

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = list(map(int, input().split(' ')))
L = np.zeros(N).astype(int)
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(N):
    tot += L[i]
    if tot >= K:
        print(i)
        break

Fixed submission:
import numpy as np

L = np.zeros(10**5).astype(int)
N, K = list(map(int, input().split(' ')))
for _ in range(N):
    a, b = list(map(int, input().split(' ')))
    L[a-1] += b
    
tot = 0
for i in range(10**5):
    tot += L[i]
    if tot >= K:
        print(i+1)
        break
Buggy python submission (verdict: Runtime Error):
a, b, c = [int(i) for i in input().split()]
for i in range(2, b+1):
    if a*i % b == c:
        print("YES")
        break
    else:
        print("NO")



Fixed submission:
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()
if b-a  == c-b:
    print("YES")
else:
    print("NO")


Fixed submission:
a, b, c = map(int,input().split())
if (b-a)  == (c-b):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
    a,b,c = map(int,input().split())
     
    if a <= b and b <= c:
     print ("Yes")
    else:
     print ("No")

Fixed submission:
a,b,c = map(int,input().split())
if a <= c and c <= b:
 print ("Yes")
else:
 print ("No")

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input(),split())

if a <= b and b <= c:
 print ("Yes")
else:
 print ("No")

Fixed submission:
a,b,c = map(int,input().split())
if a <= c and c <= b:
 print ("Yes")
else:
 print ("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
ls = []
b_num = 0

for i in range(n):
    a,b = [int(i) for i in input().split()]
    if b_num <= k:
        tmp = [a] * b
        ls.extend(tmp)
        ls.sort()
        b_num += b
    else:
        if(a <= ls[-1]):
            tmp = [a] * b
            ls.extend(tmp)
            ls.sort()
        
print(ls[k-1])

Fixed submission:
n,m = map(int,input().split())
road = []

for i in range(m):
    a,b = [int(i) for i in input().split()]
    road.append([a,b])

road = sum(road,[])
#print(road)
    
for j in range(n):
   print (road.count(j+1))
Buggy python submission (verdict: Runtime Error):
n = int(row())
print n

Fixed submission:
n = int(input())
x = n / 15
res = 800 * n - 200 * int(x)
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
power = 1

for i in range(1,N+1):
 power = (i * power % P) 

print(power)

Fixed submission:
N = int(input())
P = 10**9 + 7

power = 1

for i in range(1,N+1):
 power = (i * power % P)

print(power)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = 10**9 + 7

power = 1

for i in range(1,N+1):
 power *= i

print(power % P)

Fixed submission:
N = int(input())
P = 10**9 + 7

power = 1

for i in range(1,N+1):
 power = (i * power % P)

print(power)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split(" "))
l = []
for i in range(n):
    a, b = map(int, input().split(" "))
    l.extend([a] * b)
l.sort()
print(l[k - 1])


Fixed submission:
n, k = map(int,input().split(" "))
num_count = dict()
for i in range(n):
    a, b = map(int, input().split(" "))
    if a not in num_count:
        num_count[a] = 0

    num_count[a] += b

temp = 0
for key in sorted(num_count.keys()):
    temp += num_count[key]
    if temp >= k:
        print(key)
        break
Buggy python submission (verdict: Runtime Error):
def main():
    o = input()
    e = input()

    pw = [0]*(len(o)+len(e))

    for i in range(len(o)):
        pw[i*2] = o[i*2]

    for i in range(len(e)):
        pw[i*2 + 1] = e[i*2 + 1]

    print("".join(pw))

    # if len(o) == len(e):
    #     pw = [o[i]+e[i] for i in range(len(o))]
    # else:
    #     pw = [o[i]+e[i] for i in range(len(e))]
    #     pw.append(o[-1])
    # 
    # print("".join(pw))
    # 


if __name__ == "__main__":

    main()


Fixed submission:
def main():
    o = input()
    e = input()

    if len(o) == len(e):
        pw = [o[i]+e[i] for i in range(len(o))]
    else:
        pw = [o[i]+e[i] for i in range(len(e))]
        pw.append(o[-1])

    print("".join(pw))


if __name__ == "__main__":

    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    students = [tuple(map(int, input().split())) for i in range(n)]
    check_points = [tuple(map(int, input().split())) for i in range(m)]

    for a, b in students:
        dist = [abs(a - c) + abs(b - d) for c, d in check_points]
        print(check_points.index(min(dist) + 1))
        
    # for st in students:
    #     min_pt = check_points[0]
    #     for pt in check_points:
    #         if abs(pt[0] - st[0]) + abs(pt[1] - st[1]) < \
    #            abs(min_pt[0] - st[0]) + abs(min_pt[1] - st[1]):
    #             min_pt = pt
    #     print(check_points.index(min_pt) + 1)


if __name__ == "__main__":

    main()


Fixed submission:
def main():
    n, m = map(int, input().split())
    students = [tuple(map(int, input().split())) for i in range(n)]
    check_points = [tuple(map(int, input().split())) for i in range(m)]

    for st in students:
        min_pt = check_points[0]
        for pt in check_points:
            if abs(pt[0] - st[0]) + abs(pt[1] - st[1]) < \
               abs(min_pt[0] - st[0]) + abs(min_pt[1] - st[1]):
                min_pt = pt
        print(check_points.index(min_pt) + 1)


if __name__ == "__main__":

    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())

    power = 1

    for i in range(1, n + 1):
        power *= i

    print(power % (10 ** 9 + 7)) 


if __name__ == "__main__":

    main()


Fixed submission:
import math


def main():
    n = int(input())

    print(math.factorial(n) % (10 ** 9 + 7))

    # power = 1
    # 
    # for i in range(1, n + 1):
    #     power *= i

    # print(power % (10 ** 9 + 7))


if __name__ == "__main__":

    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    k, s = map(int, input().split())

    pattern = 0

    if s > 3 * k:
        print(pattern)
        return

    for x in range(k + 1):
        for y in range(min(k + 1, s - x + 1)):
            for z in range(min(k + 1, s - x - y + 1)):
                if x + y + z == s:
                    pattern += 1

    print(pattern)


if __name__ == "__main__":

    main()


Fixed submission:
def main():
    k, s = map(int, input().split())

    pattern = 0

    for x in range(k + 1):
        for y in range(k + 1):
            if (s - x - y >= 0) and (s - x - y <= k):
                pattern += 1

    # Wrong Anser
    # 
    # # 3,4 --> 0 start
    # # 3,5 --> 0 start
    # # 3,7 --> 1 start
    # # 3,8 --> 2 start
    # # 3,9 --> 3 start 
    # # 4,8 --> 0 start
    # # 4,9 --> 1 start
    # # 4,10 --> 2 start
    # # s // k * 2
    # 
    # for x in range(s // 3, k + 1):
    #     for y in range(s // 3, min(k + 1, s - x + 1)):
    #         for z in range(s // 3, min(k + 1, s - x - y + 1)):
    #             if x + y + z == s:
    #                 pattern += 1
    # 

    print(pattern)


if __name__ == "__main__":

    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    k, s = map(int, input().split())

    pattern = 0

    for x in range(k + 1):
        for y in range(min(k + 1, s - x + 1)):
            for z in range(min(k + 1, s - x - y + 1)):
                if x + y + z == s:
                    pattern += 1

    print(pattern)


if __name__ == "__main__":

    main()


Fixed submission:
def main():
    k, s = map(int, input().split())

    pattern = 0

    for x in range(k + 1):
        for y in range(k + 1):
            if (s - x - y >= 0) and (s - x - y <= k):
                pattern += 1

    # Wrong Anser
    # 
    # # 3,4 --> 0 start
    # # 3,5 --> 0 start
    # # 3,7 --> 1 start
    # # 3,8 --> 2 start
    # # 3,9 --> 3 start 
    # # 4,8 --> 0 start
    # # 4,9 --> 1 start
    # # 4,10 --> 2 start
    # # s // k * 2
    # 
    # for x in range(s // 3, k + 1):
    #     for y in range(s // 3, min(k + 1, s - x + 1)):
    #         for z in range(s // 3, min(k + 1, s - x - y + 1)):
    #             if x + y + z == s:
    #                 pattern += 1
    # 

    print(pattern)


if __name__ == "__main__":

    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

    x = [0 for i in range(m)]

    for i in range(m):
        _, x[i] = map(int, input().split())

    for i in range(m):
        print(sum(t) - t[i] + x[i])


if __name__ == "__main__":

    main()


Fixed submission:
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

    p = [0 for i in range(m)]
    x = [0 for i in range(m)]

    for i in range(m):
        p[i], x[i] = map(int, input().split())

    for i in range(m):
        print(sum(t) - t[p[i] - 1] + x[i])


if __name__ == "__main__":

    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    a, b, x = map(int, input().split())
    mod = [i for i in range(a, b + 1) if i % x == 0]
    print(len(mod))

if __name__ == "__main__":

    main()

Fixed submission:
def main():
    a, b, x = map(int, input().split())

    b_count = (b // x) + 1
    if a == 0:
        a_count = 0
    else:
        a_count = ((a - 1) // x) + 1
    print(b_count - a_count)

    # mod = [i for i in range(a, b + 1) if i % x == 0]
    # print(len(mod))

if __name__ == "__main__":

    main()
Buggy python submission (verdict: Runtime Error):
def main():
    x_max, y_max, n = map(int, input().split())
    x_min, y_min = 0, 0

    for n in range(n)def main():
    x_max, y_max, n = map(int, input().split())
    x_min, y_min = 0, 0

    for n in range(n):
        x, y, a = map(int, input().split())

        if a == 1:
            x_min = max(x_min, x)
        elif a == 2:
            x_max = min(x_max, x)
        elif a == 3:
            y_min = max(y_min, y)
        elif a == 4:
            y_max = min(y_max, y)

    print(max(0, x_max - x_min) * max(0, y_max - y_min))

        # if (a == 1) and (x > x_min):
        #     x_min = x
        # elif (a == 2) and (x < x_max):
        #     x_max = x
        # elif (a == 3) and (y > y_min):
        #     y_min = y
        # elif (a == 4) and (y < y_max):
        #     y_max = y
        # 
        # if (x_max <= x_min) or (y_max <= y_min):
        #     print(0)
        #     return

    # print((x_max - x_min) * (y_max - y_min))

if __name__ == "__main__":

    main()
:
        x, y, a = map(int, input().split())

        if a == 1:
            x_min = max(x_min, x)
        elif a == 2:
            x_max = min(x_max, x)
        elif a == 3:
            y_min = max(y_max, y)
        elif a == 4:
            y_max = min(y_max, y)

    print(max(0, x_max - x_min) * max(0, y_max - y_min))

        # if (a == 1) and (x > x_min):
        #     x_min = x
        # elif (a == 2) and (x < x_max):
        #     x_max = x
        # elif (a == 3) and (y > y_min):
        #     y_min = y
        # elif (a == 4) and (y < y_max):
        #     y_max = y
        # 
        # if (x_max <= x_min) or (y_max <= y_min):
        #     print(0)
        #     return

    # print((x_max - x_min) * (y_max - y_min))

if __name__ == "__main__":

    main()


Fixed submission:
def main():
    x_max, y_max, n = map(int, input().split())
    x_min, y_min = 0, 0

    for n in range(n):
        x, y, a = map(int, input().split())

        if (a == 1) and (x > x_min):
            x_min = x
        elif (a == 2) and (x < x_max):
            x_max = x
        elif (a == 3) and (y > y_min):
            y_min = y
        elif (a == 4) and (y < y_max):
            y_max = y

        if (x_max <= x_min) or (y_max <= y_min):
            print(0)
            return

    print((x_max - x_min) * (y_max - y_min))

if __name__ == "__main__":

    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from string import ascii_lowercase


def list_n():
    return [int(e) for e in input().split()]


def list_s():
    return [s for e in input().split()]


def main(n, ss):
    answer = ''
    for c in ascii_lowercase:
        answer += c * min([s.count(c) for s in ss])
    return answer


if __name__ == '__main__':
    n = int(input())
    ss = list_s()
    print(main(n, ss))


Fixed submission:
# -*- coding: utf-8 -*-
from string import ascii_lowercase


def list_n():
    return [int(e) for e in input().split()]


def list_s():
    return [s for e in input().split()]


def main(n, ss):
    answer = ''
    for c in ascii_lowercase:
        answer += c * min([s.count(c) for s in ss])
    return answer


if __name__ == '__main__':
    n = int(input())
    ss = [input() for _ in range(n)]
    print(main(n, ss))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


def main():
    a, b = [int(e) for e in input().split()]
    answer = (a + b) % 23
    return answer


print((main())


Fixed submission:
# -*- coding: utf-8 -*-


def main():
    a, b = [int(e) for e in input().split()]
    answer = (a + b) % 24
    return answer


print(main())