Harryxun/stf_run huggingface dataset:
N,*A = map(int, open(0).read().split())
a = A[0]
b = A[1]
c = A[2]
d = sum(A[3:])
x = 0
m = c
n = d
df2 = max(m,n)-min(m,n)
for i in range(3,N-1):
  m += A[i]
  n -= A[i]
  if df2>max(m,n)-min(m,n):
    df2 = max(m,n)-min(m,n)
    c,d = m,n
    y = i
ans = max(a,b,c,d)-min(a,b,c,d)
for i in range(2,N-2):
  b += A[i]
  c -= A[i]
  df1 = max(a,b)-min(a,b)
  df2 = max(c,d)-min(c,d)
  while True:
    na = a+A[x+1]
    nb = b-A[x+1]
    if df1<max(na,nb)-min(na,nb):
      break
    df1 = max(na,nb)-min(na,nb)
    a,b = na,nb
    x += 1
  while True:
    nc = c+A[y+1]
    nd = d-A[y+1]
    if df2<max(nc,nd)-min(nc,nd):
      break
    df2 = max(nc,nd)-min(nc,nd)
    c,d = nc,nd
    y += 1
  ans = min(ans,max(a,b,c,d)-min(a,b,c,d))
print(ans)

### FIXED CODE ###

N,*A = map(int, open(0).read().split())
a = A[0]
b = A[1]
c = A[2]
d = sum(A[3:])
x = 0
m = c
n = d
df2 = max(m,n)-min(m,n)
y = 2
for i in range(3,N-1):
  m += A[i]
  n -= A[i]
  if df2>max(m,n)-min(m,n):
    df2 = max(m,n)-min(m,n)
    c,d = m,n
    y = i
ans = max(a,b,c,d)-min(a,b,c,d)
for i in range(2,N-2):
  b += A[i]
  c -= A[i]
  df1 = max(a,b)-min(a,b)
  df2 = max(c,d)-min(c,d)
  while True:
    na = a+A[x+1]
    nb = b-A[x+1]
    if df1<max(na,nb)-min(na,nb):
      break
    df1 = max(na,nb)-min(na,nb)
    a,b = na,nb
    x += 1
  while True:
    nc = c+A[y+1]
    nd = d-A[y+1]
    if df2<max(nc,nd)-min(nc,nd):
      break
    df2 = max(nc,nd)-min(nc,nd)
    c,d = nc,nd
    y += 1
  ans = min(ans,max(a,b,c,d)-min(a,b,c,d))
print(ans)
S, W = list(map(int, input().split()))

if (W >= S){
    print('unsafe')
} else{
    print('safe')
}

### FIXED CODE ###

S, W = list(map(int, input().split()))

if (W >= S):
    print('unsafe')
else:
    print('safe')
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""
def f(n, a0, cnt, sa, sign):
    a = a0[:]
    if sign == -1:
        cnt += abs(a[0])+1
        a[0] = -a[0]/abs(a[0])
    for i in range(n-1):
        sa += a[i]
        na = -sa//abs(sa)*(abs(sa)+1)
        if abs(a[i+1]) > abs(na) and a[i+1]*na > 0:
            continue
        else:
            cnt += abs(na-a[i+1])
            a[i+1] = na
    return cnt

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

cnt0 = f(n, a, 0, 0, -1)
cnt1 = f(n, a, 0, 0, 1)
cnt = min([cnt0,cnt1])
print(cnt)
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""

def sign(x):
    return x//abs(x)

def f(n, a0, s):
    cnt = 0
    cum = 0
    for i, ai in enumerate(a):
        cum += ai
        if cum == 0:
            cnt += 1
            cum = (-1)**i*s
        elif sign(cum) == (-1)**i*s:
            continue
        else:
            cnt += abs(cum)+1
            cum = (-1)**i*s
    return cnt

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

cnt = 0
cnt0 = f(n, a, -1)
cnt1 = f(n, a, 1)
cnt = min([cnt0,cnt1])
print(cnt)
import sys
input=sys.stdin.readline

