Harryxun/stf_run huggingface dataset:
import math
N = int(input())
print(2 * N // math.gcd(2, N))

### FIXED CODE ###

N = int(input())
print(N if N % 2 == 0 else 2 * N)
A=int(input())
B=int(input())
C=A + B
 
if  A%3==0 or B%3==0 or C%3==0: print("Possible")
else: print("Impossible")

### FIXED CODE ###

a,b=map(int,input().split())
c=a + b
 
if  a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")
H, W, N = map(int, input().split())
field = [list(input()) for i in range(H)]
node_posi = {}
Q = []

for i in range(H):
	for j in range(W):
		if field[i][j] in 'S123456789':
			node_posi[field[i][j]] = [j, i, 0]

s =	'S123456789'
cost = 0
for i in range(len(node_posi)-1):
	Q.clear()
	searched = [[0]*W for i in range(H)]
	start, goal = node_posi[s[i]], node_posi[s[i+1]]
	Q.append(start)
	while Q:
		x, y, c = Q.pop(0)
		searched[y][x] = 1
		
		if ([x, y, 0] == goal):
			cost += c
			break
		for q in range(4):
			nx = x + [1,0,-1,0][q]
			ny = y + [0,1,0,-1][q]
			if (nx >= 0 and nx <= W-1) and (ny >= 0 and ny <= H-1) and (searched[ny][nx] == 0) and (field[ny][nx] != 'X'):
				Q.append([nx, ny, c+1])
print(cost)


### FIXED CODE ###

#import time, sys#
from collections import deque

H, W, N = map(int, input().split())
field = [list(input()) for i in range(H)]
'''
20 30 9
.......X..8.XXXX.XX..XX.X.XX..
X.XX....X.XX..X.X.X....XXXX..X
..X.X..XX..X.....XX.X..X.XX...
....X.X.X.XXX.X..X..X.X..XX.X.
..XXX.XX...X.X....X.X..X..X...
..X...........X.X...X.1.XX...X
.X.X....X..XX..XX......9.X...4
..X....X........X......X......
....XXX.X...XX.X.....X.X..X.X.
..S..XXX..X....X.X.......X..X.
.5...XX..X.X..X....X...XXX....
..X...X.X....X....X..X.2X.....
XXXXXXXX.X.XX..XX..XX.......X.
.....X...........3..XX.XXX.X.X
..X.....X..X..XX.XX..X.X...XX.
...X..X.XXX.XX......X...X..XXX
.X.XX.X.........X.X...X...X..X
..X...X..X..XX..XXX..X.XX...X.
X....X.X....X...X.X..XX.XX..X.
...X6X..X........X.X.....7.X..
'''

#input = input().split('\n')#
#H, W, N = map(int, input.pop(0).split())#
#field = [line for line in input]#
node_posi = [0 for i in range(N+1)]

#s1 = time.time()#
nodes = 'S123456789'
for i in range(H):
	for j in range(W):
		if field[i][j] in nodes:
			node_posi[nodes.index(field[i][j])] = [j, i]
#e1 = time.time()#
#print("b:{}".format(e1-s1))#

cost = 0
#count = 1#
for i in range(len(node_posi)-1):
	#s2 = time.time()#
	searched = [[-1]*W for i in range(H)]
	start, goal = node_posi[i], node_posi[i+1]
	Q = deque([start])
	searched[start[1]][start[0]] = 0
	goal_flag = False
	
	while Q and not goal_flag:
		x, y = Q.popleft()
		goal_flag = False

		for q in range(4):
			nx = x + [1,0,-1,0][q]
			ny = y + [0,1,0,-1][q]
			
			if nx >= 0 and nx < W and ny >= 0 and ny < H:
				if searched[ny][nx] == -1 and field[ny][nx] != 'X':
					Q.append([nx, ny])
					searched[ny][nx] = searched[y][x] + 1
					if ([nx, ny] == goal):
						cost += searched[ny][nx]
						goal_flag = True
						break

			#s = "\n".join(["".join(map(lambda x: str(x)[:1], j)) for j in searched])#
			#sys.stdout.write("\r{}".format(s))#
			#sys.stdout.flush()#
	
	#e2 = time.time()#
	#print("{}:{}".format(count, e2-s2))#
	#count += 1#
print(cost)
t=int(input())
if(t==1):
  print(0)
else:
  print(1)/

### FIXED CODE ###

t=int(input())
if(t==1):
  print(0)
else:
  print(1)
S = input()
Q = int(input())
P = [input().split() for i in range(Q)]

count = 0

for query in P:
    if query[0]=="1":
        count+=1
    else:
        if query[1]=="1":
            if count%2==0:
                S=query[2]+S
            else:
                S=S+query[2]
        else:
            if count%2==0:
                S=S+query[2]
            else:
                S=query[2]+S
if count%2==1:
    S=S[::-1]
    
print(S)


### FIXED CODE ###

S = input()
Q = int(input())
P = [input().split() for i in range(Q)]

count = 0
left = ""
right = ""
for query in P:
    if query[0]=="1":
        count+=1
    else:
        if query[1]=="1":
            if count%2==0:
                left+=query[2]
            else:
                right+=query[2]
        else:
            if count%2==0:
                right+=query[2]
            else:
                left+=query[2]
                
S = left[::-1]+S+right
if count%2==1:
    S=S[::-1]
    
print(S)
N=int(input())
print(sum(range(1,N)))


### FIXED CODE ###

S=list(input())
T=list(input())
if S[0]==T[0] and S[1]==T[1] and S[2]==T[2]:
  print(3)
elif S[0]==T[0] and S[1]!=T[1] and S[2]!=T[2]:
  print(1)
elif S[0]!=T[0] and S[1]==T[1] and S[2]!=T[2]:
  print(1)
elif S[0]!=T[0] and S[1]!=T[1] and S[2]==T[2]:
  print(1)
elif S[0]!=T[0] and S[1]!=T[1] and S[2]!=T[2]:
  print(0)
else:
  print(2)
A, B, C = map(int, input().split())
if A == B:
    if B==C:
        print(‘Yes’)
    else:
        print(‘No’)
else:
    print(‘No’)


### FIXED CODE ###

A, B, C = map(int, input().split( ))
if A == B & B==C:
    print('Yes')
else: 
    print('No')
# -*- coding: utf-8 -*-

n = list(int(input()))

def digit_list(num):
    num = str(num)
    num = list(num)
    num = list(map(int,num))
    return num

n = digit_list(n)

if n[0] == n[-1]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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

n = int(input())

def digit_list(num):
    num = str(num)
    num = list(num)
    num = list(map(int,num))
    return num

n = digit_list(n)

if n[0] == n[-1]:
    print("Yes")
else:
    print("No")
def main(n:int,lst:list)->int:
    lst1 = lst[::2]
    lst2 = lst[1::2]
    ans1 =count2(lst1)
    ans2 =count2(lst2)
    if ans1[0][0] == ans2[0][0]:
        if ans1[1] and ans2[1]:
            return n - max(ans1[0][1] + ans2[1],ans2[0][1] + ans1[1])
        else:
            return n//2
    else:
        return n - ans1[0][1] - ans2[0][1]
def count2(lst):
    lst.sort()
    ans = [["",0],0]
    last =lst[0]
    a = 0
    for e in lst:
        if last == e:
            a +=1
        else:
            ans = check(a,ans)
            last = e
            a = 1
    return check(a,ans)
def check(a,ans):
    if a > ans[0][1]:
        ans[1] = ans[0][1]
        ans[0][0] = e
        ans[0][1] = a
    elif a > ans[1]:
        ans[1] = a
    return ans
n = int(input())
lst = input().split()
print(main(n,lst))


### FIXED CODE ###

from collections import Counter


def solve(V):
    n = len(V)
    ac = Counter(V[::2]).most_common(2)
    bc = Counter(V[1::2]).most_common(2)

    if ac[0][0] != bc[0][0]:
        return n - ac[0][1] - bc[0][1]
    else:
        if len(bc) == 1 or len(ac) == 1:
            return n // 2
        else:
            return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])


