Harryxun/stf_run huggingface dataset:
n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0

def merge(S, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    for i in range(n1):
        L[i] = S[left + i]
    for i in range(n2):
        R[i] = S[mid + i]
    L[n1] = r[n2] = SENTINEL
    i = j = 0
    for k in range(left, right):
        count += 1
        if(L[i] <= R[i]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1

mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)

mergeSort(S, 0, n)
print(*S)
print(count)

### FIXED CODE ###

n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0
 
def merge(S, left, mid, right):
    L = S[left:mid] + [SENTINEL]
    R = S[mid:right] + [SENTINEL]
    i = j = 0
    global count
    for k in range(left, right):
        count += 1
        if (L[i] <= R[j]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1
 
def mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)
 
mergeSort(S, 0, n)
print(*S)
print(count)
n = int(input())
if 9 in n:
    print('Yes')
else:
    print('No') 

### FIXED CODE ###

n = input()
if '9' in n:
    print('Yes')
else:
    print('No')
N = int(input())
words = input()
ans = 0
for i, word in enumerate(words):
	if word == "A":
		if words[i+1] == "B":
			if words[i+2] == "C":
				ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
words = input()
ans = 0
for i in range(N-2):
    if words[i] == "A":
        if words[i+1] == "B":
            if words[i+2] == "C":
                ans += 1
print(ans)
N, K= map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if K>=N:
  print(0)
else:
  if K==0:
    SUM = sum(lists)
    print(SUM)
  else:
      del lists[-K:]
      SUM = sum(lists)
      print(SUM)

### FIXED CODE ###

H, A = map(int,input().split())
a = int(H/A)
b = H/A
if a==b:
  print(a)
else:
  c = a+1
  print(c)
from math import ceil
 
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
 
T.sort()
 
bus = 0
bus_time = T[0] + K
tmp_bus = 1
 
for i in range(1,N):
    if T[i] > bus_time:
        bus += 1
        bus_time = T[i+1] + K
        tmp_bus = 0
    else:
        tmp_bus += 1
    
    if tmp_bus == C:
        bus += 1
        bus_time = T[i+1] + K
        tmp_bus = 0
 
print(bus+1)

### FIXED CODE ###

n,c,k = tuple(map(int,input().split()))
t = []

for i in range(n):
  t.append(int(input()))
t = sorted(t)
t_0 = t[0]
p = 1
ans = 0
for t_i in t[1:]:
  if p<c and t_i-t_0<=k:
    p+=1
  else:
    p = 1
    t_0 = t_i
    ans+=1
    
print(ans+1)
a = input()
b = input()
c = a * b
d = 2 * (a + b)
print (int(c) int(d))

### FIXED CODE ###

x = raw_input().split()
y = map(int,x)
a = y[0]
b = y[1]

c = a * b
d = (a + b) * 2
print c,d
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
else:
  if s[0] == s[1]:
      if s[2] == s[3]:
        print('Yes')
      else:
        print('No')
    elif s[0] == s[2]:
      if s[1] == s[3]:
        print('Yes')
      else:
        print('No')
    elif s[0] == s[3]:
      if s[1] == s[2]:
        print('Yes')
      else:
        print('No')

### FIXED CODE ###

s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
else:
  if s[0] == s[1]:
      if s[2] == s[3]:
        print('Yes')
      else:
        print('No')
  elif s[0] == s[2]:
      if s[1] == s[3]:
        print('Yes')
      else:
        print('No')
  elif s[0] == s[3]:
      if s[1] == s[2]:
        print('Yes')
      else:
        print('No')
  else:
    print('No')
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI1()
	L = [0]*N
	b = [0]*N
	t = 1
	for i,a in enumerate(A):
		L[a]+=1
		if(i==0):
			b[0]=t
		else:
			b[i]=b[i-1]+t
		t+=1
	L_s = L.copy()
	L_s.sort(reverse=True)
	max_c = 0
	for l in L_s:
		if l <= 1:
			break
		else:
			max_c += b[l-2]
	ans = [max_c]*N
	for i,a in enumerate(A):
		if(L[a]>=2):
			ans[i]+=(-L[a]+1)
	printV(ans)


if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI1()
	L = [0]*N
	b = [0]*N
	t = 1
	for i,a in enumerate(A):
		L[a]+=1
		if(i==0):
			b[0]=t
		else:
			b[i]=b[i-1]+t
		t+=1
	L_s = L.copy()
	L_s.sort(reverse=True)
	max_c = 0
	for l in L_s:
		if l <= 1:
			break
		else:
			max_c += b[l-2]
	ans = [max_c]*N
	for i,a in enumerate(A):
		if(L[a]>=2):
			ans[i]+=(-L[a]+1)
	printV(ans)


if __name__ == '__main__':
	main()
a, x, b = input()

if x == '+':
    ans = int(a)+int(b)
else:
    ans = int(a)-int(b)

print(ans)


### FIXED CODE ###

a, x, b = input().split()

if x == '+':
    ans = int(a)+int(b)
else:
    ans = int(a)-int(b)

print(ans)
n,k = map(int,input().split())
s = input()

ans = 0
c = 0
for i in range(1,n):
    if s[i] == s[i-1]:
     ans += 1
    else:
        c += 1
if c == 1:
    print(ans+1)
    exit()

t = -1
for i in range(1,n):
    now = s[i-1]
    if s[i] != now:
        t += 1
    if t == 1 and k > 0:
        k -= 1
        ans += 2
        t = -1
    #print(ans)

if k > 0 and now != s[n-1]:
    ans += 1
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
s = input()
if len(s) == 1:
    print(0)
    exit()

ans = 0
c = 0
for i in range(1,n):
    if s[i] == s[i-1]:
        ans += 1
    else:
        c += 1

if c == 1:
    print(n-1)
    exit()


t = -1
left = s[0]
q = -1
for i in range(1,n):
    if s[i] != left:
        t += 1
        left = s[i]
    if t == 1 and k > 0:
        k -= 1
        ans += 2
        t = -1

if t == 0 and k > 0:
    ans += 1
print(ans)
N = int(raw_input())
act = [map(int, raw_input().split()) for _ in range(N)]
memo = [[-1]*3 for _ in range(N)]

def happy(n, i):
  if memo[n][i] >= 0:
    return memo[n][i]
  if n == 0:
    h = act[n][i]
  else:
    h = -1
    for j in range(3):
      if j == i:
        continue
      c = happy(n-1,j)+act[n][i]
      h = h if h > c else c
  memo[n][i] = h
  return h
print max(happy(N-1,0),happy(N-1,1),happy(N-1,2))



### FIXED CODE ###


import sys

sys.setrecursionlimit(100000)
N = int(raw_input())
act = [map(int, raw_input().split()) for _ in range(N)]
memo = [[-1]*3 for _ in range(N)]

def happy(n, i):
  if memo[n][i] >= 0:
    return memo[n][i]
  if n == 0:
    h = act[n][i]
  else:
    h = -1
    for j in range(3):
      if j == i:
        continue
      c = happy(n-1,j)+act[n][i]
      h = h if h > c else c
  memo[n][i] = h
  return h
print max(happy(N-1,0),happy(N-1,1),happy(N-1,2))
h,n=map(int,input().split())
a=[0]*n
b=[0]*n
inf=10**10
for i in range(n):
    a[i],b[i]=map(int,input().split())
dp = [[inf for i in range(h+2)] for j in range(n+1)]
for i in range(n):
    cnt=1
    for j in range(h+1):
            if j-a[i]<0:
                dp[i+1][j]=min(dp[i][j],dp[i][j-a[i]]+b[i],b[i]*cnt)
            else:
                dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i],dp[i][j-a[i]]+b[i],b[i]*cnt)
                cnt+=1
