jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        mut s: [chars; n],
    }

    let mut cs = s[0].clone();
    cs.sort();
    for i in 0..n {
        s[i].sort();

        let mut j = 0;
        let mut k = 0;
        let mut ncs = vec![];
        while j < cs.len() && k < s[i].len() {
            if cs[j] == s[i][k] {
                ncs.push(cs[j]);
                j += 1;
                k += 1;
            } else if cs[j] < s[i][k] {
                j += 1;
            } else if cs[j] > s[i][k] {
                k += 1;
            }
        }
        cs = ncs;
    }
    cs.sort();
    println!("{}", cs.into_iter().collect::<String>());
}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;
use std::char::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        s: [Chars;n],
    }

    let mut alpha: Vec<Vec<usize>> = vec![vec![0;26];n];
    for i in 0..n {
        for j in 0..s[i].len() {
            alpha[i][s[i][j] as usize - 'a' as usize] += 1;
        }
    }
    debug!(alpha);
    let mut ok: bool = true;
    let mut v = 100;
    for i in 0..26 {
        for j in 0..n {
            if alpha[j][i]!=0 {
                v = min(alpha[j][i],v);
            } else {
                ok = false;
                break;
            }
        }
        if ok {
            for k in 0..v {
                print!("{}", from_u32(i as u32 + 'a' as u32).unwrap());
            }
        }
        ok = true;
        v = 100;
    }

    print!("\n");
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let mut chars_cnt = vec![[0; 26]; n];
    for i in 0..n {
        let vc: Vec<char> = s[i].chars().collect();
        for j in 0..vc.len() {
            chars_cnt[i][(vc[j] as u8 - b'a') as usize] += 1;
        }
    }

    for i in 0..26 {
        let mut current_min = 50 * 50 + 1;
        for j in 0..n {
            current_min = current_min.min(chars_cnt[j][i]);
            if current_min == 0 {
                continue;
            }
        }

        for _ in 0..current_min {
            print!("{}", (b'a' + i as u8) as char);
        }
    }
    println!("");
}
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const ss = input.slice(1);
  let prevMap = {};
  let map = {};
  for (let i = 0; i < n; i++) {
    map = {};
    const s = ss[i];
    for (let j = 0; j < s.length; j++) {
      const char = s[j];
      if (i === 0) {
        map[char] = map[char] ? map[char] + 1 : 1;
        continue;
      }
      if (!prevMap[char]) continue;
      prevMap[char]--;
      map[char] = map[char] ? map[char] + 1 : 1;
    }
    prevMap = Object.assign({}, map);
  }
  const keys = Object.keys(map).sort();
  let result = "";
  for (const key of keys) {
    result += Array(map[key]).fill(key).join("");
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
A,B=map(int,input().split())
print("Yay!" if A<=8 and B<=8 else ":(")
//  [python]
a,b=map(int,input().split())
print('Yay!' if a<9 and b<9 else ':(')
//  [python]
A,B = map(int,input().split())
if A <=8  and B <= 8:
    print("Yay!")
else:
    print(":(")
//  [python]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools
import math


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


A, B = map(lambda x: int(x), input().split())
cake = range(1, 17)

pattern_A = [pattern for pattern in itertools.combinations(cake, A)]
# pattern_B = [pattern for pattern in itertools.combinations(range(len(cake)-A), B)]
iter_cakeB = []
for pat in pattern_A:
    cake1 = list(range(1, 17))
    for i in pat:
        cake1.remove(i)
    iter_cakeB.append(cake1)


pattern_B = [[[] for _ in range(combinations_count(len(cake)-A, B))]
             for i in range(len(iter_cakeB))]

for i, cake_put_by_A in enumerate(iter_cakeB):
    for j, pattern in enumerate(itertools.combinations(cake_put_by_A, B)):
        pattern_B[i][j] = pattern
# print(len(pattern_B))


flag = False
for cnt, patA in enumerate(pattern_A):
    a = [patA[i + 1] - patA[i] for i in range(len(patA)) if i < len(patA)-1]
    if 1 in a:
        continue
    else:
        for patB in pattern_B[cnt]:
            b = [patB[i + 1] - patB[i] for i in range(len(patB)) if i < len(patB)-1]
            if 1 in b:
                continue
            else:
                print('Yay!')
                flag = True
                break
    if flag:
        break

if cnt == len(pattern_A)-1:
    print(':(')
//  [python]
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

#a =int(input())
#b =int(input())
a,b = map(int, input().split())


if a <= 8 and b <= 8 :
    print("Yay!")
else:
    print(":(")
//  [python]
a,b=map(int,input().split())
print("Yay!" if 9>max(a,b) else ":(")
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNextInt()) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                System.out.println((a<9&&b<9)?"Yay!":":(");
            }
        }
    }
}
//  [java]


