Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

mod=10**9+7
n,k=map(int,input().split())
N=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  N[a-1]+=[b-1]
  N[b-1]+=[a-1]
Chk=[False]*n
S=[0]
Chk[0]=True
ans=k
while S:
  ss=S.pop()
  for sss in N[ss]:
    if Chk[sss]==True:
      continue
    else:
      ct=1
      for ssss in N[ss]:
        if Chk[ssss]==True:
          ct+=1
      ans=(ans*max(k-ct,0))%mod
      Chk[sss]=True
      S.append(sss)
print(ans%mod)


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

mod=10**9+7
n,k=map(int,input().split())
N=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  N[a-1]+=[b-1]
  N[b-1]+=[a-1]
Chk=[0]*n
S=[0]
Chk[0]=1
ans=k
while S:
  ss=S.pop()
  for sss in N[ss]:
    if Chk[sss]>0:
      continue
    else:
      ans=(ans*max(k-Chk[ss],0))%mod
      Chk[ss]+=1
      Chk[sss]=2
      S.append(sss)
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

mod=10**9+7
n,k=map(int,input().split())
N=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  N[a-1]+=[b-1]
  N[b-1]+=[a-1]
Chk=[False]*n
S=[0]
Chk[0]=True
ans=k
while S:
  ss=S.pop()
  for sss in N[ss]:
    if Chk[sss]==True:
      continue
    else:
      ct=1
      for ssss in N[ss]:
        if Chk[ssss]==True:
          ct+=1
      ans=(ans*max(k-ct,0))%mod
      Chk[sss]=True
      S.append(sss)
print(ans%mod)

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

mod=10**9+7
n,k=map(int,input().split())
N=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  N[a-1]+=[b-1]
  N[b-1]+=[a-1]
Chk=[0]*n
S=[0]
Chk[0]=1
ans=k
while S:
  ss=S.pop()
  for sss in N[ss]:
    if Chk[sss]>0:
      continue
    else:
      ans=(ans*max(k-Chk[ss],0))%mod
      Chk[ss]+=1
      Chk[sss]=2
      S.append(sss)
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7
n,k=map(int,input().split())
N=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  N[a-1]+=[b-1]
  N[b-1]+=[a-1]
Chk=[False]*n
S=[0]
Chk[0]=True
ans=k
while S:
  ss=S.pop(-1)
  for sss in N[ss]:
    if Chk[sss]==True:
      continue
    else:
      ct=1
      for ssss in N[ss]:
        if Chk[ssss]==True:
          ct+=1
      ans=(ans*max(k-ct,0))%mod
      Chk[sss]=True
      S.append(sss)
print(ans%mod)



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

mod=10**9+7
n,k=map(int,input().split())
N=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  N[a-1]+=[b-1]
  N[b-1]+=[a-1]
Chk=[0]*n
S=[0]
Chk[0]=1
ans=k
while S:
  ss=S.pop()
  for sss in N[ss]:
    if Chk[sss]>0:
      continue
    else:
      ans=(ans*max(k-Chk[ss],0))%mod
      Chk[ss]+=1
      Chk[sss]=2
      S.append(sss)
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
import itertools
import collections
n=int(input())
X=[]
for i in range(n):
  X.append([int(i) for i in input().split()])
X.sort(key=lambda x:(x[0],x[1]))
Y=[]
for c in itertools.combinations(range(n),2):
  x1,y1,x2,y2=X[c[0]][0],X[c[0]][1],X[c[1]][0],X[c[1]][1]
  Y.append((x2-x1,y2-y1))
yy=collections.Counter(Y)
print(n-yy.most_common()[0][1])

Fixed submission:
import itertools
import collections
n=int(input())
X=[]
for i in range(n):
  X.append([int(i) for i in input().split()])
X.sort(key=lambda x:(x[0],x[1]))
Y=[]
for c in itertools.combinations(range(n),2):
  x1,y1,x2,y2=X[c[0]][0],X[c[0]][1],X[c[1]][0],X[c[1]][1]
  Y.append((x2-x1,y2-y1))