h,w=map(int,input().split())

B,ans,cnt=[],[],0
Bappend=B.append
ansappend=ans.append
fflag=False

for i in range(h):
    A=list(map(int,input().split()))
    flag=False
    for j in range(w-1):
        if flag:
            if A[j]%2==0:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
            else:
                flag=False
        else:
            if A[j]%2==1:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
    if i!=h-1:
        if flag+fflag==1:
            if A[w-1]%2==0:
                ansappend((i+1,j+1,i+2,j+1))
                fflag=True
                cnt+=1
            else:
                fflag=False
        else:
            if A[w-1]%2==0:
                fflag=False
            else:
                ansappend((i+1,j+1,i+2,j+1))
                fflag=True
                cnt+=1
                
print(cnt)
for a in ans:
    print(*a)

### FIXED CODE ###

import sys
input=sys.stdin.readline

h,w=map(int,input().split())

B,ans,cnt=[],[],0
Bappend=B.append
ansappend=ans.append
fflag=False

for i in range(h):
    A=list(map(int,input().split()))
    flag=False
    for j in range(w-1):
        if flag:
            if A[j]%2==0:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
            else:
                flag=False
        else:
            if A[j]%2==1:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
    if i!=h-1:
        if flag+fflag==1:
            if A[w-1]%2==0:
                ansappend((i+1,w,i+2,w))
                fflag=True
                cnt+=1
            else:
                fflag=False
        else:
            if A[w-1]%2==0:
                fflag=False
            else:
                ansappend((i+1,w,i+2,w))
                fflag=True
                cnt+=1
                
print(cnt)
for a in ans:
    print(*a)
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
B = np.zeros((N, N))
for i, b in enumerate(B):
    b[i:i + 2] = 1 / 2
    if i == len(b) - 1:
        b[0] = 1 / 2
x = np.linalg.solve(B, A).astype(np.int)
print(" ".join(map(str, list(x))))

### FIXED CODE ###

import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
A = np.array(list(map(int, input().split())))
sgn = np.tile(np.array([1, -1]), N // 2)
sgn = np.concatenate([sgn, np.array([1])])
ans = np.empty(N, dtype=np.int)
ans[0] = (A * sgn).sum()
for i in range(1, N):
    ans[i] = 2 * A[i - 1] - ans[i - 1]
print(*ans)
from math import cos, sqrt, pi
a, b, h, m = map(int, input().split())
#時針の角度
ang_a = pi * h / 6 + pi * m / 360
#分針の角度
ang_b = pi * m / 30
#角度差
ang = abs(ang_a-ang_b)
#余弦定理
c = sqrt(a**2 + b**2 - 2*a*b*cos(ang))
print(c)

### FIXED CODE ###

k = int(input())
s = str(input())
if k < len(s):
    ans = s[0:k]+'...'
    print(ans)
else:
    print(s)
N = int(input())
if N == 1 :
	print("Hello World")
else :
	A = int(input())
    B = int(input())
    print(A + B)

### FIXED CODE ###

N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)
import math
A,B,C,D=map(int,input().split())


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


#print(len([x for x in range(A,B) if x%2!=0 and x%3!=0]))

size=B

cd=lcm(C,D)
allC=size//C
allD=size//D
allcd=size//cd
ALL=size-(allC+allD-allcd)

size=A-1
cd=lcm(C,D)
pC=size//C
pD=size//D
pcd=size//cd
P=size-(pC+pD-pcd)

print(ALL-P)


### FIXED CODE ###

from fractions import gcd
A,B,C,D=map(int,input().split())


def lcm(x, y):
    return (x * y) // gcd(x, y)

size=B

cd=lcm(C,D)
allC=size//C
allD=size//D
allcd=size//cd
ALL=size-(allC+allD-allcd)

size=A-1
cd=lcm(C,D)
pC=size//C
pD=size//D
pcd=size//cd
P=size-(pC+pD-pcd)

print(ALL-P)
n, m = list(map(int, input().split()))
par = list(range(n+1))
dist = [0 for _ in range(n+1)]

