Harryxun/stf_run huggingface dataset:
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
X,Y,A,B,C = LI()
p = LI()
q = LI()
r = LI()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pa =  [0] + list(itertools.accumulate(p))
qa =  [0] + list(itertools.accumulate(q))
p = [0] + p
q = [0] + q
red = X
green = Y
t = 0
pl = 0
while p[red] < r[t] or q[green] < r[t]:
    pl += r[t]
    t += 1
    if red == 0:
        green -= 1
    elif green == 0:
        red -= 1

    elif p[red] < q[green] :
        red -= 1
    else:
        green -= 1
    if t < 0 or (green ==0 and red ==0): break
print (pa[red] + qa[green] + pl)

### FIXED CODE ###

import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
X,Y,A,B,C = LI()
p = LI()
q = LI()
r = LI()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pa =  [0] + list(itertools.accumulate(p))
qa =  [0] + list(itertools.accumulate(q))
p = [INF] + p
q = [INF] + q
red = X
green = Y
t = 0
pl = 0
while p[red] < r[t] or q[green] < r[t]:
    pl += r[t]
    t += 1
    if red == 0:
        green -= 1
    elif green == 0:
        red -= 1

    elif p[red] < q[green] :
        red -= 1
    else:
        green -= 1
    if t >=C or (green ==0 and red ==0): break
print (pa[red] + qa[green] + pl)
N,M = map(int,input().split())
A = list(map(int,input().split()))
ans1 = 0
ans2 = 0
for a in A:
    if x > a:
        ans1 +=1
    else:
        ans2 +=1 
paint(min(ans1,ans2))

### FIXED CODE ###

N,M,X = map(int,input().split())
A = list(map(int,input().split()))
ans1 = 0
ans2 = 0
for a in A:
    if X > a:
        ans1 +=1
    else:
        ans2 +=1 
print(min(ans1,ans2))
A,B = map(int,input().split())

scoew = 0
if A >= B:
	score = score + A
    A = A -1
else:
	score = score + B
    B = B -1

if A >= B:
	score = score + A
    A = A -1
else:
	score = score + B
    B = B -1
    
print(score)

### FIXED CODE ###

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

score = 0
if A >= B:
    score= score + A
    A = A - 1    
else:
    score = score + B
    B = B - 1

if A >= B:
    score = score + A
    A = A - 1
else:
    score = score + B
    B = B - 1
    
print(score)
N = int(input())
h = list(map(int, input().split()))
c = []
tmp = 0
for x in reversed(range(len(h))):
  if len(h) == 1:
    c.append(h[0])
  elif h[x] <= h[x-1]:
    tmp += 1
  else:
    c.append(tmp)
    tmp = 0
print(sorted(c)[-1])


### FIXED CODE ###

N = int(input())
h = list(map(int, input().split()))
c = []
tmp = 0
for x in reversed(range(len(h))):
  if len(h) == 1:
    c.append(0)
  elif h[x] <= h[x-1]:
    tmp += 1
  else:
    c.append(tmp)
    tmp = 0
if len(c) == 0:
  c.append(tmp-1)
print(sorted(c)[-1])
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 998244353 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    ll A,B,C,D;cin>>A>>B>>C>>D;
    //i番目はi個の列or行を選んでる
    vector<map<pair<ll,ll>,ll>> dp((D+C)-(B+A)+1);
    dp[0][MP(A,B)]=1;
    //dp[1][MP(A+1,B)]=B;
    //dp[1][MP(A,B+1)]=A;
    REP(i,(D+C)-(B+A)){
        for(auto j=dp[i].begin();j!=dp[i].end();j++){
            ll a,b;a=j->F.F;b=j->F.S;
            dp[i+1][MP(a,b+1)]+=(dp[i][MP(a,b)]*(a));
            dp[i+1][MP(a,b+1)]%=MOD;
            dp[i+1][MP(a+1,b)]+=(dp[i][MP(a,b)]*(b));
            dp[i+1][MP(a+1,b)]%=MOD;
        }
        if(i==0)continue;
        for(auto j=dp[i+1].begin();j!=dp[i+1].end();j++){
            ll a,b;a=j->F.F;b=j->F.S;
            if(a!=A and b!=B){
                dp[i+1][MP(a,b)]+=MOD;
                dp[i+1][MP(a,b)]-=(dp[i-1][MP(a-1,b-1)]*(a-1)*(b-1)%MOD);
                dp[i+1][MP(a,b)]%=MOD;
            }
        }
    }
    cout<<dp[(D+C)-(B+A)][MP(C,D)]%MOD<<endl; 
    #if 0
    REP(i,(D+C)-(B+A)+1){
        for(auto j=dp[i].begin();j!=dp[i].end();j++){
            ll a,b;a=j->F.F;b=j->F.S;
            cout << a << " " << b << " " << j->S << endl;
        }
    }
    #endif
}

