Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
a=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163]

def factorization(n):
    temp=n
    i=0
    icnt=1
    while temp>1 and i<len(a):
        if temp%a[i]==0:
            cnt=0
            while temp%a[i]==0:
                cnt+=1
                temp //= a[i]
            icnt=icnt*(cnt+1)
        i+=1

    if temp!=1:
        icnt=icnt*2
    if icnt==1:
        icnt=icnt*2

    return icnt

n=int(input())
isum=1
for ii in range(2,n+1):
    icnt=1
    isum+=ii*factorization(ii)

print(isum)


Fixed submission:
n=int(input())
#n=10000000
ksum=0
for k in range(1,n+1):
    m=n//k
    ksum+=k*m*(m+1)//2
    
print(ksum)
Buggy python submission (verdict: Runtime Error):

n=int(input())

a="abcdefghijklmnopqrstuvwxyz"
aa=list(a)

stra=""
kk=n
for i in range(15):
    ki=kk%26
    if ki!=0:
        stra=aa[ki-1]+stra    
    else:
        stra=aa[26]+stra    
    kk=(kk-ki)//26
#    print(kk,ki,stra)
    if kk==0:
        break
    
print(stra)

Fixed submission:
n=int(input())

a="abcdefghijklmnopqrstuvwxyz"
aa=list(a)

stra=""
kk=n
for i in range(15):
    ki=(kk-1)%26+1
    if ki!=0:
        stra=aa[ki-1]+stra    
    else:
        stra=aa[25]+stra    
    kk=(kk-ki)//26
#    print(kk,ki,stra)
    if kk==0:
        break
    
print(stra)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

def mp(a):
    b=[]
    if len(a)%2==0:
        for i in range(0,len(a),2):
            b.append(a[i]*a[i+1]) 
    else:
        for i in range(0,len(a),2):
            b.append(a[i]*a[i+1]) 
        b.append(a[len(a)//2+1]) 
    return b

b=a.copy()
while len(b)<=1:
    b=mp(b)   
    
if ap<=10**18:
    print(ap)
else:
    print(-1)

    

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

def mp(a):
    b=[]
    if len(a)==1:
        b.append(a[0]) 
    elif len(a)%2==0:
        for i in range(0,len(a),2):
            b.append(a[i]*a[i+1]) 
    else:
        for i in range(0,len(a)-1,2):
#            print(i)
            b.append(a[i]*a[i+1]) 
#        print("1",a[len(a)//2+1])
        b.append(a[len(a)-1]) 
    return b

c=aa.copy()
while len(c)>1:
    c=mp(c)   
#    print(c)
    
if c[0]<=10**18:
    print(c[0])
else:
    print(-1)

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

ap=a[0]
for i in range(1,n):
    ap=ap*a[i]
    
if ap<=10**18:
    print(ap)
else:
    print(-1)


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

def mp(a):
    b=[]
    if len(a)==1:
        b.append(a[0]) 
    elif len(a)%2==0:
        for i in range(0,len(a),2):
            b.append(a[i]*a[i+1]) 
    else:
        for i in range(0,len(a)-1,2):
#            print(i)
            b.append(a[i]*a[i+1]) 
#        print("1",a[len(a)//2+1])
        b.append(a[len(a)-1]) 
    return b

c=aa.copy()
while len(c)>1:
    c=mp(c)   
#    print(c)
    
if c[0]<=10**18:
    print(c[0])
else:
    print(-1)

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

ap=a[0]
for i in range(1,n):
    ap=ap*a[i]
    
if ap<=10**18:
    print(ap)
else:
    print(-1)

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

def mp(a):
    b=[]
    if len(a)==1:
        b.append(a[0]) 
    elif len(a)%2==0:
        for i in range(0,len(a),2):
            b.append(a[i]*a[i+1]) 
    else:
        for i in range(0,len(a)-1,2):
#            print(i)
            b.append(a[i]*a[i+1]) 
#        print("1",a[len(a)//2+1])
        b.append(a[len(a)-1]) 
    return b

c=aa.copy()
while len(c)>1:
    c=mp(c)   
#    print(c)
    
if c[0]<=10**18:
    print(c[0])
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
import sympy

n=int(input())

arr2=sympy.factorint(n)

def cnt(nn):
    if nn<3:
        return 1
    elif nn<6:
        return 2
    elif nn<10:
        return 3
    elif nn<15:
        return 4
    elif nn<21:
        return 5
    elif nn<28:
        return 6
    elif nn<36:
        return 7
    elif nn<45:
        return 8
    elif nn<55:
        return 9
    else:
        return 10
icnt=0
for i in arr2.keys():
    icnt=icnt+cnt(arr2[i])

if n==1:
    print(0)
else:
    print(icnt)


Fixed submission:

n=int(input())

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

arr2=[]
arr2=factorization(n)

def cnt(nn):
    if nn<3:
        return 1
    elif nn<6:
        return 2
    elif nn<10:
        return 3
    elif nn<15:
        return 4
    elif nn<21:
        return 5
    elif nn<28:
        return 6
    elif nn<36:
        return 7
    elif nn<45:
        return 8
    elif nn<55:
        return 9
    else:
        return 10
icnt=0
for i in range(len(arr2)):
    icnt=icnt+cnt(arr2[i][1])

if n==1:
    print(0)
else:
    print(icnt)
Buggy python submission (verdict: Time Limit Exceeded):

n=int(input())
a=list(map(int,input().split()))

icnt=0
for i in range(n):
    for j in range(i+1,n):
        if j-i==a[j]+a[i]:
            icnt+=1
            
print(icnt)


Fixed submission:

n=int(input())
a=list(map(int,input().split()))

#icnt=0
#for i in range(n):
#    for j in range(i+1,n):
#        if j-i==a[j]+a[i]:
#            icnt+=1

ip=[0]*n
jm=dict()
for i in range(n):
    ip[i]=i+a[i]
    if i-a[i] in jm:
        jm[i-a[i]]+=1
    else:
        jm[i-a[i]]=1

icnt=0
for i in range(n):
    if ip[i] in jm:
        icnt+=jm[ip[i]]
            
print(icnt)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())

nb=n//b

xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
    for xb in range(nb):
        xv=(a*xb*b+a*(b-1))//b-a*xb
        xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n%b)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)    


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