import java.util.Scanner;

// ABC100 at 2018/06/16

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveA();
    }

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A > 8 || B > 8) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}
//  [java]
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A<=8 && B<=8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}
}
//  [cpp]
#include<stdio.h>
int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a <= 8 && b <= 8)
        printf("Yay!\n");
    else
        printf(":(\n");
    return 0;
}
//  [cpp]
#include <cstdio>
using namespace std;
int main(){
    int A,B;
    scanf("%d %d",&A,&B);
    if(A>=9){
        printf(":(\n");
    }
    else if(B>=9){
        printf(":(\n");
    }
    else{
        printf("Yay!\n");
    }
    return 0;
}
//  [cpp]
#include<cstdio>
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a>8||b>8)printf(":(");
	else printf("Yay!");
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << (a <= 8 and b <= 8 ? "Yay!" : ":(") << '\n';
  return 0;
}
//  [cpp]
//AcFreak

#include<bits/stdc++.h>
#define  lint long long int 
#define MOD (lint )(1e9+7)
using namespace std;

int main()
{
      int a,b;
      cin>>a>>b;
      
      if(a>8 ||b>8)
      cout<<":("<<endl;
      else
      cout<<"Yay!"<<endl;
      return 0;
}
//  [cpp]
#include <iostream>

using namespace std;
int main(void) {
    int a, b;
    cin >> a >> b;
    if(a<=8 && b<=8)
        cout << "Yay!\n";
    else
        cout << ":(\n";
}
//  [c]
#include <stdio.h>

int main()
{
        int A = 0;
        int B = 0;

        scanf("%d %d", &A, &B);

        if(A <= 8 && B <= 8)
        {
                printf("Yay!\n");
        }
        else
        {
                printf(":(\n");
        }

        return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
int main(){
    int A,B;
    

    scanf("%d",&A);
        scanf("%d",&B);


      if (A<=8 && B<=8) printf("Yay!\n");
       else  printf(":(\n");
   
    return 0;
    
}
//  [c]
#include <stdio.h>
int main(void){
int a,b;
scanf("%d",&a);
scanf("%d",&b);
if(a < 9 && b < 9){
printf("Yay!");
}else{
printf(":(");
}
return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<=8 && b<=8){
    printf("Yay!\n");
  }else{
    printf(":(\n");
  }
  return 0;
}
//  [c]
#include <stdio.h>

