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

# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-07
#

# Usage
#
"""
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import absolute_import

def read():
    """Read like as below.
    N A B
    t_1
    t_n
    """
    line_1 = input().split(" ")
    num_of_class = int(line_1[0])
    blocked_class = line_1[1:2]
    blocked_class = range(int(line_1[1]), int(line_1[2]))

    following_class = [int(input()) for _ in range(num_of_class)]

    return following_class, blocked_class


def check_available_class(following_class, blocked_class):
    """Check how many class you can attend.
    >>> check_available_class([4,3,6,9,1], [5,6,7,8])
    4
    >>> check_available_class([5,6,7,8,9], [4,5,6,7,8])
    1
    """
    return len(set(following_class).difference(set(blocked_class)))


if __name__ == "__main__":
    f, b = read()
    print(check_available_class(f,b))


### FIXED CODE ###

# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-07
#

# Usage
#
"""

def read():
    """Read like as below.
    N A B
    t_1
    t_n
    """
    line_1 = input().split(" ")
    num_of_class = int(line_1[0])
    blocked_class = line_1[1:2]
    blocked_class = range(int(line_1[1]), int(line_1[2]))

    following_class = {int(input()) for _ in range(num_of_class)}

    return following_class, blocked_class


def check_available_class(following_class, blocked_class):
    """Check how many class you can attend.
    >>> check_available_class([4,3,6,9,1], [5,6,7,8])
    4
    >>> check_available_class([5,6,7,8,9], [4,5,6,7,8])
    1
    """
    # return len(set(following_class).difference(blocked_class))
    attendable = [i for i in following_class if not i in blocked_class]
    return len(attendable)

if __name__ == "__main__":
    import doctest
    doctest.testmod()
    f, b = read()
    print(check_available_class(f,b))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n=int(input())
N=[str(i) for i in range(1,n+1)]

count=0
for a in N:
  for b in N:
    if a[0]==b[-1] and a[-1]==b[0]:
      count+=1

print(count)


### FIXED CODE ###

N=int(input())
d=[[0]*10 for i in range(10)]
#10x10のグリッドを作る

#9x9パターンに分類されるため、各数字をグリッドに振り分ける
for i in range(1,N+1):
  n=str(i)
  d[int(n[0])][int(n[-1])]+=1

#組み合わせの数は[Aの数]x[Bの数] 先頭か語尾に0が付くものはカウントしない
r=0
for i in range(9):
  for j in range(9):
    r+=d[i+1][j+1]*d[j+1][i+1]
print(r)
### BUGGY CODE ###

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


N = int(input())
memo = [[[-1]*(N+1) for _ in range(N+1)] for _ in range(N+1)]

def dp(a, b, c):
    if a == b == c == 0: return 0
    if memo[a][b][c] != -1:
        return memo[a][b][c]
    
    res = N
    if a > 0: res += a*dp(a-1, b, c)
    if b > 0: res += b*dp(a+1, b-1, c)
    if c > 0: res += c*dp(a, b+1, c-1)
    res /= a+b+c
    
    memo[a][b][c] = res
    return res

def main():
    A = list(map(int, input().split()))
    
    count = Counter(A)
    for i in range(1, 4):
        if not i in count: count[i] = 0
    x, y, z = count[1], count[2], count[3]

    
    ans = dp(x, y, z)
    
    print(ans)
        

    
if __name__ == "__main__":
    main()



### FIXED CODE ###

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


N = int(input())
memo = [[[-1]*(N+1) for _ in range(N+1)] for _ in range(N+1)]

def dp(a, b, c):
    if a == b == c == 0: return 0
    if memo[a][b][c] != -1:
        return memo[a][b][c]
    
    res = N
    if a > 0: res += a*dp(a-1, b, c)
    if b > 0: res += b*dp(a+1, b-1, c)
    if c > 0: res += c*dp(a, b+1, c-1)
    res /= a+b+c
    
    memo[a][b][c] = res
    return res

def main():
    A = list(map(int, input().split()))
    
    count = Counter(A)
    for i in range(1, 4):
        if not i in count: count[i] = 0
    x, y, z = count[1], count[2], count[3]

    
    ans = dp(x, y, z)
    
    print(ans)
        

    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