### FIXED CODE ###

a,b,c,d=map(int,input().split());x=range(c+d);D=[[0]*6011for _ in[0]*6011];D[a][b]=1
for i in x:
 for j in x:D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%998244353
print(D[c][d])
N, M = map(int, input().split())
N_str = str(N)
flag = 1
kettei = [-1 for i in range(N)]
for i in range(M):
  s, c = map(int, input().split())
  if kettei[s-1] == -1:
    kettei[s-1] = c
  elif kettei[s-1] != c:
    flag = 0
if kettei[0] == 0 :
  flag = 0
    
ans = ""

for i in range(N):
  if kettei[i] == -1:
    ans += "1"
  else:
    ans += kettei[i]
if flag:
  print(ans)
else:
  print(-1)

### FIXED CODE ###

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

S, C = [], []
for i in range(M):
  s, c = map(int, input().split())
  S += [s-1]
  C += [str(c)]
  
if N == 1:
  for i in range(10):
    flag = 1
    for m in range(M):
      if str(i) != C[m]:
        flag = 0
        break
    if flag:
      print(i)
      break
  else:
    print(-1) 
else:
  for i in range(10**(N-1), 10**N):
    flag = 1
    i_str = str(i)
    for m in range(M):
      if i_str[S[m]] != C[m]:
        flag = 0
        break
    if flag:
      print(i)
      break
  else:
    print(-1)
X,A=map(int,input())
if X<A:
    print(0)
else:
    print(10)

### FIXED CODE ###

X,A=map(int,input().split())
if X<A:
    print(0)
else:
    print(10)
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K > A:
    N = K - A
    all_number = 1*A
    print(all_number)

    if N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    else:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

### FIXED CODE ###

A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)
n=input()
a=[int(input()) for _ in range(n)]
if any(x%2==1 for x in a):
    print('first')
else:
    print('second')

### FIXED CODE ###

n=int(input())
a=[int(input()) for _ in range(n)]
if any(x%2==1 for x in a):
    print('first')
else:
    print('second')