int main()
{
	int A, B;
	scanf("%d %d", &A, &B);
	if (A <= 8 && B <= 8) printf("Yay!\n");
	else printf(":(\n");
	fflush(stdout);
	return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
		if(a<9 && b<9) printf("Yay!");
		else printf(":(");
	return 0;
}
//  [javascript]
function Main(input) {
	var inputs = input.split(" ");
	var a = inputs[0];
	var b = inputs[1];

	var valid = true;
	if (a > 8 || b > 8) {
		valid = false;
	}

	console.log(valid ? "Yay!" : ":(");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.split(' ')
  var A = parseInt(input[0])
  var B = parseInt(input[1])

  if (A <= 8 && B <= 8) {
    console.log('Yay!')
  } else {
    console.log(':(')
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
A = l[0]
B = l[1]
console.log(A <= 8 && B <= 8 ? 'Yay!' : ':(')
//  [javascript]
function main(input) {
    var line = input.split(' ');
    var A = line[0];
    var B = line[1];
    var answer = A <= 8 && B <= 8 ? 'Yay!' : ':(';
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input){

input=input.split(" ");
inA=parseInt(input[0]);
inB=parseInt(input[1]);

answerY = "Yay!";
answerN = ":(";

answer = answerY;
if (inA > 8 || inB > 8 ) {
    answer = answerN;
}

console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
/*
declare function require(id:string);
const {stdin} = require('process');
let input = "";
stdin.on('data', x => {input += x});
stdin.on('end', () => {
    let [a, b] = input.split(' ')
        .map(x=>x.trim()).map(x=>parseInt(x));
    if (8 < a || 8 < b) {
        console.log(':(');
    }
    else {
        console.log('Yay!');
    }
});
*/

var stdin = require('process').stdin;
var input = "";
stdin.on('data', function (x) { input += x; });
stdin.on('end', function () {
    var _a = input.split(' ')
        .map(function (x) { return x.trim(); }).map(function (x) { return parseInt(x); }), a = _a[0], b = _a[1];
    if (8 < a || 8 < b) {
        console.log(':(');
    }
    else {
        console.log('Yay!');
    }
});
//  [go]
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a <= 8 && b <= 8 {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}
//  [go]
package main

import (
    . "fmt"
)

func main() {
    var a, b int
    Scanf("%d %d", &a, &b)

    if a <= 8 && b <= 8 {
        Println("Yay!")
    } else {
        Println(":(")
    }
}
//  [go]
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a > 8 || b > 8 {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}
//  [go]
package main
 
import (
  "fmt"
)
 
func main() {
  var a, b int
  fmt.Scanf("%d %d", &a, &b)
  
  ans := "Yay!"
  if a > 8 {
    ans = ":("
  }
  if b > 8 {
    ans = ":("
  }
  
  fmt.Printf("%s\n", ans)
}
//  [go]
package main

import (
	"fmt"
)

func main() {

	var a, b int
	fmt.Scan(&a, &b)

	if a <= 8 && b <= 8 {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}
//  [ruby]
A = gets.split(' ').map(&:to_i)

if A[0] > 8 || A[1] > 8
    puts(':(');
else
    puts('Yay!');
end
//  [ruby]
a,b=gets.split.map(&:to_i);puts a<9&&b<9 ? "Yay!" : ":("
//  [ruby]
a,b=gets.split.map(&:to_i)
if a>8 or b>8 then
  puts ':('
else 
  puts 'Yay!'
end
//  [ruby]
puts`dd`[/1\d|9/]?":(": :Yay!
//  [ruby]
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
a,b=gi
puts a <= 8 && b <= 8 ? 'Yay!':':('
//  [ruby]
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

A,B=gets.chomp.split(' ').map{|n| n.to_i}

if(A + B <= 16 && A <= 8 && B <= 8)
	puts "Yay!"
else
	puts ":("
end
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	if a > 8 || b > 8 {
		println!(":(");
	}else{
		println!("Yay!");
	}
}
//  [rust]
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();
    let mut it = input.trim().split_whitespace();
    let a:u8 = it.next().unwrap().parse().unwrap();
    let b:u8 = it.next().unwrap().parse().unwrap();
    if a <= 8 && b <= 8 {println!("Yay!")} else {println!(":(")}
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    if a <= 8 && b <= 8 {
        println!("Yay!");
    } else {
        println!(":(")
    }
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    }
    println!("{}",if a<9&&b<9 {"Yay!"}else{":("})
}
//  [rust]
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		a: usize,
		b: usize,
	}

	if a <= 8 && b <= 8 {
		println!("Yay!");
	}
	else {
		println!(":(");
	}
}
//  [rust]
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    if a <= 8 && b <= 8 {
        "Yay!".to_string()
    } else {
        ":(".to_string()
    }
}
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(i[0]<9&&i[1]<9 ?"Yay!":":(")
//  [typescript]
const main = (input) => {
  input = input.trim();
  input = input.split(' ');
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  
  if(a<9&&b<9){
    console.log("Yay!");
  }else{
    console.log(":(");
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const ab = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const f = ab.filter(e => 8 >= e)

console.log(f.length === 2 ? 'Yay!' : ':(')
//  [typescript]
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	const [left, right] = input[0].split(" ");
        if (+left <= 8 && right <= 8) {
          console.log('Yay!')
        } else {
          console.log(':(')
        }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B] = input[0].map(Number);

  return A <= 8 && B <= 8 ? "Yay!" : ":(";
};

