Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def calc(list_of_int):
  # 1と0で構成されているとする
  length = len(list_of_int)
  res = list_of_int[0]
  keisu = 1
  for i,r in zip(list_of_int[1:],range(N-1)):
    
    keisu = keisu*(N-r-1)//(r+1)
    # print(keisu,(N-r)-1,(r+1))
    res = (res + (keisu*i) )% 2
  return res
  
N = int(input())
S = input()
a = [int(s)-1 for s in S]
if 1 in a:
  print(calc(a))
else:
  print(calc(list(map(lambda x:x//2,a)))*2)

Fixed submission:
N = int(input())
S = input()
a = [int(s)-1 for s in S]


from collections import defaultdict

r = 1
d = defaultdict(int)
while 2**r  <= N:
  for i in range(1,N):
    if i*(2**r) <= N:
      d[i*(2**r)] += 1
    else:
      break
  r+=1

def calc(list_of_int):
  # 1と0で構成されているとする
  length = len(list_of_int)
  res = list_of_int[0]
  
  keisu = 0
  for i,r in zip(list_of_int[1:], range(N-1)):
    keisu += d[N-r-1]-d[r+1]
    res = (res + ((2 if keisu>0 else 1)*i) )% 2
  return res

if 1 in a:
  print(calc(a))
else:
  print(calc(list(map(lambda x:x//2,a)))*2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
a = [int(S[i]) for i in range(N)]

from collections import Counter

b = [abs(a[i+1]-a[i]) for i in range(N-1)]
c = Counter(b)
if c[1] == 0 and c[2]==1 and (b[0] ==2 or b[-1] ==2):
  print(2)
elif c[1] == 0 and c[0]==1 and (b[0] ==0 or a[-1] ==0):
  print(2)
else:
  if N == 2:
    print(abs(a[0]-a[1]))
  else:
    a = [abs(a[i+1]-a[i]) for i in range(N-1)]
    cd = Counter(a[1:-1])
    cde = Counter(a[0:1] + a[-1:])
    if ((cd[1] * 2) + cde[1])%2 ==1:
      print(1)
    else:
      print(0)
print(cde)

Fixed submission:
N = int(input())
S = input()
a = [int(s)-1 for s in S]


from collections import defaultdict

r = 1
d = defaultdict(int)
while 2**r  <= N:
  for i in range(1,N):
    if i*(2**r) <= N:
      d[i*(2**r)] += 1
    else:
      break
  r+=1

def calc(list_of_int):
  # 1と0で構成されているとする
  length = len(list_of_int)
  res = list_of_int[0]
  
  keisu = 0
  for i,r in zip(list_of_int[1:], range(N-1)):
    keisu += d[N-r-1]-d[r+1]
    res = (res + ((2 if keisu>0 else 1)*i) )% 2
  return res

if 1 in a:
  print(calc(a))
else:
  print(calc(list(map(lambda x:x//2,a)))*2)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from math import sqrt

a,b,c = list(map(int,input().split()))

if np.isclose(sqrt(a) +sqrt(b),sqrt(c),rtol=0,atol=1e-10):
  print("No")
elif sqrt(a) +sqrt(b) < sqrt(c):
  print("Yes")
else:
  print("No")


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

if c-a-b>0 and 4*a*b<(c-a-b)**2:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in a:
    ans = fractions.gcd(ans, i)

A = a[0]//ans
B = a[1]//ans
C = a[2]//ans

def bisearch(f, n):
    l = 0
    r = n
    fl = f(l)
    fr = f(r)
    while l <= r:
        m = (l + r) // 2
        fm = f(m)
        #print l,m,r,fl,fm,fr,n
        if fm == n:
            return m
        elif fm > n:
            r = m - 1
            fr = f(r)
        else:
            l = m + 1
            fl = f(l)

def try_square_root(n2):
    return bisearch(lambda n:n*n, n2)

if try_square_root(A) + try_square_root(B) == try_square_root(C):
  print("No")
elif sqrt(A) +sqrt(B) < sqrt(C):
  print("Yes")
else:
  print("No")

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

if c-a-b>0 and 4*a*b<(c-a-b)**2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  d[input()] += 1

max_cnt = max(d.value())
for v in sorted([key for key,value in d.items() if value == max_cnt]):
  print(v)

Fixed submission:
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  d[input()] += 1

max_cnt = max(d.values())
for v in sorted([key for key,value in d.items() if value == max_cnt]):
  print(v)
Buggy python submission (verdict: Runtime Error):
from math import ceil
(lambda H,A : print( ceil(H/A) ))(map(int,input().split()))

Fixed submission:
from math import ceil
(lambda H,A : print( ceil(H/A) ))(*map(int,input().split()))
Buggy python submission (verdict: Runtime Error):
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in map(int,input().split()):
  for idx,j in enumerate(reversed('{:b}'.format(i))):
    if j == "1":
      d[idx]+=1

m = max( set(d.keys()) )
print(int(sum([((2**i)* (N-d[i])*d[i])%(1e9+7) for i in range(m+1)])%(1e9+7)))

Fixed submission:
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in map(int,input().split()):
  for idx,j in enumerate(reversed('{:b}'.format(i))):
    if j == "1":
      d[idx]+=1

m = max( set(d.keys())|set([0]))
print(int(sum([((2**i)* (N-d[i])*d[i])%(1e9+7) for i in range(m+1)])%(1e9+7)))

Buggy python submission (verdict: Runtime Error):
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in map(int,input().split()):
  for idx,j in enumerate(reversed('{:b}'.format(i))):
    if j == "1":
      d[idx]+=1

m = max( set(d.keys()) )

A=1
res=0
for i in range(m+1):
  res += (A* (N-d[i])*d[i])%(1e9+7) 
  A = int((A*2) %(1e9+7))
  
print(int(res%(1e9+7)))

Fixed submission:
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in map(int,input().split()):
  for idx,j in enumerate(reversed('{:b}'.format(i))):
    if j == "1":
      d[idx]+=1

m = max( set(d.keys())|set([0]))
print(int(sum([((2**i)* (N-d[i])*d[i])%(1e9+7) for i in range(m+1)])%(1e9+7)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
from collections import defaultdict
d = dict()
d[0] = defaultdict(int)
d[1] = defaultdict(int)
for i in map(int,input().split()):
  for idx,j in enumerate(reversed('{:b}'.format(i))):
    d[int(j)][idx]+=1

m = max(set(d[0].keys()) | set(d[1].keys()) )

print(int(sum([((2**i)* (N-d[1][i])*d[1][i])%(1e9+7) for i in range(m+1)])%(1e9+7)))


Fixed submission:
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in map(int,input().split()):
  for idx,j in enumerate(reversed('{:b}'.format(i))):
    if j == "1":
      d[idx]+=1

m = max( set(d.keys())|set([0]))
print(int(sum([((2**i)* (N-d[i])*d[i])%(1e9+7) for i in range(m+1)])%(1e9+7)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
from collections import Counter
D = [int(i) for i in input().split()]
c = Counter(D)


if D[0] != 0:
  break
if c[0] != 1:
  print(0)
  quit()
if len(c.keys()) != max(c.keys())+1:
  print(0)
  quit()

  
res = 1
for i in range(1,1+max(c.keys())):
  res *= c[i-1]**c[i]
  res %= 998244353
print(res)


Fixed submission:
N = int(input())
from collections import Counter
D = [int(i) for i in input().split()]
c = Counter(D)


if D[0] != 0:
  print(0)
  quit()
if c[0] != 1:
  print(0)
  quit()
if len(c.keys()) != max(c.keys())+1:
  print(0)
  quit()

  
res = 1
for i in range(1,1+max(c.keys())):
  res *= c[i-1]**c[i]
  res %= 998244353
print(res)
Buggy python submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))

print(max(0,(A - B*2))

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

print(max(0,(A - B*2)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(sorted(map(int,input().split())))

cnt = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      # print("{} {} {} {} {} {}".format(i,j,k,S[i],S[j],S[k]))
      if S[i]+S[j] <= S[k]:
        #print("break")
        cnt += k-j-1
        break 
    else:
      cnt += k-j
         
        
print(cnt)

Fixed submission:
N = int(input())
S = list(sorted(map(int,input().split())))
cnt = 0
for j in range(1,N-1):
  k=j+1
  for i in range(j):
    while True:
      
      if k == N or S[i]+S[j] <= S[k]:
        k-=1
        break
      k+=1
    #print(i,j,k)
    #print(S[i],S[j], S[j+1:k+1],k-j)
    cnt += k-j
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
if len(set(string)) ==1:
    print(K*len(string)//2)
else:
    if(string[0]==string[-1]):
        ## 両端が同じ文字なら…
        start = string[0]
        startFlag = True
        cnt = defaultdict(int)
        length = 0
        
        for char in string:
            #print(char,start,length)
            if char == start:
                length +=1
                
            else:
                if startFlag:
                    startlen = length
                    startFlag = False
                cnt[length] +=1
                start = char
                length = 1
        else:
            ## 両端をカウントしない
            cnt[startlen] -= 1
            cnt[startlen +length] += 1
        print(sum([(key//2)*value*K for key,value in cnt.items()])-(startlen+length)//2+startlen//2+length//2)
    else:
        ## 両端が同じ文字なら…
        start = string[0]
        cnt = defaultdict(int)
        length = 0
        for char in string:
            #print(char,start,length)
            if char == start:
                length +=1
                
            else:
                cnt[length] +=1
                start = char
                length = 1
        else:
            ## 両端をカウントしない
            cnt[length] += 1
        print(sum([(key//2)*value*K for key,value in cnt.items()]))
              

Fixed submission:
string = input()
K = int(input())
from collections import defaultdict
if len(set(string)) ==1:
    print(K*len(string)//2)
else:
    if(string[0]==string[-1]):
        ## 両端が同じ文字なら…
        start = string[0]
        startFlag = True
        cnt = defaultdict(int)
        length = 0
        
        for char in string:
            #print(char,start,length)
            if char == start:
                length +=1
                
            else:
                if startFlag:
                    startlen = length
                    startFlag = False
                cnt[length] +=1
                start = char
                length = 1
        else:
            ## 両端をカウントしない
            cnt[startlen] -= 1
            cnt[startlen +length] += 1
        print(sum([(key//2)*value*K for key,value in cnt.items()])-(startlen+length)//2+startlen//2+length//2)
    else:
        ## 両端が同じ文字なら…
        start = string[0]
        cnt = defaultdict(int)
        length = 0
        for char in string:
            #print(char,start,length)
            if char == start:
                length +=1
                
            else:
                cnt[length] +=1
                start = char
                length = 1
        else:
            ## 両端をカウントしない
            cnt[length] += 1
        print(sum([(key//2)*value*K for key,value in cnt.items()]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

print(sum([i+1 for i in range(N-1)]))

Fixed submission:
N = int(input())

print(int((N)*(N-1)//2))
Buggy python submission (verdict: Runtime Error):
S = int(input())
v = 1e9
x=(v-s%v)%v
y=(s+x)/v
print("0 0 1000000000 1 ",x,y)

Fixed submission:
s = int(input())
v = 1000000000
x=(v-s%v)%v
y=(s+x)//v
print("0 0 1000000000 1",int(x),int(y))

Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt
S = 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
            if n//i < 1e9:
                arr.append([i, cnt])
                return arr
            else:
                continue
            
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
for i,_ in factorization(S):

    if (S)%i == 0 and (S)//i<1e9:
    
      print("0 0 0 {} {} 0".format((S)//i,i))
      break

Fixed submission:
s = int(input())
v = 1000000000
x=(v-s%v)%v
y=(s+x)//v
print("0 0 1000000000 1",int(x),int(y))
Buggy python submission (verdict: Runtime Error):
L,R = list(map(int,input().split()))

from collections import defaultdict

d = defaultdict(int)

for i in range(L,R+1):
  d[i%2019] += 1
  if d[0]>0:
    break

cnt = 0a
ans = list()
for k,v in sorted(d.items()):
  _v = v
  
  while _v > 0:
    cnt +=1
    ans += [k]
    _v -= 1
    if cnt >=2:
      print((ans[0]*ans[1])%2019)
      break
  if cnt >=2:
    break    

Fixed submission:
L,R = list(map(int,input().split()))
from itertools import combinations

numbers = [i for i in range(L,min(R+1,L+2019))]
ans = 2019
for conb in combinations(numbers,2):
  if ans > (conb[0]*conb[1])%2019:
     ans = (conb[0]*conb[1])%2019
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

import numpy as np
from numpy.linalg import solve
N = int(input())
A = np.array(list(map(int,input().split())))


x = np.roll(np.eye(N),1)
x[0,0]=0
x[N-1,0]=1
x += np.eye(N)
x /= 2


Q, R = linalg.qr(x)
t = np.dot(Q.T, A)
x = linalg.solve(R, t)

print(" ".join( list(map(str,list(map(int,x).tolist())))))


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

# A[0]は0と1の間に振ったものなので、
a = 0
for i in range(N//2):
  a +=  A[2*i] - A[2*i+1]

a0 = (a + A[-1]) //2

for i in A:
  print(a0*2,end=" ")
  a0 = i - a0

Buggy python submission (verdict: Runtime Error):
import numpy as np
from numpy.linalg import solve
N = int(input())
A = np.array(list(map(int,input().split())))


x = np.roll(np.eye(N),1)
x[0,0]=0
x[N-1,0]=1
x += np.eye(N)
x /= 2


print(" ".join( list(map(str,list(map(int,solve(x,A).tolist()))))))

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

# A[0]は0と1の間に振ったものなので、
a = 0
for i in range(N//2):
  a +=  A[2*i] - A[2*i+1]

a0 = (a + A[-1]) //2

for i in A:
  print(a0*2,end=" ")
  a0 = i - a0

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


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


x = np.roll(np.eye(N),1)
x[0,0]=0
x[N-1,0]=1
x += np.eye(N)
x /= 2

print(" ".join( list(map(str,list(map(int,np.dot(np.linalg.inv(x),A).tolist()))))))

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

# A[0]は0と1の間に振ったものなので、
a = 0
for i in range(N//2):
  a +=  A[2*i] - A[2*i+1]

a0 = (a + A[-1]) //2

for i in A:
  print(a0*2,end=" ")
  a0 = i - a0
Buggy python submission (verdict: Runtime Error):
N,A,B,C,D =list(map(int,input().split()))
s=input()

if "##" in s[A-1:C]+" "+s[B-1:D]:
  print("NO")
  quit()
st,e=0,0
for spl in s.split("##"):
  e += len(spl)
  if st <A<max(C,D)<end:
    break
  st+= len(spl)

if "..." in s[st:e]:
  print("YES")
elif D<C:
  print("NO")
else:
  print("YES")


Fixed submission:
N,A,B,C,D =list(map(int,input().split()))
s=input()

if "##" in s[A-1:max(C,D)]:
  print("No")
  quit()
st,e=0,0

for spl in s.split("##"):
  e += (len(spl)+2)
  if st <A<max(C,D)<=e:
    break
  st+= (len(spl)+2)

if "..." in s[B-2:min(C,D)+1] or B<C<D:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s=input()
s.replace("BC","D").replace("B","C")
l=[i for i in split("C") if len(i) !=0]
cnt=0
for line in l:
  dcnt =0 
  for ch in reversed(line):
    if ch = "D":
      dcnt+=1
    else:
      cnt+=dcnt

print(cnt)

Fixed submission:
s=input()
s=s.replace("BC","D").replace("B","C")
l=[i for i in s.split("C") if len(i) !=0]
cnt=0

for line in l:
  dcnt =0 
  for ch in reversed(line):
    if ch == "D":
      dcnt+=1
    else:
      cnt+=dcnt

print(cnt)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M =  list(map(int,input().split()))
A = sorted(list(map(int,input().split())))
q = [tuple(map(int,input().split())) for i in range(M)]
q.sort(key= lambda x:-x[1])
#print(q)  

mask = []
for num,cost in q:
  mask += [cost]*num
  if A[len(mask)-1] >= cost:
    break
    
res = 0
for idx,cost in enumerate(mask):
  if cost > A[idx]:
    res += cost
  else:
    break
else:
  idx+=1
    
for i in range(idx,len(A)):
  #print(i)
  res += A[i]
  
print(res)
  

Fixed submission:
import sys
input = sys.stdin.readline

N,M =  list(map(int,input().split()))
A = sorted(list(map(int,input().split())))
q = [tuple(map(int,input().split())) for i in range(M)]
q.sort(key= lambda x:-x[1])
#print(q)  

mask = []
for num,cost in q:
  mask += [cost]*num
  
  if len(mask) >=N:
    break
  if A[len(mask)-1] >= cost:
    break
    
res = 0
for idx,cost in enumerate(mask):
  if idx >= N:
    break
  if cost > A[idx]:
    res += cost
  else:
    break
else:
  idx+=1
    
for i in range(idx,len(A)):
  #print(i)
  res += A[i]
  
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
N = [[0 for _ in range(len(S))] for _  in  range(2)]
B,W = 0,1
# 左から.W 右へ#B
for idx,s in enumerate(S):
  if s is "#":
    N[idx][B] = N[idx-1][B] + 1
    N[idx][W] = N[idx-1][W]
  else:
    N[idx][B] = N[idx-1][B]
    N[idx][W] = N[idx-1][W] + 1

print(int(min([N[i][B]+N[-1][W]-N[i][W] for i in range(len(S)-1)]+[N[-1][W],N[-1][B]]   )))


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

import numpy as np

N = np.zeros((len(S),2))
B,W = 0,1
# 左から.W 右へ#B
for idx,s in enumerate(S):
  if s is "#":
    N[idx,B] = N[idx-1,B] + 1
    N[idx,W] = N[idx-1,W]
  else:
    N[idx,B] = N[idx-1,B]
    N[idx,W] = N[idx-1,W] + 1

print(int(min([N[i,B]+N[-1,W]-N[i,W] for i in range(len(S)-1)]+[N[-1,W],N[-1,B]]   )))
Buggy python submission (verdict: Runtime Error):
N, K = tuple(map(int, input().split()))
S = "1"+input()+"1"

prev = S[0]
if prev == "0":
  fst_is_0 = True
else:
  fst_is_0 = False

cnt = 0
cnt_0 = 0

cnt_lst = []
for idx, s in enumerate(S):
  if s == prev:
    cnt += 1
  else:
    cnt_lst.append(cnt)
    if s == "0":
      cnt_0 += 1
    prev = s
else:
  cnt_lst.append(cnt)
#print(cnt_lst)


if cnt_0 <= K:
  print(len(S)-2)
else:
  l = [cnt_lst[2*idx+2*K+1] -cnt_lst[idx*2] for idx in range( int( (len(cnt_lst)+1)/2) -K)   ]
  #print(l)
  ss = []
  for idx,sss in enumerate(l):
    if idx == 0:
      ss.append(sss-1)
    elif idx == len(l)-1:
      
      ss.append(sss-1)
    else:
      ss.append(sss)
      
  print(max(ss))

Fixed submission:
N, K = tuple(map(int, input().split()))
S = "1"+input()+"1"

prev = S[0]
if prev == "0":
  fst_is_0 = True
else:
  fst_is_0 = False

cnt = 0
cnt_0 = 0

cnt_lst = []
for idx, s in enumerate(S):
  if s == prev:
    cnt += 1
  else:
    cnt_lst.append(cnt)
    cnt = 1
    if s == "0":
      cnt_0 += 1
    prev = s
else:
  cnt_lst.append(cnt)
#print(cnt_lst)


if cnt_0 <= K:
  print(len(S)-2)
else:
  prev = "1"
  cnt_lst = [0]
  for idx,s in enumerate(S):
    if prev != s:
      cnt_lst.append(idx)
    prev=s
  cnt_lst.append(len(S))
  s_ =[]
  for idx in range( int( (len(cnt_lst)+1)/2) -K):
    #print(2*idx+2*K,idx*2,cnt_lst[2*idx+2*K+1] -cnt_lst[idx*2])
    if idx==0 or idx==int( (len(cnt_lst)+1)/2) -K-1:
      s_.append(cnt_lst[2*idx+2*K+1] -cnt_lst[idx*2]-1)
    else:
      s_.append(cnt_lst[2*idx+2*K+1] -cnt_lst[idx*2])
  print(max(s_))
Buggy python submission (verdict: Runtime Error):
string = input()
ch = string[0]
max_string_len = 0
prev_len = 0
for idx,ch in enumerate(string):
  if ch  in {"A","T","G","C"}:
    prev_len += 1
  	max_string_len = max(max_string_len,prev_len)
  else:
    prev_len = 0
    
print(max_string_len)

Fixed submission:
string = input()
ch = string[0]
max_string_len = 0
prev_len = 0
for idx,ch in enumerate(string):
  if ch  in {"A","T","G","C"}:
    prev_len += 1
    max_string_len = max(max_string_len,prev_len)
  else:
    prev_len = 0
    
print(max_string_len)
Buggy python submission (verdict: Runtime Error):
def checkAGC(string):
    str0 = string[0] +string[1] +string[2] +string[3]
    str1 = string[1] +string[0] +string[2] +string[3]
    str2 = string[0] +string[2] +string[1] +string[3]
    str3 = string[0] +string[1] +string[3] +string[2]
    
    if "AGC" in str0 or "AGC" in str1 or "AGC" in str2 or "AGC" in str3:
        return True
    else:
        return False

def checkAGC3(string):
    str0 = string[0] +string[1] +string[2]
    str1 = string[1] +string[0] +string[2] 
    str2 = string[0] +string[2] +string[1] 
    
    if "AGC" in str0 or "AGC" in str1 or "AGC" in str2 :
        return True
    else:
        return False
      

import itertools

words = list(itertools.product("ATGC", "ATGC","ATGC"))

#3文字のインデックスを返す
nucleotide_dict =  dict(list( (words[i],i) for i in range(len(words))))

import numpy as np
# 重み行列を求める
W = np.zeros((len(words),len(words)))
for word_prev in words:
    for word_next in words:
        if word_prev[1:] == word_next[:-1] and not checkAGC(word_prev[:-1]+word_next[1:]):
            #print(nucleotide_dict[word_next],nucleotide_dict[word_prev],word_prev[:-1]+word_next[1:] )
            W[nucleotide_dict[word_next],nucleotide_dict[word_prev]] = 1
b = np.array([0 if checkAGC3(i) else 1 for i in words])

def mod(num):
    return num % int(pow(10,9)+7)
  
res = b
for i in range(N-3):
    res = np.vectorize(lambda x: mod(x))(W@res)
print(int(mod(np.sum(res))))

Fixed submission:
N = int(input())

def checkAGC(string):
    str0 = string[0] +string[1] +string[2] +string[3]
    str1 = string[1] +string[0] +string[2] +string[3]
    str2 = string[0] +string[2] +string[1] +string[3]
    str3 = string[0] +string[1] +string[3] +string[2]
    
    if "AGC" in str0 or "AGC" in str1 or "AGC" in str2 or "AGC" in str3:
        return True
    else:
        return False

def checkAGC3(string):
    str0 = string[0] +string[1] +string[2]
    str1 = string[1] +string[0] +string[2] 
    str2 = string[0] +string[2] +string[1] 
    
    if "AGC" in str0 or "AGC" in str1 or "AGC" in str2 :
        return True
    else:
        return False
      

import itertools

words = list(itertools.product("ATGC", "ATGC","ATGC"))

#3文字のインデックスを返す
nucleotide_dict =  dict(list( (words[i],i) for i in range(len(words))))

import numpy as np
# 重み行列を求める
W = np.zeros((len(words),len(words)))
for word_prev in words:
    for word_next in words:
        if word_prev[1:] == word_next[:-1] and not checkAGC(word_prev[:-1]+word_next[1:]):
            #print(nucleotide_dict[word_next],nucleotide_dict[word_prev],word_prev[:-1]+word_next[1:] )
            W[nucleotide_dict[word_next],nucleotide_dict[word_prev]] = 1
b = np.array([0 if checkAGC3(i) else 1 for i in words])

def mod(num):
    return num % int(pow(10,9)+7)
  
res = b
for i in range(N-3):
    res = np.vectorize(lambda x: mod(x))(np.dot(W,res))
print(int(mod(np.sum(res))))
Buggy python submission (verdict: Runtime Error):
N,M,C = list(map(int,input().split()))
import numpy as np
B = np.array(input().split() ,dtype=np.int64)
ret  =0
for i in range(N):
    if( np.sum(np.matmul(B , np.array(input().split() ,dtype=np.int64))) +C>0):
        ret += 1
print(ret)

Fixed submission:
N,M,C = list(map(int,input().split()))
import numpy as np
B = np.array(input().split() ,dtype=np.int64)
ret =0
for i in range(N):
    if( np.sum(B * np.array(input().split() ,dtype=np.int64)) +C>0):
        ret += 1
print(ret)

Buggy python submission (verdict: Runtime Error):
N,M,C = list(map(int,input().split()))
import numpy as np
B = np.array(input().split() ,dtype=np.int64)
ret  =0
for i in range(N):
    if( np.sum(np.matmul(B , np.array(input().split() ,dtype=np.int64))) +C>0):
        ret += 1
print(ret)
    

Fixed submission:
N,M,C = list(map(int,input().split()))
import numpy as np
B = np.array(input().split() ,dtype=np.int64)
ret =0
for i in range(N):
    if( np.sum(B * np.array(input().split() ,dtype=np.int64)) +C>0):
        ret += 1
print(ret)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int,input().split()))
a = A[0]
for i in A:
    a = math.gcd(a,i)
print(a)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
a = A[0]

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

for i in A:
    a = gcd(a,i)
print(a)