k, s = map(int, input().rstrip("\n").split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            count += (x + y + z == s)

print(count)


### FIXED CODE ###

n, lo, hi = map(int, input().rstrip("\n").split())
print(sum([i if lo <= sum(map(int, str(i))) <= hi else 0 for i in range(n + 1)]))
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    one_count = 0

    for si in s:
        if si == '1':
            one_count += 1
        else:
            break

    if s[0] == '1':
        if k == 1:
            print(s[0])
        elif one_count >= k:
            print(1)
        elif one_count < k:
            print(s[k - 1])
        else:
            print(s[1])
    else:
        print(s[0])


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    one_count = 0

    for si in s:
        if si == '1':
            one_count += 1
        else:
            break

    if s[0] == '1':
        if k == 1:
            print(s[0])
        elif one_count >= k:
            print(1)
        elif one_count < k:
            print(s[one_count])
        else:
            print(s[1])
    else:
        print(s[0])


if __name__ == '__main__':
    main()
N,x = map(int, input().split())
candy_list = list(map(int, input().split()))

count_candy_eat = 0

if(candy_list[-1] == 0):
    for i in (reversed(N)):
        if (i == N):
            continue
        else:
            if (candy_list[i] + candy_list[i-1] > x):
                count_candy_eat += candy_list[i] + candy_list[i-1] - x
                candy_list[i-1] = x - candy_list[i]

print(candy_list)

for i in range(N):
    if(i == 0):
        continue
    else:
        if(candy_list[i-1] + candy_list[i] > x):
            count_candy_eat += candy_list[i-1] + candy_list[i] - x
            candy_list[i] = x - candy_list[i-1]

print(count_candy_eat)

### FIXED CODE ###



N,x = map(int, input().split())
candy_list = list(map(int, input().split()))

count_candy_eat = 0

for i in range(N):
    if(i == 0):
        if(candy_list[0] > x):
            count_candy_eat += candy_list[0] - x
            candy_list[0] = x
    else:
        if(candy_list[i-1] + candy_list[i] > x):
            if(x - candy_list[i-1] > 0):
                count_candy_eat += candy_list[i-1] + candy_list[i] - x
                candy_list[i] = x - candy_list[i-1]
            else:
                count_candy_eat += candy_list[i]
                candy_list[i] = 0


print(count_candy_eat)
d,g = map(int,input().split())
li = []

for i in range(d):
    p,c = map(int,input().split())
    li.append([p,c])

ans = 10**9
for i in range(1<<d):
    ttl = 0
    cnt = 0
    memo = [0 for i in range(d)]
    for j in range(d):
        if (i>>j)&1:
            ttl += li[j][1]+(j+1)*li[j][0]*100
            cnt += li[j][0]
            memo[j] = 1

    if ttl < g:
        memo2 = g- ttl
        for j in range(d-1,-1,-1):
            if memo[j] == 0:
                if memo2%(100*(j+1)) == 0:
                    cnt2 = min(memo2//(100*(j+1)),p[j]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                else:
                    cnt += memo2//(100*(j+1))+1
                    ttl += (memo2//(100*(j+1))+1)*(100*(j+1))
                break
    if ttl >= g:
        ans = min(ans,cnt)
    

    
    

print(ans)



### FIXED CODE ###

d,g = map(int,input().split())
li = []

for i in range(d):
    p,c = map(int,input().split())
    li.append([p,c])

ans = 10**9
for i in range(1<<d):
    ttl = 0
    cnt = 0
    memo = [0 for i in range(d)]
    for j in range(d):
        if (i>>j)&1:
            ttl += li[j][1]+(j+1)*li[j][0]*100
            cnt += li[j][0]
            memo[j] = 1
    #print(memo,ttl)
    if ttl < g:
        memo2 = g- ttl
        for j in range(d-1,-1,-1):
            if memo[j] == 0:
                if memo2%(100*(j+1)) == 0:
                    cnt2 = min(memo2//(100*(j+1)),li[j][0]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                    #print(44444444)
                else:
                    cnt2 = min(((memo2//(100*(j+1)))+1),li[j][0]-1)
                    #print(((memo2//(100*(j+1)))+1))
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                break
    if ttl >= g:
        ans = min(ans,cnt)
"""   
    if ans == cnt:
        print(memo,ttl,111111)
"""   
    

print(ans)
N = int(input())
A = list(map(int, input().split()))
count = [0] * N
last = [0] * N
used = [0] * N

for i in range(3 * N):
  now = A[i] - 1
  count[now] += 1
  if count[now] == 3:
    last[now] = i
  #print(now)  
#print(count, last)    

score = 0
now = [A[0], A[1], A[2], A[3], A[4]]
for i in range(N - 1):
  L = [0] * 5
  for j in range(5):
    L[j] = [last[now[j] - 1], j]
  L = sorted(L)
  #print(L)
  if L[1][0] == L[2][0]:
    if L[0][0] == L[1][0]:
      score += 1
      one, two = L[3][1], L[4][1]
    elif L[2][0] == L[3][0]:
      score += 1
      one, two = L[0][1], L[4][1]
    else:
      one, two = L[0][1], L[1][1]
  elif L[2[0]] == L[3][0] and L[3][0] == L[4][0]:
    score += 1
    one, two = L[0][1], L[1][1]
  else:
    one, two = L[0][1], L[1][1]
    
  if i != N - 2:
    now = [A[one], A[two], A[5 + 3 * i], A[6 + 3 * i], A[7 + 3 * i]]
  else:
    now = [A[one], A[two], A[-1]]
  
if now[0] == now[1] and now[1] == now[2]:
  score += 1
    
print(score)  
      
      
  
  
  
  
  
  
  
  
  
  
  
  





### FIXED CODE ###

#ABC176 #F 問題 (Question F) #解説方針 #提出参考
N = int(input())
A = list(map(int, input().split()))

#DP(動的計画法)用配列
ans = [[-N] * (N+1) for _ in range(N+1)]
#初期化 (Initialization)
a0, a1 = A[:2]
ans[a0][a1] = 0
ans[a1][a0] = 0

##最大値の管理
#ans[i] の最大値を集めた配列 (0 <= i <= N)
ma = [-N] * (N+1) 
#ans の初期化に合わせて初期化
ma[a0] = 0
ma[a1] = 0
#ansの全要素の最大値、0で初期化
all_max = 0

#3, 4, 5番目の数が等しいときに加算するための変数
add = 0

#DP部分 多分 O(N ** 2)
for i in range(N - 1): 
    #3, 4, 5番目の数を a, b, c とする
    a, b, c = A[3 * i + 2], A[3 * i + 3], A[3 * i + 4]
    #3つとも等しいとき、最後の三枚を消す
    if a == b == c:
        add += 1
        continue
    Q = []
    for _ in range(3):
        a, b, c = b, c, a
        # a, b, c から残す数を2つ選ぶ
        # ans[c][c] + 1 は [c,c,a,b,c]を想定
        # all_max は DP[i][k][l]の最大値で最大化するときに対応
        Q.append((a, b, max(all_max, ans[c][c] + 1)))
        
        # a, b, c から残す数を1つ選ぶ
        for j in range(1, N + 1):
            #これまでのDP[i][k][l] (k, lのうち片方の変数として見たとき) の最大値
            val = ma[j]
            #2つの数が等しいとき
            if b == c:
                val = max(val, ans[b][j] + 1)
            Q.append((a, j, val))
            
        #配列を使いまわしているので、DP[i + 1][k][l] を DP[i][k][l]で最大化し直す必要なし
        #もしDP[i][k][l]が最大なら、maxを取る過程でこれが残る
    for i, j, val in Q:
        #DP配列の更新
        ans[i][j] = max(ans[i][j], val)
        ans[j][i] = max(ans[j][i], val)
        #最大値の管理
        ma[i] = max(ma[i], val)
        ma[j] = max(ma[j], val)
        all_max = max(all_max, val)
        
#ans の中から最大の値を見つけ出す。O(N ** 2)        
answer = 0
for i in range(1, N + 1):
    for j in range(1, N + 1):
        #最後に残った3枚が同じならもう1点加算
        if i == j == A[-1]:
            answer = max(answer, ans[i][j] + 1)
        else:
            answer = max(answer, ans[i][j])
            
print(answer + add)
import numpy as np

h,w = map(int,input().split())

field = []

l = np.zeros((h+2,w+2),dtype=np.int64)
r = np.zeros((h+2,w+2),dtype=np.int64)
u = np.zeros((h+2,w+2),dtype=np.int64)
d = np.zeros((h+2,w+2),dtype=np.int64)
tot = np.zeros((h,w),dtype=np.int64)

for i in range(h):
    field.append(list(input()))

field = np.pad(field,(1,1),"constant",constant_values="#")

# print(field)

for i in range(h+2):
    for j in range(w+1):
        if field[i][j+1] == ".":
            l[i][j+1] = l[i][j] + 1
        else:
            continue

for i in range(h+2):
    for j in range(1,w+1):
        if field[i][-j-1] == ".":
            r[i][-j-1] = r[i][-j] + 1
        else:
            continue

for i in range(w+2):
    for j in range(h+1):
        if field[j+1][i] == ".":
            u[j+1][i] = u[j][i] + 1
        else:
            continue

for i in range(w+2):
    for j in range(1,h+1):
        if field[-j-1][i] == ".":
            d[-j-1][i] = d[-j][i] + 1
        else:
            continue

# print(l)
# print(r)
# print(u)
# print(d)

for i in range(h):
    for j in range(w):
        tot[i][j] = l[i+1][j+1]+r[i+1][j+1]+u[i+1][j+1]+d[i+1][j+1]-3

# print(tot)

print(np.max(tot))

### FIXED CODE ###

import numpy as np

H,W = map(int, input().split())
s = [list(input()) for j in range(H)]
s = (np.array(s) == ".") * 1

L = np.zeros((H, W), dtype = int)
R = np.zeros((H, W), dtype = int)
U = np.zeros((H, W), dtype = int)
D = np.zeros((H, W), dtype = int)


for j in range(W):
    if j == 0:
        L[:,j] = s[:,j]
    else:
        L[:,j] = (L[:,j-1] + 1) * s[:,j]
        

for j in reversed(range(W)):
    if j == W-1:
        R[:,j] = s[:,j]
    else:
        R[:,j] = (R[:,j+1] + 1) * s[:,j]


for i in range(H):
    if i == 0:
        U[i,:] = s[i,:]
    else:
        U[i,:] = (U[i-1,:] + 1) * s[i,:]

for i in reversed(range(H)):
    if i == H-1:
        D[i,:] = s[i,:]
    else:
        D[i,:] = (D[i+1,:] + 1) * s[i,:]

print(np.max(L + R + U + D - 3))
N=int(input())
a=list(map(int,input().split()))
if N==3:
    if a[0]^a[1]==a[2]:
        print("Yes")
    else:
        print("No")
    input()
else:
    if max(a)==0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

import collections
N=int(input())
a=list(map(int,input().split()))
l=[]
if max(a)==0:
    print("Yes")
elif (N%3)==0:
    c=collections.Counter(a)
    values = list(c.values())  # aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
    key = list(c.keys())  # 先のvalue値に相当する要素のリスト(要素1,要素2,…)
    for i in range(len(key)):
        l.append([key[i], values[i]])  # lは[要素i,n_i]の情報を詰めたmatrix
    l.sort(key=lambda x:x[1],reverse=True)
    #print(l)
    if (len(l)==3)and(l[0][1]==l[1][1]==l[2][1])and(l[0][0]^l[1][0]==l[2][0]):
        print("Yes")
    elif (len(l)==2)and(l[0][1]==2*l[1][1])and(l[1][0]==0):
        print("Yes")
    else:
        print("No")
else:
    print("No")
#n = 5
#C = list(map(int,"1 2 3 4 5".split()))
#line = ["1 2", "2 3", "3 4", "3 5"]


n = int(input())
C = list(map(int,input().split()))
 
ci = [set() for _ in range(n)]
for i,c in enumerate(C):
    ci[c-1].add(i)

path = [set() for _ in range(n)]
 
#line = ["1 2", "2 3"]
    
for i in range(n-1):
    a,b = map(int,input().split())
    #a,b = map(int,line[i].split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
ans = [n*(n+1)//2]*n
size = [0]*n
cparent = [[] for _ in range(n)]
reached = [False]*n
root_size = [n]*n

def dfs (p):
    c = C[p] - 1
    cparent[c].append(p)
    s = 1
    for nxt in path[p]:
        #print (nxt)
        size[p] = 0
        if reached[nxt]:
            continue
        reached[nxt] = True
        ret = dfs(nxt)
        s += ret
        size[p] +=ret
        ans[c] -= size[p] * (size[p] + 1)//2
    cparent[c].pop()
    if cparent[c]:
        size[cparent[c][-1]] -=s
    else:
        root_size[c] -=s    
    return s

reached[0] = True
dfs (0)

for i in range(n):
    print (ans[i]-root_size[i]*(root_size[i]+1)//2)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

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

path = [set() for _ in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
ans = [n*(n+1)//2]*n
size = [0]*n
cparent = [[] for _ in range(n)]
reached = [False]*n
root_size = [n]*n

def dfs (p):
    c = C[p] - 1
    cparent[c].append(p)
    s = 1
    for nxt in path[p]:
        #print (nxt)
        
        if reached[nxt]:
            continue
        size[p] = 0
        reached[nxt] = True
        ret = dfs(nxt)
        s += ret
        size[p] +=ret
        ans[c] -= size[p] * (size[p] + 1)//2
    cparent[c].pop()
    if cparent[c]:
        size[cparent[c][-1]] -=s
    else:
        root_size[c] -=s    
    return s

reached[0] = True
dfs (0)

for i in range(n):
    print (ans[i]-root_size[i]*(root_size[i]+1)//2)
n, k = map(int, input())
print(n-k+1)

### FIXED CODE ###

n, k = map(int, input().split())
print(n-k+1)
n = int(input())
a = list(map(int,input().split()))
l =[]
for i in a:
    l.append(i//400)
x = set()
y = 0
for i in l:
    if i< 7:
        x.add(i)
    else:
        y +=1
x = len(x)
if x:
    mi =x
else:
    mi =1
ma =x+y
print('{}{}'.format(mi.ma))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
l =[]
for i in a:
    l.append(i//400)
x = set()
y = 0
for i in l:
    if i<= 7:
        x.add(i)
    else:
        y +=1
x = len(x)
if x:
    mi =x
else:
    mi =1
ma = x+y
print('{} {}'.format(mi, ma))
MOD = 10**9 + 7
L = input().rstrip()
n = len(L)

ans = 0
l_num = L.count("1")
dp_t = [[0] * n for _ in range(2)]
dp_l = [[0] * n for _ in range(2)]
dp_t[1][0] = 2
dp_l[0][1] = 1
dp_l[1][1] = 2
for i in range(1, n):
    if L[i] == "0":
        dp_t[0][i] += dp_t[0][i-1] + dp_t[1][i-1] 
    elif L[i] == "1":
        dp_t[1][i] += (dp_t[0][i-1] + dp_t[1][i-1]) * 2
        dp_l[0][i] += dp_t[0][i-1] + dp_t[1][i-1]
    dp_l[0][i] += dp_l[0][i-1] + dp_l[1][i-1]
    dp_l[1][i] += (dp_l[0][i-1] + dp_l[1][i-1]) * 2

    dp_l[1][i] %= MOD
    dp_l[0][i] %= MOD
    dp_t[1][i] %= MOD
    dp_t[0][i] %= MOD

print((dp_t[1][n-1] + dp_t[0][n-1] + dp_l[1][n-1] + dp_l[0][n-1]) % MOD)

### FIXED CODE ###

MOD = 10**9 + 7
L = input().rstrip()
if L == "1":
    print(3)
    exit()
n = len(L)

ans = 0
l_num = L.count("1")
dp_t = [[0] * n for _ in range(2)]
dp_l = [[0] * n for _ in range(2)]
dp_t[1][0] = 2
dp_l[0][1] = 1
dp_l[1][1] = 2
for i in range(1, n):
    if L[i] == "0":
        dp_t[0][i] += dp_t[0][i-1] + dp_t[1][i-1] 
    elif L[i] == "1":
        dp_t[1][i] += (dp_t[0][i-1] + dp_t[1][i-1]) * 2
        dp_l[0][i] += dp_t[0][i-1] + dp_t[1][i-1]
    dp_l[0][i] += dp_l[0][i-1] + dp_l[1][i-1]
    dp_l[1][i] += (dp_l[0][i-1] + dp_l[1][i-1]) * 2

    dp_l[1][i] %= MOD
    dp_l[0][i] %= MOD
    dp_t[1][i] %= MOD
    dp_t[0][i] %= MOD

print((dp_t[1][n-1] + dp_t[0][n-1] + dp_l[1][n-1] + dp_l[0][n-1]) % MOD)
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
S1 = input()
S2 = input()

if 1 < N and S1[0] == S1[1]:
	ans = 6
	tmp = 2
	flg = 1
else:
	ans = 3
	tmp = 1
	flg = 0


while tmp < N:
	if tmp < N-1 and S1[tmp] == S1[tmp+1]:
		if flg:
			ans *= 3
		else:
			ans *= 2
		flg = 1
		tmp += 2

	else:
		if flg:
			ans *= 1
		else:
			ans *= 2
		flg = 0
		tmp += 1
	ans %= mod


print(ans)




### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
x, a, b = MAP()
if abs(a-x) > abs(b-x):
	print("B")
else:
	print("A")