"""
for i in range(1,n+1):
    for j in range(h+1):
        if j+a[i]<=h:
            dp[i+1][j+a[i]]=min(dp[i+1][a[i]],dp[i][j]+b[i])"""
print(dp[n][h])
#print(dp)


### FIXED CODE ###

h,n=map(int,input().split())
a=[0]*n
b=[0]*n
inf=10**10
for i in range(n):
    a[i],b[i]=map(int,input().split())
dp = [[inf for i in range(h+1)] for j in range(n+1)]
for i in range(n):
    cnt=1
    for j in range(h+1):
            if j-a[i]<0:
                dp[i+1][j]=min(dp[i][j],dp[i][0]+b[i],b[i]*cnt)
            else:
                dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i],dp[i][j-a[i]]+b[i],b[i]*cnt)
                cnt+=1
"""
for i in range(1,n+1):
    for j in range(h+1):
        if j+a[i]<=h:
            dp[i+1][j+a[i]]=min(dp[i+1][a[i]],dp[i][j]+b[i])"""
print(dp[n][h])
#print(dp)
#! /usr/bin/python3
# Factors of Factorial

"""
1≦N≦103
"""

import math
import sympy

test = False

N = int(input())


def yakusu_no_kosu(n):
    """
    n! の約数の個数
    """
    d = sympy.factorint(math.factorial(n))
    # n!を素因数分解 {素因数1: 個数, 素因数2: 個数, …}
    l_d = list(d.values())
    # 各素因数(key)の個数(value)のみリストにする

    if test:
        print('l_d =', l_d)

    kosu = 1
    # 約数の数

    for v in l_d:
        kosu *= v + 1
    # 各素因数(key)の個数v(value)から約数の個数を算出

    return kosu


