Harryxun/stf_run huggingface dataset:
c2,c3 = 0,0
def ret(a,b,c):
  global c2,c3
  if a == b:
    if c == 2:
      c2 += 1
    else:
      c3 += 1
    if b == "0":
      return "1"
    else:
      return "0"
  else:
    return b
S = input()
S2,S3 = list(S),list(S)
default = S2[0]
for j,k in enumerate(S2):
  if j == 0:
    continue
  S2[j] = ret(S2[j-1],k,2)
  print(S2,c2)
for j,k in enumerate(S3):
  if j == 0:
    S3[0] = ret(default,S3[0],3)
  S3[j] = ret(S3[j-1],k,3)
  print(S3,c3)
print(c2 if c2 <= c3 else c3)

### FIXED CODE ###

c2,c3 = 0,0
def ret(a,b,c):
  global c2,c3
  if a == b:
    if c == 2:
      c2 += 1
    else:
      c3 += 1
    if b == "0":
      return "1"
    else:
      return "0"
  else:
    return b
S = input()
S2,S3 = list(S),list(S)
default = S2[0]
for j,k in enumerate(S2):
  if j == 0:
    continue
  S2[j] = ret(S2[j-1],k,2)
for j,k in enumerate(S3):
  if j == 0:
    S3[0] = ret(default,S3[0],3)
  S3[j] = ret(S3[j-1],k,3)
print(c2 if c2 <= c3 else c3)
import math

N = int(input())
heights = list(map(int, input().strip().split()))

dp = [math.inf for _ in range(N)]

dp[0] = 0
dp[1] = abs(heights[1] - heights[0])


for i in range(2, N):
    dp[i] = min(
        dp[i],
        dp[i - 1] + abs(heights[i] - heights[i - 1]),
        dp[i - 2] + abs(heights[i] - heights[i - 2]),
    )

print(dp[N - 1])


### FIXED CODE ###

N = int(input())
heights = list(map(int, input().strip().split()))

dp = [float("inf") for _ in range(N)]

dp[0] = 0
if N > 1:
    dp[1] = abs(heights[1] - heights[0])


for i in range(2, N):
    dp[i] = min(
        dp[i],
        dp[i - 1] + abs(heights[i] - heights[i - 1]),
        dp[i - 2] + abs(heights[i] - heights[i - 2]),
    )

print(dp[N - 1])
a = int(input())

for i in range(3):
    if str(a)[i] == str(a)[i+1]:
        print(i)
        print("Good")
        break
    elif i == 2:
        print("Bad")

### FIXED CODE ###

x = input()
def samenum(string):
  for i in range(3):
    if string[i] == string[i+1]:
        return "Bad"
        quit()
  return "Good"
 
print(samenum(x))
N, X = map(int, input().split())
positions = list(map(int, input().split()))


ans = 1
D = 0
for i in range(N + 1):
    if D + positions[i] <= X:
        D += positions[i]
        ans += 1
    else:
        print(ans)
        exit()
print(ans)


### FIXED CODE ###

N, X = map(int, input().split())
positions = list(map(int, input().split()))


ans = 1
D = 0
for i in range(N):
    if D + positions[i] <= X:
        D += positions[i]
        ans += 1
    else:
        print(ans)
        exit()
print(ans)
S, T = input().split()

correct = 0
for i in range(0, 3):
    if S[i] == T[i]:
        correct += 1
        
print(correct)

### FIXED CODE ###

# https://atcoder.jp/contests/abc139/tasks/abc139_a
S = input()
T = input()

correct = 0
for i in range(0, 3):
    if S[i] == T[i]:
        correct += 1
        
print(correct)
a,b = map(flaot,input().split())
print(math.floor(a*(100*b)/100))

### FIXED CODE ###

a,b = map(str,input().split())
a = int(a)
b = float(b)
 
b = round(b*100)
 
