Harryxun/stf_run huggingface dataset:
N,M=map(int, input().split())

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

for _ in range(M):
    B,C = map(int, input().split())
    A.sort()

    for i in range(B):
        if A[i]<C:
            A[i] = C
            print(A)
            print('-----------\n')

print(sum(A))


### FIXED CODE ###

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

A = list(map(int, input().split()))
S = [list(map(int,input().split())) for i in range(M)]

A.sort()
S.sort(key=lambda x: x[1], reverse=True)

idx = 0

for i in range(M):
    for j in range(idx, min(N, idx + S[i][0])):
        if A[j] < S[i][1]:
            A[j] = S[i][1]
            idx += 1
        else:
            break

print(sum(A))
#adfjklsdjsfljfl;kdjldkjflkdsdfjksfjdklsfjdkjsfdjfsddfsfsdfsdfdfs
print(s.replace(',', ' '))

### FIXED CODE ###

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

N, H = MAP() 
ab = [LIST() for _ in range(N)]

a, b = zip(*ab)
a = list(a)
b = list(b)

b.sort()
A = max(a)

B = b[bisect(b, A):][::-1]
B = list(accumulate(B))

if H <= sum(B):
	print(bisect_left(B, H)+1)
else:
	print(len(B) + ceil((H-B[-1])/A))


### FIXED CODE ###

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

N, H = MAP() 
ab = [LIST() for _ in range(N)]

a, b = zip(*ab)
b = list(b)

b.sort()
A = max(a)

B = b[bisect(b, A):][::-1]
if B:
	B = list(accumulate(B))
else:
	B = [0]


if H <= B[-1]:
	print(bisect_left(B, H)+1)
else:
	if B[-1] == 0:
		print(ceil(H/A))
	else:
		print(len(B) + ceil((H-B[-1])/A))
a = int(input()) 
b = int(input())
c = int(input())
d = int(input())
print(max(a*b, c*d))

### FIXED CODE ###

a,b,c,d = map(int,input().split())
print(max(a*b, c*d))
n, q = map(int, input().split())

#print(n,q)
edge = []
for i in range(n-1):
    a = list(map(int, input().split()))
    edge.append(a)

add_list = []
for i in range(q):
    p = list(map(int, input().split()))
    add_list.append(p)

#print(edge,add_list)


dir_edge = []
for i in range(n):
    dir_edge.append([])

for e in edge:
    dir_edge[e[0]-1].append(e[1]-1)
    dir_edge[e[1]-1].append(e[0]-1)
#print(dir_edge)


ans = [0]*n
for v in add_list:
    ans[v[0]-1] += v[1]
#print(add_value)


def dfs(index, parent):
    if parent != -1:
        ans[index] += ans[parent]
    for i in dir_edge[index]:
        if (parent == i):
            continue
        dfs(i,index)
        

dfs(0, -1)
print(*ans)

### FIXED CODE ###

n,q = map(int,input().split())

#print(n,q)
edge=[]
for i in range(n-1):
    a = list(map(int,input().split()))
    edge.append(a)

add_list = []
for i in range(q):
    p = list(map(int,input().split()))
    add_list.append(p)

#print(edge,add_list)

ans = [0] * n
edge_list = [-1] * n

for e in edge:
    edge_list[e[1]-1] = e[0]-1

add_value = [0]*n
for v in add_list:
    add_value[v[0]-1] += v[1]

#print(edge_list)
#print(add_value)


dp = [-1] * n
def get_value(i):
    if(dp[i]!=-1):
        return dp[i]
    tmp = add_value[i]
    if edge_list[i] != -1:
        tmp += get_value(edge_list[i])
    dp[i] = tmp
    return dp[i]

for i in range(n):
    ans[i] = get_value(i)
    #print(i,ans)