def root(x):
  if x == par[x]:
    return x
  r = root(par[x])
  dist[x] += direct_cost(par[x])
  par[r] = r
  return r

def direct_cost(x):
  if x == par[x]:
    return 0
  return dist[x] + direct_cost(par[x])
  
def diff(x, y):
  return dist[x] - dist[y]

flag = True
for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が異なってたらとりあえず併合、同じならdifを取って整合性を確かめる
  rootx, rooty = root(l), root(r)
  if rootx != rooty:
    if r != rooty:
      # 直接yにつなげる
      dist[rootx] = d - direct_cost(x)
    else:
      # yの根につなげる
      dist[rootx] = d - (dist[l] - dist[rooty])
    par[rootx] = rooty
  else:
    if d != diff(l, r):
      flag = False
"""
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(par)]
print()
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(dist)]
print()
"""

print("Yes" if flag else "No")
  

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

class WeightedUnionFindTree:
  def __init__(self, n):
    self.par = list(range(n))
    self.rank = [0 for _ in range(n)]
    self.weight = [0 for _ in range(n)]
   
  def root(self, t):
    if t == self.par[t]:
      return t
    # 経路圧縮してみる
    r = self.root(self.par[t])
    self.weight[t] += self.weight[self.par[t]]
    self.par[t] = r
    return r
   
  def rec_weight(self, t):
    if t == self.par[t]:
      return 0
    return self.weight[t] + self.rec_weight(self.par[t])
   
  def same(self, x, y):
    return self.root(x) == self.root(y)
     
  def unite(self, x, y, w):
    rootx = self.root(x)
    rooty = self.root(y)
    if rootx != rooty:
      if y != rooty:
        # 直接yにつなげる
        self.weight[rootx] = w - self.rec_weight(x)
      else:
        # 根につなげる
        self.weight[rootx] = w - (self.weight[x] - self.weight[y])
      # ここで親を更新
      self.par[rootx] = y
    else:
      return w == self.diff(x, y)
 
  def diff(self, x, y):
    return self.rec_weight(x) - self.rec_weight(y)

n, m = list(map(int, input().split()))
par = list(range(n+1))
dist = [0 for _ in range(n+1)]


wuft = WeightedUnionFindTree(n+1)
flag = True
for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が異なってたらとりあえず併合、同じならdifを取って整合性を確かめる
  a = wuft.unite(l, r, d)
  if a is not None:
    if a == False:
      flag = False
"""
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(wuft.par)]
print()
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(wuft.weight)]
print()
"""

print("Yes" if flag else "No")
from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        if 1<=len(S)<=10 and S.islower==1 and 0<=P<=100 and type(P) is int :
            args.append([S,P])
        else :
            print("ERROR")
            exit()

            
def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    uniequ_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
	print("ERORR")
	exit()
    # else :                                                                                         
    #     print("restaurant is ok.")                                                                 


def main():
    num=int(input())
    if 1<=num<=100:
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

if __name__ == "__main__":
    main()


### FIXED CODE ###

from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        P=int(P)
        if 1<=len(S)<=10 and S.islower()==1 and S.isalpha()==1 \
           and 0<=P<=100 and isinstance(P,int)==1:
            args.append([S,P])
        else :
            print("ERROR")
            exit()



def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
        print("ERORR")
        exit()
    # else :                                                                                         
    #     print("restaurant is ok.")           



def main():
    # restaurant=[['N1',88],['N2',85],['N3',92],['N7',21],['N4',34],['N8',45],['N2',24],['N2',35]]   
    # num=8                                                                                          

    num=int(input())
    if 1<=num<=100:
        # [[] for i in range(5)]                                                                     
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        # print(restaurant)                                                                          
        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

if __name__ == "__main__":
    main()