print(a*b//100)
a,b,c,x,y=map(int,input().split())
z=min(x,y)
if a+b>2*c:
    print(z*2*c+min((x-z)*a+(y-z)*b,(x+y-z*2)*2*c))
else:
    print(a*x+b*y)

### FIXED CODE ###

s=list(input())
 
print(700+100*(s.count('o')))
h,w=int(input())
for i in range(h):
  s=input()
  print(s)
  print(s)

### FIXED CODE ###

h,w=map(int,input().split())
for i in range(h):
  c=input()
  print(c)
  print(c)
N,A,B=map(int, input().split())
ans=0

def my_sum(x):
  ret=0
  for j in range(4):
    ret+=x%10
    x=x//10
  return ret 

for i in range(N+1):
  if A<=my_sum(i)<==B:
    ans+=1

print(ans)

### FIXED CODE ###

N,A,B=map(int, input().split())
ans=0

def my_sum(x):
  ret=0
  while x>0:
    ret+=x%10
    x=x//10
  return ret 

for i in range(N+1):
  if A<=my_sum(i)<=B:
    ans+=i

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

ans = 1

if 0 in A:
  ans = 0
else:
  for i in A:
    ans *= A
    i += 1
    if ans > 10**18:
      ans = -1
      break

print(ans)

### FIXED CODE ###

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

ans = 1

if 0 in A:
  ans = 0
else:
  for i in range(N):
    ans *= A[i]
    i += 1
    if ans > 10**18:
      ans = -1
      break

print(ans)
a = input()
b = input()
c = list(b)
e = []
for i in range(len(c)+1):  #左からi個を白にする
    if i == 0: #全て黒に変える場合
        e.append(c.count("."))
        ans = e[0]
    else:
        if c[i-1] == ".":
            d = d + 1
        e.append(((i - d) + (c.count(".") - d)))
        if ans >= e[i]:
            ans = e[i]
print(ans)

### FIXED CODE ###

a = input()
b = input()
c = list(b)
d = 0
e = c.count(".")
f = 0
for i in range(len(c)+1): #左からi個を白にする　0<=i<=len(c)
    if i == 0:
        ans = e
    else:
        if c[i-1] == ".":
            d = d + 1 #dは左からi個のうちの白の個数を指す
        f = (i - d) + (e - d) #左側の(i-d)個の黒を白にし、右側(e-d)個の白を黒にする
        ans = min(ans, f)
print(ans)
import sys
from collections import defaultdict

n, m = map(int, input().split())
tmp = [0] * n
memo = defaultdict(int)

for i in range(m):
    s, c = map(int, input().split())
    if i==0:
        memo[s] = c
    elif s in memo & memo[s]!=c:
        print(-1)
        sys.exit()
    elif (n==3 & s==1 & c==0):
        print(-1)
        sys.exit()
    else:
        tmp[s-1] = c
    
print(0) if sum(tmp) == 0 else print(*tmp, sep="")

### FIXED CODE ###

import sys
from collections import defaultdict

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

for i in range(M):
    s, c = map(int, input().split())
    if (d[s] != 0) & (d[s] != c):
        print(-1)
        sys.exit()
    elif ((s == 1) & (c == 0)) & (N > 1):
        print(-1)
        sys.exit()
    elif d[s] == 0:
        d[s] = c
    else:
        continue

if N==1:
    print(d[1])
    sys.exit()

ans = ["1"] + ["0"] * (N - 1)

for s, c in d.items():
    ans[int(s) - 1] = str(c)

print("".join(ans))
n = input()
k = int(input())

if(k == 1):
    print(n[0])
elif(len(n)==1):
    print(n)
elif(n[0]== '1'):
    i = 1
    while(n[i] == '1' or i + 1 < len(n)):
        i += 1
    if(k <= i):
        print(1)
    else:
        print(n[i])
else:
    print(n[0])

### FIXED CODE ###

n = input()
k = int(input())

if(k == 1):
    print(n[0])
elif(len(n)==1):
    print(n)
elif(n[0]== '1'):
    i = 1
    while(n[i] == '1'):
        i += 1
        if(i == len(n)):
            break
    if(k <= i):
        print(1)
    else:
        print(n[i])
else:
    print(n[0])
N = int(input())
k = 0
while k ** 2 < N:
  k++
for i in range(k, 0, -1):
  if N % i:
    continue
  print(N // i + i - 2)
  break

### FIXED CODE ###

N = int(input())
k = 0
while k ** 2 < N:
  k += 1
for i in range(k, 0, -1):
  if N % i:
    continue
  print(N // i + i - 2)
  break
n,m = list(map(int,input().split()))
b = [0 for i in range(m)]
for i in range(n):
  ka = list(map(int,input().split()))
  k = ka[0]
  a = ka[1:]
  for j in range(k):
    b[a[j]-1] += 1
c = 0
for i in range(m):
  if b[i] == n:
    c += 1
print(c)


### FIXED CODE ###

a,b = list(map(int,input().split()))
if b%a == 0:
  print(a+b)
else:
  print(b-a)
n=input(n)
t=False

for i in range(1,10):
  for j in range(1,10):
    if i*j==n:
      t=True
      break
if t:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

n=int(input())
t=False

for i in range(1,10):
  for j in range(1,10):
    if i*j==n:
      t=True
      break
if t:
  print('Yes')
else:
  print('No')
seq = [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(seq[int(input())])

### FIXED CODE ###

seq = [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(seq[int(input()) - 1])
x = input().split()
A = [int(item) for item in x]
N = A.pop(0)

print(' '.join([str(item) for item in A]))
for i in range(1, N):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j+1] = A[j]
        j = j - 1
    A[j+1] = key
    print(' '.join([str(item) for item in A]))

### FIXED CODE ###

N = int(input())
A = [int(s) for s in input().split()]

print(' '.join([str(item) for item in A]))
for i in range(1, N):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j+1] = A[j]
        j = j - 1
    A[j+1] = key
    print(' '.join([str(item) for item in A]))
i = 1
while True:
    input = int(input())
    if input == 0:
        break
    print("Case {}: {}".format( i, input))
    i += 1

### FIXED CODE ###

import sys, itertools
  
for count, input in zip(itertools.count(1), sys.stdin):
    if int(input) == 0: break
    print('Case {0}: {1}'.format(count, input), end='')
from collections import Counter

n = int(input())

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

total = 0

cnt = [0]*n
for i in range(n):
    cnt[a[i]] += 1
    
for i in cnt:
    if i > 0:
        total += (i*(i-1))//2

for i in range(n):
    ans = 0
    before = (cnt[a[i]]*(cnt[a[i]]-1))//2
    after = ((cnt[a[i]]-1)*(cnt[a[i]]-2))//2
    
    ans = total - before + after
    print(ans)

### FIXED CODE ###

import collections

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

a=collections.Counter(A)

total=0
for v in a.values():
    if v>1:
        c=(v*(v-1))//2
        total+=c

for i in A:
    ans=total-(a[i]*(a[i]-1))//2+((a[i]-1)*(a[i]-2))//2
    print(ans)
print("YES" if int(input().replace(" ",""))%4==0 else "NO)

### FIXED CODE ###

print("YES" if int(input().replace(" ",""))%4==0 else "NO")
# 【考察】
# 0-indexedで考える。Aは降順ソートして考える。
# まず、初期状態でTop Pに含まれる問題はすべて出題されうる。
# なので初期でTop q (q > P)の問題が出題されるか否かを考えていく。
# 最終的にTop Pに入れるか否かが問題なので、Top 1 ~ P-1の問題は無視。
# Top qの問題に毎回投票しつつ、Top P ~ q-1の問題になるべく投票しないようにしたい。
# そこで数列 A[P], A[P+1], ..., A[q-1] を考える。
# この中から最大でN-V個の数字を選んで1減らすことをM回繰り返し、
# すべてA[q]以下にすることができればTop qの問題は出題されうる。
# 当然A[P]-A[q] > Mだったら無理（出題されない）。
# 以後A[P]-A[q] <= Mとする。
# この時、(A[P]-A[q]) + (A[P+1]-A[q]) + ... + (A[q-1]-A[q]) <= M * (N-V) であればTop qのは出題可能。
# 整理すると A[P] + A[P+1] + ... + A[q-1] <= M * (N-V) + A[q] * (q-P) となるので、
# Aの累積和のデータを保持しておけば各qにおいてO(1)で出題可否が判定可能。


def main():
    # N, M, V, P = list(map(int, input().split()))
    # A = list(map(int, input().split()))
    with open('PastAGC/01-08.txt', 'r') as f:
        N, M, V, P = list(map(int, f.readline().split()))
        A = list(map(int, f.readline().split()))
    P -= 1  # to 0-indexed
    A.sort(reverse=True)  # 降順ソート
    cumsum = [0] * N
    cumsum[0] = A[0]
    for i in range(1, N):
        cumsum[i] = cumsum[i - 1] + A[i]
    q = P + 1
    while q < N:
        left = cumsum[q - 1]
        if P > 0:
            left -= cumsum[P - 1]
        right = M * (N - V) + A[q] * (q - P)
        if A[P] - A[q] > M or left > right:
            print(q)
            return
        q += 1
    print(q)


if __name__ == '__main__':
    main()

### FIXED CODE ###

# 【考察】
# 0-indexedで考える。Aは降順ソートして考える。
# まず、初期状態でTop Pに含まれる問題はすべて出題されうる。
# なので初期でTop q (q > P)の問題が出題されるか否かを考えていく。
# 最終的にTop Pに入れるか否かが問題なので、Top 1 ~ P-1の問題は無視。
# Top qの問題に毎回投票しつつ、Top P ~ q-1の問題になるべく投票しないようにしたい。
# そこで数列 A[P], A[P+1], ..., A[q-1] を考える。
# この中から最大でN-V個の数字を選んで1減らすことをM回繰り返し、
# すべてA[q]以下にすることができればTop qの問題は出題されうる。
# 当然A[P]-A[q] > Mだったら無理（出題されない）。
# 以後A[P]-A[q] <= Mとする。
# この時、(A[P]-A[q]) + (A[P+1]-A[q]) + ... + (A[q-1]-A[q]) <= M * (N-V) であればTop qのは出題可能。
# 整理すると A[P] + A[P+1] + ... + A[q-1] <= M * (N-V) + A[q] * (q-P) となるので、
# Aの累積和のデータを保持しておけば各qにおいてO(1)で出題可否が判定可能。


def main():
    N, M, V, P = list(map(int, input().split()))
    A = list(map(int, input().split()))
    P -= 1  # to 0-indexed
    A.sort(reverse=True)  # 降順ソート
    cumsum = [0] * N
    cumsum[0] = A[0]
    for i in range(1, N):
        cumsum[i] = cumsum[i - 1] + A[i]
    q = P + 1
    while q < N:
        left = cumsum[q - 1]
        if P > 0:
            left -= cumsum[P - 1]
        right = M * (N - V) + A[q] * (q - P)
        if A[P] - A[q] > M or left > right:
            print(q)
            return
        q += 1
    print(q)


if __name__ == '__main__':
    main()
from collections import deque

n = int(input())
a = sorted(int(input()) for _ in range(n))
q = deque(a)
l = q.popleft()
r = q.pop()
ans = abs(l - r)
while q:
    if flag == 0:
        x = q.popleft()
        flag = 1
    else:
        x = q.pop()
        flag = 0
    if abs(l - x) >= abs(x - r):
        ans += abs(l - x)
        l = x
    else:
        ans += abs(x - r)
        r = x
print(ans)


### FIXED CODE ###

n = int(input())
a = sorted(int(input()) for _ in range(n))
m = n // 2
if n % 2 == 0:
    ans = (sum(a[m:]) - sum(a[:m])) * 2 - a[m] + a[m-1]
    print(ans)
else:
    ans1 = (sum(a[m+1:]) - sum(a[:m])) * 2 - a[m] + a[m-1]
    ans2 = (sum(a[m+1:]) - sum(a[:m])) * 2 - a[m+1] + a[m]
    print(max(ans1, ans2))
from math import gcd

def lcm(x,y):
	return (x*y)//gcd(x,y)
	
a,b=map(int,input().split())

print(lcm(a,b))

### FIXED CODE ###

from fractions import gcd

def lcm(x,y):
	return (x*y)//gcd(x,y)
	
a,b=map(int,input().split())

print(lcm(a,b))
H, W = map(int, input().split())
import numpy as np
x = np.empty((H,W), dtype=object)
for i in range(H):
  x[i,] = map(int, input().split())

temp_list = []
for i in range(H):
  for j in range(W):
    if x[i,j] == "#":
      pass
    elif i == 0 and j == 0:
      temp_list = [x[i,j+1],x[i+1,j],x[i+1,j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == 0 and j == W-1:
      temp_list = [x[i,j-1],x[i+1,j],x[i+1,j-1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == H-1 and j == 0:
      temp_list = [x[i-1,j],x[i-1,j+1],x[i,j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == H-1 and j == W-1:
      temp_list = [x[i-1,j-1],x[i-1,j],x[i,j-1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == 0:
      temp_list = [x[i,j-1],x[i,j+1],x[i+1,j-1],x[i+1,j],x[i+1,j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == H-1:
      temp_list = [x[i,j-1],x[i,j+1],x[i-1,j-1],x[i-1,j],x[i-1,j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif j == 0:
      temp_list = [x[i-1,j],x[i-1,j+1],x[i,j+1],x[i+1,j],x[i+1,j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif j == W-1:
      temp_list = [x[i-1,j-1],x[i-1,j],x[i,j-1],x[i+1,j-1],x[i+1,j]]
      counts = temp_list.count("#")
      x[i,j] = counts
    else:
      temp_list = [x[i-1,j-1],x[i-1,j],x[i-1,j+1],x[i,j-1],x[i,j+1],x[i+1,j-1],x[i+1,j],x[i+1,j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts

printlist = [""] * H
for i in range(H):
  for j in range(W):
    printlist[i] += str(x[i,j]) 

for i in range(H):
    print(printlist[i])
    
    

### FIXED CODE ###

H, W = map(int, input().split())
S =[input() for i in range(H)]

L = [""]*H
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
        L[i] += "#"
    else:
      c = sum(t[max(0,j-1):min(W,j+2)].count("#") for t in S[max(0,i-1):min(H,i+2)])
      L[i] += str(c)
for i in range(H):
  print(L[i])
n = int(raw_input())
p = []
m = []
for i in range(1,n+1):
 m[i][i] = 0
 p[i-1], p[i] = map(int, raw_input().split())

for m in range(2,n+1):
 for i in range(1,n-m+1+1):
  j = i + m - 1
  m[i][j] = 999999999999999
  for k in range(i,j-1+1):
   m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j])

print m[1][n]

### FIXED CODE ###

n = int(raw_input())
p = [0 for i in range(0, 101)]
m = [[0 for i in range(0, 101)] for j in range(0, 101)]
for i in range(1, n+1):
    p[i-1], p[i] = map(int, raw_input().split())
     
for l in range(2, n+1):
    for i in range(1, n-l+2):
        j = i+l-1
        m[i][j] = float("inf")
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j])
 
print m[1][n]
N=int(input())
s=input()
b_count=0
r_count=0
for i in range(N):
  is s[i]=='R':
    r_count+=1
  elif s[i]=='B':
    b_count+=1
if r_count>b_count:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N=int(input())
s=input()
b_count=0
r_count=0
for i in range(N):
  if s[i]=='R':
    r_count+=1
  elif s[i]=='B':
    b_count+=1
if r_count>b_count:
  print('Yes')
else:
  print('No')
a=int(input())
if a==1:
  print(0)
if a==0
  print(1)

### FIXED CODE ###

a=int(input())
if a==1:
  print(0)
if a==0:
  print(1)
n = int(input())
a = map(int, input().split())

for i in range(1, n+1):
    print(str(a[-i]) + " ", end = "")
print()

### FIXED CODE ###

n = int(input())
a = input().split()

for i in range(1, n):
    print(str(a[-i]) + " ", end = "")
print(a[0])
n, k = map(int, input().split())
dlist = list(map(int, input().split()))

for i in range(n, 10000):
    flg: bool = True
    for s in str(i):
        if int(s) in dlist:
            flg = False
            break
    if flg:
        print(i)
        break


### FIXED CODE ###

n, k = map(int, input().split())
dlist = input().split()
flg = True
while flg:
    s = str(n)
    for t in s:
        if t in dlist:
            n += 1
            break
    else:
        flg = False
print(n)
a,b = map(int,input().split())
123456789012 123456789012
if b - a == 0:
    answer = a
else:
    answer = 0
    if a % 2 == 0:
        first_odd = a
    else:
        first_odd = a+1
    if b % 2 == 0:
        last_even = b-1
    else:
        last_even = b
    odd_even = int((last_even - first_odd + 1) // 2)
    if a % 2 == 1 and b % 2 == 0:
        answer += (odd_even + 1) % 2
        b2 = []
        while b > 0:
            b2.append(b % 2)
            b = int((b-b%2)//2)
        a2 = []
        for i in range(len(b2)):
            a2.append(a % 2)
            a = int((a-a%2)//2)
        for i in range(1,len(b2)):
            if a2[i]+b2[i] == 1:
                answer += 2**i
    elif a % 2 == 1:
        answer += (odd_even + 1) % 2 + a - 1
    elif b % 2 == 0:
        answer += odd_even % 2 + b
    else:
        answer += odd_even % 2

print(answer)


### FIXED CODE ###

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

if b - a == 0:
    answer = a
else:
    answer = 0
    if a % 2 == 0:
        first_odd = a
    else:
        first_odd = a+1
    if b % 2 == 0:
        last_even = b-1
    else:
        last_even = b
    odd_even = int((last_even - first_odd + 1) // 2)
    if a % 2 == 1 and b % 2 == 0:
        answer += (odd_even + 1) % 2
        b2 = []
        while b > 0:
            b2.append(b % 2)
            b = int((b-b%2)//2)
        a2 = []
        for i in range(len(b2)):
            a2.append(a % 2)
            a = int((a-a%2)//2)
        for i in range(1,len(b2)):
            if a2[i]+b2[i] == 1:
                answer += 2**i
    elif a % 2 == 1:
        answer += (odd_even + 1) % 2 + a - 1
    elif b % 2 == 0:
        answer += odd_even % 2 + b
    else:
        answer += odd_even % 2

print(answer)
import sys
n = int(input())
s = input()
t = input()

for i in range(n):
   if s[i:] == t[:n-i]:
		print(n+i)
		exit()

print(2*n)

### FIXED CODE ###

n = int(input())
s = input()
t = input()

for i in range(n):
   if s[i:] == t[:n-i]:
       print(n+i)
       exit()

print(2*n)
from functools import reduce
from operator import xor

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

def main():
    val = []
    for i in range(A,B+1):
        val.append(i)
        print(val)
    ans = reduce(xor,val)
    return ans

print(main())

### FIXED CODE ###

from functools import reduce
from operator import xor

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


def calc(A):
    A = A+1
    cnt = 0
    ans = 0
    for i in range(0,50):
        # i=0 2回周期で1が出現
        # i=1 4回周期で1が出現
        loop = pow(2,i+1)

        #端数を覗いた2の出現回数
        #Aが6 / iが1のときは loop=4
        # 7//4 = 1 * 2^1 = 2
        cnt = (A//loop)*pow(2,i)

        # 端数を計算
        # 7%4 - 4/2 = 3-2 = 1
        # 端数は1なので加算
        if((A%loop - loop//2) > 0):
            cnt = cnt + (A%loop - loop//2)

        # cntが奇数の場合は ans 2^iをに加算
        if(cnt%2 == 1):
            ans = ans + pow(2,i)

    return ans



def main():
    return calc(A-1)^calc(B)

print(main())
s=input()
s.sort()

if s=="abc":
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s=list(input())
s.sort()
s="".join(s)

if s=="abc":
    print("Yes")
else:
    print("No")
K,X = map(int,input().split())
if 500*K >= X:
    print('Yes')
else:
    print('No')
K,X = map(int,input().split())
if 500*K >= X:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

K,X = map(int,input().split())
if 500*K >= X:
    print('Yes')
else:
    print('No')
n = int(input())
INF = 10**12

A = []
for i in range(n):
  A.append(list(map(int,input().split())))

B = [[1]*n for _ in range(n)]
G = A.copy()

for k in range(n):
  for i in range(n):
    for j in range(n):
      G[i][j] = min(G[i][j], G[i][k]+G[k][j])
      if not (i==j or j==k or k==i):
        if G[i][j] == G[i][k]+G[k][j]:
          B[i][j] = 0
      
if A==G:
  ans = 0
  for i in range(n):
    for j in range(i+1,n):      
      ans += G[i][j] * B[i][j]
  print(ans)
else:
  print(-1)

### FIXED CODE ###

from copy import deepcopy
n = int(input())
INF = 10**12

A = []
for i in range(n):
  A.append(list(map(int,input().split())))

B = [[1]*n for _ in range(n)]
G = deepcopy(A)

for k in range(n):
  for i in range(n):
    for j in range(n):
      G[i][j] = min(G[i][j], G[i][k]+G[k][j])
      if not (i==j or j==k or k==i):
        if G[i][j] == G[i][k]+G[k][j]:
          B[i][j] = 0
      
if A==G:
  ans = 0
  for i in range(n):
    for j in range(i+1,n):      
      ans += G[i][j] * B[i][j]
  print(ans)
else:
  print(-1)
import numpy as np

A, B, Q = [int(i) for i in input().split()]

s = np.array([[int(input()) for i in range(A)]])
t = np.array([[int(input()) for i in range(B)]])
x = np.array([[int(input()) for i in range(Q)]])

stot = np.abs(s-t.T).argmin(axis=0)
ttos = np.abs(s-t.T).argmin(axis=1)
xtot = np.abs(x-t.T).argmin(axis=0)
xtos = np.abs(s-x.T).argmin(axis=1)

for i, (a, b) in enumerate(zip(xtot, xtos)):
    pata = abs(x[0, i] - t[0, a]) + abs(t[0, a] - s[0, ttos[a]]) 
    patb = abs(x[0, i] - s[0, b]) + abs(s[0, b] - t[0, stot[b]]) 
    if pata <= patb:
        print(pata)
    else:
        print(patb)


### FIXED CODE ###

import bisect

A, B, Q = [int(i) for i in input().split()]

s = [-10**12] + [int(input()) for i in range(A)] + [10**12]
t = [-10**12] + [int(input()) for i in range(B)] + [10**12]
x = [int(input()) for i in range(Q)]

for item in x:
    a, c = bisect.bisect_left(s, item), bisect.bisect_left(t, item)
    min_value = 10**12
    for item_a in [s[a-1], s[a]]:
        for item_c in [t[c-1], t[c]]:
            pata = abs(item_a - item) + abs(item_a - item_c)
            patb = abs(item_c - item) + abs(item_a - item_c)
            min_value = min(min_value, pata, patb)
    print(min_value)
from math import gcd

N = int(input())
AB = [map(int, input().split()) for _ in range(N)]

t = []
d = {}
for a, b in AB:
    i = gcd(a, b)
    a //= i
    b //= i
    t.append((a, b))
    d.setdefault(a, {})
    d[a].setdefault(b, 0)
    d[a][b] += 1

used = set()
result = 1
for a, b in t:
    if (a, b) in used:
        continue
    used.add((a, b))
    if a == 0 and b == 0:
        i = d[a][b]
        result *= pow(2, i, 1000000007) - 1
        result %= 1000000007
    else:
        i = d[a][b]
        j, k, l = 0, 0, 0
        if -a in d and -b in d[-a]:
            j = d[-a][-b]
            used.add((-a, -b))
        if -b in d and a in d[-b]:
            k = d[-b][a]
            used.add((-b, a))
        if b in d and -a in d[b]:
            l = d[b][-a]
            used.add((b, -a))
        result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1
        result %= 1000000007
print(result - 1)


### FIXED CODE ###

from math import gcd

N = int(input())
AB = [map(int, input().split()) for _ in range(N)]

t = []
d = {}
d[0] = {}
d[0][0] = 0
for a, b in AB:
    i = gcd(a, b)
    if i != 0:
        a //= i
        b //= i
    t.append((a, b))
    d.setdefault(a, {})
    d[a].setdefault(b, 0)
    d[a][b] += 1

used = set()
result = 1
for a, b in t:
    if (a, b) in used:
        continue
    used.add((a, b))
    if a == 0 and b == 0:
        continue
    i = d[a][b]
    j, k, l = 0, 0, 0
    if -a in d and -b in d[-a]:
        j = d[-a][-b]
        used.add((-a, -b))
    if -b in d and a in d[-b]:
        k = d[-b][a]
        used.add((-b, a))
    if b in d and -a in d[b]:
        l = d[b][-a]
        used.add((b, -a))
    result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1
    result %= 1000000007
result += d[0][0] - 1
result %= 1000000007
print(result)