Harryxun/stf_run huggingface dataset:
import collections
N=int(input())
x=list(map(int,input().split()))
c=collections.Counter(x)
t=[2**i for i in range(len(str(bin(max(x)*2))[2:])+1)[::-1]]
count=0
start=0
x.sort()
for i in range(len(x))[::-1]:
    for j in range(start,len(t)):
        if t[j] > 2*x[i]:
            start = j
        if t[j] < x[i]:
            break
        if t[j]-x[i] in c.keys():
            if t[j]-x[i] == x[i]:
                if c[x[i]] >= 2:
                    c[x[i]] -= 2
                    count +=1
            else:
                if c[t[j]-x[i]]>0 and c[x[i]]>0:
                    c[t[j]-x[i]] -= 1
                    c[x[i]] -= 1
                    count+=1
print(count)

### FIXED CODE ###

S=input()
count=0
def sigma(i):
    a=[b for b in range(0,i+1)]
    return sum(a)
place=0
flag=0
start=0
for i in range(len(S)):
    if S[i]=="B":
        flag=1
    elif S[i]=="W":
        if flag == 1:
            count += 1
            place += i - start
        else:
            start+=1
ans=place-sigma(count-1)
print(ans)
n, *l = map(int, open(0).read.split())

a = 1
for i in l:
	a *= i
	if a > 1e18:
		a =-1
		break
print(a)
	

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
a = 1
for i in l:
	a *= i
	if a > 10**18:
		a = -1
		break