nb=n//b

#xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
#    for xb in range(nb):
#        xv=(a*xb*b+a*(b-1))//b-a*xb
#        xmax=max(xmax,xv)
    xb=nb-1
    xv=(a*xb*b+a*(b-1))//b-a*xb
    xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n%b)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)

Buggy python submission (verdict: Time Limit Exceeded):

a,b,n=map(int,input().split())

nb=n//b

xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
    for xb in range(nb):
        xv=(a*xb*b+a*(b-1))//b-a*xb
        xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n%b)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)    



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

nb=n//b

#xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
#    for xb in range(nb):
#        xv=(a*xb*b+a*(b-1))//b-a*xb
#        xmax=max(xmax,xv)
    xb=nb-1
    xv=(a*xb*b+a*(b-1))//b-a*xb
    xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n%b)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)
Buggy python submission (verdict: Time Limit Exceeded):

s=input()

mod=2019
tc=[0]*2019

lens=len(s)
#tim=int(s[lens-1])
#tc[tim]+=1
#for i in range(len(s)-1,-1,-1):
#    print(i,(10*tim+int(s[i]))%mod)    
#    ti=(10*tim+int(s[i]))%mod
#    tc[ti]+=1
#    tim=ti

tc[0]=1
for i in range(len(s)-1,-1,-1):
    ti=int(s[i:lens])%mod
    tc[ti]+=1
#    print(i,s[i:lens],ti,tc[ti])    
    
tsum=0
for i in tc:
    tsum+=(i*(i-1))//2
    
print(tsum)


Fixed submission:
s=input()

mod=2019
tc=[0]*2019

lens=len(s)

tc[0]=1
tim=0
p10=1
for i in range(len(s)-1,-1,-1):
    ti=(tim+int(s[i])*p10)%mod
    tc[ti]+=1