yy=collections.Counter(Y)
print(1 if n==1 else n-yy.most_common()[0][1])
Buggy python submission (verdict: Runtime Error):
p,q,r=map(int,input().split())

print(min([p+q,q+r,r+p])

Fixed submission:
p,q,r=map(int,input().split())

print(min([p+q,q+r,r+p]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
mod=10**9+7
n,m=map(int,input().split())
A=[]
for i in range(m):
  a=int(input())
  A.append(a)
S=[0]*(n+1)
S[0]=1
if 1 not in A:
  S[1]=1
for i in range(2,n+1):
  if i in A:
    S[i]=0
  else:
    S[i]=(S[i-1]+S[i-2])%mod
print(S[n]%mod)


Fixed submission:
import sys
input = sys.stdin.readline
mod=10**9+7
n,m=map(int,input().split())
A=set()
for i in range(m):
  A.add(int(input()))
S=[0]*(n+1)
S[0]=1
if 1 not in A:
  S[1]=1
for i in range(2,n+1):
  if i in A:
    S[i]=0
  else:
    S[i]=(S[i-1]+S[i-2])%mod
print(S[n]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
mod=10**9+7
n,m=map(int,input().split())
A=[]
for i in range(m):
  a=int(input())
  A.append(a)
S=[0]*(n+1)
S[0]=1
if 1 not in A:
  S[1]=1
for i in range(2,n+1):
  if i in A:
    S[i]=0
  else:
    S[i]=(S[i-1]+S[i-2])%mod
print(S[n]%mod)


Fixed submission:
import sys
input = sys.stdin.readline
mod=10**9+7
n,m=map(int,input().split())
A=set()
for i in range(m):
  A.add(int(input()))
S=[0]*(n+1)
S[0]=1
if 1 not in A:
  S[1]=1
for i in range(2,n+1):
  if i in A:
    S[i]=0
  else:
    S[i]=(S[i-1]+S[i-2])%mod
print(S[n]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
mod=10**9+7
n,m=map(int,input().split())
A=[]
for i in range(m):
  a=int(input())
  A.append(a)
S=[0]*(n+1)
S[0]=1
if 1 not in A:
  S[1]=1
for i in range(2,n+1):
  if i in A:
    S[i]=0
  else:
    S[i]=S[i-1]+S[i-2]
print(S[n]%mod)


Fixed submission:
import sys
input = sys.stdin.readline
mod=10**9+7
n,m=map(int,input().split())
A=set()
for i in range(m):
  A.add(int(input()))
S=[0]*(n+1)
S[0]=1
if 1 not in A:
  S[1]=1
for i in range(2,n+1):
  if i in A:
    S[i]=0
  else:
    S[i]=(S[i-1]+S[i-2])%mod
print(S[n]%mod)
Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
T=[["#"]*(w+2)]
T.extend([["#"]+[s for s in input()]+["#"] for _ in range(h)])
T.append(["#"]*(w+2))
L=[[0]*w for _ in range(h)]
R=[[0]*w for _ in range(h)]
U=[[0]*w for _ in range(h)]
D=[[0]*w for _ in range(h)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if T[i][j]==".":
      if j==1:
        L[i-1][j-1]=1
      else:
        L[i-1][j-1]=L[i-1][j-2]+1
      if i==1:
        U[i-1][j-1]=1
      else:
        U[i-1][j-1]=U[i-2][j-1]+1
    if T[h+1-i][w+1-j]==".":
      if j==1:
        R[h-i][w-j]=1
      else:
        R[h-i][w-j]=R[h-i][w-j+1]+1
      if i==1:
        D[h-i][w-j]=1
      else:
        D[h-i][w-j]=D[h-i+1][w-j]+1
ans=0
for i in range(h):
  for j in range(w):
    ans=max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
print(ans)

Fixed submission:
h,w=map(int,input().split())
T=[["#"]*(w+2)]
T.extend([["#"]+[s for s in input()]+["#"] for _ in range(h)])
T.append(["#"]*(w+2))
L=[[0]*w for _ in range(h)]
R=[[0]*w for _ in range(h)]
U=[[0]*w for _ in range(h)]
D=[[0]*w for _ in range(h)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if T[i][j]==".":
      if j==1:
        L[i-1][j-1]=1
      else:
        L[i-1][j-1]=L[i-1][j-2]+1
      if i==1:
        U[i-1][j-1]=1
      else:
        U[i-1][j-1]=U[i-2][j-1]+1
    if T[h+1-i][w+1-j]==".":
      if j==1:
        R[h-i][w-j]=1
      else:
        R[h-i][w-j]=R[h-i][w-j+1]+1
      if i==1:
        D[h-i][w-j]=1
      else:
        D[h-i][w-j]=D[h-i+1][w-j]+1
ans=0
for i in range(h):
  for j in range(w):
    ans=max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
mod=10**6+3
n_max=mod
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=pow(F[i+1],mod-2,mod)
for i in range(int(input())):
  x,d,n=map(int,input().split())
  print(((d**n)*F[(x*pow(d,mod-2,mod)+n-1)%mod]*FI[(x*pow(d,mod-2,mod)-1)%mod])%mod)


Fixed submission:
import sys
input = sys.stdin.readline
mod=10**6+3
n_max=mod
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=pow(F[i+1],mod-2,mod)
for i in range(int(input())):
  x,d,n=map(int,input().split())
  if d==0:
    print(pow(x,n,mod))
  else:
    s=(x*pow(d,mod-2,mod)-1)%mod
    if s+n>=mod:
      print(0)
    else:
      g=(x*pow(d,mod-2,mod)+n-1)%mod
      print(((pow(d,n,mod))*F[g]*FI[s])%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
mod=10**9+7
import math
def f(x):
  return math.factorial(x)
def c(x,y):
  return f(x)//(f(x-y)*f(y))

ans=(n**2*(m-1)*m*(m+1)//6)%mod
ans=(ans+m**2*(n-1)*n*(n+1)//6)%mod
ans=(ans*c(m*n-2,k-2))%mod
print(ans)

Fixed submission:
n,m,k=map(int,input().split())
import math
def f(x): return math.factorial(x)
def c(x,y): return f(x)//(f(x-y)*f(y))
print(((n**2*(m-1)*m*(m+1)//6+m**2*(n-1)*n*(n+1)//6)*c(m*n-2,k-2))%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n=int(input())
E=[]
for i in range(n-1):
  u,v,w=map(int,input().split())
  E.append([u,v,w])
def BFS(edges,N):
  roots=[[] for i in range(N)]
  for a,b,c in edges:
    roots[a-1]+=[(b-1,c)]
    roots[b-1]+=[(a-1,c)]
  dist=[-1]*N
  stack=[]
  stack.append(0)
  dist[0]=0
  while stack:
    label=stack.pop(-1)
    for i,c in roots[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        stack+=[i]
  return dist
for i in range(n):
  print(0 if BFS(E,n)[i]%2==0 else 1)

Fixed submission:
import sys
input = sys.stdin.readline
n=int(input())
E=[]
for i in range(n-1):
  u,v,w=map(int,input().split())
  E.append([u,v,w])
def BFS(edges,N):
  roots=[[] for i in range(N)]
  for a,b,c in edges:
    roots[a-1]+=[(b-1,c)]
    roots[b-1]+=[(a-1,c)]
  dist=[-1]*N
  stack=[]
  stack.append(0)
  dist[0]=0
  while stack:
    label=stack.pop(-1)
    for i,c in roots[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        stack+=[i]
  return dist
D=BFS(E,n)
for i in range(n):
  print(0 if D[i]%2==0 else 1)

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse.csgraph import floyd_warshall
n=int(input())
T=[[0]*n for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  T[u-1][v-1]=w
  T[v-1][u-1]=w
d=floyd_warshall(csgraph=T, directed=False, return_predecessors=False)
for i in range(n):
  print(0 if d[0][i]%2==0 else 1)

Fixed submission:
import sys
input = sys.stdin.readline
n=int(input())
E=[]
for i in range(n-1):
  u,v,w=map(int,input().split())
  E.append([u,v,w])
def BFS(edges,N):
  roots=[[] for i in range(N)]
  for a,b,c in edges:
    roots[a-1]+=[(b-1,c)]
    roots[b-1]+=[(a-1,c)]
  dist=[-1]*N
  stack=[]
  stack.append(0)
  dist[0]=0
  while stack:
    label=stack.pop(-1)
    for i,c in roots[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        stack+=[i]
  return dist
D=BFS(E,n)
for i in range(n):
  print(0 if D[i]%2==0 else 1)
Buggy python submission (verdict: Runtime Error):
m,k=map(int,input().split())
if k>=2**m-1:
  print(-1)
else:
  if k==0:
    Ans=[]
    for i in range(2**m):
      Ans.append(i)
      Ans.append(i)
    print(*Ans)
  else:
    Ans=[k]
    for i in range(2**m):
      if i!=k:
        Ans.append(i)
    Ans.append(k)
    for i in range(2**m):
      if i!=k
        Ans.append(2**m-1-i)
    print(*Ans)

Fixed submission:
m,k=map(int,input().split())
if m==0 and k==0:
  print(0,0)
elif m==1 and k==1:
  print(-1)
elif k>2**m-1:
  print(-1)
elif k==2**m-1:
  Ans=[]
  for i in range(2**m-1):
    Ans.append(2**m-2-i)
  Ans.append(2**m-1)
  for i in range(2**m):
    Ans.append(i)
  print(*Ans)
else:
  if k==0:
    Ans=[]
    for i in range(2**m):
      Ans.append(i)
      Ans.append(i)
    print(*Ans)
  else:
    Ans=[k]
    for i in range(2**m):
      if i!=k:
        Ans.append(i)
    Ans.append(k)
    for i in range(2**m):
      if i!=2**m-1-k:
        Ans.append(2**m-1-i)
    print(*Ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input(),split())
print(n-k+1)

Fixed submission:
n,k=map(int,input().split())
print(n-k+1)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
  for j in range(n//g+1):
    if (n-i*r-j*g)%b==0 and (n-i*r-j*g)//b>=0:
      ans+=1
print(ans)


Fixed submission:
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
  for j in range(n//g+1):
    if (n-i*r-j*g)%b==0 and (n-i*r-j*g)//b>=0:
      ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
  for j inr range(n//g+1):
    if (n-i*r-j*g)%b==0 and (n-i*r-j*g)//b>=0:
      ans+=1
print(ans)

Fixed submission:
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
  for j in range(n//g+1):
    if (n-i*r-j*g)%b==0 and (n-i*r-j*g)//b>=0:
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a,b,c=0,0,0
count=0
for i in range(n):
  s=input()
  count+=s.count('AB')
  if s[0]=='B' and s[-1]=='A':
    a+r=1
  elif s[0]=='B':
    b+=1
  elif s[-1]=='A':
    c+=1
if b==0 and c==0:
  print(count+a-1)
else:
  print(count+a+min(b,c))

Fixed submission:
n=int(input())
a,b,c=0,0,0
count=0
for i in range(n):
  s=input()
  count+=s.count('AB')
  if s[0]=='B' and s[-1]=='A':
    a+=1
  elif s[0]=='B':
    b+=1
  elif s[-1]=='A':
    c+=1
if b==0 and c==0:
  print(count+max(0,a-1))
else:
  print(count+a+min(b,c))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=998244353
A=[]
for i in range(n):
  A.append(int(input()))
t=sum(A)
DP=[[0]*(t) for _ in range(n+1)]
DP[0][0]=1
for i in range(n):
  a=A[i]
  for j in range(t):
    DP[i+1][j]=(2*DP[i][j]+DP[i][max(0,j-a)])%mod

DP2=[[0]*(t) for _ in range(n+1)]
DP2[0][0]=1
for i in range(n):
  a=A[i]
  for j in range(t):
    if j>=a:
      DP2[i+1][j]=(DP2[i][j]+DP2[i][j-a])%mod
    else:
      DP2[i+1][j]=DP2[i][j]

ans=1
for i in range(n):
  ans=(ans*3)%mod
if t%2==1:
  print((ans-3*DP[n][t//2+1])%mod)
else:
  print((ans-3*DP[n][t//2]+3*DP2[n][t//2])%mod)



Fixed submission:
n=int(input())
mod=998244353
A=[]
for i in range(n):
  A.append(int(input()))
t=sum(A)
DP=[[0]*(t) for _ in range(n+1)]
DP[0][0]=1
for i in range(n):
  a=A[i]
  for j in range(t):
    DP[i+1][j]=(2*DP[i][j]+DP[i][max(0,j-a)])%mod

DP2=[[0]*(t) for _ in range(n+1)]
DP2[0][0]=1
for i in range(n):
  a=A[i]
  for j in range(t):
    if j>=a:
      DP2[i+1][j]=(DP2[i][j]+DP2[i][j-a])%mod
    else:
      DP2[i+1][j]=DP2[i][j]

ans=1
for i in range(n):
  ans=(ans*3)%mod
if t%2==1:
  print((ans-3*DP[n][t//2+1])%mod)
else:
  print((ans-3*DP[n][t//2]+3*DP2[n][t//2])%mod)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
List=[]
i=1
j=1
while i<n:
  if s[i-1]==s[i]:
    j+=1
    i+=1
    if i==n-1:
      List.append(j)
  else:
    List.append(j)
    i+=1
    j=1
if s[0]=="0":
  List.insert(0,0)
ans=max(List)
rg=2*k+1
for i in range(0,len(List)-rg+1,2):
  ans=max(ans,sum(List[i:i+rg]))
print(ans)
  

Fixed submission:
n,k=map(int,input().split())
s=input()
A=[]
cur=s[0]
for i in range(1,n):
  if s[i]!=cur:
    A.append(i)
    cur=s[i]
A.append(n)
start,end=s[0],s[-1]
nn=len(A)
ans=0
if start=="0" and nn<=2*k:
  ans=n
elif start=="1" and nn<=2*k+1:
  ans=n
elif start=="0":
  ans=A[2*k-1]
  for i in range(1,nn//2-k+1):
    ans=max(ans,A[2*k-1+2*i]-A[2*i-2])
  if end=="0":
    ans=max(ans,A[-1]-A[-2*(k+1)+1])
else:
  ans=A[2*k]
  for i in range(1,(nn-1)//2-k+1):
    ans=max(ans,A[2*k+2*i]-A[2*i-1])
  if end=="0":
    ans=max(ans,A[-1]-A[-2*(k+1)+1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,c,d,e=[int(input()) for i in range(6)]
dist=[n,0,0,0,0,0]
move=[a,b,c,d,e,0]
t=0
while dist[5]<n:
  dist_t=[max(0,dist[0]-move[0])]
  for j in range(1,6):
    dist_t.append(max(0,dist[j]-move[j])+min(dist[j-1],move[j-1]))
  t=t+1
  dist=dist_t
print(t)
    


Fixed submission:
n=int(input())
A=[int(input()) for i in range(5)]
print(5+(n-1)//min(A))

Buggy python submission (verdict: Runtime Error):
n,a,b,c,d,e=[int(input()) for i in range(6)]
dist=[n,0,0,0,0,0]
move=[a,b,c,d,e,0]
t=0
for while dist[5]<n:
  dist_t=[max(0,dist[0]-move[0])]
  for j in range(1,6):
    dist_t.append(max(0,dist[j]-move[j])+min(dist[j-1],move[j-1]))
  t=t+1
  dist=dist_t
print(t)
    


Fixed submission:
n=int(input())
A=[int(input()) for i in range(5)]
print(5+(n-1)//min(A))

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,c,d,e=[int(input()) for i in range(6)]
dist=[n,0,0,0,0,0]
move=[a,b,c,d,e]
t=0
while dist[5]<n:
  dist[0]=max(0,dist[0]-move[0])
  for j in range(1,5):
    dist[j]=max(0,dist[j]-move[j])+min(dist[j-1],move[j-1])
  dist[5]=dist[5]+min(dist[4],move[4])
  t=t+1
print(t)
    


Fixed submission:
n=int(input())
A=[int(input()) for i in range(5)]
print(5+(n-1)//min(A))

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,c,d,e=[int(input()) for i in range(6)]
dist=[n,0,0,0,0,0]
move=[a,b,c,d,e]
t=0
while dist[5]<n:
  dist[0]=max(0,dist[0]-move[0])
  dist[5]=dist[5]+min(dist[4],move[4])
  for j in range(1,5):
    dist[j]=max(0,dist[j]-move[j])+min(dist[j-1],move[j-1])
  t=t+1
print(t)
    


Fixed submission:
n=int(input())
A=[int(input()) for i in range(5)]
print(5+(n-1)//min(A))
Buggy python submission (verdict: Runtime Error):
B=input()
print("T" if B=="A" else "A" if B=="T" else "G" if B=="C" else "C" if B=="G")


Fixed submission:
B=input()
print("T" if B=="A" else "A" if B=="T" else "G" if B=="C" else "C")

Buggy python submission (verdict: Runtime Error):
b=input()
print("T" if B=="A" else "A" if B=="T" else "G" if B=="C" else "C" if B=="G")


Fixed submission:
B=input()
print("T" if B=="A" else "A" if B=="T" else "G" if B=="C" else "C")

Buggy python submission (verdict: Runtime Error):
b=input()
print("T" if B="A" else "A" if B="T" else "G" if B="C" else "C" if B="G")

Fixed submission:
B=input()
print("T" if B=="A" else "A" if B=="T" else "G" if B=="C" else "C")
Buggy python submission (verdict: Runtime Error):
s=input()
ans=0
cur=0
ACGT=set("A","C","G","T")
for ss in s:
  if ss in ACGT:
    cur+=1
  else:
    ans=max(cur,ans)
    cur=0
print(max(ans,cur))



Fixed submission:
S=input()
SS=S+"X"
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  j=0
  while SS[i+j] in ACGT:
    j+=1   
  m=max(m,j)
print(m)

Buggy python submission (verdict: Runtime Error):
S=input()
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  j=0
  while S[i+j] in ACGT:
    j+=1   
  m=max(m,j)
print(m)

Fixed submission:
S=input()
SS=S+"X"
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  j=0
  while SS[i+j] in ACGT:
    j+=1   
  m=max(m,j)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  n=0
  while S[i] in ACGT:
    n+=1
  m=max(m,n)
print(m)

Fixed submission:
S=input()
SS=S+"X"
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  j=0
  while SS[i+j] in ACGT:
    j+=1   
  m=max(m,j)
print(m)
Buggy python submission (verdict: Runtime Error):
N,M,C=map(int,(input()).split())
List_B=[int(i) for i in (input()).split()]
t=0
for j in range(1,N+1):
  List_A=[int(k) for k in (input()).split()]
  if sum([x*y for (x,y) in zip(List_A,List_B)])>-C:
    t+=1
print(t)


Fixed submission:
H,W=map(int,(input()).split())
h,w=map(int,(input()).split())
print((H-h)*(W-w))

Buggy python submission (verdict: Runtime Error):
H,W=int(input()).split()
h,w=int(input()).split()
print((H-h)*(W-w))

Fixed submission:
H,W=map(int,(input()).split())
h,w=map(int,(input()).split())
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
count=1
i=1
while count<K:
  i+=1
  if A%i=0 and B%i=0:
    count+=1
print(i)
  

Fixed submission:
A,B,K=map(int,input().split())
count=0
i=min(A,B)+1
while count<K:
  i-=1
  if A%i==0 and B%i==0:
    count+=1
print(i)
Buggy python submission (verdict: Runtime Error):
S=input()
Y=S[0:4]
M=S[5:7]
D=S[7:9]
YMD=int(Y+M+D)
if YMD<=20190430:
  print("Heisei")
else:
  print("TBD")

Fixed submission:
S=input()
Y=S[0:4]
M=S[5:7]
D=S[8:10]
YMD=int(Y+M+D)
if YMD<=20190430:
  print("Heisei")
else:
  print("TBD")
Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
  return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
 
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))
Buggy python submission (verdict: Runtime Error):
import bisect
a,b,q=map(int,input().split())
S,T=[],[]
for i in range(a):
  S.append(int(input()))
for i in range(b):
  T.append(int(input()))
def f(list,n):
  if n<list[0]:
    return [-float("inf"),list[0]]
  elif list[-1]<n:
    return [list[-1],float("inf")]
  else:
    i=bisect.bisect_left(list,n)
    return [list[i],list[i+1]]
def g(SS,TT,x):
  a,b,c,d=x-SS[0],SS[1]-x,x-TT[0],TT[1]-x
  dis1=max(a,c)
  dis2=min(2*a+d,2*d+a)
  dis3=max(b,d)
  dis4=min(2*b+c,2*c+b)
  return min([dis1,dis2,dis3,dis4])
for i in range(q):
  x=int(input())
  print(g(f(S,x),f(T,x),x))

Fixed submission:
import bisect
a,b,q=map(int,input().split())
S,T=[],[]
for i in range(a):
  S.append(int(input()))
for i in range(b):
  T.append(int(input()))
def f(list,n):
  if n<list[0]:
    return [-float("inf"),list[0]]
  elif list[-1]<n:
    return [list[-1],float("inf")]
  else:
    i=bisect.bisect_left(list,n)
    return [list[i-1],list[i]]
def g(SS,TT,x):
  a,b,c,d=x-SS[0],SS[1]-x,x-TT[0],TT[1]-x
  dis1=max(a,c)
  dis2=min(2*a+d,2*d+a)
  dis3=max(b,d)
  dis4=min(2*b+c,2*c+b)
  return min([dis1,dis2,dis3,dis4])
for i in range(q):
  x=int(input())
  print(g(f(S,x),f(T,x),x))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,q=map(int,input().split())
S,T=[],[]
for i in range(a):
  S.append(int(input()))
for i in range(b):
  T.append(int(input()))
def f(list,n):
  if n<list[0]:
    return [-float("inf"),list[0]]
  elif list[-1]<n:
    return [list[-1],float("inf")]
  else:
    flag,count=0,0
    l=len(list)
    i=(l-1)//2
    while flag==0:
      if list[i]<n<list[i+1]:
        flag=1
        return [list[i],list[i+1]]
      elif n<list[i]:
        i//=2
        count+=1
      else:
        i+=(l-1)//(2**(count+1))
        count+=1
def g(SS,TT,x):
  a,b,c,d=x-SS[0],SS[1]-x,x-TT[0],TT[1]-x
  dis1=max(a,c)
  dis2=min(2*a+d,2*d+a)
  dis3=max(b,d)
  dis4=min(2*b+c,2*c+b)
  return min([dis1,dis2,dis3,dis4])
        
for i in range(q):
  x=int(input())
  print(g(f(S,x),f(T,x),x))

Fixed submission:
import bisect
a,b,q=map(int,input().split())
S,T=[],[]
for i in range(a):
  S.append(int(input()))
for i in range(b):
  T.append(int(input()))
def f(list,n):
  if n<list[0]:
    return [-float("inf"),list[0]]
  elif list[-1]<n:
    return [list[-1],float("inf")]
  else:
    i=bisect.bisect_left(list,n)
    return [list[i-1],list[i]]
def g(SS,TT,x):
  a,b,c,d=x-SS[0],SS[1]-x,x-TT[0],TT[1]-x
  dis1=max(a,c)
  dis2=min(2*a+d,2*d+a)
  dis3=max(b,d)
  dis4=min(2*b+c,2*c+b)
  return min([dis1,dis2,dis3,dis4])
for i in range(q):
  x=int(input())
  print(g(f(S,x),f(T,x),x))