Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

visited=[0]*N
frnds=[[] for i in range(N)]

for _ in range(M):
    a,b=map(int,input().split())
    frnds[a-1].append(b-1)
    frnds[b-1].append(a-1)

for i in range(N):
    frnds[i]=list(set(frnds[i]))

def saiki(num):
    value=1
    visited[num]=1
    for f in frnds[num]:
        if visited[f]!=1:
            value+=saiki(f)
    return value

ans=0
for i in range(N):
    if visited[i]!=1:
        ans=max(saiki(i),ans)

print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())

visited=[0]*N
frnds=[[] for i in range(N)]

for _ in range(M):
    a,b=map(int,input().split())
    frnds[a-1].append(b-1)
    frnds[b-1].append(a-1)

for i in range(N):
    frnds[i]=list(set(frnds[i]))

def saiki(num):
    value=1
    visited[num]=1
    for f in frnds[num]:
        if visited[f]!=1:
            value+=saiki(f)
    return value

ans=0
for i in range(N):
    if visited[i]!=1:
        ans=max(saiki(i),ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(float, input().split()))

low=-1
high=10**9+1

while high-low!=1:
    mid=(high+low)//2
    cut_temp=0
    ans=-1
    
    for a in A:
        cut_temp+=-(-a//mid)-1
    if cut_temp>K:
        low=mid
    else:
        high=mid
    
print(high)

Fixed submission:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(float, input().split()))

low=0
high=10**9+1

while high-low!=1:
    mid=(high+low)//2
    cut_temp=0
    ans=-1
    
    for a in A:
        cut_temp+=-(-a//mid)-1
    if cut_temp>K:
        low=mid
    else:
        high=mid
    
print(high)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(int,input().split()))

for _ in range(K):
    ans=[0]*len(A)
    start=[0]*len(A)
    end=[0]*len(A)
    
    for index,item in enumerate(A):
        start[max(0,index-item)]+=1
        end[min(len(end)-1,index+item)]+=1
    
    #print(start)
    #print(end)
    
    temp=0
    for i in range(len(ans)):
        temp+=start[i]
        ans[i]=temp
        temp-=end[i]
    
    A=ans[:]

print(*ans)

Fixed submission:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(int,input().split()))


for _ in range(K):
    ans=[0]*len(A)
    start=[0]*len(A)
    end=[0]*len(A)
    
    for index,item in enumerate(A):
        start[max(0,index-item)]+=1
        end[min(len(end)-1,index+item)]+=1
    
    #print(start)
    #print(end)
    
    temp=0
    for i in range(len(ans)):
        temp+=start[i]
        ans[i]=temp
        temp-=end[i]
    
    if A==ans:
        break
    else:
        A=ans[:]

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect

line=[i*(i+1)//2 for i in range(10**7+1)]

N=int(input())

if N==1:
    print(0)
    exit()

do=[0 for i in range(10**6+1)]

for i in range(2,int(N**0.5)+1):
    while N%i==0:
        N/=i
        do[i]+=1

ans=0
judge=True

for _,item in enumerate(do):
    index=(bisect.bisect_right(line,item))-1
    ans+=index
    if index!=0:
        judge=False

print(ans+1 if judge else ans)




Fixed submission:
# coding: utf-8
# Your code here!
import bisect

line=[i*(i+1)//2 for i in range(10**6+1)]

N=int(input())


do=[0 for i in range(10**6+1)]

for i in range(2,int(N**0.5)+1):
    while N%i==0:
        N/=i
        do[i]+=1

ans=0 if N==1 else 1

for _,item in enumerate(do):
    index=(bisect.bisect_right(line,item))-1
    ans+=index

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

S=list(input())
S=list(map(int,S))[::-1]


mod=[0]*2019
mod[0]+=1

ans=0
temp=0
for i in range(len(S)):
    temp+=S[i]*10**i
    temp%=2019
    ans+=mod[temp]
    mod[temp]+=1

print(ans)


Fixed submission:
# coding: utf-8
# Your code here!

S=list(input())
S=list(map(int,S))[::-1]


mod=[0]*2019
mod[0]+=1

ans=0
temp=0
p=1
for i in range(len(S)):
    temp+=S[i]*p
    p=p*10%2019
    temp%=2019
    ans+=mod[temp]
    mod[temp]+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N=int(input())

A=list(map(int,input().split()))

if N==2:
  print(max(0,A[0],A[1]))

dp=[[-10**18 for i in range(N)] for j in range(3)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]

for n in range(3):
    for index in range(N):
        if dp[n][index]!=-1:
            if n!=2 and index+3<N:
                dp[n+1][index+3]=max(dp[n+1][index+3],dp[n][index]+A[index+3])
            if n==0 and index+4<N:
                dp[n+2][index+4]=max(dp[n+2][index+4],dp[n][index]+A[index+4])
            if index+2<N:
                dp[n][index+2]=max(dp[n][index+2],dp[n][index]+A[index+2])

a=(dp[0][-1])
b=(dp[1][-1])
c=(dp[2][-1])

print(max(a,b,c))


        


Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())

A=list(map(int,input().split()))

if N==2:
    print(max(0,A[0],A[1]))
    exit()
if N==3:
    print(max(0,A[0],A[1],A[2]))
    exit()

dp=[[-10**18 for i in range(N)] for j in range(3)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]

for n in range(3):
    for index in range(N):
        if dp[n][index]!=-1:
            if n!=2 and index+3<N:
                dp[n+1][index+3]=max(dp[n+1][index+3],dp[n][index]+A[index+3])
            if n==0 and index+4<N:
                dp[n+2][index+4]=max(dp[n+2][index+4],dp[n][index]+A[index+4])
            if index+2<N:
                dp[n][index+2]=max(dp[n][index+2],dp[n][index]+A[index+2])

a=(dp[0][-1])
b=(dp[1][-1])
c=(dp[2][-1])

print(max(a,b,c))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N=int(input())

A=list(map(int,input().split()))

dp=[[-10**9 for i in range(N)] for j in range(3)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]

for n in range(3):
    for index in range(N):
        if dp[n][index]!=-1:
            if n!=2 and index+3<N:
                dp[n+1][index+3]=max(dp[n+1][index+3],dp[n][index]+A[index+3])
            if n==0 and index+4<N:
                dp[n+2][index+4]=max(dp[n+2][index+4],dp[n][index]+A[index+4])
            if index+2<N:
                dp[n][index+2]=max(dp[n][index+2],dp[n][index]+A[index+2])

a=(dp[0][-1])
b=(dp[1][-1])
c=(dp[2][-1])

print(max(a,b,c))


        

Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())

A=list(map(int,input().split()))

if N==2:
    print(max(0,A[0],A[1]))
    exit()
if N==3:
    print(max(0,A[0],A[1],A[2]))
    exit()

dp=[[-10**18 for i in range(N)] for j in range(3)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]

for n in range(3):
    for index in range(N):
        if dp[n][index]!=-1:
            if n!=2 and index+3<N:
                dp[n+1][index+3]=max(dp[n+1][index+3],dp[n][index]+A[index+3])
            if n==0 and index+4<N:
                dp[n+2][index+4]=max(dp[n+2][index+4],dp[n][index]+A[index+4])
            if index+2<N:
                dp[n][index+2]=max(dp[n][index+2],dp[n][index]+A[index+2])

a=(dp[0][-1])
b=(dp[1][-1])
c=(dp[2][-1])

print(max(a,b,c))
Buggy python submission (verdict: Runtime Error):
%%time
import scipy.stats
from sklearn.datasets import load_breast_cancer
from sklearn.svm import LinearSVC
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import RandomizedSearchCV
from sklearn.model_selection import train_test_split
from sklearn.metrics import f1_score

import pandas as pd

#乳癌データの読み込み
df=pd.read_csv("ダミーデータ.csv",index_col=0)
X=df.iloc[:, 1:].values.tolist()
y=df["y"].values

print(X)

#条件設定
max_score = 0
SearchMethod = 0
LSVC_grid = {LinearSVC(): {"C": [10 ** i for i in range(-5, 6)],
                           "multi_class": ["ovr", "crammer_singer"],
                           "class_weight": ["balanced"],
                           "random_state": [i for i in range(0, 101)]}}
LSVC_random = {LinearSVC(): {"C": scipy.stats.uniform(0.00001, 1000),
                             "multi_class": ["ovr", "crammer_singer"],
                             "class_weight": ["balanced"],
                             "random_state": scipy.stats.randint(0, 100)}}

#トレーニングデータ、テストデータの分離
train_X, test_X, train_y, test_y = train_test_split(X, y, test_size=0.2, random_state=0)