def main():
    """
    N! の約数の個数を 10^9+7 で割った余りを出力
    """
    print(yakusu_no_kosu(N) % (10**9 + 7))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#! /usr/bin/python3
# Factors of Factorial

"""
1≦N≦103
"""

import math
import collections
# import sympy

test = False

N = int(input())


def prime_factors(n):
    """
    自然数 n の素因数のリスト
    """
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            # n = n // i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


def yakusu_no_kosu(n):
    """
    n! の約数の個数
    """

    l = prime_factors(math.factorial(n))
    c = collections.Counter(l)
    l_c = list(c.values())
    if test:
        print('l =', l)
        print('c =', c)
        print('l_c =', l_c)


    kosu = 1
    # 約数の数
    for v in l_c:
        kosu *= v + 1
    # 各素因数(key)の個数v(value)から約数の個数を算出

    """
    d = sympy.factorint(math.factorial(n))
    # n!を素因数分解 {素因数1: 個数, 素因数2: 個数, …}
    l_d = list(d.values())
    # 各素因数(key)の個数(value)のみリストにする

    if test:
        print('l_d =', l_d)

    kosu = 1
    # 約数の数

    for v in l_d:
        kosu *= v + 1
    # 各素因数(key)の個数v(value)から約数の個数を算出
    """

    return kosu


def main():
    """
    N! の約数の個数を 10^9+7 で割った余りを出力
    """
    print(yakusu_no_kosu(N) % (10**9 + 7))


if __name__ == '__main__':
    main()
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))
if len(ship) == 0:
    print("IMPOSSIBLE")
    exit()

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1
if i == len(ship):
    print("IMPOSSIBLE")


for j in range(i):
    for k in range(i, len(ship)):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()
        elif ship[j][1] < ship[k][0]:
            break

print("IMPOSSIBLE")


### FIXED CODE ###

n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
s = list(input())
l = ['K','I','H','B','R']
j = 0