class Binary_Indexed_Tree():
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get(self, i):
        return self.sum_range(i, i)

    def sum(self, i):
        i += 1
        ret = 0
        while i:
            ret += self.data[i]
            i &= i-1
        return ret

    def sum_range(self, l, r):
        return self.sum(r)-self.sum(l-1)

    def lower_bound(self, w):
        if w<=0:
            return 0
        i = 0
        k = 1<<(self.n.bit_length())
        while k:
            if i+k <= self.n and self.data[i+k] < w:
                w -= self.data[i+k]
                i += k
            k >>= 1
        return i

n = int(input())
a = list(map(lambda x: int(x)-1, input()))

if 1 in a:
    BIT = Binary_Indexed_Tree(n+1)
    for i, ai in enumerate(a):
        if ai == 1:
            BIT.add(i, 1)
        while True:
            s = BIT.sum(i)
            if s == 0:
                break
            i = BIT.lower_bound(s)
            s = BIT.sum(i)
            if s > 1:
                j = BIT.lower_bound(s-1)
                for k in range(j+1, i):
                    BIT.add(k,1)
                BIT.add(j, -1)
                i = j
            else:
                for k in range(i):
                    BIT.add(k,1)
                break
    ans = BIT.get(0)
else:
    BIT = Binary_Indexed_Tree(n+1)
    a = [int(i==2) for i in a]
    for i, ai in enumerate(a):
        if ai == 1:
            BIT.add(i, 1)
        while True:
            s = BIT.sum(i)
            if s == 0:
                break
            i = BIT.lower_bound(s)
            s = BIT.sum(i)
            if s > 1:
                j = BIT.lower_bound(s-1)
                for k in range(j+1, i):
                    BIT.add(k,1)
                BIT.add(j, -1)
                i = j
            else:
                for k in range(i):
                    BIT.add(k,1)
                break
    ans = 2*BIT.get(0)

print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(lambda x: int(x)-1, input()))

cnt = [0]
for i in range(1,n+1):
    x = 0
    while i%2==0:
        x += 1
        i //=2
    cnt.append(cnt[-1]+x)

def comb(k):
    left = cnt[n-1]
    right = cnt[k]+cnt[n-1-k]
    return left-right == 0

f = 1 in a
if f:
    a = [int(i==1) for i in a]
else:
    a = [int(i==2) for i in a]

ans = 0
for i in range(n):
    if comb(i):
        ans += a[i]

ans %= 2
if not f:
    ans *= 2

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

N, M, L = map(int,input().split(' '))
Ms=[]
inf = 10**11
for i in range(N+1):
    #for j in range(N):
    Ms.append([inf]*(N+1) )
#print(d)
#print(d[1][1])
for i in range(M):
    a,b,c = map(int,input().split(' '))
    #print(a,b,c)
    Ms[a][b] = c
    Ms[b][a] = c
    #print(Ms)
Q = int(input())

def warshall_floyd(Ms):
    for k in range(1,len(Ms)):
        for i in range(1,len(Ms)):
            for j in range(1,len(Ms)):
                Ms[i][j]=min(Ms[i][j],Ms[i][k]+Ms[k][j])
    return Ms

Ms = warshall_floyd(Ms)
#print(Ms)
#print("Ms",Ms[3][2],Ms[2][3])
Ls = Ms.copy()
for i in range(N+1):
    for j in range(N+1):
        if Ls[i][j] <= L:
            Ls[i][j] = 1
        else:
            Ls[i][j]=inf
#print("Ls",Ls[3][2])
Ls = warshall_floyd(Ls)
#print(Ls)
for i in range(Q):
    s,t = map(int,input().split(' '))
    if Ls[s][t] == inf:
        print(-1)
    else:
        print(Ls[s][t]-1)



### FIXED CODE ###

N, M, L = map(int,input().split(' '))
Ms=[]
inf = 10**11
for i in range(N+1):
    #for j in range(N):
    Ms.append([inf]*(N+1) )