print(a)
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
x=[[],[],[]]
for i in range(n):x[i%3]+=i+1,
for a,b in zip(*[iter(t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
a=[-1]*n
p=a[:]
p[0]=0
s=[0]
c=[1,0]
while s:
    v=s.pop()
    for w in e[v]:
        if p[w]<0:
            p[w]=p[v]^1
            c[p[w]]+=1
            s+=w,
if min(c)<=n//3:
    x[0]+=x[1]
    f=c[0]<=n//3
    for i,v in enumerate(p):a[i]=x[(v==f)-1].pop()
else:
    for i,v in enumerate(p):a[i]=x[v if x[v]else-1].pop()
print(*a)

### FIXED CODE ###

n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
x=[[],[],[]]
for i in range(n):
    x[i%3]+=i+1,
for a,b in zip(*[iter(t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
a=[-1]*n
p=a[:]
p[0]=0
s=[0]
c=[1,0]
while s:
    v=s.pop()
    for w in e[v]:
        if p[w]<0:
            p[w]=p[v]^1
            c[p[w]]+=1
            s+=w,
if min(c)<=n//3:
    x[0]+=x[1]
    f=c[0]<=n//3
    for i,v in enumerate(p):
        j=(v==f)-1
        a[i]=x[j if x[j]else-1].pop()
else:
    for i,v in enumerate(p):
        a[i]=x[v if x[v]else-1].pop()
print(*a)
from math import gcd 
n=int(input())
mod = 10**9+7
count = {}

num=0
for _ in range(n):
    a,b = map(int,input().split())
    if a==0 and b==0:
        num+=1
        continue
    if a*b != 0:
        g=gcd(a,b)*(b//abs(b))
    elif a != 0:
        g=a
    else:
        g=b
        
    l=a//g,b//g
    count[l]=count.get(l,0)+1
        
mem=set()
ans=1
for (x,y),z in count.items():
    k=(-1*x//abs(x)*y,abs(x))
    if k in mem:
        continue
    mem.add((x,y))
    ans*=(pow(2,z)+pow(2,count.get(k,0))-1)
    ans%=mod

print((ans+num-1)%mod)

### FIXED CODE ###

from math import gcd 
n=int(input())
mod = 10**9+7
count = {}

num=0
for _ in range(n):
    a,b = map(int,input().split())
    if a==0 and b==0:
        num+=1
        continue
    if a*b != 0:
        g=gcd(a,b)*(b//abs(b))
    elif a != 0:
        g=a
    else:
        g=b
        
    l=a//g,b//g
    count[l]=count.get(l,0)+1
        
mem=set()
ans=1
for (x,y),z in count.items():
    if x*y==0:
        k=(y,x)
    else:
        k=(-1*x//abs(x)*y,abs(x))
    if k in mem:
        continue
    mem.add((x,y))
    ans*=(pow(2,z)+pow(2,count.get(k,0))-1)
    ans%=mod

print((ans+num-1)%mod)
import sys
input = sys.stdin.buffer.readline
R,C,K = map(int,input().split())
goods = [[0]*(C+1) for _ in range(R+1)]
INF = 10**18
for i in range(K):
    ri,ci,vi = map(int,input().split())
    goods[ri][ci] = vi
DP = [[[-INF]*(C+1) for _ in range(R+1)] for _ in range(4)]
DP[0][1][1] = 0
if goods[1][1]:
    DP[1][1][1] = goods[1][1]
for j in range(1,C):
    DP[0][1][j+1] = 0
    if goods[1][j+1]:
        DP[1][1][j+1] = max(DP[1][1][j],DP[0][1][j]+goods[1][j+1])
        DP[2][1][j+1] = max(DP[2][1][j],DP[1][1][j]+goods[1][j+1])
        DP[3][1][j+1] = max(DP[3][1][j],DP[2][1][j]+goods[1][j+1])
    else:
        DP[1][1][j+1] = DP[1][1][j]
        DP[2][1][j+1] = DP[2][1][j]
        DP[3][1][j+1] = DP[3][1][j]
for i in range(1,R):
    DP[0][i+1][1] = max(DP[0][i][1],DP[1][i][1],DP[2][i][1],DP[3][i][1])
    if goods[1][i+1]:
        DP[1][i+1][1] = DP[0][i+1][1] + goods[i+1][1]
for i in range(2,R+1):
    for j in range(2,C+1):
        DP[0][i][j] = max(DP[0][i-1][j],DP[1][i-1][j],DP[2][i-1][j],DP[3][i-1][j],DP[0][i][j-1])
        if goods[i][j]:
            DP[1][i][j] = max(DP[0][i][j]+goods[i][j],DP[1][i][j-1])
            DP[2][i][j] = max(DP[2][i][j-1],DP[1][i][j-1]+goods[i][j])
            DP[3][i][j] = max(DP[3][i][j-1],DP[2][i][j-1]+goods[i][j])
        else:
            DP[1][i][j] = DP[1][i][j-1]
            DP[2][i][j] = DP[2][i][j-1]
            DP[3][i][j] = DP[3][i][j-1]
print(max(DP[0][R][C],DP[1][R][C],DP[2][R][C],DP[3][R][C]))

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
R,C,K = map(int,input().split())
goods = [[0]*(C+1) for _ in range(R+1)]
INF = 10**18
for i in range(K):
    ri,ci,vi = map(int,input().split())
    goods[ri][ci] = vi
DP = [[[-INF]*(C+1) for _ in range(R+1)] for _ in range(4)]
DP[0][1][1] = 0
if goods[1][1]:
    DP[1][1][1] = goods[1][1]
for j in range(1,C):
    DP[0][1][j+1] = 0
    if goods[1][j+1]:
        DP[1][1][j+1] = max(DP[1][1][j],DP[0][1][j]+goods[1][j+1])
        DP[2][1][j+1] = max(DP[2][1][j],DP[1][1][j]+goods[1][j+1])
        DP[3][1][j+1] = max(DP[3][1][j],DP[2][1][j]+goods[1][j+1])
    else:
        DP[1][1][j+1] = DP[1][1][j]
        DP[2][1][j+1] = DP[2][1][j]
        DP[3][1][j+1] = DP[3][1][j]
for i in range(1,R):
    DP[0][i+1][1] = max(DP[0][i][1],DP[1][i][1],DP[2][i][1],DP[3][i][1])
    if goods[i+1][1]:
        DP[1][i+1][1] = DP[0][i+1][1] + goods[i+1][1]
for i in range(2,R+1):
    for j in range(2,C+1):
        DP[0][i][j] = max(DP[0][i-1][j],DP[1][i-1][j],DP[2][i-1][j],DP[3][i-1][j],DP[0][i][j-1])
        if goods[i][j]:
            DP[1][i][j] = max(DP[0][i][j]+goods[i][j],DP[1][i][j-1])
            DP[2][i][j] = max(DP[2][i][j-1],DP[1][i][j-1]+goods[i][j])
            DP[3][i][j] = max(DP[3][i][j-1],DP[2][i][j-1]+goods[i][j])
        else:
            DP[1][i][j] = DP[1][i][j-1]
            DP[2][i][j] = DP[2][i][j-1]
            DP[3][i][j] = DP[3][i][j-1]
print(max(DP[0][R][C],DP[1][R][C],DP[2][R][C],DP[3][R][C]))
char = input()
if char == Sunny:
    print(Cloudy)
elif char == Cloudy:
    print(Rainy)
else:
    print(Sunny)

### FIXED CODE ###

char = input()
if char == "Sunny":
    print("Cloudy")
elif char == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
X, A, B = list(map(int, input().split()))
N1 = X-A
N2 = N1/B
N3 = N1-N2*B

### FIXED CODE ###

X = int(input())
A = int(input())
B = int(input())
N = (X-A) % B
print(N)
input();s=input();a=set(s)
a=1
for i in a:ans=ans*(s.count(i)+1)%(10**9+7)
print(a-1)

### FIXED CODE ###

n=int(input())
s=list(input())
s.sort()
cnt=1
cnt_list=[]
if len(s)==1:
    print(1)
    exit()
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
        if i==n-2:
            cnt_list.append(cnt)
    else:
        cnt_list.append(cnt)
        cnt=1
        if i==n-2:
            cnt_list.append(1)
ans=1
for i in range(len(cnt_list)):
    ans=ans*(cnt_list[i]+1)%(10**9+7)
print(ans-1)
import math
x,y = map(int,input().split())
mod = pow(10,9)+7
if (2*x-y)% 3 == 0 and (2*y-x)% 3 == 0:
	n = int((2 * y - x) / 3)
	m = int((2 * x - y) / 3)
	P = [1]*(n + m + 1)
	for i in range(1, n+m+1):
		P[i] = P[i-1]*i
		P[i] %= mod
	print((P[n+m]*pow(P[n],mod-2,mod)*pow(P[m],mod-2,mod)) % mod)
else:
	print(0)

### FIXED CODE ###

import math
x,y = map(int,input().split())
mod = pow(10,9)+7
if (2*x-y)% 3 != 0 or (2*y-x)% 3 != 0 or ((2 * y - x) / 3 < 0) or ((2 * x - y) / 3 < 0):
	print(0)
else:
	n = int((2 * y - x) / 3)
	m = int((2 * x - y) / 3)
	P = [1]*(n + m + 1)
	for i in range(1, n+m+1):
		P[i] = P[i-1]*i
		P[i] %= mod
	print((P[n+m]*pow(P[n],mod-2,mod)*pow(P[m],mod-2,mod)) % mod)
import numpy as np
from itertools import *

N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]

lst=[[],[],[]]

for y in range(N):
    for x in range(N):
        lst[(y+x)%3].append(c[y][x])


Revalue=10**18
for Color1,Color2,Color3 in list(permutations(list(range(1,C+1)),3)):
    value=0
    for i in lst[0]:
        value+=D[i-1][Color1-1]
    for i in lst[1]:
        value+=D[i-1][Color2-1]
    for i in lst[2]:
        value+=D[i-1][Color3-1]
    Revalue=min(Revalue,value)
print(Revalue)


### FIXED CODE ###

from itertools import *
N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]

lst=[[],[],[]]

for y in range(N):
    for x in range(N):
        lst[(y+x)%3].append(c[y][x])


Revalue=10**18

valuelst=[[0 for i in range(C)] for i in range(3)]
for v in range(3):
    for Color in range(1,C+1):
        value=0
        for i in lst[v]:
            value+=D[i-1][Color-1]
        valuelst[v][Color-1]=value


for Color1,Color2,Color3 in list(permutations(list(range(1,C+1)),3)):
    value=valuelst[0][Color1-1]+valuelst[1][Color2-1]+valuelst[2][Color3-1]

    Revalue=min(Revalue,value)
print(Revalue)
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la = la[numpy.argsort(numpy.abs(la))][::-1]
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      lal, lar = la[:k], la[k:]
      lal.sort()
      nlm = (lal < 0).sum()
      if nlm % 2 == 0:
        print(prod_mod(lal, MAX))
      else:
        mpr = numpy.max(lar)
        mmr = numpy.min(lar)
        if mpr > 0 and mmr < 0:
          if abs(mpr * lal[nlm]) > abs(mmr * lal[nlm-1]) and nlm != len(lal):
            lal[nlm-1] = mpr
          else:
            lal[nlm] = mmr
        elif mpr > 0:
          lal[nlm-1] = mpr
        elif mmr < 0 and nlm != len(lal):
          lal[nlm] = mmr
        print(prod_mod(lal, MAX))

if __name__=='__main__':
  main()



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la.sort()
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      il, ir = 0, n-1
      cnt = 0
      l = []
      if k % 2 == 1:
        l.append(la[ir])
        ir -= 1
        cnt += 1
      while k - (cnt + 2) >= 0:
        if la[il] * la[il+1] > la[ir-1] * la[ir]:
          l.extend([la[il], la[il+1]])
          il += 2
        else:
          l.extend([la[ir-1], la[ir]])
          ir -= 2
        cnt += 2
      print(prod_mod(l, MAX))
      

if __name__=='__main__':
  main()
# -*- coding: utf-8 -*-
import numpy as np
from numpy.linalg import solve

n = int(input())
a = list(map(int, input().split()))
a = np.array([_a * 2 for _a in a])

x = np.zeros((n, n))
for i in range(n-1):
    x[i][i] = 1
    x[i][i+1] = 1
x[n-1][n-1] = 1
x[n-1][0] = 1

print(" ".join(solve(x, a).astype('int').astype('str')))


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

x = [0 for _ in range(n)]
_x = 0
for i, _a in enumerate(a):
    if i % 2 == 0:
        _x += _a
    else:
        _x -= _a

x[0] = _x

for i in range(1, n):
    x[i] = a[i-1] * 2 - x[i-1]

print(" ".join(map(str, x)))
s=input()
print(s[0]+len(s[1:-1])+s[-1])

### FIXED CODE ###

s=input()
print(s[0]+str(len(s[1:-1]))+s[-1])
import math
k = int(input())
ans = 0
for i in range(1,k+1):
  ans += i
  for j in range(i+1,k+1):
    for m in range(m+1,k+1):
      ans += 3*math.gcd(math.gcd(i,j),m)
print(ans)

### FIXED CODE ###

from math import gcd
k = int(input())
ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    v = gcd(i,j)
    for m in range(1,k+1):
      ans += gcd(v,m)
print(ans)
# スペース区切りの整数の入力
a, b = map(int, input().split())
 
# 出力
if (a*b)%2:
	print "Odd"
else:
	print "Even"

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, Q = map(int, input().split())
S = [0] * N
T = [0] * N
X = [0] * N
D = [0] * Q
event = []
working = []

for i in range(N):
	S[i], T[i], X[i] = map(int, input().split())
	event.append((S[i] - X[i], 1, X[i]))
	event.append((T[i] - X[i], -1, X[i]))
	
for i in range(Q):
	D[i] = int(input())
	
event.sort()
j = 0

for i in range(len(event)):		
	while event[i][0] > D[j] and j < Q:
		if len(working) > 0:
			print(min(working))
		else:
			print(-1)
		j += 1
	
	if event[i][1] == 1:
		working.append(event[i][2])
	else:
		working.remove(event[i][2])

while j < Q:
	print(-1)
	j += 1

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, Q = map(int, input().split())
S, T, X = [0] * N, [0] * N, [0] * N
work = []

for i in range(N):
	S[i], T[i], X[i] = map(int, input().split())
	work.append((X[i], S[i] - X[i], T[i] - X[i]))

D = [int(input()) for _ in range(Q)]

work.sort()
ans = [-1] * Q
skip = [-1] * Q

for i in range(N):
	left = bisect.bisect_left(D, work[i][1])
	right = bisect.bisect_left(D, work[i][2])
	
	while left < right:
		if skip[left] == -1:
			skip[left] = right
			ans[left] = work[i][0]
			left += 1
		else:
			left = skip[left]					
		
for i in ans:
	print(i)
n,k=map(int,input().split())
s=list(input())
t=s.pop(k-1)
s.insert(k-1,t.lower())
print("".join(s)

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
t=s.pop(k-1)
s.insert(k-1,t.lower())
print("".join(s))
import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = max(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])


### FIXED CODE ###

import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = np.maximum(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])
s=input()
k=int(input())
if s[0]!='1':
  print(s[0])
else:
  cnt=0
  for i in range(len(s)):
    if s[i]=='1':
      cnt+=1 
    else:
      idx=i
      break
  if cnt>k:
    print('1')
  else:
    print(s[idx])
    
    
  
    
    

    


### FIXED CODE ###

s=input()
k=int(input())
if s[0]!='1':
  print(s[0])
else:
  cnt=0
  idx=0
  for i in range(len(s)):
    if s[i]=='1':
      cnt+=1 
    else:
      idx=i
      break
  if cnt>k-1:
    print('1')
  else:
    print(s[idx])
n=input()
print(n**3)


### FIXED CODE ###

n=int(input())
print(n**3)
while 1:
  H, W = map(int, input().split())
  if W == 0 and H == 0:
    break
  print ("#"*W)
  for i in range(1, H-1):
    print ("#" + ("." * (W-2)) + "#")
  print ("#"*W)
  print ("")

### FIXED CODE ###

while 1:
   H, W = map(int, raw_input().split())
   if H == 0 and W == 0:
      break
   print "#"*W
   for i in range(1, H-1):
      print ("#"+"."*(W-2)+"#")
   print "#"*W
   print ""
L, R=map(int, input().split())
mod=2019
A=[0]*(R-L+1)
for i in range(L, R+1):
  A[i]=i%mod
  
A=sorted(A)
print((A[0]*A[1])%mod)

### FIXED CODE ###

L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if R-L>=2019:
    print(0)
    exit()

ans=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans, (i*j)%2019)
print(ans)
N = map(int,input().split())
fizz = list()
for i in range(N):
    if i // 3 == 0 and i // 5 == 0:
        i = FizzBuzz
    elif i // 3 == 0: 
        i = Fizz
    elif i // 5 == 0:
        i = Buzz
    else:
        fizz.append(i)
print(sum(fizz))

### FIXED CODE ###

N = int(input())
a = 0
for i in range(N+1):
    if i % 3 != 0 and i % 5 != 0:
        a += i
print(a)
def MAXI(a):
    m=max(a)
    for i in range(3):
        if a[i]==m:
            id=i
    return m,id



tot=0
N=int(input())
i=0
while i<N:
    
    if i==0:
        x=[int(a) for a in input().split()]
        m,id=MAXI(x)
        tot+=m
        i=i+1
    if i==(N-1):
        x=[int(a) for a in input().split()]
        MAX=0
        for j in range(3):
            if j!=id:
                if x[j]>MAX:
                    MAX=x[j]
        tot+=MAX
        i=i+1

    else:
        x=[int(a) for a in input().split()]
        y=[int(a) for a in input().split()]
        i=i+2
        MAX=0
        for j in range(3):
            if j!=id:
                for k in range(3):
                    if k!=j:
                        s=x[j]+y[k]
                        if s>MAX:
                            MAX=s
                            id1=k
                        
        tot+=MAX
        id=id1
                            
        
print(tot)
    


### FIXED CODE ###

def fragOptimalJump(h,n):
    dp=[0]*(n+1)
    dp[2]=abs(h[1]-h[2])
    for i in range(3,n+1):
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    return dp[n]
  
N=int(input())
read = [int(n) for n in input().split()]
H=[0]+read
print(fragOptimalJump(H,N))
n, m = map(int, input().split(' '))
a = [0]*m
b = [0]*m
for i in range(m):
    a[i], b[i] = list(map(int, input().split(' ')))

c = [-1]*(m+1)

def find(num):
    if c[num] < 0:
        return num
    else:
        k = find(c[num])
        c[num] = k
    return k

result = [int(n*(n-1)/2)]
for i in range(m-1, 0,-1):
    x = find(a[i])
    y = find(b[i])

    if x != y:
        result.append(result[-1]-c[x]*c[y])
        x, y = sorted([x,y])
        c[x] += c[y]
        c[y] = x
    else:
        result.append(result[-1])

for i in result[::-1]:
    print(int(i))


### FIXED CODE ###

n, m = map(int, input().split(' '))
a = [0]*m
b = [0]*m
for i in range(m):
    a[i], b[i] = list(map(int, input().split(' ')))

c = [-1]*(m+2)

def find(num):
    if c[num] < 0:
        return num
    else:
        k = find(c[num])
        c[num] = k
        return k

result = [int(n*(n-1)/2)]
for i in range(m-1, 0,-1):
    x = find(a[i])
    y = find(b[i])

    if x != y:
        result.append(result[-1]-c[x]*c[y])
        x, y = sorted([x,y])
        c[x] += c[y]
        c[y] = x
    else:
        result.append(result[-1])

for i in result[::-1]:
    print(int(i))
S=input()
x={}
x_v=0
count=0
for i,j in enumerate(S):
    if j=="?":
        continue
    else:
        x[len(S)-i-1]=j
for m in x.keys():
    x_v+=int(x[m])*(10**m)
for k in range(10**(len(S))):
    k_l=list(str(k))
    a=0
    b=[]
    c=[]
    for key in x.keys():
        if key>=len(k_l):
            continue
        else:
            b.append( k_l[-key-1]=="0" )
            c.append(1)
    if b==c:
        for n in range(len(k_l)):
            a+=int(k_l[-n-1])*(10**n)
        a+=x_v
        if a%13==5:
            count+=1
    else:
        continue
print(count%(7+10**9))

### FIXED CODE ###

a,b=sorted(map(int,input().split()))
print((b+a)//2 if (b+a)%2==0 else "IMPOSSIBLE" )
import math

n=input()

print(math.ceil(n))

### FIXED CODE ###

import math

n=int(input())

print(math.ceil(n/2))
n=int(input())
ans=''
check='abcdefghijklmnopqrstuvwxyz'
while n!=0:
  n-=1
  ans+=check[n%26]
  n//=26
print(ans[::-1]

### FIXED CODE ###

def calc():
  n=int(input())
  arr=[]
  check='abcdefghijklmnopqrstuvwxyz'
  while n!=0:
    n-=1
    arr.append(check[n%26])
    n//=26
  arr=arr[::-1]
  print(''.join(map(str,arr)))
  
calc()
n = int(input())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])

for i in range(n):
    if i == 0:
        if not(-s[i][1] - s[i][0] <= s[i][2] <= -s[i][1] + s[i][0] and s[i][1] - s[i][0] <= s[i][2] <= s[1][1] + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(-s[i][1] + s[i - 1][1] + s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= -s[i][1] + s[i - 1][1] + s[i - 1][2] + (s[i][0] - s[i - 1][0])\
            and s[i][1] + s[i - 1][1] - s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i][1] + s[i - 1][1] - s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")


### FIXED CODE ###

n = int(input())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])

for i in range(n):
    if i == 0:
        if not(0 - s[i][0] <= s[i][1] <= 0 + s[i][0]) or not(0 - s[i][0] <= s[i][2] <= 0 + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(s[i - 1][1] - (s[i][0] - s[i - 1][0]) <= s[i][1] <= s[i - 1][1] + (s[i][0] - s[i - 1][0])) or not(s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")
s, t = input().split()
a. b = map(int, input().split())
u = input()

if s == u:
  print(a-1 b)
else:
  print(a b-1)


### FIXED CODE ###

s, t = input().split()
a, b = map(int, input().split())
u = input()

if s == u:
  print("{} {}".format(a-1, b))
else:
  print("{} {}".format(a, b-1))
import numpy as np

N, K, Q = map(int, input().split())
A = []

for a in range(Q):
    A.append(int(input()))

P = [K] * N
X = [-1] * N
B = [0] * N

P_n = np.array(P)
X_n = np.array(X)
X_n_Q = X_n * Q

R_n = P_n + X_n_Q

B_n = np.array(B)

for a in A:
    B_n[a-1] = B_n[a-1] + 1

dif_n = R_n + B_n
dif = dif_n.tolist()

for d in dif:
    if d >= 1:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

S = str(input())

if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
H,W = map(int,input().split)
h,w = map(int,input().split)
print((H-h)*(W-w))


### FIXED CODE ###

H,W = map(int,input().split())
h,w = map(int,input().split())
print((H-h)*(W-w))
N=int(input())
cnt = [0]*100000
for i in range(N):
  l, r = map(int, input().split())
  for j in range(l, r+1):
    cnt[j]+=1
print(sum(cnt))

### FIXED CODE ###

N=int(input())
cnt = [0]*100002
for i in range(N):
  l, r = map(int, input().split())
  for j in range(l, r+1):
    cnt[j]=1
print(sum(cnt))
N,K=map(int, input().split())
A=list(map(int, input().split())) 
A.sort(reverse=1)
m=A[0]
for i in range(N-1):
  m=min(m,A[i]-A[i+1])
amari=[0]*m
for j in range(m):
  for i in range(N):
    if A[i]%m==j:
      amari[j]=1
n=K%m
if K>A[0]:
  print("IMPOSSIBLE")
elif amari[n]:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

import sys
N,K=map(int, input().split())
A=list(map(int, input().split())) 
A.sort(reverse=1)
m=A[0]
for i in range(N-1):
  if A[i]!=A[i+1]:
    m=min(m,A[i]-A[i+1])

n=K%m
if K>A[0]:
  print("IMPOSSIBLE")
  sys.exit()
for i in range(N):
  if A[i]%m==n:
    print("POSSIBLE")
    sys.exit()

print("IMPOSSIBLE")