console.log(main(read()));
//  [typescript]
import {stdin} from 'process';
let input = "";
stdin.on('data', x => {input += x});
stdin.on('end', () => {
    let [a, b] = input.split(' ')
        .map(x=>x.trim()).map(x=>parseInt(x));
    if (8 < a || 8 < b) {
        console.log(':(');
    }
    else {
        console.log('Yay!');
    }
});
//  [typescript]
const main = (input: void) => {
  const A: number = input.split(' ')[0];
  const B: number = input.split(' ')[1];

  if (A > 8 || B > 8 ) {
    console.log(":(");
  } else {
    console.log("Yay!");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for k in range(a+1):
  if x-500*k < 0:
    break
  for j in range(b+1):
    if x-500*k-100*j < 0:
      break
    if (x-500*k-100*j)//50 > c:
      continue
    count += 1
print(count)
//  [python]
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    l = x - i*500
    if l == 0:
        count += 1
        break
    if l < 0:
        break
    for j in range(b+1):
        if (l - j * 100) / 50 <= c and (l - j*100) >= 0:
            count += 1
print(str(count))
//  [python]
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(X//500+1):
    #500円玉が足りなければ終了
    if A<i:
        break
    #500円玉をi枚使った残りの金額(X%(500*i)円)を、100円玉と50円玉に割り振る
    for j in range((X-500*i)//100+1):
        if B<j:
            break
        if C>=(X-(500*i)-(100*j))//50:
            ans+=1
print(ans)
//  [python]
from itertools import product
import numpy as np
a = int(input())
b = int(input())
c = int(input())
x = int(input())

a = sum([sum(el)==x for el in 
               product(
                   np.arange(a+1)*500, np.arange(b+1)*100, np.arange(c+1)*50
               )])
print(a)
//  [python]
import numpy as np
import itertools
# coin tanka
tanka = np.array([500, 100, 50])
count = 0
A = int(input())
B = int(input())
C = int(input())
X = int(input())

# each pattern
a = [a for a in range(A+1)]
b = [b for b in range(B+1)]
c = [c for c in range(C+1)]

# all patterns
itr_res = np.array(list(itertools.product(a, b, c)))

# remove 0 0 0  pattern
itr_res = itr_res[1:]

for r in itr_res:
    # seach for X  with total price
    if X == sum(r * tanka):
        count += 1
print(count)
//  [python]
import numpy as np
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
coin = np.array([500,100,50])
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a + b + c == 0:
        continue
      else:
        if X == coin.dot(np.array([a,b,c])):
            count += 1
print(count)
//  [java]
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int A, B, C, X;
	int count = 0;

	Main(BufferedReader in) throws IOException {
		A = Integer.parseInt(in.readLine());
		B = Integer.parseInt(in.readLine());
		C = Integer.parseInt(in.readLine());
		X = Integer.parseInt(in.readLine());
	}

	void calc() {
		for (int i = 0; i <= A; ++i) {
			if (500 * i <= X) {
				int remain0 = X - 500 * i;
				for (int j = 0; j <= B; ++j) {
					if (100 * j <= remain0) {
						int remain1 = remain0 - 100 * j;
						if (remain1 % 50 == 0 && remain1 / 50 <= C) {
							++count;
						}
					}
				}
			}
		}
		System.out.println(count);

	}

	void showResult() {
	}
}
//  [java]
import java.io.*;

public class Main{
  public static void main(String[] arcs)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int[] args = new int[4];
    for(int i= 0; i<3; i++){
      args[i] = Integer.parseInt(br.readLine());
    }
    args[3]=Integer.parseInt(br.readLine())/50;
    
    int c2 = 0;
    int c10 = 0;
    int counter = 0;
    
    if(args[0]*10 + args[1]*2 + args[2] >= args[3]){
        for(c10 = 0; c10 <= args[0]; c10++){
            if(c10 * 10 > args[3]){
                break;
            }
            else if(c10*10 + args[1]*2 + args[2]<args[3]){
                //何もしない
            }
            else{
                for(c2 = 0;c2<=args[1];c2++){
                    if(c10*10 + c2*2 > args[3]){
                        break;
                    }
                    else if(c10*10 + c2*2 + args[2] <args[3]){
                        //何もしない
                    }else{
                        counter++;
                    }
                }
            }
        }
    }
    System.out.println(counter);
  }
}
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int x = scanner.nextInt();
			System.out.println(IntStream.rangeClosed(0, a)
					.map(i -> (int) IntStream.rangeClosed(0, b)
							.filter(j -> (x >= (i * 500 + j * 100)) && (x <= (i * 500 + j * 100 + c * 50))).count())
					.sum());
		}
	}
}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int count = 0;
        for (int i = 0; i <= 50; i++) {
            for (int j = 0; j <= 50; j++) {
                for(int k = 0; k <= 50; k++){
                    if (500*i + 100*j + 50*k == x && i <= a && j <= b && k <= c) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}
//  [java]
import java.util.*;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int n = sc.nextInt();

        int count = 0;
        for(int i = 0; i <= a; i++){
            for(int j = 0; j <= b; j++){
                for(int k = 0; k <= c; k++){
                    if(i*500 + j*100 + k*50 == n){
                        count++;
                    }
                }
            }
        }

        System.out.println(count);
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(){
  int A,B,C,X,comb = 0;
  cin >> A >> B >> C >> X;
  for (int i = 0;i <= A;i++){
    for (int l = 0;l <= B;l++){
      for (int m = 0;m <= C;m++)
        if (500*i + 100*l + 50*m == X) comb++;
    }
  }
  cout << comb << endl;
}
//  [cpp]
#include <iostream>
using namespace std;

int A, B, C, X;

int main(){
  cin >> A >> B >> C >> X;
 
  int res = 0;
  
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        if(X == 500 * i + 100 * j + 50 * k){
          res ++;
        }
      }
    }
  }
  
  cout << res << endl;
}
//  [cpp]
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    REP(i, A + 1)
    REP(j, B + 1) REP(k, C + 1) if (X == i * 500 + j * 100 + k * 50) ans++;

    cout << ans << endl;

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int num[4],x,dp[401][51][51][51],ans;
int main()
{
	for(int i=3;i>=1;i--)
		scanf("%d",&num[i]);
	cin>>x;
	x/=50;
	dp[0][0][0][0]=1;
	for(int i=1;i<=x;i++)
		for(int j=0;j<=num[1];j++)
			for(int k=0;k<=num[2];k++)
				for(int l=0;l<=num[3];l++)	
				{
					if(j>=1)
						dp[i][j][k][l]=dp[i][j][k][l]?dp[i][j][k][l]*dp[i-1][j-1][k][l]:dp[i-1][j-1][k][l];
					if(i>=2&&k>=1)
						dp[i][j][k][l]=dp[i][j][k][l]?dp[i][j][k][l]*dp[i-2][j][k-1][l]:dp[i-2][j][k-1][l];
					if(i>=10&&l>=1)
						dp[i][j][k][l]=dp[i][j][k][l]?dp[i][j][k][l]*dp[i-10][j][k][l-1]:dp[i-10][j][k][l-1];
				}
	for(int j=0;j<=num[1];j++)
		for(int k=0;k<=num[2];k++)
			for(int l=0;l<=num[3];l++)
				ans+=dp[x][j][k][l];
	cout<<ans<<endl;
	return 0;
}
//  [cpp]
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
#define INF 1<<30

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                cerr << i * 500 + j * 100 + k * 50 << endl;
                if (i * 500 + j * 100 + k * 50 == x) ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void)
{
  
  int a,b,c,x, k;
  scanf("%d%d%d%d",&a,&b,&c,&x);
  
  int answer = 0;
  
  for(int i = 0; i <= x/500; i++){
    for(int j = 0; j<= (x - 500 * i) / 100; j ++){

      k = x - 500 * i - 100 * j;
      
      if(k % 50 == 0 && k/50 <= c && j<= b && i <= a) {
        answer++;
        
        }
      
      }
    }
  
  

  printf("%d",answer);
  
  return 0;
}
//  [c]
#include <stdio.h>
int main(void){
  int a, b, c, x, i, j, fif, count;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  for(i=0;i<=x/500;i++)
    for(j=0;j<=(x-500*i)/100;j++){
      fif = x-500*i-100*j;
      count += fif % 50 == 0 && c >= fif/50 && a >=i && b >=j;
    }
  printf("%d", count);
  return 0;
}
//  [c]
#include <stdio.h>

