Problem:


Score : 100 points

Problem Statement

You went shopping to buy cakes and donuts with X yen (the currency of Japan).

First, you bought one cake for A yen at a cake shop.
Then, you bought as many donuts as possible for B yen each, at a donut shop.

How much do you have left after shopping?

Constraints

1 \leq A, B \leq 1 000

A + B \leq X \leq 10 000

X, A and B are integers.

Input

Input is given from Standard Input in the following format:

X
A
B

Output

Print the amount you have left after shopping.

Sample Input 1

1234
150
100

Sample Output 1

84

You have 1234 - 150 = 1084 yen left after buying a cake.
With this amount, you can buy 10 donuts, after which you have 84 yen left.

Sample Input 2

1000
108
108

Sample Output 2

28

Sample Input 3

579
123
456

Sample Output 3

0

Sample Input 4

7477
549
593

Sample Output 4

405



Sample input:
1234
150
100


Sample output:
84

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for i in range(A):
    for j in range(B):
        for k in range(C):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
#define
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0

#sorting
for e in range(0,a+1):
    if e*500 >= x:
        y=x-e*500
        for f in range(0,b+1):
            if f*100 >= y:
                z=y-100*f
                for g in range(0,c+1):
                    if g*50 == z :                                            
                        count = count +1
                        
                       
print(count)

Submission status: Runtime Error

Solution code:
x=int(input())
y=int(input())
z=int(input())

i=0
while (x-a-b*i)>=0:
	i+=1
i-=1
print(x-a-b*i)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
r = 0;
for a in range(0, A + 1):
    for b in range(0, B + 1):
        for c in range(0, C + 1):
            if (500 * a + 100 * b + 50 * c == X):
                r += 1
print(r)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a):
  for j in range(b):
    for k in range(c):
      sum = i*500 + j*100 + k*50
      if sum == x:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
X = int(input())
A = int(input())
B = int(input())

tmp=X-A

while tmp => B:
  tmp=tmp-B
print(tmp)

Submission status: Runtime Error

Solution code:
a=int(input())
s=int(input())
d=int(input())
print(a-s-(a-s)//b*b)

Submission status: Runtime Error

Solution code:
# , = map(int, input.split())
#  = int(input())
x,a,b = map(int, input().split())
print((x - a) % b)

Submission status: Runtime Error

Solution code:
X = int(input())
A = int(input())
B = int(input())

remain = X - A
for i in range(100000):
  if (remain - B) < 0:
    print(ans)
    break
  elif (remain - B) == 0:
    print(0)
    break
  else:
    remain -= B

Submission status: Runtime Error

Solution code:
n,k,x,y = [int(input()) for i in range(4)]
print(n*x if k>=n else k*x + (n-k)*y)

Submission status: Runtime Error

Solution code:
a, b, c, x = map(int, [input() for i in range(4)])
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total = 500 * a + 100 * b + 50 * c
            if total == x:
                count = count + 1
print(count)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
print((a-b)%c)

Submission status: Runtime Error

Solution code:
import math
A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans=0
a=math.floor(X/500)
for i in range(min(A,a)+1):
    X2=X-500*i
    b=math.floor(X2/100)
    for j in range(min(B,b)+1):
        X3=X2-100*j
        if X3%50==0:
            c=X3/50
            if c<=C:
                ans+=1
            else:
                continue
        else:
            continue
print(ans)

Submission status: Runtime Error

Solution code:
x=int(input())　　#intで整数と指定　、input()は入力されたデータを文字列として返す。
a=int(input())
b=int(input())
print((x-a)%b)

Submission status: Runtime Error

Solution code:
import math

A = int(A)
B = int(B)
X = int(X)
Y = int(Y)
Z = int(Z)

Y = X - A

Y % B = Z



print("手元に残っている金額は" + str(Y) + "円です")

Submission status: Runtime Error

Solution code:
A, B, C, X = map(int, [input() for i in range(4)])

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1

print(count)

Submission status: Runtime Error

Solution code:
a, b, c, x = [int(input()) for i in range(4)]
counter = 0

for rep1 in range(a + 1):
    for rep2 in range(b + 1):
        for rep3 in range(c + 1):
            if rep1 * 500 + rep2 * 100 + rep3 * 50 == x:
                counter += 1

print(counter)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for re1 in range(a +1):
    for re2 in range(b + 1):
        for re3 in range(c + 1):
            if re1*500 + re2*100 + re3*50 == x:
                ans += 1

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A + 1):
    for j in range(B + 1):
        for s in range(C + 1):
            total_value = 500*i + 100*j + 50*s
            print(total_value)
            
            if total_value == X:     
                count += 1
                
                