#    print(i,(10*tim+int(s[i]))%mod,ti,tc[ti])    
    tim=ti
    p10=p10*10%mod

#tc[0]=1
#for i in range(len(s)-1,-1,-1):
#    ti=int(s[i:lens])%mod
#    tc[ti]+=1
#    print(i,s[i:lens],ti,tc[ti])    
    
tsum=0
for i in tc:
    tsum+=(i*(i-1))//2
    
print(tsum)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())

dp=[[[0]*2 for i in range(n+1)] for ii in range(n+1)]

dp[0][0][0]=0
dp[0][0][1]=0
dp[1][0][0]=0
dp[1][0][1]=1
dp[1][1][0]=1
dp[1][1][1]=1

mod=10**9+7
for nn in range(2,n+1):
    dp[nn][0][0]=0
    dp[nn][0][1]=nn
    for kk in range(1,nn):
        dp[nn][kk][0]=dp[nn-1][kk][0]
        dp[nn][kk][1]=(dp[nn-1][kk-1][1]+nn)%mod
    dp[nn][nn][0]=(dp[nn-1][nn-1][0]+nn)%mod
    dp[nn][nn][1]=(dp[nn-1][nn-1][1]+nn)%mod
ksum=0
for kk in range(k-1,n+1):
    ksum=ksum+(dp[n][kk][1]-dp[n][kk][0]+1)%mod
print(ksum)

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

dp=[[0]*2 for i in range(n+1)] 
mod=10**9+7

dp[0][0]=0
dp[0][1]=n
for i in range(n):
    dp[i+1][0]=(dp[i][0]+(i+1))%mod
dp[n][1]=dp[n][0]
for i in range(n-1,0,-1):
    dp[i][1]=(dp[i+1][1]-(n-1-i))%mod

mod=10**9+7

ksum=0
for kk in range(k-1,n+1):
    ksum=(ksum+dp[kk][1]-dp[kk][0]+1)%mod
print(ksum)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())

rev=1
for i in range(q):
    qu=input()
    if qu=="1":
        rev=-rev
    else:
        t,f,c=qu.split()
        if f=="1" and rev==1:
            s=c+s
#            print(s)
        elif f=="2" and rev==1:
            s=s+c
#            print(s)
        elif f=="1" and rev==-1:
            s=s+c
#            print(s)
        elif f=="2" and rev==-1:
            s=c+s
#            print(s)
if rev==-1:
    s=s[::-1]
#    print(s)
print(s)       

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

sb=""
sa=""
rev=1
for i in range(q):
    qu=input()
    if qu=="1":
        rev=-rev
    else:
        t,f,c=qu.split()
        if f=="1" and rev==1:
#            s=c+s
            sb=c+sb
#            print(s)
        elif f=="2" and rev==1:
#            s=s+c
            sa=sa+c
#            print(s)
        elif f=="1" and rev==-1:
#            s=s+c
            sa=sa+c
#            print(s)
        elif f=="2" and rev==-1:
#            s=c+s
            sb=c+sb
#            print(s)
s=sb+s+sa
if rev==-1:
    s=s[::-1]