int main(void){
    int A, B, C, X;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &X);

    int count = 0;
    for (int a=0; a<=A; a++) {
        for (int b=0; b<=B; b++) {
            for (int c=0; c<=C; c++) {
                if (500*a+100*b+50*c == X) {
                    count++;
                }
            }
        }
    }
    printf("%d\n", count);

    return 0;
}
//  [c]
#include<stdio.h>

int main(void){
    int a,b,c,x,i,j,k,cnt=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                if(i*500+j*100+k*50==x){
                    ++cnt;
                }
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}
//  [c]

#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる
#define _abs(x) ((x)<0 ? -(x) : (x))
#define _MAX 200000
#pragma endregion

// ABC087 B - Coins

int main(void) {
	int a, b, c, x, cnt = 0;

	scanf("%d %d %d %d", &a, &b, &c, &x);

	x /= 50;
	a = (x/10 < a) ? x/10: a;
	int tmp;
	for (int i = 0; i <= a; i++) {
		tmp = (x - i * 10)/2;
		b = (tmp < b) ? tmp : b;
		for (int j = 0; j <= b; j++) 
			if (x - (i * 10 + j * 2) <= c) 	cnt++;
	}

	printf("%d\n", cnt);
	return 0;
}
//  [c]
#include <stdio.h>