#グリッドサーチ
for model, param in LSVC_grid.items():
    clf = GridSearchCV(model, param)
    clf.fit(train_X, train_y)
    pred_y = clf.predict(test_X)
    score = f1_score(test_y, pred_y, average="micro")

    if max_score < score:
        max_score = score
        best_param = clf.best_params_
        best_model = model.__class__.__name__

#ランダムサーチ
for model, param in LSVC_random.items():
    clf =RandomizedSearchCV(model, param)
    clf.fit(train_X, train_y)
    pred_y = clf.predict(test_X)
    score = f1_score(test_y, pred_y, average="micro")

    if max_score < score:
        SearchMethod = 1
        max_score = score
        best_param = clf.best_params_
        best_model = model.__class__.__name__

if SearchMethod == 0:
    print("サーチ方法:グリッドサーチ")
else:
    print("サーチ方法:ランダムサーチ")
print("ベストスコア:{}".format(max_score))
print("モデル:{}".format(best_model))
print("パラメーター:{}".format(best_param))

#ハイパーパラメータを調整しない場合との比較
model = LinearSVC()
model.fit(train_X, train_y)
score = model.score(test_X, test_y)
print("")
print("デフォルトスコア:", score)

Fixed submission:
# coding: utf-8
# Your code here!
X,Y,Z=map(int,input().split())

print(Z,X,Y)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

#保存
import heapq
import sys
import itertools
 
sys.setrecursionlimit(10**7)

def bfs(cost,node):
    root[node]=min(root[node],cost)
    visited[node]=1
    for next_n in way[node]:
        if visited[next_n]==0:
            heapq.heappush(q,[cost+1,next_n])
    return
    
N,X,Y=map(int,input().split())
r=[i for i in range(N)]

way=[[] for i in range(N)]

for i in range(N-1):
    way[i].append(i+1)
    way[i+1].append(i)

way[X-1].append(Y-1)
way[Y-1].append(X-1)

#print(way)

made=[]


#print(q)
for start in r:
    root=[10**9]*N
    visited=[0]*N
    #print(root)
    q=[[0,start]]
    heapq.heapify(q)#costとnode
    while q:
        temp=heapq.heappop(q)
        #print(temp)
        #print(temp)
        if visited[temp[1]]==0:
            bfs(temp[0],temp[1])
    made.append(root)
#print(made)

ans=[0]*(N)
for item in made:
    for num in item:
        ans[num]+=1