if __name__ == "__main__":
    n = int(input())
    l = input()
    print(solve(l.split(" ")))
import sympy

N = int(input())

cnt = 0
for i in range(1, N + 1, 2):
    if len(sympy.divisors(i)) == 8:
        cnt += 1

print(cnt)

### FIXED CODE ###

N = int(input())

ans = 0
for i in range(1, N + 1, 2):
    cnt = 0
    for j in range(1, i + 1):
        if i % j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
        cnt = 0
    
print(ans)
x, y = input().split(' ')
x = int(x)
y = int(y)

return y / 2 + x

### FIXED CODE ###

x, y = input().split(' ')
x = int(x)
y = int(y)
print(int(y / 2 + x))
import numpy as np

a,b=map(int,input().split())
c=[]
for i in range(b):
    c.append(int(input()))
c.append(a+1)    
def Fib(n):
    fib=1/np.sqrt(5)*(((1+np.sqrt(5))/2)**(n)-((1-np.sqrt(5))/2)**(n))
    return(int(fib))

d=[]
z=-1
for j in c:
    di=j-z-1
    if j-z==1:
        print(0)
        exit()
    else:
        d.append(Fib(di))
        z=j
ans=1
for k in d:
    ans=ans*k
print(ans%1000000007)

### FIXED CODE ###

