Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n,c = map(int,input().split())
X = []
V = []
for i in range(n):
  x,v = map(int,input().split())
  X.append(x)
  V.append(v)
right = []
right2 = []
left = []
count = 0
left2 = []
for i in range(n):
  if i == 0:
    count += (V[i] - X[i])
    right.append(count)
    right2.append(count - X[i])
  else:
    count += (V[i] - (X[i] - X[i - 1]))
    right.append(count)
    right2.append(max(right2[-1],count - X[i]))

count = 0
for i in range(n):
  if i == 0:
    count += (V[(i + 1) * (-1)] - (c - X[(i + 1) * (-1)]))
    left.append(count)
    left2.append(count - (c - X[(i + 1) * (-1)]))
  else:
    count += (V[(i + 1) * (-1)] - ((X[i * (-1)] - X[((i + 1) * (-1))])))
    left.append(count)
    left2.append(max(left2[-1],count - (c - X[(i + 1) * (-1)])))
ans = max(0,max(right),max(left))
for i in range(n):
  if n - i - 1 > 0:
    ans = max(ans, right2[i] + max(left[0:n-i-1]))
for i in range(n):
  if n - i - 1 > 0:
    ans = max(ans, left2[i] + max(right[0:n-i-1]))
print(ans)

### FIXED CODE ###

n,c = map(int,input().split())
X = []
V = []
for i in range(n):
  x,v = map(int,input().split())
  X.append(x)
  V.append(v)
right = []
right2 = []
left = []
count = 0
left2 = []
for i in range(n):
  if i == 0:
    count += (V[i] - X[i])
    right.append(count)
    right2.append(count)
  else:
    count += (V[i] - (X[i] - X[i - 1]))
    right.append(count)
    right2.append(max(right2[-1],count))

count = 0
for i in range(n):
  if i == 0:
    count += (V[(i + 1) * (-1)] - (c - X[(i + 1) * (-1)]))
    left.append(count)
    left2.append(count)
  else:
    count += (V[(i + 1) * (-1)] - ((X[i * (-1)] - X[((i + 1) * (-1))])))
    left.append(count)
    left2.append(max(left2[-1],count))
ans = max(0,max(right),max(left))
for i in range(n - 1):
  ans = max(ans, right[i] - X[i] + left2[n-i-2])
for i in range(n - 1):
  ans = max(ans, left[i] - (c - X[(i + 1) * (-1)]) + right2[n-i-2])
print(ans)
### BUGGY CODE ###

h,w = map(int,input().split())
raw = []
for _ in range(h):
  raw.append(input())
ans = [[0 for _ in range(w)] for _ in range(h)]
#print(raw)
#print(ans)
for x in range(h):
  tmp = 0
  for y in range(w):
    if raw[x][y] == '.':
      tmp += 1
    else:
      for j in range(tmp):
        ans[x][y-j-1] += tmp
      tmp = 0
  for j in range(tmp):
    ans[x][y-j] += tmp
for y in range(w):
  tmp = 0
  for x in range(h):
    if raw[x][y] == '.':
      tmp += 1
    else:
      for i in range(tmp):
        ans[x-i-1][y] += tmp
      tmp = 0
  for i in range(tmp):
    ans[x-i-1][y] += tmp
can = []
for x in range(h):
  can.append(max(ans[x]))
print(max(can)-1)

### FIXED CODE ###

#21:10
h,w = map(int,input().split())
raw = []
for x in range(h):
  raw.append(input())
xx = []
for x in range(h):
  now = []
  tmp = 0
  for y in range(w):
    if raw[x][y] == '.':
      tmp += 1
    else:
      now += [tmp] * tmp
      tmp = 0
      now.append(0)
  now += [tmp] * tmp
  xx.append(now)
yy = []
for y in range(w):
  now = []
  tmp = 0
  for x in range(h):
    if raw[x][y] == '.':
      tmp += 1
    else:
      now += [tmp] * tmp
      tmp = 0
      now.append(0)
  now += [tmp] * tmp
  yy.append(now)
'''
for x in range(h):
  print(xx[x])
for y in range(w):
  print(yy[y])
'''
maxi = 0
for x in range(h):
  for y in range(w):
    maxi = max(maxi,xx[x][y]+yy[y][x]-1)