for a in ans[1:]:
    print(a//2)

"""
ans=10**9
for order in itertools.permutations([i for i in range(len(r))]):
    #print(order)
    temp=0
    for i in range(len(order)-1):
        fro=r[order[i]]
        aft=r[order[i+1]]
        #print("YES")
        #print(order[i]-1,order[i+1]-1)
        #print(root[order[i]-1][0])
        temp+=abs(made[order[i]][aft-1]-made[order[i]][fro-1])
    ans=min(ans,temp)
print(ans)
"""



Fixed submission:
# coding: utf-8
# Your code here!
N,X,Y=map(int,input().split())
X-=1
Y-=1

ans=[0]*N
for n in range(N-1):
    for tgt in range(n+1,N):
        temp=min(abs(tgt-n),abs(n-X)+abs(Y-tgt)+1)
        #print(n,tgt,temp)
        ans[temp]+=1


for a in ans[1:]:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
def saiki(num,lis):
    if num==H:
        cand.append(lis)
    else:
        saiki(num+1,lis+[lis[-1]])
        saiki(num+1,lis+[num])
#全探索
H,W,K=map(int,input().split())

S=[]
for h in range(H):
    s=list(input())
    S.append(list(map(int,s)))
        
cand=[]

saiki(1,[0])

ans=[]
for item in cand:
    temp=len(list(set(item)))-1
    wa=[[0]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            wa[item[i]][j]+=S[i][j]
    #クラスタを作っていきたい
    sam=[0]*H
    count=0
    for w in range(W):
        judge=False
        for h in range(H):
            if wa[h][w]>K:
                judge=True
            sam[h]+=wa[h][w]
            if w!=W-1:
                if sam[h]+wa[h][w+1]>K:
                    count+=1
                    for i in range(H):
                        
                        sam[i]=0
                    break
        if judge:
            count=10**9
            break
    """
    print("------------------")
    print(item)
    print(sam)
    """
    ans.append(temp+count)
    #print(wa)
print(min(ans))
#print(cand)
#print(S)

Fixed submission:
# coding: utf-8
# Your code here!
def saiki(num,lis):
    if num==H:
        cand.append(lis)
    else:
        saiki(num+1,lis+[lis[-1]])
        saiki(num+1,lis+[num])
#全探索
H,W,K=map(int,input().split())

S=[]
for h in range(H):
    s=list(input())
    S.append(list(map(int,s)))
        
cand=[]

saiki(1,[0])

ans=[]
for item in cand:
    temp=len(list(set(item)))-1
    wa=[[0]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            wa[item[i]][j]+=S[i][j]
    #クラスタを作っていきたい
    sam=[0]*H
    count=0
    for w in range(W):
        judge=False
        for h in range(H):
            if wa[h][w]>K:
                judge=True
            sam[h]+=wa[h][w]
            if w!=W-1:
                if sam[h]+wa[h][w+1]>K:
                    count+=1
                    for i in range(H):
                        
                        sam[i]=0
                    break
        if judge:
            count=10**9
            break
    """
    print("------------------")
    print(item)
    print(sam)
    """
    ans.append(temp+count)
    #print(wa)
print(min(ans))
#print(cand)
#print(S)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

# coding: utf-8 
# Your code here! 
H,W=map(int,input().split()) 
S=[] 

for _ in range(H):
    S.append(list(input()))


def dfs(h,w,num):
    if h==H-1 and w==W-1:
        ans.append(num)
    
    if h!=H-1: 
        if S[h+1][w]=="#": 
            dfs(h+1,w,num+1)
        else:
            dfs(h+1,w,num)

    if w!=W-1: 
        if S[h][w+1]=="#": 
            dfs(h,w+1,num+1)
        else:
            dfs(h,w+1,num)

ans=[]
dfs(0,0,1) if S[0][0]=="#" else dfs(0,0,0)

print(min(ans))



Fixed submission:
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

meizu=[]
for _ in range(H):
    meizu.append(list(input()))

dp=[[10**9 for w in range(W)] for h in range(H)]
dp[0][0]=1 if meizu[0][0]=="#" else 0

for h in range(H):
    for w in range(W):
        if h!=H-1:
            dp[h+1][w]=min(dp[h+1][w],dp[h][w]+1 if meizu[h+1][w]=="#" and meizu[h][w]=="." else dp[h][w])
        if w!=W-1:
            dp[h][w+1]=min(dp[h][w+1],dp[h][w]+1 if meizu[h][w+1]=="#" and meizu[h][w]=="." else dp[h][w])
    
print(dp[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

# coding: utf-8 
# Your code here! 
H,W=map(int,input().split()) 
S=[] 

for _ in range(H):
    S.append(list(input()))


def dfs(h,w,num):
    if h==H-1 and w==W-1:
        ans.append(num)
    
    if h!=H-1: 
        if S[h+1][w]=="#": 
            dfs(h+1,w,num+1)
        else:
            dfs(h+1,w,num)

    if w!=W-1: 
        if S[h][w+1]=="#": 
            dfs(h,w+1,num+1)
        else:
            dfs(h,w+1,num)

ans=[]
dfs(0,0,1) if S[0][0]=="#" else dfs(0,0,0)

print(min(ans))



Fixed submission:
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

meizu=[]
for _ in range(H):
    meizu.append(list(input()))

dp=[[10**9 for w in range(W)] for h in range(H)]
dp[0][0]=1 if meizu[0][0]=="#" else 0

for h in range(H):
    for w in range(W):
        if h!=H-1:
            dp[h+1][w]=min(dp[h+1][w],dp[h][w]+1 if meizu[h+1][w]=="#" and meizu[h][w]=="." else dp[h][w])
        if w!=W-1:
            dp[h][w+1]=min(dp[h][w+1],dp[h][w]+1 if meizu[h][w+1]=="#" and meizu[h][w]=="." else dp[h][w])
    
print(dp[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
S=(input())

Q=int(input())

for _ in range(Q):
    temp=list(input().split())
    if len(temp)==1:
        S=S[::-1]
    else:
        if temp[1]=="1":
            S=temp[2]+S
        else:
            S=S+temp[2]
            
print(S)

Fixed submission:
# coding: utf-8
# Your code here!
from collections import deque
S=list(input())
Q=int(input())
r=0

d=deque(S)

for _ in range(Q):
    temp=list(input().split())
    if len(temp)==1:
        r^=1
    else:
        if r==0:
            if temp[1]=="1":
                d.appendleft(temp[2])
            else:
                d.append(temp[2])
        else:
            if temp[1]=="1":
                d.append(temp[2])
            else:
                d.appendleft(temp[2])
ans=list(d)
print("".join(ans) if r==0 else "".join(ans[::-1]))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
H,N=map(int,input().split())

cost=[]
for _ in range(N):
    A,B=map(int,input().split())
    cost.append([A/B,A,B])
"""
mx=0
mi=10**12
ind=-1
for index,item in enumerate(cost):
    mx=max(mx,item[0])
    if mx==item[0] and mi>item[1]:
        ind=index

ans=0
temp=cost[ind][1]
ans+=H//(temp)*cost[ind][2]

H-=temp*(H//temp-1)
"""

dp=[10**12]*H
dp[0]=0
sans=10**12
for item in cost:
    for i in range(len(dp)):
        if dp[i]!=10**12:
            if i+item[1]>=H:
                sans=min(sans,dp[i]+item[2])
            else:
                dp[i+item[1]]=min(item[2]+dp[i],dp[i+item[1]])
    
print(sans)
    



Fixed submission:
# coding: utf-8
# Your code here!
H,N=map(int,input().split())

cost=[]
for _ in range(N):
    A,B=map(int,input().split())
    cost.append([A/B,A,B])
"""
mx=0
mi=10**12
ind=-1
for index,item in enumerate(cost):
    mx=max(mx,item[0])
    if mx==item[0] and mi>item[1]:
        ind=index

ans=0
temp=cost[ind][1]
ans+=H//(temp)*cost[ind][2]

H-=temp*(H//temp-1)
"""

dp=[10**12]*H
dp[0]=0
sans=10**12
for item in cost:
    for i in range(len(dp)):
        if dp[i]!=10**12:
            if i+item[1]>=H:
                sans=min(sans,dp[i]+item[2])
            else:
                dp[i+item[1]]=min(item[2]+dp[i],dp[i+item[1]])
    
print(sans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
from math import gcd
 
N,M=map(int,input().split())

A=list(map(int,input().split()))

if N==1:
    print(0)
    exit()

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//gcd(A[i],A[i+1])

#print(A[-1])
if A[-1]%2==1 or (A[-1]//2)%2==0:
    print(0)
else:
    print((M-A[-1]//2)//A[-1]+1)

Fixed submission:
# coding: utf-8
# Your code here!
import fractions

N,M=map(int,input().split())
A=list(map(int,input().split()))

have2=[0]*len(A)

for index,item in enumerate(A):
    while item%2==0:
        item/=2
        have2[index]+=1

if len(list(set(have2)))!=1:
    print(0)
    exit()

f=0
f2=1
for item in A:
    f=fractions.gcd(f2,item)
    f2=f2*item//f
if M>=f2//2:
    M-=f2//2
    print(max(M//f2+1,0))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
from math import gcd
 
N,M=map(int,input().split())

A=list(map(int,input().split()))


for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//gcd(A[i],A[i+1])

#print(A[-1])
if A[-1]%2==1 or (A[-1]//2)%2==0:
    print(0)
else:
    print((M-A[-1]//2)//A[-1]+1)

Fixed submission:
# coding: utf-8
# Your code here!
import fractions

N,M=map(int,input().split())
A=list(map(int,input().split()))

have2=[0]*len(A)

for index,item in enumerate(A):
    while item%2==0:
        item/=2
        have2[index]+=1

if len(list(set(have2)))!=1:
    print(0)
    exit()

f=0
f2=1
for item in A:
    f=fractions.gcd(f2,item)
    f2=f2*item//f
if M>=f2//2:
    M-=f2//2
    print(max(M//f2+1,0))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import fractions

N,M=map(int,input().split())

A=list(map(int,input().split()))

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//(fractions.gcd(A[i],A[i+1]))
    B=[A[-1]//2]


if M<B[-1]:
    print(0)
else:
    print((M-B[-1])//A[-1]+1)




Fixed submission:
# coding: utf-8
# Your code here!
import fractions

N,M=map(int,input().split())
A=list(map(int,input().split()))

have2=[0]*len(A)

for index,item in enumerate(A):
    while item%2==0:
        item/=2
        have2[index]+=1

if len(list(set(have2)))!=1:
    print(0)
    exit()

f=0
f2=1
for item in A:
    f=fractions.gcd(f2,item)
    f2=f2*item//f
if M>=f2//2:
    M-=f2//2
    print(max(M//f2+1,0))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
A,B=map(int,input().split())

print(A*B//math.gcd(A,B))

Fixed submission:
# coding: utf-8
# Your code here!
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    

A,B=map(int,input().split())

print(A*B//gcd(A,B))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N=int(input())

A=list(map(int,input().split()))

two=[2**i for i in range(61)]
two=two[::-1]
log=[0]*61

for i in range(len(A)):
    for j in range(len(two)):
        if A[i]-two[j]>=0:
            A[i]-=two[j]
            log[j]+=1

ans=0
for i in range(len(two)):
    ans+=(N-log[i])*log[i]*two[i]

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


Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())

A=list(map(int,input().split()))

two=[2**i for i in range(61)]
two=two[::-1]
log=[0]*61

for i in range(len(A)):
    for j in range(len(two)):
        if A[i]-two[j]>=0:
            A[i]-=two[j]
            log[j]+=1

ans=0
for i in range(len(two)):
    ans+=(N-log[i])*log[i]*two[i]

print(ans%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N,T=map(int,input().split())

l=[]
for _ in range(N):
    a,b=map(int,input().split())
    l.append([a,b])

l.sort()

dp=[-1]*(6001)
dp[0]=0

for cand in l:
    for i in range(T)[::-1]:
        if dp[i]!=-1:
            dp[i+cand[0]]=max(dp[i+cand[0]],dp[i]+cand[1])
print(max(dp))



Fixed submission:
# coding: utf-8
# Your code here!
N,T=map(int,input().split())

l=[]
for _ in range(N):
    a,b=map(int,input().split())
    l.append([a,b])

l.sort()

dp=[-1]*(6001)
dp[0]=0

for cand in l:
    for i in range(T)[::-1]:
        if dp[i]!=-1:
            dp[i+cand[0]]=max(dp[i+cand[0]],dp[i]+cand[1])
print(max(dp))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N=int(input())
l=list(map(int,input().split()))

if temp[0]==0:
    print(0)
    exit()

ans=1
for i in range(2,len(temp)):
    #print(ans)
    ans=ans*temp[i-1]**temp[i]
print(ans)



Fixed submission:
N=int(input())
D=list(map(int,input().split()))
layer=[0]*N

mx=0
for item in D:
    layer[item]+=1
    mx=max(mx,item)

if layer[0]!=1 or D[0]!=0:
    print(0)
    exit()

ans=1
for i in range(mx):
    ans*=(layer[i]**layer[i+1])

print(ans%998244353)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
S=list(input())

nums=[1 if S[0]=="<" else -1]
for i in range(len(S)-1):
    if S[i+1]==S[i]:
        if S[i+1]=="<":
            nums[-1]+=1
        else:
            nums[-1]-=1
    else:
        if S[i+1]=="<":
            nums.append(1)
        else:
            nums.append(-1)

ans=0
if nums[0]<0:
    are=nums.pop(0)
    ans+=are*(are+1)//2
if nums[-1]>0:
    are=nums.pop(-1)
    ans+=are*(are+1)//2

temp=list(map(lambda x:abs(x)-1,nums))
temp=list(map(lambda x:x*(x+1)//2,temp))

ans+=sum(temp)
#print(ans)
for i in range(len(nums)-1):
    if nums[i]>0:
        ans+=max(nums[i],-nums[i+1])
#print(nums)
print(ans)


Fixed submission:
# coding: utf-8
# Your code here!
S=list(input())

nums=[1 if S[0]=="<" else -1]
for i in range(len(S)-1):
    if S[i+1]==S[i]:
        if S[i+1]=="<":
            nums[-1]+=1
        else:
            nums[-1]-=1
    else:
        if S[i+1]=="<":
            nums.append(1)
        else:
            nums.append(-1)

ans=0
if nums[0]<0:
    are=-nums.pop(0)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()
if nums[-1]>0:
    are=nums.pop(-1)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()

temp=list(map(lambda x:abs(x)-1,nums))
temp=list(map(lambda x:x*(x+1)//2,temp))

#print(temp)
ans+=sum(temp)
#print(ans)
for i in range(len(nums)-1):
    if nums[i]>0:
        ans+=max(nums[i],-nums[i+1])

print(ans)