import sys

n,m=map(int,input().split())
c=set(map(int,sys.stdin))

d=[0]*(n+1)
d[0]=1
d[1]=1 if 1 not in c else 0
for j in range(2,n+1):
    if j in c:
        pass
    else:
        d[j]=(d[j-1]+d[j-2])%1000000007

print(d[n])
k= int(input(). strip())
a, b = map(int,input().split())

num = (a-1)
while num <= b:
    num += 1
        if num % k != 0:
            continue
        else:
            print('OK')
            break
    else:
        print('NG')

### FIXED CODE ###

k= int(input(). strip())
a, b = map(int,input().split())

if k == 1:
  print('OK')
  exit( )
else:
  pass
  
num = a
for num in range(a,b+1):
    if num % k != 0:
        num += 1
    else:
        print('OK')
        break
else:
	print('NG')
n=int(input())
d=list(map(int, input().split()))

d.sort()

print(int(d[n/2]-d[n/2-1]))

### FIXED CODE ###

N=int(input())
temp=input().split()
d=[int(temp[i]) for i in range(N)]
d.sort()
  
a=d[int(N/2-1)]
b=d[int(N/2)]
print(int(b-a))
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())))[::-1]
B=sorted(list(map(int,input().split())))[::-1]
C=sorted(list(map(int,input().split())))[::-1]
ans=[0]*max((len(A)*len(B)*len(C)),K)
ind=0
for a in range(len(A)):
  for b in range(len(B)):
    for c in range(len(C)):
      if (a+1)*(b+1)*(c+1)>K:
        break
      ans[ind]=A[a]+B[b]+C[c]
      ind+=1

ans=sorted(ans)[::-1]
for i in range(min(K,len(ans))):
  print(ans[i])


### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())))[::-1]
B=sorted(list(map(int,input().split())))[::-1]
C=sorted(list(map(int,input().split())))[::-1]
ans=[]
for a in range(len(A)):
  for b in range(len(B)):
    for c in range(len(C)):
      if (a+1)*(b+1)*(c+1)>K:
        break
      ans.append(A[a]+B[b]+C[c])

ans=sorted(ans)[::-1]
for i in range(min(K,len(ans))):
  print(ans[i])
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

xs = 0
for i in range(N):
    xs += i  * X[i]
    xs -= (N - i - 1) * X[i]
    xs %= MOD
ys = 0
for i in range(M):
    ys += i  * Y[i]
    ys -= (M - i - 1) * Y[i]
    ys %= MOD
print(xs * ys % MOD)


### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

xs = 0
for i in range(N):
    xs += i  * X[i]
    xs -= (N - i - 1) * X[i]
    xs %= MOD
ys = 0
for i in range(M):
    ys += i  * Y[i]
    ys -= (M - i - 1) * Y[i]
    ys %= MOD
print(xs * ys % MOD)
a,b = map(int,input().split())
print("Even" if a * b % 2 == 0:"Odd");

### FIXED CODE ###

a,b = map(int,input().split())
if a*b % 2 == 0:
    print('Even')
else:
    print('Odd')
a=int(input())
if a=3 or a=5 or a=7:
    print("YES")
else:
    print("NO ")

### FIXED CODE ###

a=int(input())
if a==3 or a==5 or a==7:
    print("YES")
else:
    print("NO ")
N = input()
if N == 1:
  print("Hello World")
else:
  A = input()
  B = input()
  print(A + B)

### FIXED CODE ###

N = int(input())
if N == 1:
  print("Hello World")
else:
  A = int(input())
  B = int(input())
  print(A + B)
max = 0
i = 0
j = 0
k = 0
n_max = 0
??
n_max = int(raw_input())
price = [1,2,3,4,5,6]
for i in range(6):
????for j in range(6):
????????????if max <= price[j] - price[i]:
????????????????????print max

### FIXED CODE ###

import sys

n = int(raw_input())

min_R = int(raw_input())
nums = map(int, sys.stdin.readlines())

ans = -10**9