#    print(s)
print(s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[]
for i in range(n):
    s.append(input())

#n=7
#s.append("beat")
#s.append("vet")
#s.append("beet")
#s.append("bed")
#s.append("vet")
#s.append("bet")
#s.append("beet")

s.sort()

t=[]
icnt=0
t.append([1,s[0]])
for i in range(1,len(s)):
    if s[i-1]==s[i]:
        t[icnt][0]=t[icnt][0]+1
    else:
        icnt=icnt+1
        t.append([1,s[i]])
        
#print(t)
t.sort(reverse=True)
#print(t)

u=[]
u.append(t[0][1])
for i in range(len(t)):
    if t[i][0]==t[i+1][0]:
        u.append(t[i+1][1])
    else:
        break
    
u.sort()

for i in range(len(u)):
    print(u[i])

Fixed submission:
n=int(input())
s=[]
for i in range(n):
    s.append(input())

s.sort()

t=[]
icnt=0
t.append([1,s[0]])
for i in range(1,len(s)):
    if s[i-1]==s[i]:
        t[icnt][0]=t[icnt][0]+1
    else:
        icnt=icnt+1
        t.append([1,s[i]])
        
#print(t)
t.sort(reverse=True)
#print(t)

u=[]
u.append(t[0][1])
for i in range(len(t)-1):
    if t[i][0]==t[i+1][0]:
        u.append(t[i+1][1])
    else:
        break

if len(u)==0:
    print(u[0])    
else:
    u.sort()
    for i in range(len(u)):
        print(u[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
pi=list(map(int,input().split()))

pmax=0
for i in range(n-k+1):
    psum=sum(pi[i:i+k])
    if psum>pmax:
        pmax=psum
px=(k+pmax)/2
print(px)   

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

pmax=sum(pi[0:k])
#print(pmax)
psum=pmax
for i in range(1,n-k+1):
    psum=psum-pi[i-1]+pi[i+k-1]
#    print(i,k,psum)
    if psum>pmax:
        pmax=psum
px=(k+pmax)/2
print(px)
Buggy python submission (verdict: Time Limit Exceeded):
def sigma(n,i,j):
    icnt=0
    stri=str(i)
    strj=str(j)
    for k in range(n):
        strk=str(k+1)
        if strk[0]==stri and strk[-1]==strj:
            icnt=icnt+1
    return icnt
            

n=int(input())
ncnt=0
for k in range(10):
    for m in range(10):
        s1=sigma(n,k,m)
        s2=sigma(n,m,k)
        ncnt=ncnt+s1*s2
print(ncnt)     

Fixed submission:
def sigma2(n,i,j):
    if i==j and n<i:
        ncnt= 0
    elif i==j and i<=n:
        ncnt=1
    else:
        ncnt=0    

    if i*10+j<=n:
        ncnt=ncnt+1
        
    mcnt=-1
    nn=0
    for kt in range(1,6,1):
       for kt2 in range(10**kt):
           mcnt=mcnt+1
           nn=i*10**(kt+1)+kt2*10+j
           if nn>n:
               break
       if nn>n:
           break
               
    return mcnt+ncnt                


n=int(input())
ncnt=0
for k in range(1,10,1):
    for m in range(1,10,1):
        s1=sigma2(n,k,m)
        s2=sigma2(n,m,k)
        ncnt=ncnt+s1*s2
#        if s1*s2>0:
#            print(k,m,s1,s2)
print(ncnt)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)

N,M=map(int,input().split())
    
ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[iii]==True:
        Wsum=Wsum+WACNT[iii]

print(Asum,Wsum)


Fixed submission:
N,M=map(int,input().split())
    
if M==0 :
    print(0,0)
    exit()

ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[i]==True:
        Wsum=Wsum+WACNT[i]

print(Asum,Wsum)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N,M=map(int,input().split())
    
ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[iii]==True:
        Wsum=Wsum+WACNT[iii]

print(Asum,Wsum)


Fixed submission:
N,M=map(int,input().split())
    
if M==0 :
    print(0,0)
    exit()

ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[i]==True:
        Wsum=Wsum+WACNT[i]

print(Asum,Wsum)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
    
ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[iii]==True:
        Wsum=Wsum+WACNT[iii]

print(Asum,Wsum)

Fixed submission:
N,M=map(int,input().split())
    
if M==0 :
    print(0,0)
    exit()

ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[i]==True:
        Wsum=Wsum+WACNT[i]

print(Asum,Wsum)
Buggy python submission (verdict: Time Limit Exceeded):
inf=float("inf")  


h,w=map(int,input().split())
s=[["#"]*(w+2) for i in range(h+2)]
for i in range(h):
    s[i+1]=["#"]+list(input())+["#"]

#h,w=3,5
#s=[['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]    

nv=h*w
dp=[[inf]*nv for i in range(nv)] 

def nhw(hi,wi):
    return (hi-1)*w+wi-1

for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=="#":
            continue
        vij=nhw(i,j)
        if s[i-1][j]==".":
            vij2=nhw(i-1,j)
            dp[vij][vij2]=1
            dp[vij2][vij]=1
        if s[i+1][j]==".":
            vij2=nhw(i+1,j)
            dp[vij][vij2]=1
            dp[vij2][vij]=1
        if s[i][j-1]==".":
            vij2=nhw(i,j-1)
            dp[vij][vij2]=1
            dp[vij2][vij]=1
        if s[i][j+1]==".":
            vij2=nhw(i,j+1)
            dp[vij][vij2]=1
            dp[vij2][vij]=1
for i in range(nv):
    dp[i][i]=0
           
#print(dp)
for k in range(nv):
    for i in range(nv):
        for j in range(nv):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
#    print(dp)
#print(dp)
dpmax=0
for i in range(nv):
    for j in range(nv):
        if dp[i][j]!=inf:
            if dpmax<dp[i][j]:
                dpmax=dp[i][j]
print(dpmax)

Fixed submission:
inf=float("inf")  


h,w=map(int,input().split())
s=[["#"]*(w+2) for i in range(h+2)]
for i in range(h):
    s[i+1]=["#"]+list(input())+["#"]

#h,w=3,5
#s=[['#', '#', '#', '#', '#', '#', '#'], ['#', '.', '.', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '.', '.', '#'], ['#', '#', '#', '#', '#', '#', '#']]    

nv=h*w
dp=[[inf]*nv for i in range(nv)] 

def nhw(hi,wi):
    return (hi-1)*w+wi-1

for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=="#":
            continue
        vij=nhw(i,j)
        if s[i-1][j]==".":
            vij2=nhw(i-1,j)
            dp[vij][vij2]=1
            dp[vij2][vij]=1
        if s[i+1][j]==".":
            vij2=nhw(i+1,j)
            dp[vij][vij2]=1
            dp[vij2][vij]=1
        if s[i][j-1]==".":
            vij2=nhw(i,j-1)
            dp[vij][vij2]=1
            dp[vij2][vij]=1
        if s[i][j+1]==".":
            vij2=nhw(i,j+1)
            dp[vij][vij2]=1
            dp[vij2][vij]=1
for i in range(nv):
    dp[i][i]=0
           
#print(dp)
for k in range(nv):
    for i in range(nv):
        for j in range(nv):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
#    print(dp)
#print(dp)
dpmax=0
for i in range(nv):
    for j in range(nv):
        if dp[i][j]!=inf:
            if dpmax<dp[i][j]:
                dpmax=dp[i][j]
print(dpmax)
Buggy python submission (verdict: Runtime Error):
icase=0
if icase==0:
    a=input()
    b=input()
    print(6-a-b)
        

Fixed submission:
icase=0
if icase==0:
    a=int(input())
    b=int(input())
    print(6-a-b)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

#n=10
#a=[3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a=[3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

mod=10**9+7
asum=0
for i in range(60):
    zcnt=0
    for ii in range(n):
        asht=a[ii]>>i
        if asht&1==0:
            zcnt+=1
    tmp=(zcnt*(n-zcnt))%mod*((2**i)%mod)
    asum+=(tmp)%mod
               
asum=asum%mod
print(asum)


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

#n=10
#a=[3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a=[3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

mod=10**9+7
asum=0
for i in range(60):
    zcnt=0
    for ii in range(n):
        asht=a[ii]>>i
        if asht&1==0:
            zcnt+=1
    tmp=(zcnt*(n-zcnt))%mod*((2**i)%mod)
    asum+=(tmp)%mod
               
asum=asum%mod
print(asum)

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

mod=10**9+7
asum=0
for i in range(n-1):
    for j in range(i+1,n):
        asum+=(a[i]^a[j])%mod

asum=asum%mod
print(asum)


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

#n=10
#a=[3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a=[3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

mod=10**9+7
asum=0
for i in range(60):
    zcnt=0
    for ii in range(n):
        asht=a[ii]>>i
        if asht&1==0:
            zcnt+=1
    tmp=(zcnt*(n-zcnt))%mod*((2**i)%mod)
    asum+=(tmp)%mod
               
asum=asum%mod
print(asum)