print(' '.join(map(str,ans)))
N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
L = N*M//gcd(N,M)
res = [0]*(L)
cnt1 = 0
for s in S:
    res[cnt1*L//N] = s
    cnt1 += 1
cnt2 = 0
for t in T:
    if res[cnt2*L//M] == 0 or res[cnt2*L//M] == t:
        res[cnt2*L//M] = t
        cnt2 += 1
    else:
        print(-1)
        exit()
print(L) 

### FIXED CODE ###

N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
G = gcd(N,M)
if S[::N//G] == T[::M//G]:
    print(N*M//G)
else:
    print(-1)
import numpy as np
n, q = map(int, input().split())

e = np.eye(n+1)

for i in range(n-1):
    a, b = map(int, input().split())
    e[a][b] = 1

for i in reversed(range(1, n+1)):
    if e[i-1][i] == 1:
        e[i-1][i+1:] += e[i][i+1:]
        print(e[1:, 1:])
    else:
        continue


point = np.zeros(n)
for i in range(q):
    p, x = map(int, input().split())
    point[p-1] += x

ans = np.dot(point, e[1:, 1:])
print(*ans)

### FIXED CODE ###

from collections import deque
n, q = map(int, input().split())
tree = [[] for _ in range(n+1)]
cnt = [0] * (n+1)

for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

for _ in range(q):
    p, x = map(int, input().split())
    cnt[p] += x

queue = deque([1])
visited = {1}
while queue:
    now = queue.popleft()
    visited.add(now)
    for t in tree[now]:
        if t in visited:
            pass
        else:
            queue.append(t)
            cnt[t] += cnt[now]

print(*cnt[1:])
S = list(input())
N = len(S)

if N == 1:
    print('No')
    exit()
for i in range(0,N,2):
    if S[i] != 'h' or S[i+1] != 'i':
        print('No')
        exit()

print('Yes')


### FIXED CODE ###

S = list(input())
N = len(S)

if N%2 == 1:
    print('No')
    exit()
for i in range(0,N,2):
    if S[i] != 'h' or S[i+1] != 'i':
        print('No')
        exit()

print('Yes')
a,b,c=[int(x) for x in input().split()]
print("YES") if sorted([a,b,c]) == [5,5,7] else print("NO")

### FIXED CODE ###

a,b,c=[int(x) for x in input().split()]
print("YES") if sorted([a,b,c]) == [5,5,7] else print("NO")
import sys
input=sys.stdin.readline
from fractions import gcd
import numpy as np
n=int(input())
A=list(map(int,input().split()))
B=np.array(A)
mod=10**9+7

if n==1:
    print(1)
else:
    g=A[0]
    l=A[0]
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
    C=l*(1/B)
    ans=int(C.sum())
    print(int(ans)%mod)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
def gyaku(a):
    return pow(a,mod-2,mod)
if n==1:
    print(1)
else:
    gya=[0]*(n)
    g=A[0]
    l=A[0]
    gya[0]=gyaku(A[0])
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
        gya[i+1]=gyaku(A[i+1])
    ans=0
    for i in range(n):
        ans+=l*gya[i]
        ans%=mod
    print(ans)
def userCeil(a,b) :
    return (a + b - 1) // b

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

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

A.sort()

maxDigit = userCeil(max(K,A[-1]), 2)

ans = 0

# 前計算
maxVal = [0] * maxDigit
for i in range(maxDigit) :
    count = 0
    mask = 2**i
    for a in A :
        count += (a & mask) // mask
    count = max(N - count, count)
    if i == 0 :
        maxVal[0] = count
    else :
        maxVal[i] = count * mask + maxVal[i-1]
print(0)

### FIXED CODE ###

N , K = map(int,input().split())
 
A = list(map(int,input().split()))
 
A.sort()
 
maxDigit = max(K,A[-1]).bit_length()
 
# 前計算
maxVal = [0] * maxDigit
for i in range(maxDigit) :
    count = 0
    mask = 2**i
    for a in A :
        count += (a & mask) // mask
    count = max(N - count, count)
    if i == 0 :
        maxVal[0] = count
    else :
        maxVal[i] = count * mask + maxVal[i-1]
 
valK = [0] * (maxDigit + 1)
for i in range(maxDigit-1, -1, -1) :
    mask = 2**i
    maskK = K & mask
    sumK = 0
    for a in A :
        val = a & mask
        if maskK != val :
            sumK += mask
    valK[i] = sumK + valK[i+1]
 
ans = valK[0]  # X = K
for i in range(maxDigit-1, -1, -1) :  # 上からi+1桁まではKと同じ
    if not K & (2**i) > 0  :  # i桁目が0の場合
        continue
 
    sumXor = valK[i+1]
 
    # i桁目 0にする
    mask = 2**i
    for n in range(N) :
        if A[n] & mask > 0 :
            sumXor += mask
 
    if i > 0 :
        sumXor += maxVal[i-1]
 
    ans = max(ans, sumXor)
 
print(ans)
N = input()
D = map(int, raw_input().split())

cnt=0
lop=0

while lop<N-2:
  if max(D[lop],D[lop+1],D[lop+2])!=D[lop+1] and min(D[lop],D[lop+1],D[lop+2])!=D[lop+1]:
    cnt=cnt+1
  else:
  lop=lop+1
print (cnt)

### FIXED CODE ###

N = input()
D = map(int, raw_input().split())

cnt=0
lop=0

while lop<N-2:
  if max(D[lop],D[lop+1],D[lop+2])!=D[lop+1] and min(D[lop],D[lop+1],D[lop+2])!=D[lop+1]:
    cnt=cnt+1
  lop=lop+1
print (cnt)
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=[0]
for i in range(K+1):
    #print(i)
    for j in range(i+1):
        if N<=i:
            temp=sorted(V)
        elif j-i!=0:
            temp=sorted(V[:j]+V[j-i:])
        else:
            temp=sorted(V[:j])
        t=0
        for k in range(i):
            if temp[k]>=0:
                t=k+1
                break
        #print(temp,t)
        #if t==0:
        #    print(":",0)
        if t>K-i:
            #print(":",temp[K-i:])
            ans.append(sum(temp[K-i:]))
        elif (K-1-t)%2==1:
            if t>=2:
                #print(":",max(sum(temp[t-2:]),sum(temp[t:])))
                ans.append(max(sum(temp[t-2:]),sum(temp[t:])))
            else:
                #print(":",sum(temp[t:]))
                ans.append(sum(temp[t:]))
        else:
            #print(":",sum(temp[t-1:]))
            ans.append(sum(temp[t-1:]))
print(max(ans))

### FIXED CODE ###

N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=[0]

for i in range(K+1):
    #print(i)
    for j in range(i+1):
        if N<=i:
            temp=sorted(V)
        elif j-i!=0:
            temp=sorted(V[:j]+V[j-i:])
        else:
            temp=sorted(V[:j])
        t=0
        for k in range(min(i,N)):
            if temp[k]>=0:
                t=k+1
                break
        #print(temp,t,j,j-i)
        #if t==0:
        #    print(":",0)
        if t>K-i:
            #print("1",temp[K-i:])
            #print("1",sum(temp[K-i:]))
            ans.append(sum(temp[K-i:]))
        elif (K-1-t)%2==1:
            if t>=2:
                #print("2",max(sum(temp[t-2:]),sum(temp[t:])))
                ans.append(max(sum(temp[t-2:]),sum(temp[t:])))
            else:
                #print("3",sum(temp[t:]))
                ans.append(sum(temp[t:]))
        else:
            #print("4",sum(temp[t-1:]))
            ans.append(sum(temp[t-1:]))
print(max(ans))
A, B = [int(i) for i in input()]
print(A*B)


### FIXED CODE ###

A, B = [int(i) for i in input().split()]
print(A*B)
a, b, c = [int(i) for i in input().split()]

count = 0
a =< b

for x in range(a,b):
    if c % x == 0:
        count += 1

print(count)

### FIXED CODE ###

a,b,c = [int(i) for i in input().split()]

count = 0

for x in range(a,b+1):
    if c % x == 0:
        count += 1

print(count)
# coding: utf-8
import time
import re
import math

def main():
    A,B,C,D=map(int,input().split())
    N=B-A+1
    sc=hoge(A,C)-A+1
    if sc<=N:
        ccount=math.floor((N+C-sc)/C)
    else:
       ccount=0

    sd=hoge(A,D)-A+1
    if sd<=N:
        dcount=math.floor((N+D-sd)/D)
    else:
       dcount=0

    CD=C * D / math.gcd(C, D)
    scd=hoge(A,CD)-A+1
    if scd<=N:
        cdcount=math.floor((N+CD-scd)/CD)
    else:
       cdcount=0
    print(N-(ccount+dcount-cdcount))


def hoge(a,b):
    return math.ceil(a/b)*b
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B



### FIXED CODE ###

# coding: utf-8
import time
import re
import math
import fractions
 
def main():
    A,B,C,D=map(int,input().split())
    N=B-A+1
    sc=hoge(A,C)-A+1
    if sc<=N:
        ccount=(N+C-sc)//C
    else:
       ccount=0
 
    sd=hoge(A,D)-A+1
    if sd<=N:
        dcount=(N+D-sd)//D
    else:
       dcount=0
 
    CD=C * D // fractions.gcd(C, D)
    scd=hoge(A,CD)-A+1
    if scd<=N:
        cdcount=(N+CD-scd)//CD
    else:
       cdcount=0
    print(N-(ccount+dcount-cdcount))
 
 
def hoge(a,b):
    if a%b==0:
        return (a//b)*b
    else:
        #print("({} // {} +1)*{} {}".format(a,b,b,(a//b+1)*b))
        return (a//b+1)*b
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B
import math

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

n, a, b, k = map(int, input().split())
count = 0
for i in range(math.floor(k/a)):
    if (k - (i * a)) % b == 0:
        count += (C(n, i) * C(n, (k-a*i)/b))
print(count%998244353)

### FIXED CODE ###

N,A,B,K = map(int,input().split())
sprime = 998244353 # approx 10**9
A,B = sorted((A,B))
if (A+B) * N < K:
	print(0)
	exit()
 
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)
 
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
 
memo = [0] * (N+1)
memo[0] = memo[N] = 1
for i in range(1,N//2+1):
	v = memo[i-1] * (N-i+1) * modinv(i,sprime)
	v = v % sprime
	memo[i] = memo[N-i] = v
 
# max is A*N + B*N
sum = 0
for b in range(N+1):
  a = (K-b*B)//A
  if 0 <= a <= N and a*A+b*B == K:
    sum += memo[a]*memo[b]
    sum %= sprime
 
print(sum)
while 1:
   a, op, b = map(raw_input().split())
 
   if op == "+":
      print a+b
   elif op == "-":
      print a-b
   elif op == "*":
      print a*b
   elif op == "/":
      print int(a)/b
   elif op == "?":
      break

### FIXED CODE ###

while 1:
   a, op, b = raw_input().split()
   A = int(a)
   B = int(b)
 
   if op == '?':
      break
   elif op == '+':
      print A+B
   elif op == '-':
      print A-B
   elif op == '*':
      print A*B
   elif op == '/':
      print A/B
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
  print('Borys')
else:
  pritn('Alice')

### FIXED CODE ###

n,a,b = map(int,input().split())
if abs(b-a) % 2 == 0:
  print('Alice')
else:
  print('Borys')
from functools import reduce

N = int(input())
mod = 10**9 + 7


def powmod(val, n, mod):
    # vals = [val]*n
    # ret = reduce(lambda x, y: x * y % mod, vals)

    # return ret

    for i in range(n):
        ret = ret * val % mod

    return ret


all = powmod(10, N, mod)
b = powmod(9, N, mod)
c = powmod(8, N, mod)

ans = (all - (2*b - c))%mod

print(ans)

### FIXED CODE ###

N = int(input())
mod = 10**9 + 7


def powmod(val, n, mod):
    ret = 1
    for i in range(n):
        ret = ret * val % mod

    return ret


all = powmod(10, N, mod)
b = powmod(9, N, mod)
c = powmod(8, N, mod)

ans = (all - (2*b - c))%mod

print(ans)
n,m=map(int,input().split())
l=[]
for i in range(1,int(m**1/2)+1):
  if m%i==0:
    l.append(i)
    if m//i!=i:
      l.append(m//i)
for i in range(1,len(l)+1):
  if l[len(l)-i]*n>m:
    del l[len(l)-i]
print(max(l))

### FIXED CODE ###

def make_divisors(n,m):
    divisors = []
    for i in range(1,min(int(m**(1/2))+1,int(m//n)+1)):
      if m % i == 0:
          divisors.append(i)
          if i != m // i and m//i<=m//n:
              divisors.append(m//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))
from numba import njit

r,c,k=map(int,input().split())
goods=[list(map(int,input().split())) for _ in range(k)]
g=[[0]*c for _ in range(r)]
for cr,cc,ck in goods:
    g[cr-1][cc-1]=ck

@njit
def calc(r,c,g):
    dp=[[[-1]*4 for _ in range(c+1)] for _ in range(r+1)]
    maxlst=[[0]*(c+1) for _ in range(r+1)]

    for i in range(r):
        dp[i][0][0]=0
    for j in range(c):
        dp[0][j][0]=0
    
    for i in range(r):
        for j in range(c):
            tmp=0
            for k in range(3):
                if g[i][j]>0 and dp[i+1][j][k]>=0:
                    dp[i+1][j+1][k+1]=max(dp[i+1][j][k+1],dp[i+1][j][k]+g[i][j])
                else:
                    dp[i+1][j+1][k+1]=dp[i+1][j][k+1]
                tmp=max(tmp,dp[i+1][j+1][k+1])
            
            dp[i+1][j+1][0]=max(maxlst[i][j+1],dp[i+1][j][0])
            tmp=max(tmp,dp[i+1][j+1][0])
            
            if g[i][j]>0 and dp[i+1][j+1][0]>=0:
                dp[i+1][j+1][1]=max(dp[i+1][j+1][1],dp[i+1][j+1][0]+g[i][j])
                tmp=max(tmp,dp[i+1][j+1][1])
            
            maxlst[i+1][j+1]=tmp
    
    return maxlst[r][c]
            
print(calc(r,c,g))

### FIXED CODE ###

import numpy as np
from numba import njit

rr,cc,kk=map(int,input().split())
goods=np.array([list(map(int,input().split())) for _ in range(kk)])
gg=np.zeros((rr,cc))
for cr,ccc,ck in goods:
    gg[cr-1][ccc-1]=ck

@njit
def calc(r,c,g):
    dp=-1*np.ones((r+1,c+1,4))
    maxlst=np.zeros((r+1,c+1))

    dp[:,0,0]=0
    dp[0,:,0]=0
    
    for i in range(r):
        for j in range(c):
            tmp=0
            for k in range(3):
                if g[i][j]>0 and dp[i+1][j][k]>=0:
                    dp[i+1][j+1][k+1]=max(dp[i+1][j][k+1],dp[i+1][j][k]+g[i][j])
                else:
                    dp[i+1][j+1][k+1]=dp[i+1][j][k+1]
                tmp=max(tmp,dp[i+1][j+1][k+1])
            
            dp[i+1][j+1][0]=max(maxlst[i][j+1],dp[i+1][j][0])
            tmp=max(tmp,dp[i+1][j+1][0])
            
            if g[i][j]>0 and dp[i+1][j+1][0]>=0:
                dp[i+1][j+1][1]=max(dp[i+1][j+1][1],dp[i+1][j+1][0]+g[i][j])
                tmp=max(tmp,dp[i+1][j+1][1])
            
            maxlst[i+1][j+1]=tmp
    
    return maxlst[r][c]
            
print(int(calc(rr,cc,gg)))
import math
# from collections import defaultdict
# import time
def steps(n,p):
  c = 0
  while n:
    c += 1
    n = n%p
    p = bin(n).count('1')
  return c

n = int(input())
x = input()
incs = [1]
decs = [1]
p = x.count('1')
for i in range(1,n):
  incs.append((incs[-1]*2)%(p+1))
  decs.append((decs[-1]*2)%(p-1))
num = int(x,2)
inc = num%(p+1)
dec = num%(p-1)
# start = time.time()
for i in range(n):
  cp = p
  if x[i] == '0':
    cp += 1
    new = (inc+incs[n-i-1])%cp
  else:
    cp -= 1
    new = (dec-decs[n-i-1])%cp
  ans = steps(new,cp)
  if ans==0:
    ans=1
  print(ans)
  # steps(new,cp)
# print(time.time()-start)

### FIXED CODE ###

import math
# from collections import defaultdict
import time
def steps(n,p):
  c = 0
  while n:
    c += 1
    n = n%p
    p = bin(n).count('1')
  return c

# n = 200000
# x = "1"*n
n = int(input())
x = input()
p = x.count('1')
ans = []
num = int(x,2)
if p==1:
  for i in range(n-1,-1,-1):
    if x[i]=='1':
      ans.append(0)
    else:
      if i==n-1 or x[n-1]=='1':
        ans.append(2)
      else:
        ans.append(1)
else:
  incs = 1
  decs = 1
  inc = num%(p+1)
  dec = num%(p-1)
  start = time.time()
  k = -1
  for i in range(n-1,-1,-1):
    cp = p
    if x[i] == '0':
      cp += 1
      new = (inc+incs)%cp
    else:
      cp -= 1
      new = (dec-decs)%cp
    k -= 1
    incs = (incs*2)%(p+1)
    decs = (decs*2)%(p-1)
    sol = steps(new,cp)
    if sol==0:
      sol=1
    ans.append(sol)
    # steps(new,cp)
  # print(time.time()-start)
ans = ans[::-1]
for x in ans:
  print(x)
import math
import sys
a, b, c = map(int, input().split())
lcm = a*b//math.gcd(a,b)
for i in [x*a for x in range(1, lcm+1)]:
    if i % b == c:
        print("YES")
        sys.exit()
print("NO")


### FIXED CODE ###

import fractions, sys
a, b, c = map(int, input().split())
for i in [x*a for x in range(1, a*b//fractions.gcd(a,b)+1)]:
    if i % b == c:
        print("YES")
        sys.exit()
print("NO")
N,K=map(int,input().split())
S=list(input())
S[K-1]=S[K-1].lower()
print("".join(K))

### FIXED CODE ###

N,K = map(int,input().split())
S = input()
n = K-1
ans = ""
for i in range(N):
    if i == n:
        ans = ans +S[i].lower()
    else:
        ans = ans + S[i]
print(ans)
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
a = [0]+a
b = [0]+b

ans = 0
ALL = 0
from bisect import bisect
for i in range(n+1):
    ALL = a[i]
    if ALL > k:
        continue
    else:idx = bisect(b,k-ALL)
    #print(i,ALL,idx)
        ans = max(ans,i+idx-1)
print(ans)

### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
a = [0]+a
b = [0]+b

ans = 0
ALL = 0
from bisect import bisect
for i in range(n+1):
    ALL = a[i]
    if ALL > k:
        continue
    else:
        idx = bisect(b,k-ALL)
    #print(i,ALL,idx)
        ans = max(ans,i+idx-1)
print(ans)
n=int(input())
A=list(int(input()) for i in range(n))
a=0
for x in range(n):
  a=a[i]
  if a==2:
    print(x)
    break

### FIXED CODE ###

n=int(input())
A=list(int(input()) for i in range(n))
a=0
for x in range(n):
  a=A[a]-1
  if a==1:
    print(x+1)
    break
else:
  print(-1)
A,B,X=map(int,input().split())
a=[]
for i in range(1,11):
  rest=X-B*i
  if rest>0 and len(str(int(rest/A)))==i:
      a.append(rest//A)
a.sort()
if a==[]:
    print(0)
else:
    print(a[len(a)-1])

### FIXED CODE ###

S=input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)
num = int(raw_input())
list = map(int, raw_input().split())

i = 0
while 1 not in map(lambda x: x % 2, list):
 list = map(lambda x: x >> 1, list)
 i += 1

print i

### FIXED CODE ###

print raw_input().count('1')
n=int(input())
dat = list(map(int, input().split()))
dan = []
for e in dat:
    e = list(str(bin(e)))
    e.reverse()

min=0
 for e in dat:
       min = min+1
             
print(min)

    
    
     
                

         
           




### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1

main()
from sys import stdin
from itertools import accumulate
n = int(stdin.readline().rstrip())
if n == 1:
    print(0)
else:
    a = list(range(1, n))
    b = list(accumulate(a))
    print(b[-1])

### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
point = n*(n-1)//2
print(point)