for i in range(len(s)):
    if s[i] == 'A':
        if i == 0:
            pass
        elif s[i-1] == 'A':
            print('NO')
            exit(0)
        elif j == 1 or j == 2:
            print('NO')
            exit(0)
        else:
            pass
    elif s[i] != l[j]:
        print('NO')
        exit(0)
    else:
        j += 1

print('YES')

### FIXED CODE ###

s = list(input())
l = ['K','I','H','B','R',-1]
j = 0

for i in range(len(s)):
    if s[i] == 'A':
        if i == 0:
            pass
        elif s[i-1] == 'A':
            print('NO')
            exit(0)
        elif j == 1 or j == 2:
            print('NO')
            exit(0)
        else:
            pass
    elif s[i] != l[j]:
        print('NO')
        exit(0)
    elif j > 4 and s[i] != 'A':
        print('NO')
        exit(0)
    else:
        j += 1

if j == 5:
    print('YES')
else:
    print('NO')
a,b,x=map(int,input().split())

import math
c=(a*a*b-x)*2

if c<a*a*b:
  d=c/(a*a)
  print(math.degrees(math.atan(d/a)))
else:
  f=(2*x)/a*b 
  print(math.degrees(math.atan(b/f)))

### FIXED CODE ###

a,b=map(int,input().split())
if a>=10 or b>=10:
  print(-1)
else:
  print(a*b)
a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)

d = b - a
d = int(d)
dv = v - w
dv = int(dv)
d = abs(d)
if abs(d) % abs(dv) == 0 and abs(d) <= int(dv) * T:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)

d = b - a
d = int(d)
dv = v - w
dv = int(dv)
d = abs(d)
if dv > 0 and abs(d) <= abs(dv) * T:
    print('YES')
else:
    print('NO')
def ct(pp, ls, xx, tct):
  tct[pp-1] += xx
  nodel = [i for i, x in enumerate(ls) if x == pp]:
  if bool(nodel):
    for j in nodel:
      ct(j, ls, xx, tct)
  return

N, Q = map(int, input().split())
nodeR = [0 for nn in range(N)]
for i in range(N):
  a, b = map(int, input().split())
  nodeR[b-1] = a
tree_ct = [0 for nn in range(N)]
for j in range(Q):
  p, x = map(int, input().split())
  ct(p, nodeR, x, tree_ct)
print(' '.join(map(str, tree_ct)))

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
 
n,q = na()
g = [[] for i in range(n)]
c = [0]*n
 
for i in range(n-1):
    a,b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
for i in range(q):
    p,x = na()
    c[p-1] += x
 
def f(b,a,r):
    r += c[a]
    c[a] = r
    for i in g[a]:
        if i != b:
            f(a,i,r)
 
f(-1,0,0)
print(' '.join([str(s) for s in c]))
l = [1, 2, 3]
A = int(stdin.readline().rstrip())
B = int(stdin.readline().rstrip())
l.remove(A)
l.remove(B)
print(l[0])

### FIXED CODE ###

l = [1, 2, 3]
A = int(input().rstrip())
B = int(input().rstrip())
l.remove(A)
l.remove(B)
print(l[0])
X, Y = list(map(int,input().split()))

from functools import reduce

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:  return 1
    numer = reduce(lambda x, y: (x * y) % p, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x * y) % p, range(1, r + 1))
    return (numer * pow(denom, p - 2, p)) % p

temp1 = 2 * X - Y
temp2 = 2 * Y - X
if temp1 % 3 or temp2 % 3:  print(0)
else:
    a = temp1 // 3
    b = temp2 // 3
    print(cmb(a + b, a, 10 ** 9 + 7))

### FIXED CODE ###

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

from functools import reduce

def cmb(n, r):
    INF = 10 ** 9 + 7
    r = min(n - r, r)
    if r == 0:  return 1
    numer = reduce(lambda x, y: (x * y) % INF, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x * y) % INF, range(1, r + 1))
    return (numer * pow(denom, INF - 2, INF)) % INF