import math
N=int(input())
sisterN=[]
SISTERn=[]
SIStern=[]
for n in range(N):
    _=int(input())
    if _<40000:
        _s= _
        if sisterN.count(_s)==1:
            sisterN.remove(_s)
        else:
            sisterN.append(_s)
    elif 40001<_<99000:
        _m= _
        if SISterN.count(_m)==1:
            SISterN.remove(_m)
        else:
            SISterN.append(_m)
    elif 99001<_:
        _b= _
        if SISTERn.count(_b)==1:
            SISTERn.remove(_b)
        else:
            SISTERn.append(_b)

print(len(sisterN)+len(SISTERn)+len(SIStern))

### FIXED CODE ###

N=int(input())
S=set()

for n in range(N):
    _=int(input())
    if _ in S:
        S.remove(_)
    else:
        S.add(_)

print(len(S))
N, M = map(int, input().split())
L1, R1 = map(int, input().split())
flag = 0
def find_key(L1,R1,L2,R2):
  if R1 < L2 or R2 < L1:
    print(0)
    flag = 1
    break
  elif:
    a = [R1,L1,R2,L2]
    a.sort()
    return(a[1],a[2])
for i in range(M - 1):
  L,R = map(int, input().split())
  L1,R1 = find_key(L1,R1,L,R)
if flag == 1:
  print(L1,R1)

### FIXED CODE ###

N, M = map(int, input().split())
L1, R1 = map(int, input().split())
flag = 0
def find_key(L1,R1,L2,R2):
    if R1 < L2 or R2 < L1:
        return(False)
    else:
        a = [R1,L1,R2,L2]
        a.sort()
        return(a[1],a[2])

for i in range(M - 1):
    L,R = map(int, input().split())
    if find_key(L1,R1,L,R) != False:
        L1,R1 = find_key(L1,R1,L,R)
    else:
        flag = 1
        print(0)
        break
if flag == 0:
    print(R1-L1+1)
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

h,w,d = li()
a = [list(li()) for _ in range(h)]

num2point = [(-1,-1)]*(h*w+1)
for r, ai in enumerate(a):
    for c, aij in enumerate(ai):
        num2point[aij] = (r, c)
    

dist = [[] for _ in range(d)]
for i in range(h*w):
    if i // d == 0 or i == d:
        dist[i%d].append(0)
        
    else:
        dist[i%d].append(abs(num2point[i][0]-num2point[i-d][0]) + abs(num2point[i][1]-num2point[i-d][1]))
        
dist_cum = [list(accumulate(dist_row)) for dist_row in dist]