print(maxi)
### BUGGY CODE ###

root=[]
n,k = map(int,input().split())
for i in range(k):
    x,y = map(int,input().split())
    root.append([x,y])

toori=[0]*(2*10**5)+[0]*n+[0]*(2*10**5)
toori[2*10**5]=1
cum=[0]*k
for a,i in enumerate (root):
    s=0
    for j in range (i[0],i[1]+1):
        s+=toori[2*10**5+1-j]
    cum[a]=s
toori[2*10**5+1]+=sum(cum)


for now in range(2,n):#nowが今の場所
    for a,i in enumerate (root):
        cum[a]=cum[a]+toori[2*10**5+now-i[0]] - toori[2*10**5+now-1-i[1]]
    toori[2*10**5+now]+=sum(cum)
    toori[2*10**5+n-1]%=998244353
    


print(toori[2*10**5+n-1]%998244353)

### FIXED CODE ###

root=[]
n,k = map(int,input().split())
for i in range(k):
    x,y = map(int,input().split())
    root.append([x,y])

toori=[0]*(2*10**5)+[0]*n+[0]*(2*10**5)
toori[2*10**5]=1
cum=[0]*k
for a,i in enumerate (root):
    s=0
    for j in range (i[0],i[1]+1):
        s+=toori[2*10**5+1-j]
    cum[a]=s
aaa=sum(cum)%998244353
toori[2*10**5+1]+=aaa


for now in range(2,n):#nowが今の場所
    hueru=0
    for a,i in enumerate (root):
        hueru+=(toori[2*10**5+now-i[0]] - toori[2*10**5+now-1-i[1]])
    aaa+=hueru
    aaa%=998244353
    toori[2*10**5+now]+=aaa
    toori[2*10**5+now]%=998244353
    


print(toori[2*10**5+n-1]%998244353)
### BUGGY CODE ###

s = input()
ans = 0

while "ABC" in s:
    ans += s.count("ABC")
    s = s.replace("ABC","BCA")

print(ans)


### FIXED CODE ###

s = input()
s = s.replace("BC","D").replace("B","E").replace("C","E")
s = s.split("E")

def solve(s):
    ans = 0 ; tmp = 0
    for char in s:
        if char == "A": tmp += 1
        else: ans += tmp
    return ans

ans = 0
for ele in s: ans += solve(ele)
print(ans)
### BUGGY CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())

a = Counter(a)
for _ in range(q):
    b, c = map(int, input().split())
    a[c] += a[b]
    a[b] = 0
    ans = [x * y for x, y in a.items()]
    print(sum(ans))


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
total = sum(a)

a = Counter(a)
for _ in range(q):
    b, c = map(int, input().split())
    total += a[b] * c
    total -= a[b] * b
    a[c] += a[b]
    del a[b]
    print(total)
### BUGGY CODE ###

N=int(input())
S=list(input())
cnt=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if S[i]!=S[j]!=S[k] and S[i]!=S[k] and (j-i!=k-j):
                cnt+=1
print(cnt)

### FIXED CODE ###

N=int(input())
S=input()
cnt=S.count("R")*S.count("G")*S.count("B")
for i in range(N):
    for j in range(i+1,N):
        k=2*j-i
        if k<N and S[i]!=S[j]!=S[k]!=S[i]:
            cnt-=1
print(cnt)
### BUGGY CODE ###

N,K=(int(x) for x in input().split())
P=list(map(int, input().split()))
S=sum(P[0:K])
for i in range(N):
    s=sum(P[i:i+K])
    S=max(S,s)
print((S+K)/2)

### FIXED CODE ###

N,K=(int(x) for x in input().split())
P=list(map(int, input().split()))
s=sum(P[0:K])
ans=[s]

for i in range(K,N):
    s=s+P[i]-P[i-K]
    ans.append(s)

S=max(ans)
print((S+K)/2)
### BUGGY CODE ###

import sys
import numpy as np
N = int(input())

A = np.zeros(N)

for n in range(N):
    A[n] = int(input())