temp1 = 2 * X - Y
temp2 = 2 * Y - X
if temp1 % 3 or temp2 % 3:  print(0)
elif temp1 < 0 or temp2 < 0:  print(0)
else:
    a = temp1 // 3
    b = temp2 // 3
    print(cmb(a + b, a))
N,M = map(int,input().split())

#表を0とする　カードの設定
G = [[0]*N for _ in range(M)]

#めくる
def turn(x,y):
    G[y][x] = (G[y][x]+1)%2
    if x > 0:
        G[y][x-1] = (G[y][x-1]+1)%2
        if y > 0:
            G[y-1][x-1] = (G[y-1][x-1]+1)%2
        if y < M-1:
            G[y+1][x-1] = (G[y+1][x-1]+1)%2
    if x < N-1:
        G[y][x+1] = (G[y][x+1]+1)%2
        if y > 0:
            G[y-1][x+1] = (G[y-1][x+1]+1)%2
        if y < M-1:
            G[y+1][x+1] = (G[y+1][x+1]+1)%2
    if y > 0:
        G[y-1][x] = (G[y-1][x]+1)%2
    if y < M-1:
        G[y+1][x] = (G[y+1][x]+1)%2
    return G

for i in range(N):
    for j in range(M):
        x = i
        y = j
        turn(x,y)

res = 0
for g in G:
    res += sum(g)
print(res)

### FIXED CODE ###

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

if N == 1 and M == 1:
    print(1)
elif N ==1 or M == 1:
    print(max(M-2,N-2))
else:
    print((N-2)*(M-2))
N = int(input())
S = input()
RGB = ['R', 'G', 'B']

import collections
dct = dict(collections.Counter(S))
#print(dct)

ans = 0
for i in range(0, N-1):
    for j in range(i+1, N):
        if S[i] != S[j]:
            for c in RGB:
                if c != S[i] and c != S[j]:
                    cnt = 0
                    if 0 <= 2 * j - i < N and S[2 * j - i] == c:
                        cnt += 1
                    if N > 2 * i - j >= 0 and S[2 * i - j] == c:
                        cnt += 1
                    if i % 2 == j % 2:
                        if 0 <= (i + j) // 2 < N and S[(i + j) // 2] == c:
                            cnt += 1
                    ans += dct[c] - cnt
                    #print(i, j, dct[c]-cnt)