int main(void){
    int a, b, c, x;

    scanf("%d %d %d %d", &a, &b, &c, &x);

    int cnt = 0;
    for(int i = 0;i <= a;++i){
        for(int j = 0;j <= b;++j){
            for(int k = 0;k <= c;++k){
                if((500 * i) + (100 * j) + (50 * k) == x) cnt++;
            }
        }
    }

    printf("%d\n", cnt);

    return 0;
}
//  [javascript]
function main(input){
  var nums = input.split('\n');
  var A = parseInt(nums[0],10);
  var B = parseInt(nums[1],10);
  var C = parseInt(nums[2],10);
  var X = parseInt(nums[3],10);
  var count = 0;
  for(var i=0 ; i<=A; i++){
	for(var j=0; j<=B; j++){
      for(var k=0; k<=C; k++){
        var sum = (500 * i) + (100 * j) + (50 * k);
        if(sum == X){
          count++;
        }
      }
    }
  }
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var A = Number(line[0]);
	var B = Number(line[1]);
	var C = Number(line[2]);
	var X = Number(line[3])/50;

	// 10*A + 2*B + C = X
	var ans = 0;
	for(var a = 0; 10*a <= X && a <= A; a++){
		for(var b = 0; 10*a + 2*b <= X && b <= B; b++){
			if(10*a + 2*b + C >= X) ans++;
		}
	}

	console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	var args = input.split("\n");
	var A = parseInt(args[0],10);
	var B = parseInt(args[1],10);
	var C = parseInt(args[2],10);
	var X = parseInt(args[3],10);
	var count = 0;

	for(var i = 0 ; i <= A ; i++){//500
		for(var j = 0 ; j <= B ; j++){//100
			for(var k = 0 ; k <= C ; k++){//50
				var sum = 500 * i + 100 * j + 50 * k;
				if(sum == X) count++;
			}
		}
	}
	//出力
	console.log(count);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function main(input) {
    const args = input.split('\n');
    const A = parseInt(args[0], 10),
          B = parseInt(args[1], 10),
          C = parseInt(args[2], 10),
          X = parseInt(args[3], 10);

    let count = 0;

    for (let a = 0; a <= A; ++a) {
        for (let b = 0; b <= B; ++b) {
            for (let c = 0; c <= C; ++c) {
                if ((a * 500) + (b * 100) + (c * 50) === X) count++;
            }
        }
    }
    console.log(count);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  "use strict";
  const lines = input.split("\n");
  const line1 = lines[0].split(" ");
  const line2 = lines[1].split(" ");
  const line3 = lines[2].split(" ");
  const line4 = lines[3].split(" ");

  const a = parseInt(line1[0], 10);
  const b = parseInt(line2[0], 10);
  const c = parseInt(line3[0], 10);
  const x = parseInt(line4[0], 10);

  var count = 0
  for (var i = 0; i <= a; i++) {
    for (var j = 0; j <= b; j++) {
      for (var k = 0; k <= c; k++) {
        if (i*500 + j*100 + k*50 === x) {
          count++

        }

      }
    }
  }
  console.log(count)
}
// Exec
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &c)
	fmt.Scanf("%d", &x)

	cnt := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500 * i + 100 * j + 50 * k == x {
					cnt += 1
				}
			}
		}
	}

	fmt.Println(cnt)
}
//  [go]
package main