if all(A):
    print(int(sum(A) // 2))
    sys.exit()

B = np.split(A, np.where(A == 0)[0][:])
count = sum([sum(item) // 2 for item in B])
print(int(count))

### FIXED CODE ###

import sys
N = int(input())

A = [0] * N
count = 0
for n in range(N):
    A[n] = int(input())

if all(A):
    print(sum(A) // 2)
    sys.exit()

index = 0
for n in range(N):
    if A[n] == 0:
        count += (sum(A[index: n]) // 2)
        index = n
count += sum(A[index:]) // 2
print(count)
### BUGGY CODE ###

import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
q=int(input())
ans=sum(a)
for _ in range(q):
  b,c=map(int,input().split())
  i=bisect.bisect_left(a,b)
  j=bisect.bisect_right(a,b)
  k=j-i
  ans=(c-b)*k+ans
  print(ans)
  a=sorted(a[:i]+a[j:]+[c]*k)

### FIXED CODE ###

import bisect
import collections
n=int(input())
a=sorted(list(map(int,input().split())))
q=int(input())
A=collections.Counter(a)
ans=sum(a)
for _ in range(q):
  b,c=map(int,input().split())
  k=A[b]
  ans=(c-b)*k+ans
  print(ans)
  del A[b]
  A[c]+=k
### BUGGY CODE ###

S = str(input())
S_len = len(S)

DP = [[0] * 13 for i in range(S_len)]

for i in reversed(range(S_len)):

    num = 10 ** (S_len - 1 - i) % 13

    if i == len(S) - 1:
        if S[i] != "?":
            DP[i][int(S[i]) % 13] = 1
        else:
            for j in range(10):
                DP[i][j] = 1

    else:

        if S[i] != "?":
            for j in range(13):
                if DP[i + 1][j] != 0:
                    DP[i][(j + int(S[i]) * num) % 13] = (DP[i][(j + int(S[i]) * (
                            10 ** (S_len - 1 - i))) % 13] + DP[i + 1][j]) % 1000000007
        else:
            for j in range(13):
                for k in range(10):
                    if DP[i + 1][j] != 0:
                        DP[i][(j + k * num) % 13] = (DP[i][
                                                         (j + k * num) % 13] +
                                                     DP[i + 1][j]) % 1000000007

print(DP[0][5])



### FIXED CODE ###

s=input()
l=len(s)
mod=10**9+7
dp=[[0 for j in range(13)] for i in range(l+1)]
dp[0][0]=1
for i in range(1,l+1):
  if s[i-1]=='?':
    for j in range(10):
      for k in range(13):
        dp[i][(k*10+j)%13]+=dp[i-1][k]%mod
  else:
    for k in range(13):
      dp[i][(k*10+int(s[i-1]))%13]+=dp[i-1][k]%mod
print(dp[-1][5]%mod)
### BUGGY CODE ###

import math
 
x = int(input())
f = True
if x == 2:
    print(2)
    exit()
 
while True:
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1

### FIXED CODE ###

import math
 
x = int(input())

if x == 2:
    print(2)
    exit()
 
while True:
    f = True
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())

    i = 0
    print(i, flush=True)
    s = str(input())
    if s == 'Vacant':
        sys.exit()
    else:
        temp = s

    pl=0
    pr=N
    while pl + 1 < pr:
        pc = (pl + pr) // 2
        print(pc, flush=True)

        s = str(input())
        if s == 'Vacant':
            sys.exit()
        elif s == 'Male':
            if (pc - pl) % 2 == 1 and temp == s:
                pr = pc
            else:
                temp = s
                pl = pc
        else:
            if (pc - pl) % 2 == 1 and temp == s:
                temp = s
                pr = pc
            else:
                temp = s
                pl = pc



resolve()

### FIXED CODE ###

N = int(input())


def query(i):
    print(i)
    s = input()
    if s == 'Vacant':
        exit()
    return s


root = query(0)


def is_ok(ind):
    # 左ならTrue
    response = query(ind)
    if ind % 2 == 1:
        return root == response
    else:
        return root != response


def bin_search_meguru():
    """
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng, okは,とり得る最小の値-1,とり得る最大の値+1
    """

    # 適当にいじる
    ng = -1  # ind=0が条件を満たすこともあるため
    ok = N  # ind=len(a)-1が条件を満たさないこともあるため

    # いじらない
    # okとngのどちらが大きいかわからないことを考慮
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return False


bin_search_meguru()
### BUGGY CODE ###

# B - Exactly N points
n=int(input())

if n==1:
    print(1)
    exit()
t=0
acc=[]
for i in range(1,n+1):
    t+=i
    acc.append(t)
max_v=-1
for i in range(len(acc)-1):
    if acc[i]<n<=acc[i+1]:
        max_v=i+2
        break
ans=[]
ans.append(max_v)
cur=max_v
vv=acc[i+1]
vv-=cur
s=max_v

while vv and s<n:
    cur-=1
    if vv>cur and s+cur<=n:
        vv-=cur
        ans.append(cur)
        s+=cur
    elif vv<cur:
        continue
    elif vv==cur:
        vv-=cur
        ans.append(cur)
        s+=cur
for a in ans:
    print(a)


### FIXED CODE ###

# B - Exactly N points
n=int(input())

if n==1:
    print(1)
    exit()
t=0
acc=[]
for i in range(1,n+1):
    t+=i
    acc.append(t)
max_v=-1
for i in range(len(acc)-1):
    if acc[i]<n<=acc[i+1]:
        max_v=i+2
        break
ans=[]
ans.append(max_v)
cur=max_v
vv=acc[i+1]
vv-=cur
s=max_v

while vv and s<n:
    cur-=1
    if vv>cur and s+cur<=n:
        vv-=cur
        ans.append(cur)
        s+=cur
    elif vv<cur:
        continue
    elif vv==cur:
        vv-=cur
        ans.append(cur)
        s+=cur
for a in ans:
    print(a)
### BUGGY CODE ###

n = int(input())
list = []
max = 0

for i in range(n):
    num = int(input())
    if num > max:
        max = num
    list.append(num)

max_index = [i for i,x in enumerate(list) if x == max]
#print(max_index)

list2 = [i for i in list if i != max]
#print(list2)
if list2 != []:
    second = sorted(list2)[-1]
else:
    second = 0
#print(second)

for i in range(n):
    if (i in max_index) & (len(max_index) == 1):
        print(second)
    else:
        print(max)


### FIXED CODE ###

n = int(input())
list = []
max = 0
second = 0
max_index = []

for i in range(n):
    num = int(input())
    if (num > max):
        max = num
    elif (num > second):
        second = num
    list.append(num)

counter = list.count(max)

for i,x in enumerate(list):
    if (x == max) & (counter == 1):
        print(second)
    else:
        print(max)
### BUGGY CODE ###

n, m, q = map(int,input().split())
t = [list(map(int,input().split())) for i in range(m)]
cond = [list(map(int,input().split())) for j in range(q)]
for i in range(q):
    cond1 = [(t[j][0]-cond[i][0],t[j][1]-cond[i][1]) for j in range(m)]
    cond2 = [1 if cond1[i][0] >= 0 and cond1[i][1] <= 0 else 0 for i in range(m)]
    print(sum(cond2))

### FIXED CODE ###

import numpy as np
import sys

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

I = sys.stdin.read().split()

L,R = np.array(I[:2*M], np.int32).reshape([2,-1], order='F')
p,q = np.array(I[2*M:], np.int32).reshape(2,-1, order='F')
d = np.zeros([N+1, N+1], np.int32)

d = np.zeros([1+N, 1+N], np.int32)
np.add.at(d, (N-L,R), 1)

d = np.add.accumulate(d, axis = 1)
d = np.add.accumulate(d)

ans = d[N-p,q]

for a in ans:
	print(a)
### BUGGY CODE ###

n = int(input())
l = []
for _ in range(n):
    s = list(input())
    s.sort()
    l.append("".join(s))
c = 0
for i, s in enumerate(l[:-1]):
    c += len([j for j in range(i + 1, n) if s == l[j]])
print(c)

### FIXED CODE ###

from collections import Counter
import numpy as np
n = int(input())
ll = []
ans = 0
for _ in range(n):
    c = list(input())
    c.sort()
    ll.append("".join(c))
ans = np.sum([np.arange(v).sum() for v in Counter(ll).values() if v > 1])
print(int(ans))
### BUGGY CODE ###

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

option = {(0, 0)}


def main():
    global option
    last_list = [0, 0, 0]
    N = int(input())
    for i in range(N):
        this_list = list(map(int, input().split()))
        add_option(this_list[0] - last_list[0], (this_list[1], this_list[2]))
        if (this_list[1], this_list[2]) not in option:
            print('No')
            return
        option = {(this_list[1], this_list[2])}
        last_list = this_list
    print('Yes')


def add_option(step, this_postion):
    global option
    xi, yi = this_postion
    for i in range(step):
        temp_option = set()
        for position in option:
            x, y = position
            diff = abs(x - xi) + abs(y - yi)
            rest = step - i
            if diff > rest:
                continue
            if x < 100000:
                temp_option.add((x + 1, y))
            if y < 100000:
                temp_option.add((x, y + 1))
            if x > 0:
                temp_option.add((x - 1, y))
            if y > 0:
                temp_option.add((x, y - 1))
        option = temp_option


main()


### FIXED CODE ###

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

judge = 'Yes'

N = int(input())
for i in range(N):
    t, x, y = map(int, input().split())
    if t < (x + y) or t % 2 != (x + y) % 2:
        judge = 'No'

print(judge)
### BUGGY CODE ###

x,b = map(int,input().split())
for i in range(x+1,b+1):
    x=x*i
if x>0:
    print("Positive")
elif x<0:
    print("Negative")
elif x==0:
    print("Zero")

### FIXED CODE ###

a,b = map(int,input().split())
if 0<a and a<=b:
    print("Positive")
elif a<=b and b<0:
    if (b-a+1)%2==0:
        print("Positive")
    else:
        print("Negative")
elif a<=0 and 0<=b:
    print("Zero")
### BUGGY CODE ###

import bisect

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

INF = float('inf')
for _ in range(q):
    x = int(input())
    if x > s[a-1]:
        sl = x - s[a-1]
        sr = INF
    elif x < s[0]:
        sl = INF
        sr = s[0] - x
    else:
        si = bisect.bisect_right(s, x)
        sl = x - s[si-1]
        sr = s[si] - x

    if x > t[b-1]:
        tl = x - t[b-1]
        tr = INF
    elif x < t[0]:
        tl = INF
        tr = t[0] - x
    else:
        ti = bisect.bisect_right(t, x)
        tl = x - t[ti-1]
        tr = t[ti] - x

    ans = min(max(sl, tl), max(sr, tr))

    ans = min(ans, sr*2+tl)
    ans = min(ans, sr+tl*2)
    ans = min(ans, sl*2+tr)
    ans = min(ans, sl+tr*2)

    print(ans)


### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

INF = float('inf')
for _ in range(q):
    x = int(input())
    if x > s[a-1]:
        sl = x - s[a-1]
        sr = INF
    elif x < s[0]:
        sl = INF
        sr = s[0] - x
    else:
        si = bisect.bisect_right(s, x)
        sl = x - s[si-1]
        sr = s[si] - x

    if x > t[b-1]:
        tl = x - t[b-1]
        tr = INF
    elif x < t[0]:
        tl = INF
        tr = t[0] - x
    else:
        ti = bisect.bisect_right(t, x)
        tl = x - t[ti-1]
        tr = t[ti] - x

    ans = min(max(sl, tl), max(sr, tr))

    ans = min(ans, sr*2+tl)
    ans = min(ans, sr+tl*2)
    ans = min(ans, sl*2+tr)
    ans = min(ans, sl+tr*2)

    print(ans)
### BUGGY CODE ###

def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[]*n for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)
    
    ans=[-1]*(n)
    goal=deque([0])
    while (-1 in ans):
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()
    


### FIXED CODE ###

def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()
### BUGGY CODE ###

N, K = [int(x) for x in input().split(" ")]
lst = [int(x) for x in input().split(" ")]

dic= {}
cnt = 0 
swap = 0

for i in range(1,N+1):
	dic["{}".format(i)] = 0

for i in range(0,N):
	dic["{}".format(lst[i])] += 1

sorted_dic = sorted(dic.items(), key = lambda x : x[1])
    
for i in range(0,N):
  swap += sorted_dic[i][1]
  if sorted_dic[i][1] != 0:
    cnt +=1
  if cnt >= len(set(lst))-K:
    break
      
print(swap)

### FIXED CODE ###

N, K = [int(x) for x in input().split(" ")]
lst = [int(x) for x in input().split(" ")]

dic= {}
cnt = 0 
swap = 0
prep = len(set(lst))-K

for i in range(1,N+1):
	dic["{}".format(i)] = 0

for i in range(0,N):
	dic["{}".format(lst[i])] += 1

sorted_dic = sorted(dic.items(), key = lambda x : x[1])
    
for i in range(0,N):
  swap += sorted_dic[i][1]
  if sorted_dic[i][1] != 0:
    cnt +=1
  if cnt >= prep:
    break
      
print(swap)
### BUGGY CODE ###

debug_mode=True
debug_mode=False
def dprint(x):
    if debug_mode: print(x)

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

score_k=1 # k学期までの評点
for i in range(k):
    score_k *= a[i]

prev_score = score_k
for i in range(k,n):
    dprint(score_k)
    score_k /= a[i-k]
    score_k *= a[i]
    if score_k > prev_score: print('Yes')
    else: print('No')
    prev_score = score_k



### FIXED CODE ###

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

for i in range(n-k):
    if a[i]<a[i+k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import itertools
import sys

N=int(input())
S=[int(input()) for _ in range(N)]
ans=0

if sum(S)%10!=0:
  print(sum(S))
  sys.exit()

i=N-1
while True:
  if ans!=0 or i==0:
    break
  for j in itertools.combinations(S,i):
    s=sum(j)
    if s%10!=0:
      ans=max(ans,s)

print(ans)

### FIXED CODE ###

import sys

N=int(input())
S=[int(input()) for _ in range(N)]
S.sort()
ans=sum(S)

if ans%10!=0:
  print(ans)
  sys.exit()
else:
  for i in range(N):
    if S[i]%10!=0:
      print(ans-S[i])
      sys.exit()
  else:
    print(0)
### BUGGY CODE ###

n = int(input())
ans = 0
for i in range(1, n):
    ans += i
print(ans)


### FIXED CODE ###

n = int(input())
ans = (n+1) * (n//2) - n
if n%2 == 1:
    ans += n//2 + 1
print(ans)
### BUGGY CODE ###

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

ans = 0

for i in range(N):
	for j in range(i+1,N):
		ans = (ans +  A[i]*A[j]) % (10**9+7)

print(ans)

### FIXED CODE ###

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

DIV = 10**9+7
ans = 0
Asum = sum(A)
Asum_sq = Asum**2

for i in range(N):
	ans += A[i]**2

res = (Asum_sq-ans)//2
print(res%DIV)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
for i in range(q):
    l, r = map(int, input().split())
    lr = s[l-1:r]
    ans = 0
    for j in range(len(lr)-1):
        if lr[j:j+2] == 'AC':
            ans += 1
    print(ans)

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
a = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        a[i+1] = 1
    if i > 0:
        a[i] += a[i-1]
a[n-1] += a[n-2]

for i in range(q):
    l, r = map(int, input().split())
    t = a[r-1]-a[l-1]
    print(t)
### BUGGY CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
def f(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
    
ans = 0
for a in A:
    for j in f(a):
        if j == a:
            if C[j] > 1:
                break
        else:
            if C[j] > 0:
                break
    else:
        ans += 1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import Counter

n = int(input())
A = sorted(map(int, input().split()))
U = 10**6
B = [0]*(U+1)
C = Counter(A)
ans = 0
for a in A:
  if B[a]:
    continue
  if C[a] == 1:
    ans += 1
  for j in range(a, U+1, a):
    B[j] = 1
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

r = A[-1]*F[0]

l = -1

while(r-l > 1):
    tmp = (l+r)//2
    k = 0
    for x, y in zip(A, F):
        k += max(0, x - (tmp // y))
    if k > K:
        l = tmp
    else:
        r = tmp
print(r)


### FIXED CODE ###

import sys
import bisect
import math
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

B = [(A[i]*F[i], F[i]) for i in range(N)]
B.sort(reverse=True)
L = 0
R = B[0][0]
if sum(A) <= K:
    print(0)
    exit(0)
while(1):
    ans = (L+R) // 2
    flag = True
    tmp = 0
    for i in range(N):
        tmp += math.ceil(max(B[i][0] - ans, 0) / B[i][1])
        if tmp > K:
            flag = False
            break
    if flag:
        R = ans
    else:
        L = ans
    if L == R or L+1 == R:
        print(R)
        break