Harryxun/stf_run huggingface dataset:
import numpy as np
def fun(x):
    return np.floor(A*x/B)-A*np.floor(x/B)

A, B, N = map(int,input().split())
x = np.arange(0, B, 1)
print(fun(x))
print(int(max(fun(x))))


### FIXED CODE ###

import math
def fun(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

A, B, N = map(int,input().split())
x = min(B-1, N)
print(int(fun(A, B, x)))
#!/usr/bin/env python2
# coding: utf-8

def casar(s, n):
  d = {}
  for c in (65, 97):
    for i in range(26):
      d[chr(i+c)] = chr((i+n) % 26 + c)

  return "".join([d.get(c, c) for c in s])
  

try:
  while True:
    encrypttxt = raw_input()
    for i in range(26):
      t = casar(encrypttxt, i)
      if  "the" in t or "this" in t or "that" in t:
        print t

except EOFError:
  break

### FIXED CODE ###

#!/usr/bin/env python2
# coding: utf-8

def caesar(s, n):
    d = {}
    for c in (65, 97):
        for i in range(26):
            d[chr(i+c)] = chr((i+n) % 26 + c)

    return "".join([d.get(c, c) for c in s])


while True:
    try:
        encrypt_txt = raw_input()
    except EOFError:
        break

    for i in range(26):
        t = caesar(encrypt_txt, i)
        if  "the" in t or "this" in t or "that" in t:
            print t
            break
from collections import deque
 
S = deque(input())
Q = int(input())
 
Q_list = [list(map(str, input().split())) for i in range(Q)]

rev = False

for i in range(Q):
  if int(Q_list[i][0]) == 1:
    rev = not rev
  
  else:
    F = Q_list[i][1]
    C = Q_list[i][2]
    
    if rev ^ (int(F) == 1): # 排他的論理和片方真片方ぎの時真になる
      S.appendleft(C)
    else:
      S.append(C)
      
if rev:
  S = S[::-1]
  
print(''.join(S))

### FIXED CODE ###

from collections import deque
 
S = deque(input())
Q = int(input())
 
Q_list = [list(map(str, input().split())) for i in range(Q)]
 
rev = False
 
for i in range(Q):
  if int(Q_list[i][0]) == 1:
    rev = not rev
  
  else:
    F = Q_list[i][1]
    C = Q_list[i][2]
    
    if rev ^ (int(F) == 1): # 排他的論理和片方真片方ぎの時真になる
      S.appendleft(C)
    else:
      S.append(C)
      
if rev:
  S.reverse()
  
print(''.join(S))
a,b,c,d=map(int,input().split())

for i in range(2**3):
  e=['+','+','+']
  for j in range(len(e)):
    if (i<<j)&1:
      e[j]='-'
  if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
    print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
	break

### FIXED CODE ###

a,b,c,d = input()
for i in range(2**3):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break
import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
b = np.abs(a)
b.sort(reverse = True)
b_k = b[k-1] 
a_new = [a[i] for i in a if np.abs(a)[i] >= b_k]
 
comb = itertools.combinations(a_new,k)  
l = [list(_) for _ in comb]  
A = (functools.reduce(operator.mul,l[_]) for _ in range(len(l)))
l_max = max(A)
waru = 10**9 + 7
print(l_max % waru)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
N, M = map(int, input().split())

to = [[] for i in range(100010)]

for i in range(M):
    a, b = map(int, input().split())
    to[a].append(b)
    to[b].append(a)

dist = [0] * (N+1)
q = [1]

#print(to[:4])

dist = [0] * N
pre = [0] * N

while len(q) != 0:
    a = q.pop(0)
    for i in to[a]:
        if dist[i-1] == 0:
            dist[i-1] = dist[a-1] + 1
            pre[i-1] = a
            q.append(i)
    print(q)

print("Yes")
for i in range(1, N):
    print(pre[i])

### FIXED CODE ###

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

to = [[] for i in range(100010)]

for i in range(M):
    a, b = map(int, input().split())
    to[a].append(b)
    to[b].append(a)

dist = [0] * (N+1)
q = [1]
dist[0] = -1
#print(to[:4])

dist = [0] * N
pre = [0] * N

while len(q) != 0:
    a = q.pop(0)
    for i in to[a]:
        if dist[i-1] == 0:
            dist[i-1] = dist[a-1] + 1
            pre[i-1] = a
            q.append(i)
    #print(q)

print("Yes")
for i in range(1, N):
    print(pre[i])
H, N=map(int, input().split())
List=list(map(int,input().split()))
a = 0:
for j in range(N):
  a = a + List[j]

if a >= H:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

H, N=map(int, input().split())
List=list(map(int,input().split()))
a = 0
for j in range(N):
  a = a + List[j]

if a >= H:
  print("Yes")
else:
  print("No")
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
dp = [0]*(N*2+1)
dp[1] = 1
dp[2] = -1
mod = 998244353
LR = [list(mapint()) for _ in range(K)]
for i in range(1, N+1):
    dp[i] = (dp[i]+dp[i-1])%mod
    for l, r in LR:
        dp[i+l] = (dp[i+l]+dp[i])%mod
        dp[i+r+1] = (dp[i+r+1]-dp[i])%mod

print(dp[N])
    

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
mod = 998244353
dp = [0]*(N+1)
dp[1] = 1

Ks = [list(mapint()) for _ in range(K)]
Ks.sort()

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sums(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

bit = Bit(N)
bit.add(1, 1)

for i in range(2, N+1):
    for l, r in Ks:
        if i-l<0:
            break
        dp[i] += bit.sums(i-l) - bit.sums(max(0, i-r-1))
        dp[i] %= mod
    bit.add(i, dp[i])

print(dp[-1])
a, b = map(int, input().split())
if a + b < 10:
  print(a + b):
else:
  print("error")

### FIXED CODE ###

a, b = map(int, input().split())
if a + b < 10:
  print(a + b)
else:
  print("error")
a, b, x = map(int, input().split())
print(b//x - (a-1)//x)

### FIXED CODE ###

a, b, c = map(str, input().split())
B = b[0]
print("A{}C".format(B))
def main:
  s=0
  N=int(input())
  for i in range(1,N+1):
    if (len(str(i)))%2!=0:
      s+=1
  print(s)
main()

### FIXED CODE ###

s=0
N=int(input())
for i in range(1,N+1):
  if (len(str(i)))%2!=0:
    s+=1
print(s)
s = list(input())
def move_children(RL, li):
    newli = li.copy()
    for n, rl in enumerate(RL):
        if rl == "R":
            newli[n]-=li[n]
            newli[n+1]+=li[n]
        elif rl=="L":
            newli[n]-=li[n]
            newli[n-1]+=li[n]
    return newli
pre = [1 for i in range(len(s))]

for f in range(10**5):
    counter+=1
    nextli=move_children(s,pre)

print(nextli)

### FIXED CODE ###

s = list(input())
output = [0 for i in s]
ruiseki = 0
for p in range(len(s)):
    if s[p] == "R":
        if s[p+1] == "R":
            ruiseki+=1
        else:
            ruiseki+=1
            output[p] += ruiseki//2 + ruiseki%2
            output[p+1] += ruiseki//2
            ruiseki=0
    
ruiseki = 0
for q in range(len(s)-1, -1, -1):
    if s[q] == "L":
        if s[q-1]=="L":
            ruiseki+=1
        else:
            ruiseki+=1
            output[q] += ruiseki//2 + ruiseki%2
            output[q-1] += ruiseki//2
            ruiseki=0
print(" ".join(map(str,output)))
N, K = map(int,input().split())
if(N%K == 0)
  print(0)
else:
  print(1)

### FIXED CODE ###

N, K = map(int,input().split())
if(N%K == 0):
  print(0)
else:
  print(1)
A, B = map(int, input().split())
K = 5
G = [['.' for j in range(2 * K)] for i in range(K)] + [['#' for j in range(2 * K)] for i in range(K)]
x = 0
while B > 1:
  for y in range(min(K, B - 1)):
    G[x][x % 2 + 2 * y] = '#'
    B -= 1
  x += 1
x = 2 * K - 1
while A > 1:
  for y in range(min(K, A - 1)):
    G[x][x % 2 + 2 * y] = '.'
    A -= 1
  x -= 1
print(2 * K, 2 * K)
for i in range(2 * K):
  print(''.join(G[i]))

### FIXED CODE ###

A, B = map(int, input().split())
K = 50
G = [['.' for j in range(2 * K)] for i in range(K)] + [['#' for j in range(2 * K)] for i in range(K)]
x = 0
while B > 1:
  for y in range(min(K, B - 1)):
    G[x][x % 2 + 2 * y] = '#'
    B -= 1
  x += 2
x = 2 * K - 1
while A > 1:
  for y in range(min(K, A - 1)):
    G[x][x % 2 + 2 * y] = '.'
    A -= 1
  x -= 2
print(2 * K, 2 * K)
for i in range(2 * K):
  print(''.join(G[i]))
data = input().split()
A = int(data[0])
B = int(data[2])
if op == '+':
	S =  A + B
else:
	S = A - B
print(S)


### FIXED CODE ###

data = input().split()
A = int(data[0])
B = int(data[2])
if data[1] == '+':
	S =  A + B
else:
	S = A - B
print(S)
n, q = map(int, input().split())
g = [list() for i in range(n)]
node = [0] * n

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

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

def dfs(v, p=-1):
    for u in g[v]:
        if u == p: continue
        node[u] += node[v]
        dfs(u, v)

dfs(0)
print(*node)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
g = [list() for i in range(n)]
node = [0] * n

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

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

def dfs(v, p=-1):
    for u in g[v]:
        if u == p: continue
        node[u] += node[v]
        dfs(u, v)

dfs(0)
print(*node)
str = input()
num = list(map(int,str.split(' ')))
if (num[0]%2)and(num[1]%2)and(num[2])==0:
	print(0)
else:
	num.sort()
        print(num[0]*num[1])


### FIXED CODE ###

str = input()
num = list(map(int,str.split(' ')))
if ((num[0]%2)and(num[1]%2)and(num[2]%2))==0:
	print(0)
else:
	num.sort()
	print(num[0]*num[1])
N=int(input())
A={}
for _ in range(N):
    a=int(input())
    if a not in A:
        A.append(a)
    else:
        A.remove(a)
print(len(A))

### FIXED CODE ###

N=int(input())
A=set()
for _ in range(N):
    a=int(input())
    if a not in A:
        A.add(a)
    else:
        A.remove(a)
print(len(A))
n = int(input())
d = list(map(int, input().split()))

for i in range(max(d)+1):
	x.append(d.count(i))
ans = 1
if d[0] == 0 and x[0] == 1:
	for i in range(1, len(x)):
		ans = ans * (x[i]**x[i+1])
else:
	ans = 0

print(ans%998244353)

### FIXED CODE ###

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

dd = sorted(d)
c = []
j = 0
for i in range(max(d)+1):
	tmp = 0
	while dd[j] == i:
		tmp += 1
		j += 1
		if j == n:
			break
	c.append(tmp)

ans = 1
if d[0] == 0 and d.count(0) == 1 and c.count(0) == 0:
	for i in range(1, max(d)):
		ans = ans * (c[i]**c[i+1])
else:
	ans = 0

print(ans%998244353)
from array import array

def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    n, a = reads()
    x = reads()
    s = sum(x)
    dp = [[array('I', [0]*3500) for j in range(n+1)] for i in range(n+1)]
    dp[0][0][0] = 1
    for i in range(n):
        for j in range(n):
            for k in range(s):
                dp[i][j+1][k] += dp[i][j][k]
                dp[i+1][j+1][k+x[j]] += dp[i][j][k]
    r = 0
    for j in range(1, n+1):
        r += dp[j][n][j*a]
    print(r)

main()


### FIXED CODE ###

def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    n, a = reads()
    x = reads()
    s = sum(x)
    dp = [[[0]*3500 for j in range(n+1)] for i in range(n+1)]
    dp[0][0][0] = 1
    for i in range(n):
        for j in range(n):
            for k in range(s):
                dp[i][j+1][k] += dp[i][j][k]
                dp[i+1][j+1][k+x[j]] += dp[i][j][k]
    r = 0
    for j in range(1, n+1):
        r += dp[j][n][j*a]
    print(r)

main()
n,m,o=input().split()

if n != "7" and m != "7" and o !="7":
    print("No")
else:
    print("Yes")

### FIXED CODE ###

t=input()
n=t[0]
m=t[1]
o=t[2]

if n != "7" and m != "7" and o !="7":
    print("No")
else:
    print("Yes")
N,D=map(int,input().split())
l=[]
l1=[]
count=0
for i in range(N):
  x,y=map(int,input().split())
  l.append(x)
  l1.append(y)
for i in range(N):
  if (l[i]**2 +l1**2)**0.5 <=D:
    count+=1
print(count)    
  


### FIXED CODE ###

N,D=map(int,input().split())
l=[]
l1=[]
count=0
for i in range(N):
  x,y=map(int,input().split())
  l.append(x)
  l1.append(y)
for i in range(N):
  if (l[i]**2 +l1[i]**2)**0.5 <=D:
    count+=1
print(count)
n = int(input())
C = list(map(int,input().split()))

path = [set() for _ in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
ans = [n*(n+1)//2]*n
size = [0]*n
cparent = [[] for _ in range(n)]
reached = [False]*n
root_size = [n]*n

def dfs (p):
    c = C[p] - 1
    cparent[c].append(p)
    s = 1
    for nxt in path[p]:
        #print (nxt)
        
        if reached[nxt]:
            continue
        size[p] = 0
        reached[nxt] = True
        ret = dfs(nxt)
        s += ret
        size[p] +=ret
        ans[c] -= size[p] * (size[p] + 1)//2
    cparent[c].pop()
    if cparent[c]:
        size[cparent[c][-1]] -=s
    else:
        root_size[c] -=s    
    return s

reached[0] = True
dfs (0)

for i in range(n):
    print (ans[i]-root_size[i]*(root_size[i]+1)//2)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

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

path = [set() for _ in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
ans = [n*(n+1)//2]*n
size = [0]*n
cparent = [[] for _ in range(n)]
reached = [False]*n
root_size = [n]*n

def dfs (p):
    c = C[p] - 1
    cparent[c].append(p)
    s = 1
    for nxt in path[p]:
        #print (nxt)
        
        if reached[nxt]:
            continue
        size[p] = 0
        reached[nxt] = True
        ret = dfs(nxt)
        s += ret
        size[p] +=ret
        ans[c] -= size[p] * (size[p] + 1)//2
    cparent[c].pop()
    if cparent[c]:
        size[cparent[c][-1]] -=s
    else:
        root_size[c] -=s    
    return s

reached[0] = True
dfs (0)

for i in range(n):
    print (ans[i]-root_size[i]*(root_size[i]+1)//2)
n, k = map(int, input().split())
a = list(map(int, input().split()))

pos = -1
seen = [False] * n
finished = [False] * n
hist = []
cycle = []
cycles = [-1] * n
cn = {}

def dfs(v, p):
    global pos
    seen[v] = True
    hist.insert(0, v)
    next = a[v]-1
    if (next != p):
        if (finished[next] == False):
            if (seen[next]):
                pos = next
                return
            dfs(next, v)
            if (pos != -1):
                return

    hist.pop(0)
    finished[v] = True

dfs(0, -1)
cnt = 0
while(len(hist) != 0):
    b = hist[0]
    cycle.append(b)
    cycles[b] = cnt
    cn[b] = cnt
    cnt += 1
    hist.pop(0)
    if (b == pos):
        break
cycle = list(reversed(cycle))

n = 0
ans = -1
while(cycles[n] == -1 and k > 0):
    k -= 1
    n = a[n] - 1
    if(k == 0):
        ans = n

if (k > 0):
    dc = len(cycle) - cn[n] - 1
    d = (k+dc) % len(cycle)
    ans = cycle[d] + 1

print(ans)



### FIXED CODE ###

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

pos = -1
seen = [False] * n
last = [-1] * n
hist = []
i = 0
cnt = 0

while(seen[i] == False):
    seen[i] = True
    last[i] = cnt
    cnt += 1
    hist.append(i)
    ne = a[i]-1
    i = ne
    if (seen[i] == True):
        pos = i

cycle = hist[last[pos]:]
preCircle = last[pos]

if (k <= preCircle):
    print(hist[k] + 1)
else:
    k -= preCircle
    ans = k % len(cycle)
    print(cycle[ans] + 1)
import math
C=math.pi
print("{0:.6f} {1:.6f}").format(C*r**2,C*2*r)

### FIXED CODE ###

import math
r=float(input())
C=math.pi
print("{0:.6f} {1:.6f}".format(C*r**2,C*2*r))
try:
  s = input()
  t = input()
  count = 0
  for i in range(len(s)):
  if not s[i] == t[i]:
    count += 1
  print(count)
except EOFError:
  print('EOFError')
  

### FIXED CODE ###

m=input()
n=input()
count=0
for i in range(len(m)):
   if m[i]!=n[i]:
      count+=1
print(count)
import numpy as np
class UnionFind:
    def __init__(self, n):
        self.parent = np.array([-1] * n)
        self.size = np.array([1] * n)
        # self.parent = [-1] * n
        # self.size = [1] * n
    def find(self, x):
        if self.parent[x] == -1:
            return x
        else:
            a = self.find(self.parent[x])
            self.parent[x] = a
            return a
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            self.parent[x] = y
            self.size[y] += self.size[x]
    def get_size(self, x):
        return self.size[self.find(x)]
    def printout(self):
        print(self.parent)
        print(self.size)

N, M, K = map(int, input().split())
uf = UnionFind(N)

ab = [[int(i)-1 for i in input().split()] for j in range(M)]
cd = [[int(i)-1 for i in input().split()] for j in range(K)]

for a, b in ab:
    uf.union(a, b)

ans =[uf.get_size(i) -1 for i in range(N)]

for a, b in ab:
    ans[a] -= 1
    ans[b] -= 1

for c, d in cd:
    if uf.find(c) == uf.find(d):
        ans[c] -= 1
        ans[d] -= 1

print(*ans)

### FIXED CODE ###

import sys #追加
sys.setrecursionlimit(500*500) #追加

class UnionFind:
    def __init__(self, n):
        self.parent = [-1] * n
        self.size = [1] * n
    def find(self, x):
        if self.parent[x] == -1:
            return x
        else:
            a = self.find(self.parent[x])
            self.parent[x] = a
            return a
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            self.parent[x] = y
            self.size[y] += self.size[x]
    def get_size(self, x):
        return self.size[self.find(x)]
    def printout(self):
        print(self.parent)
        print(self.size)

N, M, K = map(int, input().split())
uf = UnionFind(N)

ab = [[int(i)-1 for i in input().split()] for j in range(M)]
cd = [[int(i)-1 for i in input().split()] for j in range(K)]

for a, b in ab:
    uf.union(a, b) #RE

ans =[uf.get_size(i)-1 for i in range(N)]

for a, b in ab:
    ans[a] -= 1
    ans[b] -= 1

for c, d in cd:
    if uf.find(c) == uf.find(d):
        ans[c] -= 1
        ans[d] -= 1

print(*ans)
a,b,c == map(int,input().split())

if a==b and b==c:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

# coding: utf-8
# Your code here!
a,b,c = map(int,input().split())
 
if a==b and b==c:
  print("Yes")
else:
  print("No")
n = input(int())
a = input(int())
print(n*n-a)

### FIXED CODE ###

n = int(input())
a = int(input())
print(n*n-a)
n, m, x, y = map(int, input().split())

xl = list(map(int, input().split()))
yl = list(map(int, input().split()))

if max(xl + x) < min(yl + y):
    print("No War")
else:
    print("War")

### FIXED CODE ###

n, m, x, y = map(int, input().split())

xl = list(map(int, input().split()))
yl = list(map(int, input().split()))

if max(xl + [x]) < min(yl + [y]):
    print("No War")
else:
    print("War")
import math

def overlap(p1, p2, d):
    return (p1[0] - p2[0])**2 + (p1[1] - p2[1])**2 <= d

def intersection(o1,o2):
    a  = 2*(o2[0] - o1[0])
    b  = 2*(o2[1] - o1[1])
    c  = (o1[0] - o2[0])*(o1[0] + o2[0]) + (o1[1] - o2[1])*(o1[1] + o2[1])
    a2 = a**2 + b**2
    b2 = a*c + a*b*o1[1] - b**2*o1[0]
    c2 = b**2*(o1[0]**2 + o1[1]**2 - 1) + c**2 + 2*b*c*o1[1]
    x1 = (-b2 + math.sqrt(b2**2 + a2*c2))/a2
    x2 = (-b2 - math.sqrt(b2**2 + a2*c2))/a2
    if b < 10e-6:
        y1 = (o1[1] + o2[1])/2
        y2 = (o1[1] + o2[1])/2
    else:
        y1 = -(a*x1 + c)/b
        y2 = -(a*x2 + c)/b
    if b2**2 - a2*c2 < 10e-6:
        return [x1, y1], [None, None]
    else:
        return [x1, y1], [x2, y2]

while True:
    n = int(input())
    if n == 0:
        break
    p = []
    for i in range(n):
        p.append(list(map(float, input().split(","))))
    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            if not overlap(p[i], p[j], 4):
                continue
            elif overlap(p[i], p[j], 10e-6):
                continue
            p1, p2 = intersection(p[i], p[j])
            cnt1 = 0
            cnt2 = 0
            for k in range(n):
                if overlap(p1, p[k], 1):
                    cnt1 += 1
                if p2[0] != None and overlap(p2, p[k], 1):
                    cnt2 += 1
            ans = max([ans, cnt1, cnt2])
    print(ans)



### FIXED CODE ###

import math

def dist(p1, p2):
    return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)

def intersection(o1,o2):
    if dist(o1,o2) > 2:
        p1, p2 =  [None, None], [None, None]
    elif dist(o1,o2) == 2:
        p1, p2 =  [(o1[0] + o2[0])/2, (o1[1] + o2[1])/2], [None, None]
    else:
        m = [(o1[0] + o2[0])/2, (o1[1] + o2[1])/2]
        v = [m[0] - o1[0], m[1] - o1[1]]
        v_abs = dist(v,[0,0])
        w = [v[1], -v[0]]
        w_abs = dist(w,[0,0])
        n = [w[0]/w_abs, w[1]/w_abs]
        l = math.sqrt(1 - v_abs**2)
        p1 = [m[0] + l*n[0], m[1] + l*n[1]]
        p2 = [m[0] - l*n[0], m[1] - l*n[1]]
    return p1, p2
err = 1.0e-6
while True:
    n = int(input())
    if n == 0:
        break
    p = []
    for i in range(n):
        p.append(list(map(float, input().split(","))))
    ans = 1
    for i in range(n - 1):
        for j in range(i + 1, n):
            p1, p2 = intersection(p[i], p[j])
            cnt1 = 0
            cnt2 = 0
            for k in range(n):
                if p1[0] and dist(p1, p[k]) <= 1 + err:
                    cnt1 += 1
                if p2[0] and dist(p2, p[k]) <= 1 + err:
                    cnt2 += 1
            ans = max([ans, cnt1, cnt2])
    print(ans)
H,W = map(int,input().split())
s = [list(input()) for i in range(H)]
for i in range(H):
	for j in range(W):
		if s[i][j] == "#":
			if s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
			    print("No")
			    exit()
print("Yes") 

### FIXED CODE ###

H,W = map(int,input().split())
s = [list(input()) for i in range(H)]
for i in range(H):
	for j in range(W):
		if s[i][j] == "#":
			if s[max(0,i-1)][j] == "." and s[min(H-1,i+1)][j] == "." and s[i][max(0,j-1)] == "." and s[i][min(W-1,j+1)] == ".":
			    print("No")
			    exit()
print("Yes")
s=input().replace(" ","*").replace(".","")
t=eval(s)
t=int(t//100)
print(t)

### FIXED CODE ###

a,b=map(int,input().replace(".","").split())
t=(a*b)//100
t=int(t)
print(t)
n, x = map(int,input().split())
a = list(map(int,input().split()))
mina = min(a)
b = x - mina

a2 = []
a3 = []
for i in range(n):
    if i % 2 == 0:
        a2.append(mina)
        a3.append(b)
    else:
        a2.append(b)
        a3.append(mina)

cnt2 = 0
cnt3 = 0
for i in range(n):
    if a[i] >= a2[i]:
        cnt2 += a[i] - a2[i]
    else:
        cnt2 = None
        break
    
for i in range(n):
    if a[i] >= a3[i]:
        cnt3 += a[i] - a3[i]
    else:
        cnt3 = None
        break

if cnt2 and cnt3:
    print(min(cnt2,cnt3))
elif cnta2:
    print(cnt2)
elif cnta3:
    print(cnt3)
else:
    print(0)


### FIXED CODE ###

n, x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
for i in range(1, n):
    if a[i] + a[i-1] > x:
        b = a[i] + a[i-1] - x
        minab = min(a[i], b)
        a[i] -= minab
        cnt += minab
        
        b -= minab
        cnt += b
        a[i-1] -= b
print(cnt)