for num in nums:
    if num - min_R > ans:
        ans = num - min_R
    if num < min_R:
        min_R = num
        
print ans
a,b,k = 0
for i in range(6):
  t = int(input())
  if(i == 0):
    a = t
  elif(i == 4):
    b = t
  elif(i == 6):
    k = t

if(b - a > k):
  print(':(')
else:
  print('Yay!')

### FIXED CODE ###

k = 0
a = 0
b = 0
for i in range(6):
  t = int(input())
  if(i == 0):
    a = t
  elif(i == 4):
    b = t
  elif(i == 5):
    k = t

if(b - a > k):
  print(':(')
else:
  print('Yay!')
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

h,w = iim()

flag = True

l = []
dx = [0,0,1,-1]
dy = [1,-1,0,0]
for i in range(h):
    l.append(list(input()))

for i in range(h):
    for j in range(w):
        if l[i][j] == '#':
            check = False
            for k in range(4):
                if i+dx[k] < 0 or i+dx[k] >= w:
                    continue
                if j+dy[k] < 0 or j+dy[k] >= h:
                    continue
                if l[i+dx[k]][j+dy[k]] == '#':
                    check = True
            if not check:
                flag = False

print('Yes' if flag else 'No')

### FIXED CODE ###

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

h,w = iim()

flag = True

l = []
dx = [0,0,1,-1]
dy = [1,-1,0,0]
for i in range(h):
    l.append(list(input()))

for i in range(h):
    for j in range(w):
        if l[i][j] == '#':
            check = False
            for k in range(4):
                if i+dx[k] < 0 or i+dx[k] >= h:
                    continue
                if j+dy[k] < 0 or j+dy[k] >= w:
                    continue
                if l[i+dx[k]][j+dy[k]] == '#':
                    check = True
            if not check:
                flag = False

print('Yes' if flag else 'No')
n,k = map(int, input().split())
if k=1:
  print(0)
else:
  print(n-k)

### FIXED CODE ###

n,k = map(int, input().split())
if k==1:
  print(0)
else:
  print(n-k)
while 1:
	x,y = list(map(int,input()split()))
	if x == 0:
		break

	pp = [1,-1,0,0]
	qq = [0,0,1,-1]
	m = []
	for i in range(y):
		m.append(list(input()))
		if '@' in m[-1]:
			ss = m[-1].index('@')
			tt = i
	cnt = 0

	def move (cx,cy):
		global cnt
		if cy >= y or cy < 0 or cx >= x or cx < 0:
			return 0
		if m[cy][cx] = '.'v or  m[cy][cx] = '@'
			cnt += 1
			m[cy][cx] = '0'
			for i in range(4):
				move(cx + pp[i],cy + qq[i])
	move(ss,tt)
	print(cnt)



### FIXED CODE ###

while 1:
	x,y = list(map(int,input().split()))
	if x == 0:
		break

	pp = [1,-1,0,0]
	qq = [0,0,1,-1]
	m = []
	for i in range(y):
		m.append(list(input()))
		if '@' in m[-1]:
			ss = m[-1].index('@')
			tt = i
	cnt = 0

	def move (cx,cy):
		global cnt
		if cy >= y or cy < 0 or cx >= x or cx < 0:
			return
		if m[cy][cx] == '.' or  m[cy][cx] == '@':
			cnt += 1
			m[cy][cx] = '0'
			for i in range(4):
				move(cx + pp[i],cy + qq[i])
	move(ss,tt)
	print(cnt)
def hoge():
  dp = [0] * (n + 5)
  for i in range(1, n):
    p = [dp[j] + abs(h_list[i] - h_list[j]) for j in range(max(0, i - k), i)]
    dp[i] = min(p)
  return dp[n - 1]

def solve():
  global n, k, h_list
  n, k = map(int, input().split())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()

### FIXED CODE ###

def hoge():
  dp = [0] * (n + 5)
  dp[1] = abs(h_list[1] - h_list[0])
  for i in range(2, n):
    dp[i] = min(
      dp[i - 2] + abs(h_list[i] - h_list[i - 2]),
      dp[i - 1] + abs(h_list[i] - h_list[i - 1])
      )
  return dp[n - 1]

def solve():
  global n, h_list
  n = int(input())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()
from math import gcd

N = int(input())
ret = 1
for i in range(N):
    hoge = int(input())
    ret = int((ret * hoge)/gcd(ret, hoge))
print(ret)


### FIXED CODE ###

def gcd(a, b):
    if b>a:
        a,b = b,a
    if b==0:
        return a
    return gcd(b, a%b)

