Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import factorial
n = int(input())

dic={}
for i in range(n):
    s=''.join(sorted(list(input())))
    dic[s]=dic.get(s,0)+1

ans=0
for key,value in dic.items():
    if value<2:
        continue
    ans+=int(factorial(value) / factorial(2) / factorial(value - 2))
print(ans)

Fixed submission:
from math import factorial
n = int(input())

dic={}
for i in range(n):
    s=''.join(sorted(list(input())))
    dic[s]=dic.get(s,0)+1

ans=0
for key,value in dic.items():
    if value<2:
        continue
    ans+=factorial(value)//(factorial(2)*factorial(value - 2))
print(ans)

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

dic={}
for i in range(n):
    s=''.join(sorted(list(input())))
    dic[s]=dic.get(s,0)+1

ans=0
for key,value in dic.items():
    if value<2:
        continue
    ans+=int(factorial(value) / factorial(2) / factorial(value - 2))
print(ans)

Fixed submission:
from math import factorial
n = int(input())

dic={}
for i in range(n):
    s=''.join(sorted(list(input())))
    dic[s]=dic.get(s,0)+1

ans=0
for key,value in dic.items():
    if value<2:
        continue
    ans+=factorial(value)//(factorial(2)*factorial(value - 2))
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import factorial
n = int(input())

dic={}
for i in range(n):
    s = ''.join(sorted(set(input())))
    dic[s]=dic.get(s,0)+1

ans=0
for key,value in dic.items():
    if value<2:
        continue
    ans+=int(factorial(value) / factorial(2) / factorial(value - 2))
print(ans)

Fixed submission:
from math import factorial
n = int(input())

dic={}
for i in range(n):
    s=''.join(sorted(list(input())))
    dic[s]=dic.get(s,0)+1

ans=0
for key,value in dic.items():
    if value<2:
        continue
    ans+=factorial(value)//(factorial(2)*factorial(value - 2))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
#RLはフリップの関係にある、[RL]以外のマスの移動を考える
cost_map = [1]*n
ans=0
while True:
    new_map=cost_map.copy()
    for i in range(n):
        if cost_map[i]>0:
            if s[i]=='R':
                new_map[i+1]+=cost_map[i]
                new_map[i]-=cost_map[i]
            if s[i]=='L':
                new_map[i-1]+=cost_map[i]
                new_map[i]-=cost_map[i]
    new2_map = new_map.copy()
    for i in range(n):
        if new_map[i]>0:
            if s[i]=='R':
                new2_map[i+1]+=new_map[i]
                new2_map[i]-=new_map[i]
            if s[i]=='L':
                new2_map[i-1]+=new_map[i]
                new2_map[i]-=new_map[i]        

    ans+=1
    if cost_map==new2_map:
        if ans%2==0:
            print(' '.join(map(str,new_map)))
        else:
            print(' '.join(map(str,new2_map)))
        break
    cost_map=new_map

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

#RRLRL=(R2L),(RL)
#ランレングス圧縮でRLを圧縮し、数の偶奇で分配する
#n<=10**5なので、10**5移動させた後の値でも求められる
v=[]
def RLE(s,v):
    for i in range(len(s)):
        if len(v)==0 or v[-1][0]!=s[i]:
            v.append([s[i],1])
        else:
            v[-1][1]+=1
    return v
rle_li = RLE(s,v)

string_li = [0]*n
for i in range(1,n):
    if s[i-1]=='R' and s[i]=='L':
        x = rle_li.pop(0)[1]
        y = rle_li.pop(0)[1]
        if x==1 and y==1:
            string_li[i-1]=1
            string_li[i]=1
        else:
            if y%2==0:
                string_li[i-1]+=y//2
                string_li[i]+=y//2
            else:
                string_li[i-1]+=y//2
                string_li[i]+=y//2+1
            if x%2==0:
                string_li[i-1]+=x//2
                string_li[i]+=x//2
            else:
                string_li[i-1]+=x//2+1
                string_li[i]+=x//2