#print(d)
#print(d[1][1])
for i in range(M):
    a,b,c = map(int,input().split(' '))
    #print(a,b,c)
    Ms[a][b] = c
    Ms[b][a] = c
    #print(Ms)
Q = int(input())

def warshall_floyd(Ms):
    for k in range(1,len(Ms)):
        for i in range(1,len(Ms)):
            for j in range(1,len(Ms)):
                Ms[i][j]=min(Ms[i][j],Ms[i][k]+Ms[k][j])
    return Ms

Ms = warshall_floyd(Ms)
#print(Ms)
#print("Ms",Ms[3][2],Ms[2][3])
#Ls = Ms.copy()
Ls = Ms
for i in range(N+1):
    for j in range(N+1):
        if Ls[i][j] <= L:
            Ls[i][j] = 1
        else:
            Ls[i][j]=inf
#print("Ls",Ls[3][2])
Ls = warshall_floyd(Ls)
#print(Ls)
for i in range(Q):
    s,t = map(int,input().split(' '))
    if Ls[s][t] == inf:
        print(-1)
    else:
        print(Ls[s][t]-1)
### BUGGY CODE ###

n,q = map(int, raw_input().split())
ls = [set([i]) for i in range(n)]
for i in range(q):
	com,x,y = map(int, raw_input().split())
	if com == 0: # unite
		ls[x] = ls[x]|ls[y]
		for i in list(ls[x]):
			ls[i] = ls[x]
	else: # same
		print 1 if y in ls[x] and x in ls[y] else 0
		

### FIXED CODE ###

class UnionFind:
    def __init__(self, size):
        self.rank = [0] * size
        self.par = range(size)
        self.g_num = size

    def find(self, x):
        if x == self.par[x]: return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return

        self.g_num -= 1
        if (self.rank[x] > self.rank[y]):
            self.par[y] = x
        else:
            self.par[x] = y
            if (self.rank[x] == self.rank[y]): self.rank[y] += 1

    def group_num(self):
        return self.g_num

n, q = map(int, raw_input().split())
uf = UnionFind(n)
for i in xrange(q):
    c, x, y = map(int, raw_input().split())
    if c == 0:
        uf.unite(x, y)
    else:
        print int(uf.same(x, y))
### BUGGY CODE ###

w, h = map(int, raw_input().split())
p = []
q = []
for i in range(w):
    p.append(int(raw_input()))
for i in range(h):
    q.append(int(raw_input()))

wl = w
hl = h

cost = 0

p.sort()
q.sort()

p.append(10 ** 8 + 1)
q.append(10 ** 8 + 1)

while(wl + hl > 0):
    if p[0] < q[0]:
        cost += (hl + 1) * p[0]
        p.pop(0)
        wl -= 1
    else:
        cost += (wl + 1) * q[0]
        q.pop(0)
        hl -= 1

print cost


### FIXED CODE ###

w, h = map(int, raw_input().split())
p = []
q = []
for i in xrange(w):
    p.append(int(raw_input()))
for i in xrange(h):
    q.append(int(raw_input()))

wl = w
hl = h

cost = 0

p.sort()
q.sort()

p.append(10 ** 8 + 1)
q.append(10 ** 8 + 1)

pc = 0
qc = 0

while(wl + hl - pc - qc> 0):
    if p[pc] < q[qc]:
        cost += (hl - qc + 1) * p[pc]
        pc += 1
    else:
        cost += (wl - pc + 1) * q[qc]
        qc += 1

print cost
### BUGGY CODE ###

from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter()
    count.update(A)
    sum_ = sum([i*(i-1)/2 for i in count.values()])

    for i in range(len(A)):
        remain = A[:i] + A[i+1:]
        took = A[i]
        took_count = count[took]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

S = input()
l = len(S)

count = 0
for i in range(l):
  for j in range(l):
    if i < (j-3):
      new_s = int(S[i:j+1])
      if new_s % 2019 == 0:
        count += 1
      else:
        continue
    else:
      continue
print(count)

### FIXED CODE ###

from collections import Counter
S=input()[::-1]
mod=2019