N = int(input())
ret = 1
for i in range(N):
    hoge = int(input())
    ret = (ret * hoge)//gcd(ret, hoge)
print(ret)
import numpy as np
import itertools
N, K = [int(_) for _ in input().split()]
XYC = []
b = np.zeros((2 * K, 2 * K), dtype=int)
for _ in range(N):
    x, y, c = input().split()
    x = int(x)
    y = int(y)
    if c == 'W':
        y += K
    dy = K * (y // (2 * K))
    y -= dy
    x -= dy
    x %= 2 * K
    b[x, y] += 1
    b[(x + K) % (2 * K), y + K] += 1
c = np.pad(b, [(1, 0), (1, 0)], 'constant')
acc = c.cumsum(axis=0).cumsum(axis=1)
ans = max(acc[i + K, j + K] - acc[i, j + K] - acc[i + K, j] + acc[i, j]
          for i, j in itertools.product(range(K), range(K)))
print(ans)


### FIXED CODE ###

import itertools
import numpy as np
N, K, *XYC = open(0).read().split()
N = int(N)
K = int(K)
board = np.zeros((4 * K + 1, 4 * K + 1), dtype=np.uint16)
for x, y, c in zip(XYC[::3], XYC[1::3], XYC[2::3]):
    x = int(x)
    y = int(y)
    if c == 'W':
        x += K
    x = x % (2 * K)
    y = y % (2 * K)
    board[x, y] += 1
    board[(x + K) % (2 * K), (y + K) % (2 * K)] += 1
board[1 + 2 * K:, 1 + 2 * K:] = board[:2 * K, :2 * K]
board[1:1 + 2 * K, 1 + 2 * K:] = board[1 + 2 * K:, 1 + 2 * K:]
board[1 + 2 * K:, 1:1 + 2 * K] = board[1 + 2 * K:, 1 + 2 * K:]
board[1:1 + 2 * K, 1:1 + 2 * K] = board[1 + 2 * K:, 1 + 2 * K:]
board[0, :] = 0
board[:, 0] = 0
for j in range(1, 1 + 4 * K):
    board[:, j] += board[:, j - 1]
for j in range(1, 1 + 4 * K):
    board[j, :] += board[j - 1, :]
ans = np.max(board[K:3 * K, K:3 * K] + board[:2 * K, :2 * K] -
             board[:2 * K, K:3 * K] - board[K:3 * K, :2 * K])
print(ans)
K = input()
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[K+1])

### FIXED CODE ###

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
if K < 32:
    print(list[K-1])
else:
    print(list[31])
n,z,w = map(int,input().split())

al = list(map(int,input().split()))
if len(al) == 1:
    print(abs(al[-1] - w))
ans1 = abs(al[-1] - al[-2])
ans2 = abs(al[-1] - w)

print(max(ans1, ans2))


### FIXED CODE ###

n,z,w = map(int,input().split())

al = list(map(int,input().split()))
if len(al) == 1:
    print(abs(al[-1] - w))
    exit()
ans1 = abs(al[-1] - al[-2])
ans2 = abs(al[-1] - w)

print(max(ans1, ans2))
N, M = map(int,input().sprit())
A = list(map(int,input().sprit()))

enjoy = N - sum(A)

if N >= sum(A):
    print(enjoy)

else:
    print('-1')

### FIXED CODE ###

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

enjoy = N - sum(A)

if N >= sum(A):
    print(enjoy)

else:
    print('-1')
import math
x,y = map(int,input().split())
sum_xy = x+y

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if sum_xy%3!=0:
    print(0)
else:
    ab_sum = sum_xy//3
    a = x-ab_sum
    b = y-ab_sum
    print(cmb(ab_sum,a,inf))

### FIXED CODE ###

x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
    exit()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
 
a = (2*x-y)//3
b = (2*y-x)//3
n = a+b
r = a
res = cmb(n,r,mod)
print(res)
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = math.ceil((n-1)/(k-1))
print(ans)

### FIXED CODE ###

inp = input()
plus = int(inp.count("+"))
minus = int(inp.count("-"))
print(plus-minus)
N, Q = [int(_) for _ in input().split()]
S = input()
l_r_list = [[int(_) for _ in input().split()] for _ in range(Q)]

AC_accumulation = [0]

for i in range(1, N + 1):
    if S[i] == "C":
        if S[i - 1] == "A":
            AC_accumulation.append(AC_accumulation[-1] + 1)
    else:
        AC_accumulation.append(AC_accumulation[-1])