q = ni()
for _ in range(q):
    l,r = li()
    print(dist_cum[l%d][r//d] - dist_cum[l%d][l//d])

### FIXED CODE ###

import sys
sdin = sys.stdin.readline

H,W,D = map(int, sdin().split())
A = []
for h in range(H):
    A.append(list(map(int, sdin().split())))
Q = int(sdin())
RL = []
for q in range(Q):
    RL.append(tuple(map(int, sdin().split())))


codn = {}
for h in range(H):
    for w in range(W):
        codn[A[h][w]] = (h+1, w+1)
        
# mod D上での累積和
cums = []
for d in range(D):
    cum = []
    res = D
    if d!=0:
        res = d
    
    cum = [0]
    while res+D <= H*W:
        prev = codn[res]
        nex = codn[res+D]
        cost = abs(nex[0]-prev[0]) + abs(nex[1]-prev[1])
        cum.append(cum[-1]+cost)
        
        res += D
    
    cums.append(cum)
    
# 各クエリの処理
ans = 0
for query in range(Q):
    q = RL[query]
    mod = q[0] % D
    start = (q[0]-mod) // D
    last = (q[1]-mod) // D
    if mod == 0:
        start -= 1
        last -= 1
    
    ans = cums[mod][last] - cums[mod][start]   
    
    print(ans)
N = int(input())
max_num = []
  
def yakusu(num):
    cd = []
    for i in range(1, int(num*0.5 + 1)):
        if num % i ==0:
            cd.append(i)
    return cd
  
for A in yakusu(N):
    for B in yakusu(N):
        if A * B == N:
            max_num.append(max(A, B))
            
print(len(str(max(max_num))))

### FIXED CODE ###

n = int(input())
a = int(n **(0.5) + 1)
num = 1
for i in range(1,a + 1):
    if  n%i == 0:
        num = i
ans = max(num, n // num)
print(len(str(ans)))
N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    edge[a].append(b)


color = [0] * N

def dfs(v, c):
    color[v] = c
    now = 0
    for nv in edge[v]:
        now += 1
        if now == c:
            now += 1
        dfs(nv, now)

dfs(0, 0)
color[0] = max(color)
print(*color, sep="\n")


### FIXED CODE ###

class ColorMgmt:
    from heapq import heappop, heappush
    def __init__(self, n):
        self.colors_hash = [set() for _ in range(n)]
        self.next_colors = [1] * n
    
    def set_color(self, v, c):
        self.colors_hash[v].add(c)
        while self.next_colors[v] in self.colors_hash[v]:
            self.next_colors[v] += 1
    
    def get_color(self, v):
        return self.next_colors[v]


N = int(input())
ab = [list(map(int, input().split())) for _ in range(N-1)]
edge = [[] for _ in range(N)]
edge_cnt = [0] * N
for idx, (a, b) in enumerate(ab):
    a, b = a-1, b-1
    edge[a].append([b, a, 0, idx])
    edge_cnt[a] += 1
    edge_cnt[b] += 1
K = max(edge_cnt)

next_list = []
now_list = [0]
color_mgmt = ColorMgmt(N)
while len(now_list) > 0:
    for v in now_list:
        for idx, nextv in enumerate(edge[v]):
            if v == nextv[0]:
                continue
            colors1 = color_mgmt.get_color(nextv[1])
            colors2 = color_mgmt.get_color(nextv[0])
            color = max(colors1, colors2)
            color_mgmt.set_color(nextv[1], color)
            color_mgmt.set_color(nextv[0], color)
            edge[v][idx][2] = color
            next_list.append(nextv[0])
    
    now_list = list(next_list)
    next_list = []

ret = []
for edges in edge:
    for e in edges:
        ret.append(e)
ret.sort(key=lambda x:x[3])
print(K)
for r in ret:
    print(r[2])
f=str(input())
if f.islower == True:
  print(a)
else:
  print(A)

### FIXED CODE ###

f=str(input())
if f.islower() == True:
  print('a')
else:
  print('A')
X,Y,Z,K=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A_B=[]
SUM=[]
for i in range(X):
  for j in range(Y):
    A_B.append(A[i]+B[j])
A_B.sort(reverse=True)
for i in range(K):
  for j in range(Z):
    SUM.append(A_B[i]+C[j])
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])

### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
SUM=[]
for i in range(X):
  for j in range(Y):
    for k in range(Z):
      if (i+1)*(j+1)*(k+1)<=K:
        SUM.append(A[i]+B[j]+C[k])
      else:
        break
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])
def main():
    S = input()
    T = input()
    # Sのi文字目をTの先頭として，それらの文字列の一致度を見る．

    st = {}
    for i in range(len(S)-len(T)+1):
        cnt = 0
        for s, t in zip(S[i:i+len(T)], T):
            cnt += s == t
        st.add(cnt)
    print(len(T) - max(st))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    S = input()
    T = input()
    # Sのi文字目をTの先頭として，それらの文字列の一致度を見る．

    st = set()
    for i in range(len(S)-len(T)+1):
        cnt = 0
        for s, t in zip(S[i:i+len(T)], T):
            cnt += s == t
        st.add(cnt)
    print(len(T) - max(st))


if __name__ == '__main__':
    main()
N, M = map(int, input().split())
E = [sorted(list(map(int, input().split()))) for i in range(M)]
E.sort()
print(E)
L = [-1]*(N+1)
L[1] = 0
al = False
for e in E:
    a, b = e
    if L[b] == -1:
        L[b] = 1-L[a]
    elif L[a] + L[b] != 1:
        al = True
        break