X = [0]
for i, s in enumerate(S):
  X.append((X[-1] + int(s)*pow(10, i, mod)) % mod)

C = Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)
### BUGGY CODE ###

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

import collections
count = collections.Counter(a)

import math
def p(n, r):
    return math.factorial(n) // math.factorial(n - r)
def c(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# print(count)
s = 0
for i in count.keys():
    s += c(count[i], 2)
# print(s)

for i in range(n):
    ans = s - c(count[a[i]], 2) + c(count[a[i]] - 1, 2)
    print(ans)

### FIXED CODE ###

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

import collections
count = collections.Counter(a)

import math
def p(n, r):
    return math.factorial(n) // math.factorial(n - r)
def c(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# print(count)
s = 0
cmb = {}
for i in count.keys():
    cmb[i] = (c(count[i], 2),c(count[i] - 1, 2))
    s += cmb[i][0]
# print(s)
# print(cmb)

for i in range(n):
    ans = s - cmb[a[i]][0] + cmb[a[i]][1]
    print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
P = [int(i) for i in input().split()]
max_p = 0
for n in range(N-K+1):
    temp = 0
    for k in range(K):
        temp += (P[n+k] + 1) / 2
    max_p = max(max_p,temp)
print(max_p)

### FIXED CODE ###

N,K = map(int,input().split())
P = [(int(i)+1)/2 for i in input().split()]
max_p = 0
for n in range(N-K+1):
    if n == 0:
        temp = sum(P[0:K])
    else:
        temp -= P[n-1]
        temp += P[n+K-1]
    max_p = max(max_p,temp)
print(max_p)
### BUGGY CODE ###

import collections
N = int(input())
s = [""]*N
S = []
for i in range(N):
    # s[i] = input()
    S.append(collections.Counter(input()))
# print(s)
# print(S)
count = 0
for i in range(N-1):
    for j in range(i+1,N):
        if S[i] == S[j]:
            count+=1
print(count)

### FIXED CODE ###

import collections
import math

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

N = int(input())
s = [""]*N
S = []
for i in range(N):
    s[i] = input()
    test = list(s[i])
    test.sort()
    S.append("".join(test))
ana = sorted(collections.Counter(S).values())
count = 0
for i in ana:
    if i >= 2:
        count += combinations_count(i,2)
print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
INF = -10**10
queue = [-1]


def insert(queue, key):
    h = len(queue) - 1
    queue.append(INF)
    heap_increase_key(queue, h + 1, key)


def heap_increase_key(queue, i, key):
    if key < queue[i]:
        raise ValueError('The new key is smaller than the present key')
    queue[i] = key
    while i > 1 and queue[i // 2] < queue[i]:
        queue[i], queue[i // 2] = queue[i // 2], queue[i]
        i = i // 2


def extract_max(queue):
    h = len(queue) - 1
    if h < 1:
        raise TypeError('Heap underflowed')
    max = queue[1]
    queue[1] = queue.pop()
    max_heapify(queue, 1)

    return max


def max_heapify(queue, i):
    h = len(queue) - 1
    l = 2 * i
    r = 2 * i + 1
    if l <= h and queue[l] > queue[i]:
        largest = l
    else:
        largest = i
    if r <= h and queue[r] > queue[largest]:
        largest = r

    if largest != i:
        queue[i], queue[largest] = queue[largest], queue[i]
        max_heapify(queue, largest)


if __name__ == '__main__':
    import sys
    ords = [line.strip().split() for line in sys.stdin]

    for ord in ords:
        if len(ord) > 1:
            ord, key = ord[0], int(ord[1])
        else:
            ord = ord[0]
        if ord[0] == 'i':
            insert(queue, key)
        elif len(ord) == 7:
            print(extract_max(queue))
        else:
            break



### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from heapq import *

q = []
while True:
    cmd = sys.stdin.readline().split()
    if cmd[0] == 'end':
        break
    elif cmd[0] == 'insert':
        heappush(q, -int(cmd[1]))
    else:
        print(-heappop(q))
### BUGGY CODE ###

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

from collections import defaultdict
from queue import deque

def main():
  n = int(input())
  graph = defaultdict(list)
  
  def is_bt():
    def bfs():
      colors = [-1] * len(graph)
      visited = [False] * len(graph)
      dq = deque()
      dq.append((0, 0))
      while dq:
        inode, color = dq.popleft()
        if visited[inode]:
          continue
        visited[inode] = True
        for ichild in graph[inode]:
          if colors[ichild] == -1:
            colors[ichild] = abs(color-1)
          else:
            if colors[ichild] != abs(color-1):
              return False
          if not visited[ichild]:
            dq.append((ichild, abs(color-1)))
      return True
    return bfs()
  
  def wf(edges):
    dp = edges
    for k in range(len(graph)):
      for i in range(len(graph)):
        for j in range(len(graph)):
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
    return dp
  
  edges = [[n+1] * n for _ in range(n)]  
  for i in range(n):
    for j, c in enumerate(input().strip()):
      if c == '1':
        graph[i].append(j)
        edges[i][j] = 1
    edges[i][i] = 0
    
  if not is_bt():
    print(-1)
    return
  print(max([max(x) for x in wf(edges)]) + 1)
  
if __name__=='__main__':
  main()



### FIXED CODE ###

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

from collections import defaultdict
from queue import deque

def main():
  n = int(input())
  graph = defaultdict(list)
  
  def is_bt():
    def bfs():
      colors = [-1] * len(graph)
      dq = deque()
      dq.append(0)
      colors[0] = 0
      while dq:
        inode = dq.popleft()
        for ichild in graph[inode]:
          if colors[ichild] == -1:
            colors[ichild] = abs(colors[inode]-1)
            dq.append(ichild)
          else:
            if colors[ichild] == colors[inode]:
              return False
      return True
    return bfs()
  
  def wf(edges):
    dp = edges
    for k in range(len(graph)):
      for i in range(len(graph)):
        for j in range(len(graph)):
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
    return dp
  
  edges = [[n+1] * n for _ in range(n)]  
  for i in range(n):
    for j, c in enumerate(input().strip()):
      if c == '1':
        graph[i].append(j)
        edges[i][j] = 1
    edges[i][i] = 0
  graph = dict(graph)
    
  if not is_bt():
    print(-1)
    return
  print(max([max(x) for x in wf(edges)]) + 1)
  
if __name__=='__main__':
  main()
### BUGGY CODE ###

from collections import deque
import sys

N, M = map(int, input().split())
adj = [[] for _ in range(N + 1)]
for _ in range(M):
    L, R, D = map(int, input().split())
    adj[L].append((R, D))
    adj[R].append((L, -D))
seen = [0] * (N + 1)


def dfs(adj, seen, start):
    inf = 10 ** 10
    que = deque()
    que.append(start)
    x = [inf] * (N + 1)
    x[start] = 0
    while que:
        v = que.pop()
        seen[v] = 1
        for u, d in adj[v]:
            if seen[u] == 0:
                que.append(u)
                if x[u] == inf:
                    x[u] = x[v] + d
                else:
                    if x[u] != x[v] + d:
                        return 0, seen
    return 1, seen


for i in range(1, N + 1):
    if seen[i] == 0:
        ok, seen = dfs(adj, seen, i)
        if not ok:
            print('No')
            sys.exit()

print('Yes')



### FIXED CODE ###

from collections import deque
import sys
import time
input = sys.stdin.readline


def main():
    t1 = time.time()
    N, M = map(int, input().split())
    adj = [[] for _ in range(N + 1)]
    for _ in range(M):
        L, R, D = map(int, input().split())
        adj[L].append((R, D))
        adj[R].append((L, -D))
    seen = [0] * (N + 1)

    def dfs(adj, seen, start):
        inf = 10 ** 10
        que = deque()
        que.append(start)
        x = [inf] * (N + 1)
        x[start] = 0
        while que:
            v = que.pop()
            seen[v] = 1
            for u, d in adj[v]:
                if seen[u] == 0:
                    que.append(u)
                    if x[u] == inf:
                        x[u] = x[v] + d
                    else:
                        if x[u] != x[v] + d:
                            print('No')
                            sys.exit()
            t2 = time.time()
            if t2 - t1 > 1.8:
                print('Yes')
                sys.exit()
        return seen

    for i in range(1, N + 1):
        if seen[i] == 0:
            seen = dfs(adj, seen, i)

    print('Yes')


if __name__ == '__main__':
    main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import copy
from operator import itemgetter

[N, M] = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
BC = []
for m in range(M):
    BC.append([int(i) for i in input().split()])

# Aをソートする
A.sort()

# BCをCが大きい順にソートする
sorted_BC = sorted(BC, key=itemgetter(1, 0), reverse=True)
#sorted_BC = sorted(BC, key=lambda x:(x[1]), reverse=True)

for m in range(M):
    [B, C] = sorted_BC[m]
    # もしAの最小値がCを超えていたらもうやる意味ないので終了
    if A[0] > C:
        break

    # 小さいほうからB枚のカードをCに変える
    # ただし変えるのは元の数字より大きい時だけ
    for i in range(B):
        if A[i] < C:
            A[i] = C
    A.sort()


print (sum(A))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import copy
from operator import itemgetter

[N, M] = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
BC = []
for m in range(M):
    BC.append([int(i) for i in input().split()])

# Aをソートする
A.sort()

# BCをCが大きい順にソートする
sorted_BC = sorted(BC, key=itemgetter(1, 0), reverse=True)

new_A = []
for [B, C] in sorted_BC:
    # もしAの最小値がCを超えていたらもうやる意味ないので終了
    if A[0] > C:
        break

    # 小さいほうからB枚のカードをCに変える
    # ただし変えるのは元の数字より大きい時だけ
    I = 0
    for i in range(B):
        I = i
        if len(A) <= i:
            I -=1
            break
        if A[i] > C:
            I -=1
            break
        new_A.append(C)
        #print(new_A)

    # 変えた分はリストから除外する
    #print(A)
    #print(I)
    del A[:I+1]
    if len(A) == 0:
        break

    #print(A)

if len(A) != 0:
    new_A.extend(A)

print (sum(new_A))
### BUGGY CODE ###

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

result = 0
for b in range(60):
  a = [(e >> b) & 1 for e in A]
  bs = [0] * N
  bs[N - 1] = a[N - 1]
  for i in range(N - 2, -1, -1):
    bs[i] = bs[i + 1] + a[i]

  t = 0
  for i in range(N - 1):
    if a[i] == 0:
      t += bs[i + 1]
    else:
      t += (N - (i + 1)) - bs[i + 1]
  result = (result + t * (1 << b)) % 1000000007
print(result)


### FIXED CODE ###

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

    r = list(range(N - 2, -1, -1))
    result = 0
    for b in range(60):
        t = 0
        bs = (A[N - 1] >> b) & 1
        for i in r:
            if (A[i] >> b) & 1 == 0:
                t += bs
            else:
                t += (N - (i + 1)) - bs
                bs += 1
        result = (result + t * (1 << b)) % 1000000007
    print(result)
main()
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    # print(bc[i][0])
    # index = a.index(bc[i][0])
    index = [j for j, x in enumerate(a) if x == bc[i][0]]
    # print(index)
    for k in index:
        a[k] = bc[i][1]
    # a[index] = bc[i][1]
    print(sum(a))

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

cnt = [0 for i in range(0, 10**5 + 1)]
for i in a:
    cnt[i] += 1

total = sum(a)

for j in range(q):
    b = bc[j][0]
    c = bc[j][1]
    cnt[c] += cnt[b]
    total += (c-b)*cnt[b]
    cnt[b] = 0
    print(total)
### BUGGY CODE ###

a,b,N = map(int,input().split())
list =[]
for x in range(N+1):
    list.append(int(a*x/b)-a*int(x/b))
print(max(list))


### FIXED CODE ###

a,b,N = map(int,input().split())
x =b-1
if x<N:
        print(int(a*x/b)-a*int(x/b))
else:
    x=N
    print(int(a*x/b)-a*int(x/b))