print(' '.join(map(str,string_li)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_inputs = [int(input()) for i in range(n)]

ans_li = [max(a_inputs[0:max(i,0)]+a_inputs[min(i+1,n):n]) for i in range(n)]

for ans in ans_li:
    print(ans)

Fixed submission:
n = int(input())
a_inputs = [int(input()) for i in range(n)]

max_a = max(a_inputs)
max_index = a_inputs.index(max(a_inputs))
next_max = sorted(a_inputs)[-2]

for i in range(n):
    if i==max_index:
        print(next_max)
    else:
        print(max_a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
dic = {}
for i in range(1,n+1):
    s,p = map(str,input().split())
    dic[i]=s+str(1/int(p))
for s in sorted(dic.items(),key=lambda x:x[1]):
    print(s[0])

Fixed submission:
n = int(input())

map_list = [[0,'abc',0] for i in range(n)]

for i in range(n):
    input_line = input().split()
    map_list[i]=[i,input_line[0],int(input_line[1])]

ans_li = sorted(map_list,key=lambda x:(x[1],-x[2]))
for ans in ans_li:
    print(ans[0]+1)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
rgb = sorted([r,g,b])

ans=0
for i in range(n//rgb[2]+1):
    for j in range((n-i*rgb[2])//rgb[1]+1):
        d = n-i*rgb[2]-j*rgb[1]
        if d%rgb[0]==0 and d>=0:
            ans+=1

print(ans)

Fixed submission:
rgb = [0]*3
rgb[0],rgb[1],rgb[2],n = map(int,input().split())
rgb.sort()

ans=0
for i in range(n//rgb[2]+1):
    for j in range((n-i*rgb[2])//rgb[1]+1):
        d = n-i*rgb[2]-j*rgb[1]
        if d%rgb[0]==0 and d>=0:
            ans+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import re
n,q = map(int,input().split())
s = input()
L = [0]*q
R = [0]*q
for i in range(q):
    L[i],R[i] = map(int,input().split())

dp = [[0]*n for i in range(n)]
for i in range(n):
    for j in range(i+1,n):
        dp[i][j]=len(re.findall(r'AC',s[i:j+1]))

for i in range(q):
    print(dp[L[i]-1][R[i]-1])

Fixed submission:
n,q = map(int,input().split())
s = input()
L = [0]*q
R = [0]*q
for i in range(q):
    L[i],R[i] = map(int,input().split())

dp = [0]*n
for i in range(1,n):
    dp[i]+=dp[i-1]
    if s[i-1:i+1]=='AC':
        dp[i]+=1
for i in range(q):
    print(dp[R[i]-1]-dp[L[i]-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)

map_list = [int(i) for i in s]
ans=0
while True:
    flag=True
    for i in range(n-1):
        if map_list[i]==-1:
            continue
        j=i+1
        if map_list[i+1]==-1:
            for k in range(i+1,n):
                if map_list[k]!=-1:
                    j=k
                    break
        if min(map_list[i],map_list[j])>=0:
            if map_list[i]!=map_list[j]:
                map_list[i]=-1
                map_list[j]=-1
                flag=False
                ans+=2
                continue
    if flag:
        break
print(ans)




Fixed submission:
s = input()
print(2*min(s.count('0'),s.count('1')))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
num_s = len(s)

while True:
    new_s = []
    len_s = len(s)
    while s:
        if len(s)==1:
            new_s.append(s[0])
            break
        x=s.pop(0)
        if s[0]!=x:
            y=s.pop(0)
        else:
            new_s.append(x)
    
    s = new_s
    if len(new_s)==len_s:
        print(num_s-len_s)
        break



Fixed submission:
s = input()
print(2*min(s.count('0'),s.count('1')))
Buggy python submission (verdict: Runtime Error):
from math import gcd
n = int(input())
a_input = list(map(lambda x:-int(x),input().split()))

x = a_input.pop(0)
for i in range(len(a_input)):
    x = gcd(x,a_input[i])
print(x)

Fixed submission:
from fractions import gcd
n = int(input())
a_input = list(map(int,input().split()))

x = a_input.pop(0)
for i in range(len(a_input)):
    x = gcd(x,a_input[i])
print(x)
Buggy python submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
x_input = sorted(list(map(int,input().split())))

cost_li = []
for i in range(m-1):
    heapq.heappush(cost_li,-(x_input[i+1]-x_input[i]))

if len(cost_li)==0:
    print(0);exit()
for i in range(n-1):
    heapq.heappop(cost_li)

print(-sum(cost_li))




Fixed submission:
import heapq
n,m = map(int,input().split())
x_input = sorted(list(map(int,input().split())))

cost_li = []
for i in range(m-1):
    heapq.heappush(cost_li,-(x_input[i+1]-x_input[i]))

for i in range(n-1):
    if len(cost_li)==0:
        print(0);exit()
    heapq.heappop(cost_li)

print(-sum(cost_li))
Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int,input().split())

for i in range(int(p**(1/n)+1),0,-1):
    if p%i!=0:
        continue
    if p%(pow(i,n))==0:
        print(i);exit()

Fixed submission:
n, p = map(int, input().split())
di = {}
for i in range(2, int(p**0.5)+1):
    if p%i==0:
        tmp = 0
        while p%i==0:
            p //= i
            tmp += 1
        di[i] = tmp
    if p==1:
        break
else:
    di[p] = 1
ans = 1
for i, j in di.items():
    ans *= i**(j//n)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v_input = list(map(int,input().split()))

odd_li = []
even_li = []
for i in range(n):
    if i%2==0:
        odd_li.append(v_input[i])
    else:
        even_li.append(v_input[i])
odd_count = sorted(Counter(odd_li).items(),key=lambda x:x[1])
even_count = sorted(Counter(even_li).items(),key=lambda x:x[1])

odd_max = odd_count[0][0]
even_max = even_count[0][0]

if odd_max==even_max and len(odd_count)==1:
    ans = odd_count[0][1]

elif odd_max==even_max:
    odd_next = odd_count[1][1]
    even_next = even_count[1][1]
    ans = n//2-odd_count[0][1] + n//2 - max(odd_next)
else:
    ans = n//2-odd_count[0][1] + n//2 - even_count[0][1]

print(ans)



Fixed submission:
from collections import Counter
n = int(input())
v_input = list(map(int,input().split()))

odd_li = []
even_li = []
for i in range(n):
    if i%2==0:
        odd_li.append(v_input[i])
    else:
        even_li.append(v_input[i])

odd_count = sorted(Counter(odd_li).items(),key=lambda x:x[1],reverse=True)
even_count = sorted(Counter(even_li).items(),key=lambda x:x[1],reverse=True)

odd_max = odd_count[0][0]
even_max = even_count[0][0]

if odd_max==even_max and len(odd_count)==1:
    ans = n//2

elif odd_max==even_max:
    odd_next = odd_count[1][1]
    even_next = even_count[1][1]
    ans = n//2-odd_count[0][1] + n//2 - max(odd_next,even_next)
else:
    ans = n//2-odd_count[0][1] + n//2 - even_count[0][1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect
    from operator import mul
    from functools import reduce

    def cmb(n,r):
        r = min(n-r,r)
        if r == 0: return 1
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1,r + 1))
        return over // under
    
    ans=[0,0,0]

    for i in range(len(A)-1,-1,-1):
        x = A[i]
        y = A[i]//2

        tmp0=tmp1=tmp2=0

        if y in A:
            tmp0 = cmb(x,y)
        else:
            z = bisect.bisect_left(A,y,hi=max(0,i-1))
            tmp1 = cmb(x,A[z])
            tmp2 = cmb(x,A[max(0,z-1)])

        max_ = [[tmp0,x,y],[tmp1,x,A[z]],[tmp2,x,A[max(0,z-1)]]]
        max_ = sorted(max_,key=lambda x:x[0],reverse=True)

        if ans[0]<max_[0][0]:
            ans = max_[0]
        break
    print(ans[1],ans[2])

if __name__=='__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect

    ans = A[-1]/2
    b = bisect.bisect_left(A,ans)

    if abs(ans-A[b])<abs(ans-A[max(0,b-1)]):
        print(A[-1],A[b])
    else:
        print(A[-1],A[b-1])

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect
    from operator import mul
    from functools import reduce

    def cmb(n,r):
        r = min(n-r,r)
        if r == 0: return 1
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1,r + 1))
        return over // under
    
    ans=[0,0,0]

    for i in range(len(A)-1,-1,-1):
        x = A[i]
        y = A[i]//2

        tmp0=tmp1=tmp2=0

        if y in A:
            tmp0 = cmb(x,y)
        else:
            z = bisect.bisect_left(A,y,hi=max(0,i-1))
            tmp1 = cmb(x,A[z])
            tmp2 = cmb(x,A[max(0,z-1)])

        max_ = [[tmp0,x,y],[tmp1,x,A[z]],[tmp2,x,A[max(0,z-1)]]]
        max_ = sorted(max_,key=lambda x:x[0],reverse=True)

        if ans[0]<max_[0][0]:
            ans = max_[0]
    print(ans[1],ans[2])

if __name__=='__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect

    ans = A[-1]/2
    b = bisect.bisect_left(A,ans)

    if abs(ans-A[b])<abs(ans-A[max(0,b-1)]):
        print(A[-1],A[b])
    else:
        print(A[-1],A[b-1])

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())

ans_li = [i for i in range(a,b+1) if not a+k<=i<=b-k]
print('\n'.join(map(str,ans_li)))

Fixed submission:
a,b,k = map(int,input().split())

min_li = [i for i in range(a,min(a+k,b+1))]
max_li = [i for i in range(max(b-k+1,a),b+1)]

print('\n'.join(map(str,sorted(set(min_li+max_li)))))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())

ans_li = [i for i in range(a,b+1) if not a+k<=i<=b-k]
for ans in ans_li:
    print(ans)

Fixed submission:
a,b,k = map(int,input().split())

min_li = [i for i in range(a,min(a+k,b+1))]
max_li = [i for i in range(max(b-k+1,a),b+1)]

print('\n'.join(map(str,sorted(set(min_li+max_li)))))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_input = list(map(int,input().split()))

for i in range(n):
    tmp=0
    ans=0
    for j in range(n):
        if i==j:
            continue
        ans+=abs(tmp-a_input[j])
        tmp=a_input[j]
    if i==n-1:
        ans+=abs(a_input[-2])
    else:
        ans+=abs(a_input[-1])
    print(ans)




Fixed submission:
n = int(input())
a_input = [0]+list(map(int,input().split()))+[0]

cost_li = [0]*(n+1)
cost_li[0]=a_input[1]
cost_li[-1]=abs(a_input[-2])

for i in range(1,n+1):
    cost_li[i-1]=abs(a_input[i]-a_input[i-1])

sum_cost = sum(cost_li)

for i in range(1,n+1):
    ans = sum_cost-cost_li[i-1]-cost_li[i]+abs(a_input[i+1]-a_input[i-1])
    print(ans)
Buggy python submission (verdict: Runtime Error):
n =input()

#最上位の桁をc,桁数をkとすると、
#c以外が9の場合(ex.49999)はc,9*(k-1)となる
#それ以外の場合、c,9*(k-2),8となる(ex.9995:9989)

c = int(n[0])
k = len(n)

if int(n[1:])==int('9'*(k-1)):
    ans = c+9*(k-1)
else:
    ans = c+9*(k-1)-1

print(ans)







Fixed submission:
n =input()

#最上位の桁をc,桁数をkとすると、
#c以外が9の場合(ex.49999)はc,9*(k-1)となる
#それ以外の場合、c,9*(k-2),8となる(ex.9995:9989)

c = int(n[0])
k = len(n)
if int(n)<10:
    print(n);exit()
if int(n[1:])==int('9'*(k-1)):
    ans = c+9*(k-1)
else:
    ans = c+9*(k-1)-1

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
h,w = map(int,input().split())
map_input = [list(input()) for i in range(h)]

sx,sy = 0,0
gx,gy = w-1,h-1
#bfsで最短経路を求めて、それ以外のマスを塗りつぶせばよい
black = 0
for i in range(h):
    for j in range(w):
        if map_input[i][j]=='#':
            black+=1

mx = [0,0,1,-1]
my = [1,-1,0,0]

queue = deque([[sx,sy]])
visited = [[0]*w for i in range(h)]
visited[sy][sx] = 1

def bfs(queue,visited):
    while queue:
        x,y = queue.popleft()
        for i in range(4):
            nx = x+mx[i]
            ny = y+my[i]
            if 0<=nx<w and 0<=ny<h:
                if visited[ny][nx]!=0:
                    continue
                if map_input[ny][nx]=='#':
                    continue
                if nx==gx and ny==gy:
                    return visited[y][x]+1
                visited[ny][nx]=visited[y][x]+1
                queue.append([nx,ny])

ans = h*w-bfs(queue,visited)-black
print(ans)

Fixed submission:
from collections import deque
h,w = map(int,input().split())
map_input = [list(input()) for i in range(h)]

sx,sy = 0,0
gx,gy = w-1,h-1
#bfsで最短経路を求めて、それ以外のマスを塗りつぶせばよい
black = 0
for i in range(h):
    for j in range(w):
        if map_input[i][j]=='#':
            black+=1

mx = [0,0,1,-1]
my = [1,-1,0,0]

queue = deque([[sx,sy]])
visited = [[0]*w for i in range(h)]
visited[sy][sx] = 1

def bfs(queue,visited):
    while queue:
        x,y = queue.popleft()
        for i in range(4):
            nx = x+mx[i]
            ny = y+my[i]
            if 0<=nx<w and 0<=ny<h:
                if visited[ny][nx]!=0:
                    continue
                if map_input[ny][nx]=='#':
                    continue
                if nx==gx and ny==gy:
                    return visited[y][x]+1
                visited[ny][nx]=visited[y][x]+1
                queue.append([nx,ny])
    return -1

tmp = bfs(queue,visited)
if tmp==-1:
    print(-1)
else:
    ans = h*w-tmp-black
    print(ans)
Buggy python submission (verdict: Runtime Error):
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a_gap = 0
b_gap = 0
for i in range(n):
    if A[i]>B[i]:
        a_gap+=A[i]-B[i]
    if A[i]<B[i]:
        b_gap+=B[i]-A[i]

if a_gap*2-b_gap>0:
    print('No')
else:
    print('Yes')

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

a_gap = 0
b_gap = 0
for i in range(n):
    if A[i]>B[i]:
        a_gap+=A[i]-B[i]
    if A[i]<B[i]:
        b_gap+=(B[i]-A[i])//2

if b_gap-a_gap<0:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n,y = map(int,input().split())

for i in range(min(y//10000+1,n+1)):
    for j in range(min((y-10000*i)//5000+1,n-i+1)):
        for k in range(min((y-10000*i-5000*j)//1000+1,n-i-j+1)):
            if i*10000+j*5000+k*1000==y and i+j+k==n:
                print(i,j,k);exit()
else:
    print(-1,-1,-1)

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

for i in range(n+1):
    for j in range(n+1-i):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
            print(i,j,k);exit()
print(-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
n,y = map(int,input().split())

for i in range(y//10000+1):
    for j in range((y-10000*i)//5000+1):
        for k in range((y-10000*i-5000*j)//1000+1):
            if i*10000+j*5000+k*1000==y and i+j+k==n:
                print(i,j,k);exit()
else:
    print(-1,-1,-1)

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

for i in range(n+1):
    for j in range(n+1-i):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
            print(i,j,k);exit()
print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
def main():
    #input data
    import sys
    input = lambda:sys.stdin.readline().strip()
    S = input()
    N = len(S)
    #solve
    left = 0
    right = N-1

    ans = 0
    while True:
        if right==left:
            break
        if S[left]==S[right]:
            left+=1
            right-=1
            continue
        if S[left]!='x' and S[right]!='x':
            print(-1);exit()
        if S[left]=='x':
            left+=1
            ans+=1
        if S[right]=='x':
            right-=1
            ans+=1
    print(ans)


if __name__=='__main__':
    main()

Fixed submission:
def main():
    #input data
    import sys
    input = lambda:sys.stdin.readline().strip()
    S = input()
    N = len(S)
    #solve
    left = 0
    right = N-1

    ans = 0
    while left<=right:
        if right==left:
            break
        if S[left]==S[right]:
            left+=1
            right-=1
            continue
        if S[left]!='x' and S[right]!='x':
            print(-1);exit()
        if S[left]=='x':
            left+=1
            ans+=1
        if S[right]=='x':
            right-=1
            ans+=1
    if right>left:
        print(-1)
    else:
        print(ans)


if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_input=list(map(int,input().split()))

rate_li=[0]*9
top_coder=0
for a in a_input:
    rate_li[a//400]+=1

min_ = sum(i!=0 for i in rate_li[:8])
print(min_,min(8,min_+rate_li[-1]))

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

rate_li=[0]*9
top_coder=0
for a in a_input:
    rate_li[min(a//400,8)]+=1
#print(rate_li)
min_ = sum(i!=0 for i in rate_li[:8])
print(max(min_,1),min_+rate_li[-1])
Buggy python submission (verdict: Runtime Error):
x = int(input())

dp=[float('inf')]*(x+1)
dp[0]=0
for i in range(1,x+1):
    for j in range((i-1)*i//2+1):
        if 0<=j<=x and 0<=i+j<=x:
            dp[i+j]=min(dp[i+j],i)
print(dp[x])

Fixed submission:
x = int(input())

ans=0
y=0
for i in range(1,x+1):
    y=y+i
    ans+=1
    if y>=x:
        print(ans)
        break

Buggy python submission (verdict: Runtime Error):
x = int(input())

dp=[float('inf')]*(x+1)
dp[0]=0
for i in range(1,x+1):
    for j in range((i-1)*i//2+1):
        if j<=x and i+j<=x:
            dp[i+j]=min(dp[i+j],i)
print(dp[x])

Fixed submission:
x = int(input())

ans=0
y=0
for i in range(1,x+1):
    y=y+i
    ans+=1
    if y>=x:
        print(ans)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
m = 10**9+7

ans = 1
for i in range(2,n+1):
    ans*=i
print(ans%m)

Fixed submission:
n = int(input())
m = 10**9+7

ans = 1
for i in range(2,n+1):
    ans = ans*i%m
print(ans%m)
Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())

for i in range(1000):
    string = str(i)
    if len(string) != N:
        continue
    flag = True
    for j in range(M):
        if string[S[j] - 1] == str(C[j]):
            None
        else:
            flag = False
            break
    if flag:
        print(i)
        sys.exit(0)
print("-1")


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

if n*2>=m:
    print(m//2)
else:
    tmp=m-n*2
    print(n+tmp//4)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_input = [0]*n
b_input = [0]*n
for i in range(n):
    a_input[i],b_input[i]=map(int,input().split())

ans=0
for i in range(n-1,-1,-1):
    if a_input[i]%b_input[i]==0:
        continue
    tmp = b_input[i]-a_input[i]%b_input[i]
    ans += tmp
    for j in range(i+1):
        a_input[j]+=tmp
print(ans)


Fixed submission:
n = int(input())
a_input = [0]*n
b_input = [0]*n
for i in range(n):
    a_input[i],b_input[i]=map(int,input().split())

a_input=a_input[::-1]
b_input=b_input[::-1]

ans=0
for i in range(n):
    a = a_input[i]+ans
    b = b_input[i]
    tmp = a%b
    if tmp==0:
        continue
    ans+=(a//b+1)*b-a
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
coutn5 = [x for x in [a,b,c] if x==5]
coutn7 = [x for x in [a,b,c] if x==7]

if len(count5)==2 and len(count7)==1:
  print('YES')
else:
  print('NO')

Fixed submission:
a,b,c = map(int,input().split())

count5 = len([x for x in [a,b,c] if x==5])
count7 = len([x for x in [a,b,c] if x==7])

if count5==2 and count7==1:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
N = int(input(""))
mul = 1
while N >0 :
    a = int(input(""))
    mul = mul * a
    N -= 1





if mul > 10**18:
    print(-1)
else:
    print(mul)
    
    


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
 
ans = 1
 
a.sort(reverse=True)
 
if 0 not in a:
    for x in range(n):
        ans *= a[x]
 
        if ans > 10**18:
            ans = -1
            break
else:
    ans = 0
 
print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input(""))
b = float(input(""))

mul = int(a*b)
print(mul)

Fixed submission:
import math
a,b=input().split()
a=int(a)
b= int(b.replace(".",""))
print(a*b//100)