print(count)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

counter = 0
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if X == a * 500 + b * 100 + c * 50:
        counter += 1
print(counter)

Submission status: Runtime Error

Solution code:
coin_list = []
for i in range(3):
    s = int(input())
    coin_list.append(s)
target = int(input())
counter = 0

for a in range(coin_list[0]+1):
    for b in range(coin_list[1]+1):
        for c in range(coin_list[2]+1):
            total = 500*a + 100*b + 50*c
            if total == target:
                counter = counter + 1
            if total > target:
                break

print(counter)

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k == x:
        ans=ans+1
print(ans)

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=int(input())
X=int(input())

total,out=0,0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a*500+b*100+c*50 == 0:
        out+=1
        
print(out)

Submission status: Runtime Error

Solution code:
x=int(input())
a=int(input())
b=int(input())
ans=x-a
print(ans>=b):
  ans-=b
print('ans')

Submission status: Runtime Error

Solution code:
x = int(input())
a = int(input())
b = int(input())
X -= a
k = X//b
print(X - b*k)

Submission status: Runtime Error

Solution code:
x=int(input())
a=int(input())
b=int(input())
m=0
for i in range(1,10001)
    if (x-a)/(b*i)<1:
        m=i-1
        break
print((x-a-b*m))

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for a in range(A + 1):
    
    for b in range(B + 1):
        
        for c in range(C + 1):
            
            if(a * 500 + b * 100 + c * 50 == X):
                cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
 
counter = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if(500*a + 100*b + 50*c == X):
                counter += 1
print(counter)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
 
count = 0
for a in range(A+1):
	for b in range(B+1):
        for c in range(C+1):
            if(500*a + 100*b + 50*c == X):
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
A = int(input()) #¥500
B = int(input()) #¥100
C = int(input()) #¥50
X = int(input())
count = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a*500 + b*100 + c*50 == X:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
A = int(input()) #¥500
B = int(input()) #¥100
C = int(input()) #¥50
X = int(input())

count = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if X == (a*500 + b*100 + c*50):
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
A = int(input()) #¥500
B = int(input()) #¥100
C = int(input()) #¥50
X = int(input())
count = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if (X == a*500 + b*100 + c*50):
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
x,a,b=[int(input())for i in range(3)
c=int(x-a)
print(c%b)

Submission status: Runtime Error

Solution code:
x,a,b=[int(input()) for i range(3)]
c=int(x-a)
print(c%b)

Submission status: Runtime Error

Solution code:
x,a,b=[int(input()) for i range(3)]
c=x-a
print(c%b)

Submission status: Runtime Error

Solution code:
x,a,b=[int, input for i range(3)]
c=x-a
print(c%b)

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
c=x-a
print(c%b)

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
c=int(x-a)
print(c%b)

Submission status: Runtime Error

Solution code:
x,a,b=list(int,input().split())
c=x-a
print(c%b)

Submission status: Runtime Error

Solution code:
x,a,b = map(int, input().split())
if x-a!=0:
	print(0)
else:
	print((x-a)%b)

Submission status: Runtime Error

Solution code:
x,a,b = map(int, input().split())
print(int((x-a)/b))

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

task1 = (x // 500) if (x // 500) < a else a
for i in range(task1 + 1):
    new_x = x - 500 * i
    task2 = (new_x // 100) if (new_x // 100) < b else b
    for i in range(task2 + 1):
        y = new_x - 100 * i
        if y <= 50 * c:
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
c500 = int(input())
c100 = int(input())
c50 = int(input())
t = int(input())
s = 0

for a in range(0, c500 + 1):
    for b in range(0, c100 + 1):
        for c in range(0, c50 + 1):
            if 500*a + 100*b + 50*c == t:
                s = s + 1
print(s)

Submission status: Runtime Error

Solution code:
X, A, B = map(int, iput().split())

def cake(X, A, B):
  X -= A
  a = X//B
  X -= a*B
  return X

print(cake(X, A, B))

Submission status: Runtime Error

Solution code:
X, A, B = map(int, iput().split())

def cake(X, A, B):
  X -= A
  a = X//B
  X -= a*B
  return X

print(cake(X))

Submission status: Runtime Error

Solution code:
count_500 = int(input())
count_100 = int(input())
count_50 = int(input())
target = int(input())

count=0
for i in range(count_500+1):
  for j in range(count_100+1):
    for k in range(count_50+1):
      if target==500*i+100*j+50*k:
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if a * 500 + b * 100 + c * 50 == x:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
maxa = min([a,x//500])
maxb = min([b,x//100])
maxc = min([c,x//50])
count = 0
for i in range(maxa + 1):
    for j in range(maxb + 1):
        for k in range(maxc + 1):
            if 10*i + 2*j + k == x/50:
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input)
a = int(input)
print("Yes") if ((n % 500) <= a) else print("No")

Submission status: Runtime Error

Solution code:
a, b, c, x = [int(input()) for _ in range(4)]
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
s1, s2, s3, total =[int(input()) for h in range(4)]
ans = 0
for i in range(s1+1):
    for j in range(s2+1):
        for k in range(s3+1):
            if 500*i + 100*j + 50*k == total:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
x=int(input())
t=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        t+=1
print(t)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                count += 1 
print(count)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
counter = 0
for gohyaku in range(a+1):
   x = x - 500 *gohyaku
   for hyaku in range(b+1):
      x  = x - 100*hyaku
      if 0 <= x <= 50*c:
         counter += 1
print(counter)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
counter = 0
for gohyaku in a:
   x = x - 500 *gohyaku
   for hyaku in b:
      x  = x - 100*hyaku
      if 0 <= x <= 50*c:
         counter += 1

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
X = int(input())
fifty = [x for x in range (0,X+1,50)][:a+1]
hundred = [x for x in range (0,X+1,100)][:b+1]
five_hundred = [x for x in range (0,X+1,500)][:c+1]
pattern = [x+y+z for x in fifty for y in hundred for z in five_hundred]
len(list(filter(lambda x:x==X,pattern)))

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
X = int(input())
fifty = [x for x in range (0,X+1,50)][:a+1]
hundred = [x for x in range (0,X+1,100)][:b+1]
five_hundred = [x for x in range (0,X+1,500)][:c+1]
pattern = [x+y+z for x in fifty for y in hundred for z in five_hundred]
len(list((filter(lambda x:x==X,pattern))))

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
X = int(input())
fifty = [x for x in range (0,X+1,500)][:a+1]
hundred = [x for x in range (0,X+1,100)][:b+1]
five_hundred = [x for x in range (0,X+1,50)][:c+1]
pattern = [x+y+z for x in fifty for y in hundred for z in five_hundred]
print(len(list((filter(lambda x:x==X,pattern)))))

Submission status: Runtime Error

Solution code:
n,a,b = list(map(int,input().split()))
num_sum = 0
for ni in range(n+1):
    d1 = ni%10
    d2 = (ni//10)%10
    d3 = (ni//100)%10
    d4 = (ni//1000)%10
    d5 = (ni//10000)%10
    digit_sum = d1 + d2 + d3 + d4
    if digit_sum >= a and digit_sum <= b: num_sum += ni
print(num_sum)

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())
X = int(input())

cnt = 0
for ai in range(A+1):
    for bi in range(B+1):
        for ci in range(C+1):
            total = 500*ai + 100*bi + 50*ci
            if total == X:
                cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
gohyaku = int(input())
hyaku = int(input())
goju = int(input())
inp = int(input())
count = 0

for i in range(gohyaku+1):
	for k in range(hyaku+1):
		for j in range(goju+1):
			if i * 500+ k*100+j*50 == inp:
				count += 1
print(count)

Submission status: Runtime Error

Solution code:
A, B, C ,X = map(int, [input() for i in range(4)])
count = 0

for i in range(min(X // 500, A)+1):
  Y = X - 500 * i
  for j in range(min(Y // 100, B)+1):
    Z = Y - 100 * j
    for k in range(min(Z // 50, C)+1):
      Q = Z - 50 * k
      if Q == 0:
        count += 1
      else:
        continue
print(count)

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split()))
par = list(range(n+1))
dis = [0] * (n+1)

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

def cost(x):
  # xからxの根までのコスト
  if x == par[x]:
    return 0
  return dis[x] + cost(par[x])

for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が違ってればマージ
  # 同じなら入力されたdistanceがこれまでの入力データからなる
  # 現在の木の構造から計算した数値とあっているか判断
  rootl, rootr = root(l), root(r)
  if rootl != rootr:
    # lをrにマージする
    if r == rootr:
      dis[rootl] = d - cost(l)
    else:
      dis[rootl] = d - (dist[x] - dist[y]) # (cost(l) - cost(r))
    par[rootl] = r
  else:
    # コストが同じかどうか
    if d == cost(l) - cost(r):
      continue
    else:
      print("No")
      exit()
print("Yes")

Submission status: Runtime Error

Solution code:
import itertools


def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    cnt = 0
    for n_500, n_100, n_50 in itertools.product(range(A+1), range(B+1), range(C+1)):
        if 500 * n_500 + 100 * n_100 + 50 * n_50 == X:
           cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

A = int(input())
B = int(input())
C = int(input())
X = int(input())

# A = 2
# B = 2
# C = 2
# X = 100

count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (a + b + c == 0):
                continue
            if (X == a*500 + b*100 + c*50):
                count = count + 1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np

A = input()
B = input()
C = input()
X = input()

count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (a + b + c == 0):
                break
            if (X == a*500 + b*100 + c*50):
                count = count + 1

print(count)

Submission status: Runtime Error

Solution code:
A=int(input()) 
B=int(input())
C=int(input())
X=int(input())
ans=0

for a in range(A+1):
        for b in range(B+1):
                for c in range(C+1):
                        total=500*a+100*b+50*c
                        if int(total)==X:
                                ans+=1


print(ans)

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
a -= b
print(a%c)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(0, A+1):
    xi = X - 500 * i
    if xi < 0: break
    for j in range(0, B+1):
        xj = xi - 100 * j
        if xj < 0: break
        for k in range(0, C+1):
            xk = xj - 50 * k
            # print('{} {} {} {}'.format(i,j,k,xk))
            if xk == 0: ans += 1
            if xk < 0: break

print(ans)

Submission status: Runtime Error

Solution code:
x = int(input())
A = int(input())
B = int(input()9

print((x - A) % B)

Submission status: Runtime Error

Solution code:
x = input()
A = input()
B = input()

print((x - A) % B)

Submission status: Runtime Error

Solution code:
x = (int)input()
a = (int)input()
b = (int)input()

x -= a
x -= (int)(x/b)*b

print(x)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
lrd = []

MAX = 999999

p = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    lrd.append([l-1, r-1, d, 0])
    p[l-1].append(i)
    p[r-1].append(i)

if m <= 1:
    print('Yes')
    exit()

a = [MAX for _ in range(n)]

a[lrd[0][0]] = 0
temp = [lrd[0][0]]
next = []
t = 0
s = 0
max_a = 0
min_a = 0
while 1:
    next = []
    for x in temp:
        for y in p[x]:
            if lrd[y][0] == x:
                t = lrd[y][1]
                s = a[x] + lrd[y][2]
            else:
                t = lrd[y][0]
                s = a[x] - lrd[y][2]

            lrd[y][3] = 1
            if a[t] == MAX:
                a[t] = s
                next.append(t)
            elif a[t] != s:
                print('No')
                exit()

    if len(next) == 0:
        target = 0
        i = 0
        check = 0
        for i in range(m):
            if lrd[i][3] == 0:
                target = lrd[i][0]
                check = 1
        if check == 0:
            break
        a[target] = 0
        next = [target]

    temp = [] + list(set(next))

print('Yes')

Submission status: Runtime Error

Solution code:
x=int(input())
a=int(input())
b=ibt(input())

print((x-a)%b)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for ia in range(0, min((x//500)+1,a+1)):
    y = x-500*ia
    for ib in range(0, min((y//100)+1, b+1)):
        z = y-100*ib
        if z%50 == 0 and z//50 <= c:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
print( (int(input())-int(input())) % input())

Submission status: Runtime Error

Solution code:
print((x - a) % b)

Submission status: Runtime Error

Solution code:
//#include<iostream>
//using namespace std;
//int main(){
//    int a,b,c;
//    cin>>a>>b>>c;
//    cout<<(a-b)%c<<endl;
//}
a=input()
b=input()
c=input()
print((int(a)-int(b))%int(c))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math
a = int(input())
b = int(input())
c = int(input())
x = int(input())

f = 0
for ax in range(a + 1):
   for bx in range(b + 1):
      for cx in range(c + 1):
        if (ax*500+bx*100+cx*50 == x):
          f = f +1
print(f)

Submission status: Runtime Error

Solution code:
a, b, c, x = map(int, [input() for _ in range(4)])

n_selection = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                n_selection += 1

print(n_selection)

Submission status: Runtime Error

Solution code:
coin500 = int(input())
coin100 = int(input())
coin50 = int(input())
total = int(input())

ans = 0
for i_500 in range(coin500 + 1):
    for i_100 in range(coin100 + 1):
        for i_50 in range(coin50 + 1):
            if 500 * i_500 + 100 * i_100 + 50 * i_50 == total:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
x = int(input())
y = int(input())
z = int(input())
s = int(input())
a = 0
for i in range(x+1):
    for j in range(y+1):
        for k in range(z+1):
            if 500*i+100*j+50*k == s:
                a = a+1
print(a)

Submission status: Runtime Error

Solution code:
x = int(input())
y = int(input())
z = int(input())

s = int(input())

a = 0
for i in range(x+1):
    for j in range(y+1):
        for k in range(z+1):
            if 500*x+100*y+50*z == s:
                a = a+1


print(a)

Submission status: Runtime Error

Solution code:
# 初見分からず
# 考え方：個数の組み合わせを総当たりで全パターン試せばよい！
a, b, c, x = map(int, [input() for val in range(4)])

n_pattern = 0
for i in range(a+1):#0~a+1
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                n_pattern += 1

print(n_pattern)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())

graph = [[] for _ in range(n)]


for _ in range(m):
    l, r, d = map(int, input().split())
    graph[l - 1].append(( d,r - 1))
    graph[r - 1].append((-d,l - 1))

INF = float("inf")
dist = [-INF]*n

# 未探索ノードの距離を0とする
for n in range(n):
    if dist[n] != -INF:
        continue
    else:
        stack = [n]
        dist[n] = 0
        
    # stackが空になるまで探索を繰り返す
    while len(stack):
        cur = stack.pop()
        
        # ノードcurと隣り合う未探索ノードをstackに追加
        for cost, nex_node in graph[cur]:
            if dist[nex_node] != -INF:
                continue
            else:
                dist[nex_node] = dist[cur] + cost
                stack.append(nex_node)

flag = True
for i in range(n):
    if not flag:
        break
    for d,node in graph[i]:
        if dist[node]-dist[i] != d:
            print("No")
            flag = False

if flag:
    print("Yes")

Submission status: Runtime Error

Solution code:
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)

Submission status: Runtime Error

Solution code:
def f(a,b,c,d):
    if a<0 or b<0 or c<0 or d<0:
        return 0
    if d==0:
        return 1
    return f(a-1,b,c,d-10) + f(a,b-1,c,d-2)+f(a,b,c-1,d-1)
A=int(input())
B=int(input())
C=int(input())
D=int(input())
A//=50
B//=50
C//=50
D//=50
print(f(A,B,C,D))

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count=0
for a in [a*500 for a in range(A + 1)]:
    for b in [b*100 for b in range(B + 1)]:
        for c in [c*50 for c in range(C + 1)]:
            if a + b + c == X:
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count=0
for  i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500*i + 100*j + 50*k == X:
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for c500 in range(a+1):
    for c100 in range(b+1):
        for c50 in range(c+1):
            if c500*500 + c100*100 + c50*50 == x:
                cnt += 1
        
print(cnt)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 17 23:38:43 2018

@author: ashida
"""

N=int(input())

A1 = list( map(int, input().split()))
A2 = list( map(int, input().split()))

SA1 = [0]*N
SA2 = [0]*N

SA1[0] = A1[0]
SA2[N-1] = A2[N-1]

for i in range(N-1):
    SA1[i+1] = SA1[i]+A1[i+1]
    SA2[N-2-i] = SA1[N-1-i]+A1[N-2-i]
    
ans = [0]*N

for i in range(N):
    ans[i] = SA1[i]+SA2[i]

print(max(ans))

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
if a != 0 and a != 50:
    a = a+1
if b != 0 and b != 50:
    b = b+1
if c != 0 and c != 50:
    c = c+1
for i_a in range(a):
    for j_b in range(b):
        for k_c in range(c):
            if(i_a * 500 + j_b * 100 + k_c * 50 == x):
                count = count + 1
if a == b == c == 0:
    count = count + 1
print(count)

Submission status: Runtime Error

Solution code:
X = int(input()))
A = int(input())
B = int(input())

print(X-A-B)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res=0
for  i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500*i + 100*j + 50*k == X:
                res += 1
print(res)

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
if ((A+B+C<1) or (A<0 or A>50) or (B<0 or B>50) or (C<0 or C>50) or (X<50 or X > 20000 or X%50!=0)):
    print("条件を満たしてください")
count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            Y = i*500 + j*100 + k*50
            if (X==Y):
                count = count+1

print (count)

Submission status: Runtime Error

Solution code:
l = [int(raw_input()) for _ in range(3)]
print (l[0] - l[[1]) % l[2]

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input())
print((x-a)%b)

Submission status: Runtime Error

Solution code:
y=int(input())
y1=int(input())
y2=int(input())

print((y-y1)%y2

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=int(input())
X=int(input())
n=0
for i in range(A+1):
    for j in range(B+1):
        if 0 <= (X-500*i-100*j)//50 <= C:
            n+=1
print(n)

Submission status: Runtime Error

Solution code:
a = readline()
b = readline()
c = readline()
print((a-b)%c)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort()
xi=0
i=0
x=[None for i in range(10**5)]
while i<m:
    x[l[0][0]]=0
    if l[i][0]==xi:
        if x[l[i][1]]==None:
            x[l[i][1]]=l[i][2]+x[l[i][0]]
            i+=1
        else:
            print('No')
            break
    else:
        xi+=1
if i<m:
    pass
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
    X=int(input())
    A=int(input())
    B=int(input())
    a=X-A
    b=int(a/B)
    print(a-b*B)

Submission status: Runtime Error

Solution code:
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a + 1):
    if x - (500 * i) >= 0:
        x_0 = x - (500 * i)
        for j in range(b + 1):
            if x_0 - (100 * j) >= 0:
                x_1 = x_0 - (100 * j)
                for k in range(c + 1):
                    if x_1 - (50 * k) == 0:
                        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
HIGH = [int(x) for x in input().split()]
LOW = [int(x) for x in input().split()]

def get_sum(diff_list):
    max_abs_value = max(diff_list, key=abs)
    max_abs_index = diff_list.index(max_abs_value)
    
    down_index = max_abs_index if max_abs_value >= 0 else max_abs_index - 1
    corrects = [HIGH[i] if i <= down_index else LOW[i] for i, _ in enumerate(diff_list)]
    return sum(corrects)

def main():
    first = HIGH.pop(0)
    last = LOW.pop()
    diff_list = []
    high = low = 0
    for i in range(N - 1):
        high = high + HIGH[i]
        low = low + LOW[i]
        diff_list.append(high - low)

    sum = get_sum(diff_list) if len(diff_list) != 0 else 0
    result = first + sum + last
    print(result)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
 if 500*i>x: break
 for j in range(b+1):
  if 500*i+100*j > x: break
  if x-500*i-100*j <= 50*c:
   count += 1

print(count)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
 if 500*i>x: break
 for j in range(b+1):
  if 500*i+100*j > x: break
  if x-500*i-100*j >= 50*c: break
  count += 1

print(count)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
x = int(input())/50

count = 0
for i in range(a+1):
 if 10*i>x: break
 for j in range(b+1):
  if 10*i+2*j>x: break
  for k in range(c+1):
   if 10*i+2*j+k == x:
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
A,B,C,X = [int(input()) for i in range(4)]

count = 0
for a in range(0,A+1):
    Xa  = X - 500*a
    if Xa < 0:
        break
    for b in range(0,B+1):
        Xab = Xa - 100*b
        if Xab < 0:
            break
        for c in range(0,C+1):
            if Xabc == Xab - 50*c == 0:
                count += 1
                break
                
print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(int(i) for i input().split())
b = list(int(i) for i input().split())

ans = 0
for n in range(N+1):
    ap = a[:n]
    bp = b[n-1:]
    apsum = sum(ap)
    bpsum = sum(bp)
    s = apsum +bpsum
    if s > ans:
        ans = s
print(ans)