Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
import networkx as nx
def resolve():
    m, n = map(int, input().split())
    # row = 0, ..., m - 1, col = m, ..., m + n - 1, source = m + n, terminartion = m + n + 1
    G = nx.Graph()
    G.add_nodes_from(range(m + n + 2))
    grid = [input() for _ in range(m)]
    for i in range(m):
        for j in range(n):
            if grid[i][j] == 'S':
                si, sj = i, j
            elif grid[i][j] == 'T':
                ti, tj = i, j

    G.add_edge(m + n, si, capacity = INF)
    G.add_edge(m + n, m + sj, capacity = INF)
    G.add_edge(ti, m + n + 1, capacity = INF)
    G.add_edge(m + tj, m + n + 1, capacity = INF)
    for i in range(m):
        for j in range(n):
            if grid[i][j] == '.':
                continue
            for nj in range(n):
                if grid[i][nj] != '.':
                    G.add_edge(i, m + nj, capacity = 1)
            for ni in range(m):
                if grid[ni][j] != '.':
                    G.add_edge(ni, m + j, capacity = 1)

    ans = nx.algorithms.flow.maximum_flow_value(G, m + n, m + n + 1)
    if ans >= INF:
        ans = -1
    print(ans)
resolve()

Fixed submission:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
import networkx as nx
def resolve():
    m, n = map(int, input().split())
    # source = -1, row = 0, ..., m - 1, col = m, ..., m + n - 1, terminartion = m + n
    G = nx.Graph()
    G.add_nodes_from(range(m + n + 2))
    for i in range(m):
        for j, c in enumerate(input()):
            if c == '.':
                continue
            elif c == 'o':
                G.add_edge(i, m + j, capacity = 1)
            elif c == 'S':
                G.add_edge(-1, i, capacity = INF)
                G.add_edge(-1, m + j, capacity = INF)
            elif c == 'T':
                G.add_edge(i, m + n, capacity = INF)
                G.add_edge(m + j, m + n, capacity = INF)

    ans = nx.algorithms.flow.maximum_flow_value(G, -1, m + n)
    if ans >= INF:
        ans = -1
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
from collections import deque
def resolve():
    h,w,k=map(int,input().split())
    G=[list(input()) for _ in range(h)]
    D=[(1,0),(-1,0),(0,1),(0,-1)]
    for i,j in product(range(h),range(w)):
        if(G[i][j]=='S'):
            i0,j0=i,j
            break

    dist=[[INF]*w for _ in range(h)]
    dist[i0][j0]=0
    # BFS
    Q=deque([(i0,j0)])
    while(Q):
        i,j=Q.popleft()
        for di,dj in D:
            ni=i+di; nj=j+dj
            if(not (0<=ni<h and 0<=nj<w)): continue
            if(dist[ni][nj]!=INF or G[ni][nj]=='#'): continue
            dist[ni][nj]=dist[i][j]+1
            Q.append((ni,nj))

    print(dist)

    後は距離が k 以下の点から一直線に外に向かえばよい
    ans=INF
    for i,j in product(range(h),range(w)):
        if(dist[i][j]<=k):
            d=min(i,j,h-i-1,w-j-1)
            if(d==0):
                print(1)
                return
            else:
                ans=min(ans,2+(d-1)//k)
    print(ans)
resolve()

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
from collections import deque
def resolve():
    h,w,k=map(int,input().split())
    G=[list(input()) for _ in range(h)]
    D=[(1,0),(-1,0),(0,1),(0,-1)]
    for i,j in product(range(h),range(w)):
        if(G[i][j]=='S'):
            i0,j0=i,j
            break

    dist=[[INF]*w for _ in range(h)]
    dist[i0][j0]=0
    # BFS
    Q=deque([(i0,j0)])
    while(Q):
        i,j=Q.popleft()
        for di,dj in D:
            ni=i+di; nj=j+dj
            if(not (0<=ni<h and 0<=nj<w)): continue
            if(dist[ni][nj]!=INF or G[ni][nj]=='#'): continue
            dist[ni][nj]=dist[i][j]+1
            Q.append((ni,nj))

    # 後は距離が k 以下の点から一直線に外に向かえばよい
    ans=INF
    for i,j in product(range(h),range(w)):
        if(dist[i][j]<=k):
            d=min(i,j,h-i-1,w-j-1)
            if(d==0):
                print(1)
                return
            else:
                ans=min(ans,2+(d-1)//k)
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
import math
a,b,c = map(int,input().split())
print("YES") if c%math.gcd(a,b)==0 else print("NO")

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

a,b,c = map(int,input().split())
print("YES") if c%gcd(a,b)==0 else print("NO")
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print("GREATER") if a>b else print("LESS") if a<b else print("EQUAL")

Fixed submission:
a,b = [int(input()) for _ in range(2)]
print("GREATER") if a>b else print("LESS") if a<b else print("EQUAL")
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from statistics import median
def median_pyramid(p):
    N=len(p)
    assert(N&1)
    while(N!=1):
        p=[median((p[i],p[i+1],p[i+2])) for i in range(N-2)]
        N-=2
    return p[0]

def resolve():
    n,x=map(int,input().split())
    if(x!=1 and x!=2*n-1):
        print("Yes")
    else:
        print("No")
        return

    if(n==1):
        print(1,2,3)
        return

    if(x!=2):
        ans=[i for i in range(1,2*n) if(i not in [x-2,x-1,x,x+1])]
        ans=ans[:n-2]+[x-2,x,x+1,x-1]+ans[n-2:]
        print(*ans)
    else:
        ans=[i for i in range(5,2*n)]
        ans=ans[:n-2]+[1,2,4,3]+ans[n-2:]
        print(*ans)
resolve()

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

def resolve():
    n,x=map(int,input().split())
    if(x!=1 and x!=2*n-1):
        print("Yes")
    else:
        print("No")
        return

    if(n==2):
        print(1,2,3)
        return

    if(x!=2):
        ans=[i for i in range(1,2*n) if(i not in [x-2,x-1,x,x+1])]
        ans=ans[:n-2]+[x-2,x,x+1,x-1]+ans[n-2:]
        print(*ans)
    else:
        ans=[i for i in range(5,2*n)]
        ans=ans[:n-2]+[1,2,4,3]+ans[n-2:]
        print(*ans)
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# input=sys.stdin.readline
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import groupby,product
def resolve():
    h,w,n=map(int,input().split())
    S=[]
    for _ in range(n):
        a,b=map(int,input().split())
        for i,j in product(range(a-1,a+2),range(b-1,b+2)):
            if(2<=i<=h-1 and 2<=j<=w-1):
                S.append((i,j))
    S.sort()

    ans=[0]*10
    for key,iter in groupby(S):
        ans[len(tuple(iter))]+=1
    ans[0]=(h-2)*(w-2)-sum(ans)
    print(*ans,sep='\n')
resolve()

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import product
from collections import defaultdict
def resolve():
    h,w,n=map(int,input().split())
    D=defaultdict(int)
    for _ in range(n):
        a,b=map(int,input().split())
        for i,j in product(range(a-1,a+2),range(b-1,b+2)):
            if(1<=i<=h and 1<=j<=w):
                D[(i,j)]+=1

    ans=[0]*10
    for k,v in D.items():
        i,j=k
        if(i==1 or i==h or j==1 or j==w): continue
        ans[v]+=1
    ans[0]=(h-2)*(w-2)-sum(ans)
    print(*ans,sep='\n')
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

def f(b,n):
    if(n<b): return n
    return f(b,n//b)+n%b

def resolve():
    n=int(input())
    s=int(input())

    if(s>n):
        print(-1)
        return
    if(s==n):
        print(n+1)
        return

    k=int(n**.5)
    for b in range(2,k+1):
        if(f(b,n)==s):
            print(b)
            return

    B=[]
    for p in range(1,b):
        q=s-p
        if(0>q or b-1<q): continue
        if((n-q)%p): continue
        t=(n-q)//p
        if(k<t<=n):
            B.append(t)

    print(min(B) if(B) else -1)
resolve()

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

def f(b,n):
    if(n<b): return n
    return f(b,n//b)+n%b

def resolve():
    n=int(input())
    s=int(input())

    if(s>n):
        print(-1)
        return
    if(s==n):
        print(n+1)
        return

    # 2 <= b <= sqrt(n) を全探索
    k=int(n**.5)
    for b in range(2,k+2):
        if(f(b,n)==s):
            print(b)
            return

    # sqrt(n) < b <= n を考える
    B=[]
    for p in range(1,k+1):
        if((n-s)%p): continue
        b=(n-s)//p+1
        if(b<2): continue
        if(f(b,n)==s):
            B.append(b)

    print(min(B) if(B) else -1)
resolve()
Buggy python submission (verdict: Runtime Error):
a,b,c,d=(int(x) for x in input().split())

if(a < 0 or c < 0 or b < 0 or d < 0):
    print("")
else:
    if(b <= d):
	    if(b >= c and c >= a):
  		    print("Yes")
	    else:
  		    print("No")
    else:
        if(c <= a & a <= d):
            print("Yes")
        else:
          	print("No")

Fixed submission:
x = int(input())

if(x < 1 or x > 5):
  print("")
else:
  for i in range(x):
    print("ACL",end='')
Buggy python submission (verdict: Runtime Error):
N = int(input().strip())



a = []
c = []
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c.append(1)
		else:
			f=0


if(len(c) >= 3):
  print("Yes")
else:
  print("No")

Fixed submission:
val = input()

if(val[-1] == 's'):
  print(val + 'es')
else:
  print(val+'s')

Buggy python submission (verdict: Runtime Error):
N = int(input().strip())



a = []
c =0
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c+=1
		else:
			f=0
			c=0
	else :
		f=0
		c=0

if(c >= 3):
  print("Yes")
else:
  print("No")

Fixed submission:
val = input()

if(val[-1] == 's'):
  print(val + 'es')
else:
  print(val+'s')

Buggy python submission (verdict: Runtime Error):
N = int(input().strip())



a = []
c =0
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c+=1
		else:
			f=0
			c=0
	else :
      f=0
      c=0

if(c >= 3):
  print("Yes")
else:
  print("No")

Fixed submission:
val = input()

if(val[-1] == 's'):
  print(val + 'es')
else:
  print(val+'s')

Buggy python submission (verdict: Runtime Error):
import sys
N = int(input().strip())

if(N == 0):
  sys.exit()



a = []
c =0
f = 0
for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)
#print(a[4][1])
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c+=1
		else:
			f=0
			c=0
if(c >= 3):
  print("Yes")
else:
  print("No")

Fixed submission:
val = input()

if(val[-1] == 's'):
  print(val + 'es')
else:
  print(val+'s')
Buggy python submission (verdict: Runtime Error):
p = 0
N = int(input())
A = list(map(int , input().split()))
for i in range(N):
  for j in range(N):
    sa = abs(i-j)
    wa = A[i]+A[j]
    
    if(sa == wa):
      p += 1
print(p//2)

Fixed submission:
S = str(input())
if(S == "ARC"):
  print("ABC")
else:
  print("ARC")

Buggy python submission (verdict: Runtime Error):
X = int(input())
 
for a in range(-119 , 120 , 1):
  A = a**5
  for b in range(-119 , 120 , 1):
    B = b**5
    if(A-B==X):
      print(a, b)
      exit()
    else:
      continue
      


Fixed submission:
S = str(input())
if(S == "ARC"):
  print("ABC")
else:
  print("ARC")

Buggy python submission (verdict: Runtime Error):
X = int(input())
a = 1
b = 1
while True:  
  if(a**5 - b**5 == X):
    print(a , b)
    break
  a += 1
  for i in range(X):
    b += 1
    if(a**5 - b**5 == X):
      print(a , b)
      exit()
while True:
  if(a**5 - b**5 == X):
    print(a , b)
    break
  b -= 1
  for j in range(X):
    b -= 1
    if(a**5 - b**5 == X):
      print(a , b)
      exit()

Fixed submission:
S = str(input())
if(S == "ARC"):
  print("ABC")
else:
  print("ARC")
Buggy python submission (verdict: Runtime Error):
S = list(input())
a = S[0] + S[1]
b = S[2] + S[3]
A = int(a)
B = int(b)

if (0 < A < 13 and 0 < B < 13):
  print("AMBIGUOUS")
elif (0 < A < 13 and 12 < B < 100):
  print("MMYY")
elif (0 < A < 13 and B == 0):
  print("MMYY")
elif (0 < B < 13 and 12 < A < 100):
  print("YYMM")
elif (0 < B < 13 and A == 0):
  print("YYMM")
  
else:
  print("NA")


Fixed submission:
N, K = map(int, input().split())
S = list(input())

           
if(S[K-1] == "A"):
  S[K-1] = "a"
elif(S[K-1] == "B"):
  S[K-1] = "b"
elif(S[K-1] == "C"):
  S[K-1] = "c"
           
"".join(S)

S_1 = S[0]
for i in range(1,N):
  S_1 = S_1 + S[i]
print(S_1)

Buggy python submission (verdict: Runtime Error):
S = list(input())
a = S[0] + S[1]
b = S[2] + S[3]
A = int(a)
B = int(b)

if (0 < A < 13 and 0 < B < 13):
  print("AMBIGUOUS")
elif (0 < A < 13 and (12 < B < 100 or B == 0)):
  print("MMYY")
elif (0 < B < 13 and (12 < A < 100 or A == 0)):
  print("YYMM")
else:
  print("NA")

Fixed submission:
N, K = map(int, input().split())
S = list(input())

           
if(S[K-1] == "A"):
  S[K-1] = "a"
elif(S[K-1] == "B"):
  S[K-1] = "b"
elif(S[K-1] == "C"):
  S[K-1] = "c"
           
"".join(S)

S_1 = S[0]
for i in range(1,N):
  S_1 = S_1 + S[i]
print(S_1)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str()
if(S[K] = 'A'):
  S[K] = 'a'
elif(S[K] = 'B'):
  S[K-1] = 'b'
elif(S[K] = 'C'):
  S[K] = 'c'

Fixed submission:
N, K = map(int, input().split())
S = list(input())

           
if(S[K-1] == "A"):
  S[K-1] = "a"
elif(S[K-1] == "B"):
  S[K-1] = "b"
elif(S[K-1] == "C"):
  S[K-1] = "c"
           
"".join(S)

S_1 = S[0]
for i in range(1,N):
  S_1 = S_1 + S[i]
print(S_1)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str()
if(S[K-1] = 'A'):
  S[K-1] = 'a'
elif(S[K-1] = 'B'):
  S[K-1] = 'b'
elif(S[K-1] = 'C'):
  S[K-1] = 'c'

Fixed submission:
N, K = map(int, input().split())
S = list(input())

           
if(S[K-1] == "A"):
  S[K-1] = "a"
elif(S[K-1] == "B"):
  S[K-1] = "b"
elif(S[K-1] == "C"):
  S[K-1] = "c"
           
"".join(S)

S_1 = S[0]
for i in range(1,N):
  S_1 = S_1 + S[i]
print(S_1)
Buggy python submission (verdict: Runtime Error):

import sys
sys.setrecursionlimit(10000)

class UnionFindTree:
	def __init__(self,size):
		"""
		size個の集合を作成
		負の値は、ルートで集合の個数
		正の値は、次の要素
		"""
		self.table=[-1 for _ in range(size)]

	def find(self,x):
		"""
		グループ番号を取得
		"""
		# 本質的には、木を上に辿るだけ
		# ただし、通常、UnionFindでは経路圧縮を行うのが普通らしい
		if self.table[x] < 0:
			# 一個上がルートならば、それを返して終わり
			return x
		else:
			# そうでなければ、ルートまで辿るついでに経路圧縮
			self.table[x] = self.find(self.table[x])
			return self.table[x]
		return x

	# 併合
	def union(self,x,y):
		# s1,s2は正
		# table[s1],table[s2]は負
		s1=self.find(x)
		s2=self.find(y)
		if s1!=s2:
			# 個数が小さい方をルートにくっつける
			# ルートサイズは負なので、ルートが大きい方が個数が小さい?
			if self.table[s2]<=self.table[s1]:
				# s1が小さい
				self.table[s1]+=self.table[s2]
				self.table[s2]=s1
			else:
				# s2が小さい
				self.table[s2]+=self.table[s1]
				self.table[s1]=s2
			return True
		return False

	def groupCount(self):
		ret=0
		for i in range(len(self.table)):
			if self.table[i] < 0:
				ret+=1
		return ret

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

UF=UnionFindTree(N)

for n in range(M):
	A,B=map(int,input().split())
	UF.union(A,B)


print(UF.groupCount()-1)



Fixed submission:

import sys
sys.setrecursionlimit(10000)

class UnionFindTree:
	def __init__(self,size):
		"""
		size個の集合を作成
		負の値は、ルートで集合の個数
		正の値は、次の要素
		"""
		self.table=[-1 for _ in range(size)]

	def find(self,x):
		"""
		グループ番号を取得
		"""
		# 本質的には、木を上に辿るだけ
		# ただし、通常、UnionFindでは経路圧縮を行うのが普通らしい
		if self.table[x] < 0:
			# 一個上がルートならば、それを返して終わり
			return x
		else:
			# そうでなければ、ルートまで辿るついでに経路圧縮
			self.table[x] = self.find(self.table[x])
			return self.table[x]
		return x

	# 併合
	def union(self,x,y):
		# s1,s2は正
		# table[s1],table[s2]は負
		s1=self.find(x)
		s2=self.find(y)
		if s1!=s2:
			# 個数が小さい方をルートにくっつける
			# ルートサイズは負なので、ルートが大きい方が個数が小さい?
			if self.table[s2]<=self.table[s1]:
				# s1が小さい
				self.table[s1]+=self.table[s2]
				self.table[s2]=s1
			else:
				# s2が小さい
				self.table[s2]+=self.table[s1]
				self.table[s1]=s2
			return True
		return False

	def groupCount(self):
		ret=0
		for i in range(len(self.table)):
			if self.table[i] < 0:
				ret+=1
		return ret

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

UF=UnionFindTree(N)

for _ in range(M):
	A,B=map(int,input().split())
	UF.union(A-1,B-1)


print(UF.groupCount()-1)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N=int(input())
A=[]
PRECISION_DIGITS=9
NO_ENTRY = 0
cnt=np.full((PRECISION_DIGITS*2,PRECISION_DIGITS*2),NO_ENTRY,int)
# cnt=np.zeros((PRECISION_DIGITS*2,PRECISION_DIGITS*2),int)

# print(cnt)

for n in range(N):
	tmpA = float(input())
	tmpA = int(tmpA*10**PRECISION_DIGITS)
	#print(tmpA)

	five = 0
	two = 0
	# (10**9) -> (two,five)=(9,9)
	# min = 10**-9, ignore < 10**9 ???
	while (tmpA % 5) == 0 and five < PRECISION_DIGITS*2:
		five += 1
		tmpA //= 5
	while (tmpA % 2) == 0 and two < PRECISION_DIGITS*2:
		two += 1
		tmpA //= 2

	if cnt[two][five] == 0:
		cnt[two][five]=1
	else:
		cnt[two][five]+=1

# print(cnt)
ans = 0

for x1 in range(PRECISION_DIGITS*2):
	for y1 in range(PRECISION_DIGITS*2):
		if cnt[x1][y1] == NO_ENTRY:
			continue

		for x2 in range(PRECISION_DIGITS*2):
			for y2 in range(PRECISION_DIGITS*2):
				if cnt[x2][y2] == NO_ENTRY:
					continue
				# 2**a(a>=0) and 5**b(b>=0) => integer
				if 0 <= x1+x2 - PRECISION_DIGITS*2 and 0 <= y1+y2 -PRECISION_DIGITS*2:
					if x1 == x2 and y1 == y2:
						# same entry
						# Total number of combinations choose 2 items
						# nC2 = n*(n-1)/2
						ans += int((cnt[x1][y1]*(cnt[x2][y2]-1))//2)
					else:
						ans += cnt[x1][y1]*cnt[x2][y2]

		# count up completed entry
		cnt[x1][y1] = NO_ENTRY

print(ans)



Fixed submission:
N=int(input())
A=[]
PRECISION_DIGITS=9
cnt={}


for n in range(N):
	tmpA = float(input())
	tmpA = round(tmpA*(10**PRECISION_DIGITS))
	#print(tmpA)

	two = 0
	five = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA /= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA /= 5

	if (two,five) in cnt:
		cnt[(two,five)]+=1
	else:
		cnt[(two,five)]=1

keys=sorted(cnt.keys())
# print(keys)
ans = 0
for t1 in keys:
	for t2 in keys:
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 18 <= t1[0]+t2[0] and 18 <= t1[1]+t2[1]:
			cnt1 = cnt[(t1[0],t1[1])]
			cnt2 = cnt[(t2[0],t2[1])]
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int(cnt1*(cnt1-1)/2)


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math

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

def isOK(minVal):
	tmpK=0
	for a in A:
		# math.ceil(a//minVal)-1
		tmpK+=((-(-a//minVal))-1)

	if tmpK <= K:
		return True
	else:
		return False

ok = max(A)
ng = 0

for i in range(50):
	mid = (ok+ng) / 2
	if isOK(mid):
		ok = mid
	else:
		ng = mid

print(math.ceil(ok))

Fixed submission:
import numpy as np
import math

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

def isOK(minVal):
	tmpK=0
	for a in A:
		# math.ceil(a//minVal)-1
		tmpK+=((-(-a//minVal))-1)

	if tmpK <= K:
		return True
	else:
		return False

ok = max(A)
ng = 0

while (math.ceil(ok) != math.ceil(ng)):
	mid = (ok+ng) / 2
	if isOK(mid):
		ok = mid
	else:
		ng = mid
	#print(ok,ng)

print(math.ceil(ok))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

ans = 0

N=int(input())
A=list(map(int,input().split()))
npA=np.array(A)

uniqA, counts = np.unique(npA, return_counts=True)
ans = np.sum(npA)

Q=int(input())

for q in range(Q):
	diff = 0
	B,C = map(int,input().split())

	if B in uniqA:
		srcIndex = np.where(uniqA == B)[0]
		srcCount = int(counts[srcIndex])
		diff = ( C - int(uniqA[srcIndex]) ) * srcCount
		counts[srcIndex] = 0
		if C in uniqA:
			counts[np.where(uniqA == C)[0]] += srcCount
		else:
			uniqA = np.append(uniqA, C)
			counts = np.append(counts, srcCount)

	ans += diff
	print(ans)



Fixed submission:
import numpy as np

ans = 0

N=int(input())
A=list(map(int,input().split()))
npA=np.array(A)

counts = [0] * (10**5 + 1)

for a in npA:
	counts[a]+=1

ans = np.sum(npA)

Q=int(input())

for q in range(Q):
	diff = 0
	B,C = map(int,input().split())

	if 0 < counts[B]:
		diff = ( C - B ) * counts[B]
		counts[C] += counts[B]
		counts[B] = 0

	ans += diff
	print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N,M=map(int,input().split())
A = np.array(list(map(int,input().split())),dtype="int64")

A.sort()
# print(A)

for m in range(M):
	B,C=map(int,input().split())
	cnt=np.sum(A < C)
	A[:min(B,cnt)]=C
	A.sort()
	# print(A)


print( A.sum() )


Fixed submission:
import numpy as np
import bisect

N,M=map(int,input().split())
A = np.array(list(map(int,input().split())),dtype="int64")

A.sort()
# print(A)
tmpD=[]

for m in range(M):
	tmpD.append(list(map(int,input().split())))

tmpD.sort(key=lambda x:x[1],reverse=True)
D = np.array(tmpD)

curB = 0
dIndex=0
for n in range(N):

	if A[n] < D[dIndex][1]:
		A[n] = D[dIndex][1]
	else:
		break

	curB+=1
	if D[dIndex][0] <= curB:
		curB=0
		dIndex+=1
		if len(D) <= dIndex:
			break

# print(A)


print( A.sum() )
Buggy python submission (verdict: Time Limit Exceeded):
import fractions # python 3.4.3
# import copy
from functools import reduce

N=int(input())

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


def gcd(arr):
    return reduce(fractions.gcd, arr)

ans=gcd(A)

poped=None

for n in range(N):
	if poped != None:
		A.insert(n-1,poped)
	poped=A.pop(n)
	# print(A)
	ans=max(gcd(A),ans)

print(ans)



Fixed submission:
import fractions # python 3.4.3
# import copy
from functools import reduce

N=int(input())

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

# n個目までの最小公約数
dp=[0 for _ in range(N+1)]
dpRev=[0 for _ in range(N+1)]

def gcd(a,b):
	if a == 0: 
		return b
	elif b == 0: 
		return a
	# print(a,b)
	return reduce(fractions.gcd, (a,b))

dp[0]=0
for n in range(0,N):
	dp[n+1]=gcd(dp[n],A[n])

dpRev[N]=0
for n in range(N-1,-1,-1):
	dpRev[n]=gcd(A[n],dpRev[n+1])

# print(dp)
# print(dpRev)


ans=0
for n in range(N):
	ans = max( ans, gcd(dp[n],dpRev[n+1]) )


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

ans = N

for n in range(N):
	blk=S[:n].count("#")
	white=S[n+1:].count(".")
	ans=min(blk+white,ans)


print(ans)

Fixed submission:
N=int(input())
S=input()

blk=0
white=S.count(".")

ans=white

for n in range(N):
	if S[n]=="#":
		blk += 1
	else:
		white -= 1
	# print(blk,white)
	ans=min(blk+white,ans)


print(ans)