akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i > 0; i++)
            {
                int x = int.Parse(Console.ReadLine());
                if (x == 0)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Case {0}: {1}", i, x);
                }
            }
        }
    }
}



Measured memory_bytes: 20020
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int x;
  cin >> x;
  for (int i = -118; i <= 119; i++) {
    for (int j = -119; j <= 118; j++) {
      if (x == pow(i, 5) - pow(j, 5)) {
        cout << i << " " << j;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4120
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#define LL long long
#include<stack>
using namespace std;
int const maxn=1e6+10;
LL const inf=(LL)1e18;
struct bkn{
    int next,to;
    LL w;
}e[maxn*2],e2[maxn*2];
stack<int> st;
int tot=1,head[maxn],vis[maxn],dfn[maxn],low[maxn],cnt,scc,h[maxn];
int col[maxn],q[maxn];
LL dp[maxn],sum[maxn];
int n,m;
void add(int hg[],bkn e[],int x,int y,LL w){
    e[tot].to=y,e[tot].next=hg[x],e[tot].w=w,hg[x]=tot++;
}
void tarjan(int x){
    low[x]=dfn[x]=++cnt;
    st.push(x);
    vis[x]=1;
    for (int i=head[x];i;i=e[i].next){
        int y=e[i].to;
        if (!dfn[y]) tarjan(y),low[x]=min(low[x],low[y]);
        else if (vis[y]) low[x]=min(low[x],low[y]);
    }
    if (low[x]==dfn[x]){
        scc++;
        while (1) {
            int y=st.top();
            st.pop();
            vis[y]=0;
            col[y]=scc;
            if (x==y) break;
        }
    }
}
void dfs(int x){
    vis[x]=1;
    for (int i=h[x];i;i=e2[i].next){
        int y=e2[i].to;
        if (!vis[y]) dfs(y);
    }
    q[++cnt]=x;
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++){
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);
        add(head,e,y,x,w);
    }
    for (int i=1;i<=n;i++){
        if (!dfn[i]) tarjan(i);
    }
    tot=1;
    for (int x=1;x<=n;x++){
        for (int i=head[x];i;i=e[i].next){
            int y=e[i].to;
            if (col[y]==col[x]) {
                if (e[i].w!=0) {
                    cout<<"No"<<endl;
                    return 0;
                }
            }
            else add(h,e2,col[x],col[y],e[i].w);
        }
    }
    cnt=0;
    for (int i=1;i<=scc;i++){
        if (!vis[i]) dfs(i);
    }
    for (int i=1;i<=cnt;i++){
        int x=q[i];
        for (int j=h[x];j;j=e2[j].next){
            int y=e2[j].to;
            if (!dp[x]) dp[x]=dp[y]+e2[j].w;
            else if (dp[x]!=dp[y]+e2[j].w) {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}



Measured memory_bytes: 30464
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cassert>
#include<vector>
#include<algorithm>
using namespace std;
const int N=200005,M=305;
const int INF=1000000001;
int n,T;
struct Node
{
	int a,b;
}s[N];
long long f[N][M];
vector<int>d;
long long sum[N];
int main()
{
	scanf("%d%d",&n,&T);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&s[i].a,&s[i].b);
		if(s[i].a==0)
		{
			d.push_back(s[i].b);
			n--,i--;
		}
	}
	sort(s+1,s+n+1,[](const Node &x,const Node &y){return (double)x.a/(x.b+1)>(double)y.a/(y.b+1);});
	memset(f,63,sizeof(f));
	f[0][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=min(i,300);j++)
		{
			if(f[i-1][j]<INF) f[i][j]=f[i-1][j];
			if(j>=1)
			{
				if(f[i-1][j-1]<INF) f[i][j]=min(f[i][j],f[i-1][j-1]+(1+1LL*s[i].a*(f[i-1][j-1]+1)+s[i].b));
			}
		}
	sort(d.begin(),d.end());
	for(int i=1;i<=d.size();i++)
		sum[i]=sum[i-1]+d[i-1]+1;
	int res=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=min(i,300);j++)
			if(f[i][j]<=T)
			{
				int t=T-f[i][j];
				int l=1,r=d.size(),ans=0;
				while(l<=r)
				{
					int mid=(l+r)/2;
					auto check=[=](int x){return sum[x]<=t;};
					if(check(mid)) ans=mid,l=mid+1;
					else r=mid-1;
				}
				res=max(res,j+ans);
			}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 482180
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    a = next_int()
    b = next_int()
    c = next_int()

    ans = 0
    dic = []

    flg = False
    while True:
        abc = sorted([a, b, c])
        if abc in dic:
            ans = -1
        for v in abc:
            if v % 2 != 0:
                flg = True
        if flg or ans < 0:
            break
        ans += 1
        dic += [abc]
        x = b // 2 + c // 2
        y = c // 2 + a // 2
        z = a // 2 + b // 2
        a, b, c = x, y, z

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, m, c, ans;
int a[21][21],b[21];
signed main() {
    cin >> n >> m >> c;
    for (int i=0;i<m;i++) cin >> b[i];
    for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) cin >> a[i][j];
    }
    for (int i=0;i<n;i++) {
        int sum = c;
        for (int j=0;j<m;j++) {
            sum += a[i][j]*b[j];
        }
        if (sum > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
for i in range(n):
    if a[i] % 2 == 0:
        ans += a[i] // 2
    else:
        if i != n - 1 and a[i + 1] > 0:
            a[i + 1] -= 1
            a[i] += 1
        ans += a[i] // 2
print(ans)

Measured memory_bytes: 7072
// Problem B

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;

ll a, b, va, vb, t;

int main() {
  cin >> a >> va >> b >> vb >> t;
  ll sa = va*t;
  ll sb = vb*t;
  
  if (sa >= abs(a-b) + sb) cout << "YES\n";
  else cout << "NO\n"; 
  
  return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUGLOCAL
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,-1,1,-1,0};
const int dy[]={0,0,1,-1,1,-1,-1,1,0};

string C(string mes){
	return mes.substr(1,sz(mes)-1)+mes.substr(0,1);
}

string J(string mes){
	return mes.substr(sz(mes)-1,1)+mes.substr(0,sz(mes)-1);
}

string E(string mes){
	if(sz(mes)%2==0)return mes.substr(sz(mes)/2,sz(mes)/2)+mes.substr(0,sz(mes)/2);
	else return mes.substr(sz(mes)/2+1,sz(mes)/2)+mes.substr(sz(mes)/2,1)+mes.substr(0,sz(mes)/2);
}

string A(string mes){
	reverse(all(mes));
	return mes;
}

string M(string mes){
	rep(i,sz(mes)){
		if(isdigit(mes[i])){
			if(mes[i]=='9')mes[i]='0';
			else ++mes[i];
		}
	}
	return mes;
}

string P(string mes){
	rep(i,sz(mes)){
		if(isdigit(mes[i])){
			if(mes[i]=='0')mes[i]='9';
			else --mes[i];
		}
	}
	return mes;
}

int main() {
	int n=in();
	string mes,ord;
	while(n--){
		cin>>ord>>mes;
		repd(i,sz(ord)){
			switch(ord[i]){
			case 'J':
				mes=J(mes);
			break;
			case 'C':
				mes=C(mes);
			break;
			case 'E':
				mes=E(mes);
			break;
			case 'A':
				mes=A(mes);
			break;
			case 'P':
				mes=P(mes);
			break;
			case 'M':
				mes=M(mes);
			break;
			}
debug<<mes<<endl;
		}
		cout<<mes<<endl;
debug<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int n;
	cin >> n;
	int a[n];
	for(int i = 1; i <= n; ++i){
		int x;
		cin >> x;
		a[x] = i;
	}
	for(int i = 1; i <= n; ++i) cout << a[i] << " ";
}
  
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int> 
#define vi vector<int>
#define int ll

void solve(){
    int n, m;
    cin >> n >> m;
    if (n == m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int t = 1;
    while(t--){
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
// atcoder/abl/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int k;
  while (cin >> k) {
    for (int i = 0; i < k; ++i) {
      cout << "ACL";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 1e16+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

int main(){
    int a ,b;
    cin>>a>>b;
    int sum=a+b;
    int diff=a-b;
    int mul=a*b;
    if(sum>=diff && sum>=mul){
        cout<< sum<<endl;
    }
    else if(diff>=sum && diff>=mul){
        cout<< diff<<endl;
    }
    else if(mul>=diff && mul>=sum){
        cout<< mul<<endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n):
 s += b[a[i]-1]
 if a[i] == a[i-1] + 1 and i >= 1:
     s += c[a[i-1]-1]
print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
const double PI	 = 3.141592;
const int	 MOD = 1e9 + 7;
using namespace std;

void solve() {
	int n;
	cin >> n;
	int ans = n / 2;
	if (n % 2 != 0) ans += 1;
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a,b,c,d,e,k int
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)
  fmt.Scan(&d)
  fmt.Scan(&e)
  fmt.Scan(&k)

  if a-b>k || b-a>k {
    fmt.Println(":(")
    return
  }

    if a-c>k || c-a>k {
    fmt.Println(":(")
      return
    }
  
    if a-d>k || d-a>k {
    fmt.Println(":(")
      return
    }
    if a-e>k || e-a>k {
    fmt.Println(":(")
      return
    }
    if b-c>k || c-b>k {
    fmt.Println(":(")
      return
    }
    if b-d>k || d-b>k {
    fmt.Println(":(")
      return
    }
    if b-e>k || e-b>k {
    fmt.Println(":(")
      return
    }
  if c-d>k || d-c>k {
    fmt.Println(":(")
    return
  }
  
    if c-e>k || e-c>k {
    fmt.Println(":(")
      return
    }
    if d-e>k || e-d>k {
    fmt.Println(":(")
      return
    }
      
    fmt.Println("Yay!") 

}



Measured memory_bytes: 512
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 51;

int main(){
  int N; cin >> N;
  int a; cin >> a;
  if(N%500<=a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    LL N,M; cin >> N >> M;

    LL ans = 0;

    if(M - N * 2 >= 0)
    {
        ans += N;
        ans += (M - N * 2) / 4;

    }
    else
    {
        ans += M / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		
		int N = sc.nextInt();
		
		Set<Integer> mochi = new HashSet<>();
		
		for(int i = 0; i < N; i++) {
			int d = sc.nextInt();
			mochi.add(d);
		}
		
		System.out.println(mochi.size());
		
		
	}

}


Measured memory_bytes: 21844
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	int xx=0, ip;
	double[] array = new double[1000];
	Scanner sc = new Scanner(System.in);
	
	while(true){
	    int suma=0, sumb=0;
	    ip = sc.nextInt();
	    if(ip==0)
		break;
	    int[] x = new int[ip];
	    int[] y = new int[ip];
	    for(int i=0; i<ip; i++){
		x[i]=sc.nextInt();
		y[i]=sc.nextInt();
	    }
	    
	    for(int i=0; i<ip-1; i++){
		suma+=x[i]*y[i+1];
		sumb+=x[i+1]*y[i];
	    }
	    suma+=x[ip-1]*y[0];
	    sumb+=x[0]*y[ip-1];
	    array[xx] = Math.abs((double)(suma-sumb)/2.0);
	    xx++;
	}
	for(int pp=0; array[pp]!=0; pp++)
	    System.out.println((pp+1)+" "+array[pp]);
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;


int main(){
  string s;
  cin >> s;
  int num,ans,i,n;
  ans=0;
  num=s.size();
  n=num;
  i=0;
  while(i<num/2){
    if(s[i]!=s[n-1]){
      ans++;
    }


    i++;
    n--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

//0014
int main(){
	int d;
	const int n = 600;
	
	while(cin >> d){
		int sum=0;
		int x=0;
		for(int i=0; i<n/d; ++i){
			sum+=d*x*x;
			x+=d;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int H,W,N,a[10010],col[110][110];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> H >> W >> N;

    int i,j;
    for (i=1; i<=N; i++)
        cin >> a[i];

    int r=1,c=1,id=1;
    while (r<=H){
        while (c>0 && c<=W){
            if (a[id]==0) id++;
            col[r][c]=id;

            a[id]--;
            if (r%2) c++;
            else c--;
        }

        r++;
        if (r%2) c=1;
        else c=W;
    }

    for (i=1; i<=H; i++, cout << "\n" )
        for (j=1; j<=W; j++)
            cout << col[i][j] << " ";

    return 0;
}


Measured memory_bytes: 384
use std::io::{self, Read};
use std::collections::HashMap;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();
    buffer.clear();
    io::stdin().read_line(&mut buffer).unwrap();
    let mut xs: Vec<i32> = buffer
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    
    xs.sort();
    let mut counter = HashMap::new();
    loop {
        let (key, c) = count_and_truncate(&mut xs);
        counter.insert(key, c);
        if xs.is_empty() {break;}
    }
    let mut m = 0;
    for key in counter.keys() {
        let temp = get_default(&counter, *key-1)
            + get_default(&counter, *key)
            + get_default(&counter, *key+1);
        if temp > m {
            m = temp;
        }
    }
    println!("{}", m);
}


fn count_and_truncate(xs: &mut Vec<i32>) -> (i32, i32) {
    let mut cnt = 0;
    let key = &xs[0].clone();
    for x in xs.iter() {
        if x != key {
            break;
        }
        cnt += 1;
    }
    xs.drain(..cnt as usize);
    // println!("{:?}", xs);
    (*key, cnt)
}

fn get_default(hashmap: &HashMap<i32, i32>, key: i32) -> i32 {
    match hashmap.get(&key) {
        None => 0,
        Some(x) => *x,
    }
}


Measured memory_bytes: 10492
#include <iostream>
using namespace std;
int main(void){
    int n,m,x;
    cin>>n>>m>>x;
    int ans=0;
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        if(x>a){ans++;}
    }
    cout<<min(ans,m-ans)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    cout<<(c-a)*(d-b)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb push_back
using P = pair<int,int>;

signed main(){
    int a[5],k;
    rep(i,5) cin >>a[i];
    cin >> k;
    rep(i,5){
        for(int j=i+1;j<5;j++){
            if(abs(a[i]-a[j]) > k){
                put(":(");
                return 0;
            }
        }
    } 

    put("Yay!");


    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define df 0
#define MAX 100000

int q[2][MAX];
int head[2]={},tail[2]={};
void enq(int a,int t);
int deq(int t);
void enq(int a,int t){
  q[t][tail[t]++]=a;
}
int deq(int t){
  return q[t][head[t]++];
}
int comp(const void *a,const void *b){
  int x=*((int*)a), y=*((int*)b);
  return (x-y)*x;
}

int main(){
  int n;
  scanf("%d",&n);
  int i;  
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(a>0) enq(a,0);
    else enq(a,1);
  }
  qsort(q[0],tail[0],sizeof(int),comp);
  qsort(q[1],tail[1],sizeof(int),comp);
  if(tail[0]==0){
    enq(deq(1),0);
  }
  if(tail[1]==0){
    enq(deq(0),1);
  }
  if(df){
    int t;
    for(t=0;t<2;t++){
    printf("q[%d]:[",t);
      for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
      printf(" ]\n");
    }
  }
  int s=0;
  for(i=head[0];i<tail[0];i++){
    s+=q[0][i];
  }
  for(i=head[1];i<tail[1];i++){
    s-=q[1][i];
  }
  printf("%d\n",s);
  while(tail[0]-head[0]>1){
    int a=deq(0),b=deq(1);
    printf("%d %d\n",b,a);
    enq(b-a,1);
  if(df){
    int t;
    for(t=0;t<2;t++){
    printf("q[%d]:[",t);
      for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
      printf(" ]\n");
    }
  }
  }
  while(tail[1]-head[1]>1){
    int a=deq(0),b=deq(1);
    printf("%d %d\n",a,b);
    enq(a-b,0);
    if(df){
      int t;
      for(t=0;t<2;t++){
	printf("q[%d]:[",t);
	for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
	printf(" ]\n");
      }
    }
  }
  printf("%d %d\n",q[0][head[0]],q[1][head[1]]);
}





Measured memory_bytes: 2616
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void solve() {
	ll n;
	cin >> n;
	set<string> s;
	while(n--) {
		string a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 19260
#include<bits/stdc++.h>
using namespace std;
#define int long long
string s1;
int n,k;
int a[10001];
int dp[101][2][101][2];
int dfs(int x,int up,int num,int pre)
{
	if(x==0)
		return num==k;
	if(dp[x][up][num][pre]!=-1) return dp[x][up][num][pre];
		dp[x][up][num][pre]=0;
//	if(pre!=0)
	dp[x][up][num][pre]+=dfs(x-1,up&&('0'==s1[x-1]),num,pre);
	for(int i=1;i<=9;i++)
	{
		if(up&&i+'0'>s1[x-1])
			break;
		dp[x][up][num][pre]+=dfs(x-1,up&&(i+'0'==s1[x-1]),num+1,1);
	}
	return dp[x][up][num][pre];
}
signed main() 
{
	cin>>s1>>k;
	reverse(s1.begin(),s1.end());
	n=s1.length();
	
	memset(dp,-1,sizeof(dp));
	printf("%lld",dfs(s1.length(),1,0,0));
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

namespace AIPC2020
{
    class B
    {
        static void Main(string[] args)
        {
            //var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var LRd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 0 && a[i] % 2 == 1) ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28292
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m;
  cin >> n >> m;
  int matrix[n][m];
  int vec[m];

  rep(i, 0, n) rep(j, 0, m) cin >> matrix[i][j];
  rep(i, 0, m) cin >> vec[i];

  rep(i, 0, n) {
    int ans = 0;
    rep(j, 0, m) { ans += matrix[i][j] * vec[j]; }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


\
int main() {
	string s;
	cin >> s;
	cout << s.find_last_of("Z") - s.find("A") + 1;

	return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n, a, b := nextInt(), nextInt(), nextInt()
	puts(min(a*n, b))
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
class Elem{
public:
	Elem(){
		c = '*';
		h = 0;
		w = 0;
		area = 0;
	}
	char c;
	int h, w, area;
};
int main(void){
	while( true ){
		int H,W;
		int maxArea = 0;
		
		cin >> H >> W;
		if( H == 0 && W == 0 ) break;
		Elem **map;
		map = new Elem*[H+1];
		for(int i = 0; i < H+1; i++){
			map[i] = new Elem[W+1];
		}

		cin.ignore();
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
			cin >> map[i][j].c;
			}
		cin.ignore();
		}
		
		for(int i = H - 1; i >= 0; i--){
			for(int j = W - 1; j >= 0; j--){
				if( map[i][j].c == '.' ){
					int minWid;
					map[i][j].h = map[i+1][j].h + 1;
					map[i][j].w = map[i][j+1].w + 1;
					map[i][j].area = minWid = map[i][j].w;
					for(int k = 1; k < map[i][j].h; k++){
						minWid = min(minWid, map[i+k][j].w);
						map[i][j].area = max( map[i][j].area, minWid * (k+1));
					}
					maxArea = max( maxArea, map[i][j].area );
				}else{
					map[i][j].area = map[i][j].h = map[i][j].w = 0;
				}
			}
		}

		cout << maxArea << '\n';

		for(int i = 0; i < H+1; i++){
			delete [] map[i];
		}
		delete [] map;
	}
	return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const ll N=1001;
const ll INF=1e10;

ll fastexp(ll b,ll e){
	ll res=1;
	while(e){
		if(e&1) res=(res*b)%mod;
		b=(b*b)%mod;
		e>>=1;
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll a=fastexp(10ll,n),b=(2*fastexp(9ll,n))%mod,c=fastexp(8ll,n);
	ll ans=(a+c-b)%mod;
    if(ans<0) ans+=mod;
	cout<<ans;
}	  


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#define M 86401
using namespace std;

int main(){
    int i,n,v,tf,tt,h,m,s,l[M];
    while(1){
        scanf("%d",&n);
        if(!n){break;}
        fill(l,l+M,0);v=0;
        for(i=0;i<n;i++){
            scanf("%d:%d:%d",&h,&m,&s);
            tf=h*3600+m*60+s;
            scanf("%d:%d:%d",&h,&m,&s);
            tt=h*3600+m*60+s;
            l[tf]++;
            l[tt]--;
        }
        for(i=1;i<M;i++){
            l[i]+=l[i-1];
        }
        for(i=0;i<M;i++){
            v=max(v,l[i]);
        }
        printf("%d\n",v);
    }
    return 0;
}





Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        N -= a;
    }
    cout << max(N, -1) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;

string S;
pair<int, int> f(int &i) {
	pair<int, int> res;
	vector <vector<pair<int, int> > > vp(1);
	while (true) {
		if (i == S.size() || S[i] == ')') {
			vector<int> C(vp.size());
			for (int x = 0; x < vp.size(); x++) {
				int mn = 1000000000;
				int t = 0;
				for (int y = 0; y < vp[x].size(); y++) {
					mn = min(mn, t + vp[x][y].first);
					t += vp[x][y].second;
				}
				C[x] = mn;
				res.first += mn;
			}
			



			{

				res.second = 1000000000;
				int t = 0;
				int tmp = 0;
				for (int x = 0; x < vp.size(); x++) {
					tmp = 0;
					for (int y = 0; y < vp[x].size(); y++) {
						tmp += vp[x][y].second;
					}
					res.second = min(res.second, tmp + t);

					t += C[x];
				}
				

			}

			break;
		}
		else if (S[i] == '(') {
			i++;
			vp.back().push_back(f(i));
		}
		else if (S[i] == '?') {
			vp.back().emplace_back(1, 1);
		}
		else if (S[i] == '|') {
			vp.push_back(vector<pair<int, int> >(0));
		}
		i++;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> S;
	int i = 0;
	pair<int, int> res = f(i);
	cout << res.first << " " << res.second << endl;
}


Measured memory_bytes: 3504
n=int(input())

def pair(x):
    a=x%10
    b=int(str(x)[0])
    return (a,b)
dic={}
for i in range(1,n+1):
    p=pair(i)
    if(dic.get(p)==None):dic[p]=1
    else:dic[p]+=1
ans=0
for i in range(1,n+1):
    a,b=pair(i)
    p=(b,a)
    if(not dic.get(p)==None):ans+=dic[p]
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	int n,k;
	cin>>n>>k;
	vector<ll>a(n);ll mx=INT_MIN;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	ll l=0,r=mx;
	while(r-l>1){
		ll m = l+ (r-l)/2;
		ll cnt=0;
		for(int i=0;i<n;i++)
			cnt+=(a[i]+m-1)/m-1;
		if(cnt>k)l=m;
		else
			r=m;
	}
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 4668
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  int a[N];
  for(int i=0; i < N; i++){
    cin >> a[i];
  }
  sort(a, a+N);
  cout << a[N-1] - a[0] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl


namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	lli t = 0;
	for (int i = 0; i < n - 1; i++) {
		t += v[i];
	}
	cout << ((t > v[n - 1]) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,h;
tuple<int,int,int,int> a[100010];int fa[100010];
int find(const int &x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int ii[100010],oo[100010],mapp[100010];
void init(){
	for(int i=1;i<=n;i++){
		int f,t;
		if(f=get<2>(a[i])) f+=h;
		else f=get<0>(a[i]);
		if(t=get<3>(a[i]));
		else t=get<1>(a[i])+h;
		oo[f]++,ii[t]++;f=find(f),t=find(t);
		if(f^t) fa[f]=t;
	}
}
int main(){
	scanf("%d%d",&n,&h);
	for(int i=1;i<=1000;i++) fa[i]=i;
	int A,B,C,D;
	for(int i=1;i<=n;i++) scanf("%d%d%d%d",&A,&B,&C,&D),a[i]={A,B,C,D};
	bool fg=1;init();
	for(int i=1;i<=h;i++) if(ii[i]>oo[i]) fg=0;
	for(int i=h+1;i<=h+h;i++) if(ii[i]<oo[i]) fg=0;
	for(int i=1;i<=h+h;i++) if(ii[i]!=oo[i]||(ii[i]+oo[i]==0)) mapp[find(i)]++;
	for(int i=1;i<=h+h;i++) if(!mapp[i]&&i==fa[i]) fg=0;
	printf("%s\n",fg?"YES":"NO");
}


Measured memory_bytes: 5336
# -*- coding:utf-8 -*-
import sys

class Work():

    def __init__(self, a, b):
        self.need_time = a  # 仕事を終わらせるのに必要な時間
        self.deadline = b   # 締め切り時刻


def solve():
    N = int(input())

    works = []
    for _ in range(N):
        a, b = list(map(int, sys.stdin.readline().split()))
        works.append(Work(a, b))
    works.sort(key=lambda x: x.deadline)  # 締め切りが早い順にソート

    # 締切が早いやつから先に仕事を終らせる貪欲法
    now_time = 0  # 現在時刻
    for i in range(N):
        now_time += works[i].need_time
        if now_time > works[i].deadline:
            print("No")
            return
    print("Yes")



if __name__ == "__main__":
    solve()


Measured memory_bytes: 64768
#include <stdio.h>

int main(void) {
	
	int n, i;
	int k, p, a;
	
	scanf("%d", &n);
	
	for( i = 0; i < n; i++){
		scanf("%d%d", &k, &p);
		
		a = k % p;
		if(a == 0) a = p;
		
		printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 2752
n=int(input())
l = map(int, input().split())
kitazyun=[]

for i, kita in enumerate(l):
    kitazyun.append([kita,i+1])
# 0 Alice
# 1 Bob
# 2 Charlie

ll=sorted(kitazyun)


for i in range(n):
    print(ll[i][1])
    



Measured memory_bytes: 25972
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

unsigned long long int GCD(unsigned long long int x, unsigned long long int y)
{
	if(y == 0)
	{
		return(x);
	}
	else
	{
		GCD(y, x % y);
	}
}

void solve()
{
	int a1, m1, a2, m2, a3, m3;
	while(cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3, a1 || m1 || a2 || m2 || a3 || m3)
	{
		vector<unsigned long long int> count(3);
		int x = 1, y = 1, z = 1;
		do
		{
			x = (a1 * x) % m1;
			++count[0];
		}while(x != 1);

		do
		{
			y = (a2 * y) % m2;
			++count[1];
		}while(y != 1);
		
		do
		{
			z = (a3 * z) % m3;
			++count[2];
		}while(z != 1);
		sort(count.begin(), count.end());
		unsigned long long int gcd1 = GCD(count[2], count[1]);
		unsigned long long int lcm1 = count[2] * count[1] / gcd1;
		if(lcm1 < count[0])
		{
			unsigned long long int temp = lcm1;
			lcm1 = count[0];
			count[0] = temp;
		}
		unsigned long long int gcd2 = GCD(lcm1, count[0]);
		unsigned long long int lcm2 = lcm1 * count[0] / gcd2;
		cout << lcm2 << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1204
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
bool prime[1000005];
multiset<int>pf;
set<int>p;
int n;
long long ans=1,g,num,t,x;

int main(){
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
        prime[i]=1;
    for(int i=2;i<=n;i++){
        if(prime[i]){
            for(int j=2*i;j<=n;j+=i)
                prime[j]=0;
            p.insert(i);
            //printf("%d\n",i);
        }
    }
    for(int i=2;i<=n-1;i++){
        g=i;
        num=1;
        x=0;
        for(auto e:p){
            if(i<e)
                break;
            t=0;
            while(g%e==0){
                g/=e;
                t++;
            }
            num*=(t+1);
            if(prime[g]){
                t++;
                num*=2;
                g=1;
            }
            if(g==1)
                break;
        }
        ans+=num;
    }
printf("%lld",ans);
}


Measured memory_bytes: 7876
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  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) {
        if (i*500 + j*100 + k * 50 == x) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
const int N=2e5+5;
int n,a[N];
bool check(int m){
	map<int,int> s;
	rep (i,2,n){
		if (a[i-1]<a[i]) continue;
		if (m==1) return 0;
		int x=a[i];
		s.erase(s.upper_bound(x),s.end());
		while (s[x]==m-1){
			x--;
			if (x==0) return 0;
		}
		s.erase(s.upper_bound(x),s.end());
		s[x]++;
	}
	return 1;
}
int main(){	
	scanf("%d",&n);
	rep (i,1,n) scanf("%d",&a[i]);
	int l=1,r=n,mid;
	while (l<=r){
		mid=l+r>>1;
		if (check(mid)) r=mid-1; else l=mid+1;
	}
	printf("%d\n",r+1);
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int main(){
  int num_student;
  int num_min_pass;
  int num_max_pass;
  while(~scanf("%d %d %d", &num_student, &num_min_pass, &num_max_pass)) {
    if (num_student == 0) break;

    int score[10000];
    for (int student_i = 0; student_i < num_student; student_i++) {
      scanf("%d", &score[student_i]);
    }
    sort(score,score + num_student, greater<int>());
    int diff = -1;
    int res = 0;
    for (int pass_i = num_min_pass - 1; pass_i < num_max_pass; pass_i++) {
      int min_pass_score = score[pass_i];
      int max_fail_score = score[pass_i + 1];
      if (diff <= min_pass_score - max_fail_score) {
	diff = min_pass_score - max_fail_score;
	res = pass_i + 1;
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 3244
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 count = 0;

        for (int i = a; i < b + 1; i++) {
            int i1 = i / 10000;
            int i2 = (i % 10000) / 1000;
            int i4 = (i % 100) / 10;
            int i5 = i % 10;
            if (i1 == i5 && i2 == i4) {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,A) for(int i = 0;i < A;i++)

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A <= B * C){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
 }


Measured memory_bytes: 3644
#include <bits/stdc++.h>

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long MX = sqrt(N);
const long long H = 17;
const long long MAGIC = 1000;
const long long mod = 1e9 + 7;

using namespace std;

ll n;
ll A;
ll B;
ll h[N];

bool can(ll x)
{
        ll cnt = x;
        for(int i = 1; i <= n; i++){
                ll y = h[i] - B * x;
                if(y > 0){
                        cnt -= (y - 1) / (A - B) + 1;
                }
        }
        return cnt >= 0;
}

void solve()
{
        cin >> n >> A >> B;
        for(int i = 1; i <= n; i++){
                cin >> h[i];
        }
        ll l = 0, r = 1e9;
        while(l < r){
                ll m = (l + r) / 2;
                if(can(m)){
                        r = m;
                }
                else{
                        l = m + 1;
                }
        }
        cout << l << endl;
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("landscape.in");
        //fout("landscape.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <map>
using namespace std;
int n,m;
int main() {
  while(1){
    scanf("%d%d",&n,&m);
    if(n==0&&m==0){break;}
    if(n>m){swap(n,m);}
    printf("%d %d\n", n, m);
    }
}

Measured memory_bytes: 1172
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
ans = N%1000
if(ans != 0):
  ans = 1000-ans

print(ans)



Measured memory_bytes: 68696
A, B, C, D = map(int, input().split())

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

def lcm(a, b):
    return a*b//gcd(a, b)

def count(X, a, b):
    return X//a + X//b - X//lcm(a, b)

print((B - A + 1) + count(A-1, C, D) - count(B, C, D))         


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
long double s;
int n;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	s=n*2*3.14159265358979323846;
	cout<<fixed<<setprecision(20)<<s;
	return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int main() {
  	int cnt[10][10];
  	memset(cnt,0,sizeof cnt);
  	int N;
  	cin >> N;
  	long long cntr = 0;
  	for (int i = 1; i <= N; i++) {
    	  string s = to_string(i);
      	cnt[s[0]-'0'][s[s.length()-1]-'0']++;
    }
  	for (int i = 1; i <= N; i++) {
    	  string s = to_string(i);
      	cntr += cnt[s[s.length()-1]-'0'][s[0]-'0'];
    }
  	printf("%lld\n",cntr);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<lint>A1(N);
	rep(i, N) {
		A1[i] = i-A[i];
	}
	vector<lint>A2(N);
	rep(i, N) {
		A2[i] = -1*A[i]-i;
	}
	sort(A1);
	sort(A2);
	lint ans = 0;
	rep(i, N) {
		ans += upper(A1, A[i] + i) - lower(A1, A[i] + i);
	}
	rep(i, N) {
		ans += upper(A2, A[i] - i) - lower(A2, A[i] - i);
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 8012
#include<bits/stdc++.h>
#define ll     long long int
#define mod    1000000007
#define io     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi      vector<int>
#define endl    "\n"
using namespace std;
void solve();
int main()
{
	io

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
//	/*is Single Test case?*/cin >> t;
	for (int i = 1; i <= t; i++)
	{	//cout<<"Case #"<<i<<": ";
		solve();
		cout << "\n";
	}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
void solve()
{
	int n; cin >> n;
	if (n == 1)
		cout << 0;
	else
		cout << 1;
}




Measured memory_bytes: 3780
import numpy as np
N=int(input())
list_p=list(map(int,input().split()))
np_list_p=np.array(list_p)
np_list_s =np.array(sorted(list_p))
minus=list(np_list_p - np_list_s)
print("YES" if minus.count(0) == N or minus.count(0)== N-2 else "NO")

Measured memory_bytes: 12504
#include <iostream>
using namespace std;
int main(){
  int x, y = 0;
  while(true){
    cin >> x >> y;
    if(!x){
      break;
    }
    for(int i = 0; x > i; i++){
      for(int j = 0; y > j; j++){
        if(i == 0 || j == 0 || i == x - 1 || j == y - 1){
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define maxn 100000+10
int n;
int a[maxn];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(register int i=1;i<=n;i++){
		int t;
		cin>>t;
		a[t]=i;
	}
	for(register int i=1;i<=n;i++){
		if(a[i])cout<<a[i]<<" ";
	}
	return 0;
}


Measured memory_bytes: 1280