ans = []
for l, r in l_r_list:
    ans.append(str(AC_accumulation[r - 1] - AC_accumulation[l - 1]))

print("\n".join(ans))


### FIXED CODE ###

N, Q = [int(_) for _ in input().split()]
S = input()
l_r_list = [[int(_) for _ in input().split()] for _ in range(Q)]

AC_accumulation = [0]

for i in range(1, N):
    if S[i] == "C" and S[i - 1] == "A":
        AC_accumulation.append(AC_accumulation[-1] + 1)
    else:
        AC_accumulation.append(AC_accumulation[-1])


ans = []
for l, r in l_r_list:
    ans.append(str(AC_accumulation[r - 1] - AC_accumulation[l - 1]))

print("\n".join(ans))
X = int(input())

if X == 3 or X == 5 or X == 7:
	print('Yes')
else 
	print('No')

### FIXED CODE ###

X = int(input())


if X == 3 or X == 5 or X == 7:
	print('YES')
else :
	print('NO')
N, K = map(int, input().split())
S = input()

L = []
before = ''
cnt = 0
len_l = 0
for i in range(N):
    if before == '0' and S[i] == '0':
        cnt += 1
    elif before == '0' and S[i] == '1':
        before = '1'
        L.append(cnt)
        len_l += 1
        cnt = 0
    elif before == '1' and S[i] == '0':
        before == '0'
        cnt += 1
if cnt != 0:
    L.append(cnt)
    n_l += 1

L.sort(reverse=True)

if len_l > K:
    print(sum(L[:K])
else:
    print(sum(L))

### FIXED CODE ###

N, K = map(int, input().split())
S = input()

before = S[0]
cnt = 0
same_nums = []
if S[0] == '0':
  same_nums.append(0)
for i in range(N):
  if S[i] == before:
    cnt += 1
  else:
    same_nums.append(cnt)
    before = S[i]
    cnt = 1
same_nums.append(cnt)
if S[-1] == '0':
  same_nums.append(0)
  
sum_nums = sum(same_nums[:2*K+1])
ans = sum_nums
for i in range(0, len(same_nums)-2*K, 2):
  sum_nums = sum_nums - sum(same_nums[i:i+2]) + sum(same_nums[i+2*K+1:i+2*K+3])
  ans = max(ans, sum_nums)
print(ans)
Sa=input()
Sb=input()
Sc=input()
card=Sa[0]
Sa=Sa[1:]
while True:
  if card=='a':
    card=Sa[0]
    Sa=Sa[1:]
  if card=='b':
    card=Sb[0]
    Sb=Sb[1:]
  if card=='c':
    card=Sc[0]
    Sc=Sc[1:]
  if (Sa=='' and Sb=='') or (Sb=='' and Sc=='') or (Sc=='' and Sa==''):
    break
if card=='a' and Sa=='':
  print('A')
elif card=='b' and Sb=='':
  print('B')
elif card=='c' and Sc=='':
  print('C')

### FIXED CODE ###

Sa=input()
Sb=input()
Sc=input()

ia,ib,ic=1,0,0
card=Sa[0]

while True:
  if card=='a':
    if ia==len(Sa):
      print('A')
      break
    card=Sa[ia]
    ia+=1
  if card=='b':
    if ib==len(Sb):
      print('B')
      break
    card=Sb[ib]
    ib+=1
  if card=='c':
    if ic==len(Sc):
      print('C')
      break
    card=Sc[ic]
    ic+=1
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i],c[i] = map(int, input().split())
if n>2:
    ans=[1]+[0]*(n-1)
else:
    ans=[0]
flag = False


for i in range(m):
    if n>2 and s[i]==1 and c[i]==0:
        flag = True
    ans[s[i]-1]=c[i]
    for j in range(i+1,m):
        if s[i]==s[j]:
            if c[i]!=c[j]:
                flag=True

if flag:
    print(-1)
else:
    print("".join(map(str,ans)))


### FIXED CODE ###

n,m = map(int,input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i],c[i] = map(int, input().split())

if n>1:
    ans=[1]+[0]*(n-1)
else:
    ans=[0]
flag = False


for i in range(m):
    if n>2 and s[i]==1 and c[i]==0:
        flag = True
    ans[s[i]-1]=c[i]
    for j in range(i+1,m):
        if s[i]==s[j]:
            if c[i]!=c[j]:
                flag=True

if flag:
    print(-1)
else:
    print("".join(map(str,ans)))