import (
	"fmt"
)

// go run ./main.go < in

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)

	count, sumA, sumB, sumC := 0, 0, 0, 0
	// sum := 0
	for i := 0; i <= a; i++ {
		sumA = 500 * i
		for j := 0; j <= b; j++ {
			sumB = 100 * j
			for k := 0; k <= c; k++ {
				sumC = 50 * k
				if sumA+sumB+sumC == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}
//  [go]
package main

import (
        "fmt"
)

func solution(a, b, c, x int) int {
        out := 0
        for i := 0; i <= a; i++ {
                for j := 0; j <= b; j++ {
                        for k := 0; k <= c; k++ {
                                if x == 500*i+100*j+50*k {
                                        out++
                                }
                        }
                }
        }
        return out
}

func main() {
        var a, b, c, x int
        fmt.Scan(&a, &b, &c, &x)
        fmt.Println(solution(a, b, c, x))
}
//  [go]
package main

import (
	"fmt"
)

var debug = false

func main() {
	var a, b, c, x int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &c)
	fmt.Scanf("%d", &x)
	res := GetAnswer(a, b, c, x)
	fmt.Printf("%v\n", res)
}

// GetAnswer ...
func GetAnswer(a, b, c, x int) int {
	prt("inputs: a:%d, b:%d, c:%d, x:%d\n", a, b, c, x)
	result := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				total := (500 * i) + (100 * j) + (50 * k)
				prt("loop count a:%d b:%d c:%d total:%d\n", i, j, k, total)
				if total == x {
					result++
				}
			}
		}
	}
	prt("%v\n", result)
	return result
}

func prt(format string, inputs ...interface{}) {
	if debug {
		fmt.Printf(format, inputs...)
	}
}
//  [go]
package main

import (
	"fmt"
)

var debug = false

func main() {
	var a, b, c, x int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &c)
	fmt.Scanf("%d", &x)
	res := GetAnswer(a, b, c, x)
	fmt.Printf("%v\n", res)
}

// GetAnswer ...
func GetAnswer(a, b, c, x int) int {
	prt("inputs: a:%d, b:%d, c:%d, x:%d\n", a, b, c, x)
	a500 := a
	if 500*a > x {
		a500 = x / 500
	}
	b100 := b
	if 100*b > x {
		b100 = x / 100
	}
	c50 := c
	if 50*c > x {
		c50 = x / 50
	}
	result := 0
	for i := 0; i <= a500; i++ {
		for j := 0; j <= b100; j++ {
			for k := 0; k <= c50; k++ {
				total := (500 * i) + (100 * j) + (50 * k)
				prt("loop count a:%d b:%d c:%d total:%d\n", i, j, k, total)
				if total == x {
					result++
				}
			}
		}
	}
	prt("%v\n", result)
	return result
}

func prt(format string, inputs ...interface{}) {
	if debug {
		fmt.Printf(format, inputs...)
	}
}
//  [ruby]
eval"#{$,='0.upto(%d){|'}a|#$,b|%d<(c=%d/50-10*a-2*b)||c<0||$.+=1}}"%[*$<];p$.-4
//  [ruby]
num500 = gets.chomp.to_i
num100 = gets.chomp.to_i
num50 = gets.chomp.to_i
x = gets.chomp.to_i

def coins(x,num500,num100,num50)
  if num500 == 0 or x < 500 then
    if num100 == 0 or x < 100 then
      if x % 50 != 0 or x / 50 > num50 then
        return 0
      else
        return 1
      end
    else
      return coins(x-100,0,num100-1,num50) + coins(x,0,0,num50)
    end
  else
     return coins(x-500,num500-1,num100,num50) + coins(x,0,num100,num50)
  end
end

puts coins(x,num500,num100,num50)
//  [ruby]
x500=gets.to_i
x100=gets.to_i
x50=gets.to_i
x=gets.to_i
n=0
i=0
while i<=x500&&x>=i*500
  j=0
while j<=x100&&x>=i*500+j*100
if (x-i*500-j*100)/50<=x50
n+=1
end
  j+=1