#print(ans)
print(ans // 3)


### FIXED CODE ###

N = int(input())
S = input()
RGB = ['R', 'G', 'B']
import collections
if len(set(list(S))) <= 2:
    print(0)
else:
    dct = dict(collections.Counter(S))

    cnt = 0
    for i in range(N-2):
        for k in range((N - 1 - i) // 2 + 1):
            temp = {S[i], S[i + k], S[i + k * 2]}
            if len(temp) == 3:
                cnt += 1
            #print(cnt)
    print(dct['R'] * dct['G'] * dct['B'] - cnt)
a = int(input())
if a==3 or a==5 or a==7:
	print("YES")
else:
	print("NO")
return

### FIXED CODE ###

a = int(input())
if a==3 or a==5 or a==7:
	print("YES")
else:
	print("NO")
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13 7 2\n"
     ]
    }
   ],
   "source": [
    "all = input()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "all = input()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['13', '7', '2']"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "all = [int(num) for num in all]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[13, 7, 2]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'list' object has no attribute 'sum'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-19-1727d8e1239d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mall\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m: 'list' object has no attribute 'sum'"
     ]
    }
   ],
   "source": [
    "all.sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bust\n"
     ]
    }
   ],
   "source": [
    "if sum(all) >= 22:\n",
    "    print('bust')\n",
    "else:\n",
    "    print('win')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}


### FIXED CODE ###

S = input()
count = 0
for i in range(len(S)//2):
    if S[i] is not S[len(S)-1-i]:
        count += 1
print(count)
N=int(input())
S=input()
S_list=[]
for i in S:
    S_list.append(i)
set(S_list)
print(lens(S_list))


### FIXED CODE ###

N=int(input())
S=input()
S_list=[]
count = 0
j=''

for i in S:
    count +=1
    if (count>=2) & (i==j): continue
    else:
        S_list.append(i)
        j=i

print(len(S_list))
n,x,m = map(int, input().split())
b = x%m
add = 0

# nがm以下なら全部足せば良い
ans = 0
if n <= m:
    for i in range(n):
        ans += b    
        b = pow(b,2,m)
    print(ans)
    exit()

# nがmより大のとき、効率化
cnt = 0
while 2 ** cnt < m:
    cnt += 1

# 位数と初期値を出す
s = set()
for i in range(m):
    if i < cnt:
        add += b
        tmp = b
    else:
        s.add(b)
    b = pow(b, 2, m)
# cnt以降、和*位数+残りの和で計算
rest = (n-cnt)%len(s)
div = (n-cnt)//len(s)

rep = []
for i in range(len(s)):
    tmp = pow(tmp, 2, m)
    rep.append(tmp)

ans = add + sum(rep)*div + sum(rep[:rest])
print(ans)

### FIXED CODE ###

n,x,m = map(int, input().split())
b = x%m
add = 0

# nがm以下なら全部足せば良い
ans = 0
if n <= m:
    for i in range(n):
        ans += b    
        b = pow(b,2,m)
    print(ans)
    exit()

# nがmより大のとき、効率化
cnt = 0
while 2 ** cnt < m:
    cnt += 1

# 位数と初期値を出す
s = set()
tmp = 0
for i in range(m):
    if i < cnt:
        add += b
        tmp = b
    else:
        s.add(b)
    b = pow(b, 2, m)

# cnt以降、和*位数+残りの和で計算
rest = (n-cnt)%len(s)
div = (n-cnt)//len(s)

rep = []
for i in range(len(s)):
    tmp = pow(tmp, 2, m)
    rep.append(tmp)

ans = add + sum(rep)*div + sum(rep[:rest])
print(ans)
N, M = map(int, input().split())
D = []
for i in range(N):
    t, v = map(int, input().split())
    D.append((t, v))

D.sort(key=lambda x:x[0])

DP1 = [[0 for j in range(M)] for i in range(N + 2)]
DP2 = [[0 for j in range(M)] for i in range(N + 2)]

for i in range(1, N + 1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP1[i][j] = max(DP1[i - 1][j], DP1[i - 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP1[i][j] = DP1[i - 1][j]

for i in range(N, 0, -1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP2[i][j] = max(DP2[i + 1][j], DP2[i + 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP2[i][j] = DP2[i + 1][j]

mv = 0
for l in range(N):
    mv = max(DP1[l][M - 1] + DP2[l + 2][l + 1] + D[l][1], mv)

print(mv)


### FIXED CODE ###

N, M = map(int, input().split())
D = []
for i in range(N):
    t, v = map(int, input().split())
    D.append((t, v))

D.sort(key=lambda x:x[0])

DP = [[0 for j in range(M)] for i in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP[i][j] = DP[i - 1][j]
mv = 0
for l in range(N): #ラストオーダー
    mv = max(DP[l][M - 1] + D[l][1], mv)

print(mv)
S = input()
if "AC" in S:
	print('Yes')
else
	print('No')

### FIXED CODE ###

S = input()
if "AC" in S:
	print('Yes')
else:
	print('No')
while True:
a = 1
b = int(raw_input())
	if b != 0:
		b = int(raw_input())
		print('Case ' + str(a) + ': ' + str(b))
		a += 1
		continue
	else:
		break

### FIXED CODE ###

a = int(1)
b = int(1)
while True:
	b = int(raw_input())
	if b != 0:
		print('Case ' + str(a) + ': ' + str(b))
		a += 1
		continue
	else:
		break