if al:
    print(N*(N-1)//2-M)
else:
    c = L.count(1)
    print(c*(N-c)-M)
    raise ValueError()


### FIXED CODE ###

N, M = map(int, input().split())
V = [[] for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    V[A].append(B)
    V[B].append(A)

L = [-1]*(N+1)
L[1] = 0
al = False

from collections import deque
Open = deque()
Open.append(1)
Close = set()
while len(Open)>0:
    v = Open.pop()
    Close.add(v)
    for v2 in V[v]:
        if v2 not in Close:
            Open.append(v2)
        if L[v2] == -1:
            L[v2] = 1-L[v]
        elif L[v] + L[v2] != 1:
            al = True
            break
    if al:
        break

if al:
    print(N*(N-1)//2-M)
else:
    c = L.count(1)
    print(c*(N-c)-M)
H,W,N = [int(input()) for i in range(3)]
a = N / o
for o in range(1,10000):
  if H < W and a <= W:
    print(o)
    break
  elif H> W and a<=H:
    print(o)
    break
    
  
  

   
    
    
    





	

  
  
  



### FIXED CODE ###

H,W,N = [int(input()) for i in range(3)]
for o in range(1,10000):
  if H <= W and N / o <= W:
    break
  elif H >= W and N / o <= H:
    break
print(o)
numbers = input().split(" ")
A = numbers[0]
B = numbers[1]
C = numbers[2]

amount = C - (A - B)
print(amount)

### FIXED CODE ###

numbers = input().split(" ")
A = int(numbers[0])
B = int(numbers[1])
C = int(numbers[2])

amount = C - (A - B)
if amount < 0:
  amount = 0
print(amount)
N,M = map(int,input().split())
A = list(map(int,input().split()))

R = [A[0]%M]


for i in range(1,N):
  R.append((R[-1]+A[i])%M)

k = set(R)
dic = {i:0 for i in k}
for item in R:
  dic[item]+=1

ans = (dic[0]*(dic[0]+1))//2

for i in k:
  if i !=0 :
    ans += (dic[i]*(dic[i]-1))//2
    exit()

    
print(ans)

### FIXED CODE ###

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

R = [A[0]%M]


for i in range(1,N):
  R.append((R[-1]+A[i])%M)



import collections
c = collections.Counter(R)


ans = 0
for key in c:
  if key == 0:
    ans += (c[key]*(c[key]+1))/2
  else:
    ans += (c[key]*(c[key]-1))/2
  



print(int(ans))
#!/usr/bin/env python3
import sys

PARTS = ["eraser", "erase", "dreamer", "dream"]


def main():
    sys.setrecursionlimit(10000)
    S = input()

    if judgeStr(S):
        print("YES")
    else:
        print("NO")


def judgeStr(target: str) -> bool:
    for item in PARTS:
        if target.startswith(item):
            tempStr = target.replace(item, "", 1)
            if tempStr == "" or judgeStr(tempStr):
                return True

    return False


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

PARTS = ["eraser", "erase", "dreamer", "dream"]
# PARTS2 = []


def main():
    global PARTS2
    sys.setrecursionlimit(100000)
    S = input()

    # for i in range(0, 4):
    #     for j in range(0, 4):
    #         PARTS2.append(PARTS[i] + PARTS[j])

    # PARTS2 = PARTS2 + PARTS

    if judgeStr2(S):
        print("YES")
    else:
        print("NO")


def judgeStr2(target: str) -> bool:
    currentStr = target
    while currentStr != "":
        isNextOK = False
        for item in PARTS:
            if not currentStr.startswith(item):
                continue

            tempStr = currentStr.replace(item, "", 1)
            if tempStr == "":
                return True

            for item2 in PARTS:
                if tempStr.startswith(item2):
                    isNextOK = True
                    break

            if isNextOK:
                currentStr = tempStr
                break
        if isNextOK:
            continue
        else:
            break
    return currentStr == ""


def judgeStr(target: str) -> bool:
    for item in PARTS:
        if target.startswith(item):
            tempStr = target.replace(item, "", 1)
            if tempStr == "" or judgeStr(tempStr):
                return True

    return False


if __name__ == "__main__":
    main()