end
i +=1
end
p n
//  [ruby]
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i
count = 0
ans = 0
(0..(x/500)+1).each do |i|
    (0..(x/100)+1).each do |j|
        (0..(x/50)+1).each do |k|
            ans = 500 * i + 100 * j + 50 * k
            if ans.to_s == x.to_s && i <= a && j <= b && k <= c
                count += 1
            end
        end
    end
end
puts count
//  [ruby]
A,B,C,X=readlines.map &:to_i
M = X + 10
a = [0] * M
(A+1).times {|i| a[500*i] = 1 if 500*i<M}
b = [0] * M
(B+1).times {|i| M.times {|j| b[j+i*100] += a[j] if j+i*100<M}}
c = [0] * M
(C+1).times {|i| M.times {|j| c[j+i*50] += b[j] if j+i*50<M}}
p c[X]
//  [ruby]
# frozen_string_literal: true

a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

ary_500 = (0..a).to_a.map { |e| e * 500 }
ary_100 = (0..b).to_a.map { |e| e * 100 }
ary_50 = (0..c).to_a.map { |e| e * 50 }

ary_p = ary_500.product(ary_100).product(ary_50).map(&:flatten)

puts ary_p.select { |ary| ary.inject(:+) == x }.size
//  [rust]
use std::collections::HashMap;
use std::num;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        x: i64,
    }
    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            let target = x - 500 * i - 100 * j;
            if target < 0 {
                break;
            }
            if target % 50 == 0 && target / 50 <= c {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const A_VALUE: usize = 500;
const B_VALUE: usize = 100;
const C_VALUE: usize = 50;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }

    let mut count = 0;

    for i in 0..(a + 1) {
        for j in 0..(b + 1) {
            for k in 0..(c + 1) {
                if (A_VALUE * i + B_VALUE * j + C_VALUE * k) == x {
                    count += 1;
                }
            }
        }
    }

    println!("{}", count);
}
//  [rust]
use std::io::*;
use std::str::*;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let a: i32 = buf.trim_right().parse().unwrap();

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let b: i32 = buf.trim_right().parse().unwrap();

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let c: i32 = buf.trim_right().parse().unwrap();

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let x: i32 = buf.trim_right().parse().unwrap();
   
    let mut count = 0;

    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                let sum = 500 * i + 100 * j + 50 * k;
                if sum == x {
                    count += 1;
                }
            }
        }
    }

    let out = stdout();
    let mut out = out.lock();
    writeln!(out, "{}\n", count);

}
//  [rust]
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::Ordering;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_cols<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn count(coins: &HashMap<u32, u32>, total: u32) -> i32 {
    if total == 0 {
        return 1;
    }

    if coins.is_empty() {
        return 0;
    }

    let (next_coin, max) = coins.iter().nth(0).unwrap();

    (0..max + 1)
        .take_while(|n| n * next_coin <= total)
        .fold(0, |total_count, n| {
            let mut next_coins = coins.clone();
            next_coins.remove(next_coin);
            total_count + count(&next_coins, total - n * next_coin)
        })
}

fn main() {
    let n500 = read::<u32>();
    let n100 = read::<u32>();
    let n50 = read::<u32>();
    let price = read::<u32>();

    let mut coins = HashMap::new();
    coins.insert(500, n500);
    coins.insert(100, n100);
    coins.insert(50, n50);

    println!("{}", count(&coins, price));
}
//  [rust]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		a: usize,
		b: usize,
		c: usize,
		x: usize,
	}

	let mut ans = 0;
	for i in 0..=a {
		for j in 0..=b {
			for k in 0..=c {
				if 500*i + 100*j + 50*k == x {
					ans += 1;
				}
				if 500*i + 100*j + 50*k > x {
					continue;
				}
			}
		}
	}
	println!("{}", ans);
}
//  [swift]
import Foundation
let A = Int(readLine()!)!
let B = Int(readLine()!)!
let C = Int(readLine()!)!
let X = Int(readLine()!)!
var count = 0
//500A + 100B + 50C = X を満たす(A,B,C)

for a in 0 ... A {
    if a*500 > X {
        break
    }
    for b in 0 ... B {
        if 500*a + 100*b > X {
            break
        }
        for c in 0 ... C {
            if 500*a + 100*b + 50*c == X {
                count += 1
            }
        }
    }
}
print(count)