akhauriyash/Code-Regression huggingface dataset:
from collections import deque
n, q = map(int, input().split())
queues = [deque() for i in range(n)]
while q:
    q -= 1
    s = [*map(int, input().split())]
    if s[0] == 0:
        queues[s[1]].append(s[2])
    elif s[0] == 1 and len(queues[s[1]]):
        print(queues[s[1]][0])
    elif len(queues[s[1]]):
        queues[s[1]].popleft()


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

int main(){
    int N, ans=0;    
    cin >> N;
    vector<int> d(N);

    for(int i=0; i<N; i++)	
	cin >> d[i];
    sort(d.begin(), d.end());
    
    ans = d[N/2]-d[N/2-1];
    cout << ans << "\n";
}





Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            int A = nint(sc);
            int B = nint(sc);

            if (A + B > 16) out.println(":(");
            else if (A > 8 || B > 8) out.println(":(");
            else out.println("Yay!");
        }
    }

    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return String.valueOf(sc.next());
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#define mod 1000000007

int fib(int n, int *a){
    if(n == 1){
        a[n] = 1;
        return a[n];
    }else if(n == 2){
        int f_n1;
        if(a[n-1] < 0){f_n1 = fib(n-1, a);}
        else{f_n1 = a[n-1];}
        a[n] = 1 + f_n1;
        return a[n];
    }else{
        int f_n1, f_n2;
        if(a[n-1] < 0){f_n1 = fib(n-1, a);}
        else{f_n1 = a[n-1];}
        if(a[n-2] < 0){f_n2 = fib(n-2, a);}
        else{f_n2 = a[n-2];}
        a[n] = (f_n1 + f_n2) % mod;
        return a[n];
    }
}



int main(void){
    int n, m, tmp, i, ans;
    scanf("%d %d", &n, &m);
    int a[n+1];
    for(i = 0; i <= n; ++i){
        a[i] = -1;
    }
    for(i = 0; i < m; ++i){
        scanf("%d", &tmp);
        a[tmp] = 0;
    }
    ans = fib(n, a);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5248
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		//2????????´??°???????????????
		Scanner sc = new Scanner(System.in);
		int intA = sc.nextInt();
		int intB = sc.nextInt();

		//??´??°???????????????????°???°???????????????
		int intD = 0;
		int intE = 0;
		double dbF = 0;

		intD = intA / intB;
		intE = intA % intB;
		dbF = (double)intA / (double)intB;
		String stF = String.format("%.5f", dbF);

		System.out.println(intD + " " + intE + " " + stF);
	}
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int h0,hmax;cin>>h0>>hmax && h0|hmax;){
		int h,w; cin>>h>>w;
		vs grid(h);
		rep(i,h) cin>>grid[i];
		map<char,int> dmgs;
		{
			int len; cin>>len;
			rep(i,len){
				char c; int x; cin>>c>>x;
				dmgs[c]=x;
			}
		}
		string dirs;
		{
			int len; cin>>len;
			rep(i,len){
				char c; int x; cin>>c>>x;
				dirs.append(x,c);
			}
		}
		int m=dirs.size();
		int n; cin>>n;
		vi pots(n);
		rep(i,n) cin>>pots[i];
		
		vi decs(m);
		for(int i=0,j=0,k=0;k<m;k++){
			i+="\xff\x1\0\0"[string("UDLR").find(dirs[k])];
			j+="\0\0\xff\x1"[string("UDLR").find(dirs[k])];
			decs[k]=dmgs[grid[i][j]];
		}
		
		vi sums(1<<n);
		rep(i,1<<n) rep(j,n) if(i>>j&1) sums[i]+=pots[j];
		
		queue<tuple<int,int,int>> q;
		q.emplace(0,h0,(1<<n)-1); // (step,hp,rest)
		vvi vis(m,vi(1<<n));
		bool res=false;
		while(q.size()){
			int ci,ch,cr; tie(ci,ch,cr)=q.front(); q.pop();
			if(ci==m){
				res=true;
				break;
			}
			if(vis[ci][cr]>=ch) continue;
			vis[ci][cr]=ch;
			if(ch-decs[ci]>0){
				q.emplace(ci+1,ch-decs[ci],cr);
				continue;
			}
			for(int s=cr;s;s=s-1&cr){
				int nh=min(ch+sums[s],hmax);
				if(nh-decs[ci]>0)
					q.emplace(ci+1,nh-decs[ci],cr^s);
			}
		}
		cout<<(res?"YES":"NO")<<endl;
	}
}

Measured memory_bytes: 20404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); i++)

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    /*変数定義，入力*/
    int X;
    cin >> X;

    /*演算*/
    bool flag = false;
    for(int i = X; !flag; i++){
        if(IsPrime(i)){
            cout << i;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<stack>
#include<math.h>

using namespace std;



int main(){

	int n;
	while (cin >> n, n){
		if (n < 2){
			cout << "deficient number" << endl;
			continue;
		}

		int s = 1;
		for (int i = 2; i <= sqrt(n); i++){
			if (n%i == 0 && i == sqrt(n) && n / sqrt(n) == sqrt(n)){
				s += i;
			}
			else if (n%i == 0){
				s += i;
				s += n / i;
			}
		}

		if (n == s)cout << "perfect number" << endl;
		if (n > s)cout << "deficient number" << endl;
		if (n < s)cout << "abundant number" << endl;

	}

	return 0;

}

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

int main(void){
    string s;
	int cnt=0;
    cin >> s;
	if(s[0] == '1'){
		cnt++;
	}
	if(s[1] == '1'){
		cnt++;
	}
	if(s[2] == '1'){
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

ull gcd(ull a, ull b){
	if (b > a) swap(a, b);
	ull r = a%b;
	while (r != 0){
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}
ull lcm(ull a, ull b){
	return a / gcd(a, b) * b;
}
int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ull n, t;
	cin >> n;
	{
		ull nt;
		cin >> t;
		n--;
		while (n--){
			cin >> nt;
			t = lcm(t, nt);
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
int main() {
    Int n;
    cin >> n;
    auto s = set<Int>();
    rep(i, n) {
        Int a;
        cin >> a;
        auto x = s.size();
        s.insert(a);
        auto y = s.size();
        if (x == y) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; ++i) cin >> P[i];
    bool is_ok = true;
    for (int i = 0; i < N; ++i) {
        if (P[i] != i + 1) {
            is_ok = false;
            break;
        }
    }
    if (is_ok) {
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            vector<int> tmp(P);
            swap(tmp[i], tmp[j]);
            bool is_ok = true;
            for (int k = 0; k < N; ++k) {
                if (tmp[k] != k + 1) {
                    is_ok = false;
                    break;
                }
            }
            if (is_ok) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    string s,t; cin >> s >> t;
    sort(all(s));
    sort(rall(t));
    rep(i,s.size()) {
        int s1 = s[i] - 'a';
        int t1 = t[i] - 'a';
        if(s1 < t1) {
            cout << "Yes" << endl;
            return 0;
        }
        if(s1 == t1 and s.size() == t.size()) {
            cout << "No" << endl;
            return 0;
        }
        if(s1 ==  t1) continue;
        if(s1 > t1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

template <class T>
struct segtree {
    int n;
    T def = vector<int>(26, 0);
    vector<T> node;
    function<T(T, T)> f = [](vector<int> a, vector<int> b) {
        rep(i, 0, 26) a[i] += b[i];
        return a;
    };

    segtree(string s) {
        n = 1;
        while (n < s.size()) n *= 2;
        node.resize(2 * n - 1, def);
        for (int i = 0; i < s.size(); i++) node[i + n - 1][s[i] - 'a'] = 1;
        for (int i = n - 2; i >= 0; i--)
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
    }
    inline void update(int k, T v) {
        k += n - 1;
        node[k] = v;
        while (k > 0) {
            k = (k - 1) / 2;
            node[k] = f(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    inline T get(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def;
        if (a <= l && r <= b) return node[k];
        T vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    inline T get(int a, int b) {
        return get(a, b, 0, 0, n);
    }
    inline T get(int a) {
        return get(a, a + 1, 0, 0, n);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    string s;
    cin >> n >> s >> q;
    segtree<vector<int>> st(s);
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            vector<int> d(26);
            d[c - 'a'] = 1;
            st.update(i - 1, d);
        } else {
            int l, r;
            cin >> l >> r;
            vector<int> d = st.get(l - 1, r);
            int cnt = 0;
            rep(i, 0, 26) if (d[i]) cnt++;
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 140572
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    int n; cin >> n;
    vector<int> v(n);
    repeat (i, n) cin >> v[i];
    int s = 0;
    int t = accumulate(v.begin(), v.end(), 0);
    int ans = 1e9;
    repeat (i, n) {
        s += v[i];
        t -= v[i];
        ans = min(ans, abs(s-t));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll pp[100];
ll bb[100];

ll solve(ll n, ll x){
    if(n == 0){
        if(x >= 1) return 1;
        else return 0;
    }
    if (x == 0) return 0;
    if(x <= bb[n-1]+1) return solve(n-1, x-1);
    else if(x == bb[n-1]+2) return pp[n-1] + 1;
    else return pp[n-1] + 1 + solve(n-1, x-bb[n-1]-2);
    return 0;
}

int main(){
    ll N, X; cin >> N >> X;
    
    REP(i, 60){
        pp[i] = 0; bb[i] = 0;
    }
    pp[0] = 1; bb[0] = 1;
    REP(i,60){
        pp[i+1] = 2*pp[i]+1;
        bb[i+1] = 2*bb[i]+3;
    }
    ll ans = solve(N, X);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
C = [0 for i in range(4)]
S = [input() for i in range(N)]

S_co = Counter(S)

print('AC x ' + str(S_co['AC']))
print('WA x ' + str(S_co['WA']))
print('TLE x ' + str(S_co['TLE']))
print('RE x ' + str(S_co['RE']))

Measured memory_bytes: 16648
#include<stdio.h>
int main(void)
{
    int n,x[101];
    scanf("%d",&n);
    int i,p = 0,sum = 0,a;
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%d",&x[i]);
        
    }
    int min = x[1],max = x[n];
    for(i = 1 ; i <= n ; i++)
    {
        if(min >= x[i])
        {
            min = x[i];
        }
        if(max <= x[i])
        {
            max = x[i];
        }
    }
    a = 100000000;
    for(p = min ; p <= max ; p++)
    {
        sum = 0;
        for(i = 1 ; i <= n ; i++)
        {
            
            sum += (x[i]-p)*(x[i]-p);
        }
        
        
        if(sum < a)
        {
            a = sum;
            
            
        }
        

    }
    printf("%d\n",a);
    return 0;
}

Measured memory_bytes: 1652
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B, C; cin >> A >> B >> C;
    lint m = max({A, B, C});
    lint diff = 3 * m - (A + B + C);
    cout << diff / 2 + (diff % 2 == 0 ? 0 : 2) << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1; 
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int n, m;
	vector<vector<int>>V(200030);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	int check[200030] = {};
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		int sum = 0;
		if (check[i] == 0) {
			sum++;
			check[i] = 1;
			queue<int>q;
			q.push(i);
			while (q.size()) {
				int now = q.front();
				q.pop();
				for (auto t : V[now]) {
					if (check[t] == 0) {
						q.push(t);
						sum++;
						check[t] = 1;
					}
				}
			}
		}
		ans = max(ans, sum);
	}
	cout << ans;
}

Measured memory_bytes: 15732
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int W, a, b;
    cin >> W >> a >> b;
    if (a <= b && b <= a + W || b <= a && a <= b + W)cout << 0 << endl;
    else {
        int ans = min(abs(b - a - W), abs(a - b - W));
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,k;
	while( cin >> k >> n , k){
		bool no = false;
		int ret = 0;
		int data[100001] = {0};
	//	int memo[100000] = {0};
		
		vector<int> t;
		
		rep(i,n){
			int c; cin >> c;
			if(!c)no = true;
			else data[c-1] = 1;
		}
		
		int c = 0;
		
		rep(i,k+1){
			if(data[i]){
				c++;
			}else{
				if(i && c == 0){	
					if(t.back() != 0)t.push_back(0);
				}else{
					ret = max(ret,c);
					t.push_back(c);
					c = 0;
				}
			}
		}
		if(no){
			if(t.size() == 1)ret = max(ret,t[0]+1);
			else rep(i,t.size()-1)ret = max(ret,t[i]+t[i+1]+1);
		}
		cout << ret << endl;
	}
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

int main()
{
    ll a,p;
    cin >> a >> p;
    cout << (a*3 + p) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int p = s.length() % 2;
    bool f = (s[0] == s[s.length() - 1]);

    if((p == 0 && f == true) || (p == 1 && f == false))
    {
        cout << "First" << endl;
    }
    else
    {
        cout << "Second" << endl;
    }


    return 0;
}

Measured memory_bytes: 512
def gcd(a, b):
    c = a%b
    while(c != 0):
        a = b
        b = c
        c = a%b
    return b

def answer(s, t):
    a = len(s)
    b = len(t)
    if s[0] != t[0]:
        return -1
    if a < b:
        temp = a
        a = b
        b = temp
        temp = s
        s = t
        t = temp
    gcdAB = gcd(a, b)
    if gcdAB == 1:
        return a*b
    else:
        stack = 0
        sl = (gcdAB * (a//gcdAB) * (b//gcdAB))
        aJump = sl//a
        bJump = sl//b
        for i in range(b):
            if stack%aJump == 0:
                if s[stack//aJump] != t[i]:
                    return -1
            stack = bJump*(i+1)
        return sl
                

sl, tl = map(int, input().split())
s = input()
t = input()
print(answer(s, t))


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



void print(vector<int> v){
	
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	//cout<<endl;
}
float T,X;
int ans=0;

void solve(){
	cin>>T>>X;
	cout<<T/X<<endl;
}


int main(){

    solve();
    return 0;
}




Measured memory_bytes: 256
loop {
    a, b = gets.split.map &:to_i
    break if a == 0
    a_pairs = []
    (1..Math.sqrt(a).to_i).each{|x|
        a_pairs << [x, a / x] if a % x == 0
    }
    b_pairs = []
    (1..Math.sqrt(b).to_i).each{|x|
        b_pairs << [x, b / x] if b % x == 0
    }
    min = Float::INFINITY
    a_pairs.each{|x, y|
        b_pairs.each{|z, w|
            s = [x,y,z,w].sort.each_cons(2).map{|s, t| (s-t)**2}.inject(:+)
            min = s if s < min
        }
    }
    p min
}

Measured memory_bytes: 6140
#include <stdio.h>

int main(void) {
	int n, num;
	char c;
	int kind[4] = {'S', 'H', 'C', 'D'};
	int data[4][13] = {};
	int i, j;
	
	scanf("%d", &n);
	
	while (n--){
		scanf(" %c %d", &c, &num);
		num--;
		
		switch(c) {
			case 'S': data[0][num] = 1; break;
			case 'H': data[1][num] = 1; break;
			case 'C': data[2][num] = 1; break;
			case 'D': data[3][num] = 1; break;
		}
	}
	
	for (i = 0; i < 4; i++){
		for (j = 0; j < 13; j++){
			if (!data[i][j]){
				printf("%c %d\n", kind[i], j+1);
			}
		}
	}
	
	return 0;
}

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

int main(){
    int N;
    int d[110];
    int ans = 0;

    cin>>N;
    for(int i=0;i<N;i++)cin>>d[i];

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            int dxdy = d[i]*d[j];
            ans += dxdy;
        }
    }

    for(int i=0;i<N;i++){
        ans -= d[i]*d[i];
    }

    cout<<ans/2<<endl;
}

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

int main()
{
	int e1, e2, e3, e4;
	cin >> e1 >> e2 >> e3 >> e4;

	if (e1 == e2 && e3 == e4) cout << "yes" << endl;
	else if (e1 == e3 && e2 == e4) cout << "yes" << endl;
	else if (e1 == e4 && e2 == e3) cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}

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

vector<bool> vis;
int dfs(int i, vector<vector<int>>& v) {
  int res = 1;
  vis[i] = true;
  for (int& j: v[i])
    if (! vis[j])
      res += dfs(j, v);
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vis.assign(n, false);
  vector<vector<int>> v(n);
  for (int i=0; i<m; i++) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  
  int ans = -1;
  for (int i=0; i<n; i++) {
    if (vis[i]) continue;
    ans = max(ans, dfs(i, v));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23536
use proconio::input;
fn main() { 
    input!{
        n:usize,
        k:u64,
        a:[usize;n]
    }
    let mut doubling = vec![vec![0;n]; 62];
    for i in 0..n{
        doubling[0][i] = a[i] - 1;
    }
    for i in 1..61{
        for j in 0..n{
            let next = doubling[i-1][j];
            doubling[i][j] = doubling[i-1][next];
        }
    }
    let mut ans = 0;
    let mut now_k:u64 = k;
    for i in (0..62).rev() {
        if (1_u64 << i) <= now_k{
            now_k -= 1_u64 << i;
            ans = doubling[i][ans];
        }
    }
    println!("{}", ans+1);
}


Measured memory_bytes: 100316
indice = {}
while page_info = gets
  break if page_info.nil? || page_info.empty?
  page_contents, page_number = page_info.strip.split
  indice[page_contents] = [] unless indice.has_key?(page_contents)
  indice[page_contents] << page_number.to_i
end

indice.sort{ |(k1, v1), (k2, v2)| k1 <=> k2 }.each do |word, page_numbers|
  puts word
  puts page_numbers.sort.join(" ")
end

Measured memory_bytes: 6100
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

long long ston(string s){
  long long n;
  sscanf(s.c_str(), "%lld", &n);
  return n;
}

int main(){
  string s;
  cin>>s;
  ll mn = 1000000000000000000LL;
  rep(i,0,s.sz-3+1){
  	string s1;
  	rep(j,i,i+3){
  		s1 += s[j];
  	}
  	ll a = ston(s1);
  	mn = min(mn,abs(753-a));
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>


using namespace std;

int main(){
	int a,b;
  
  	cin >> a >> b;
  	int num ;
  	cin >> num;
  	int ans = num / max(a,b);
  	if(max(a,b) * ans != num)
  		ans ++;
  	cout << ans << endl;
  	
  	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 100000000
#define mod 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

ll modpow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}


int main() {
    ll n, i;
    cin >> n;
    ll a[n+1], cnt, ans=0;
    
    for(i=0; i<n; i++)
        cin >> a[i];
    a[n]=-1;
    
    sort(a, a+n);
    
    for(i=0; i<n; i++) {
        cnt=1;
        while(a[i]==a[i+1]) {
            cnt++;
            i++;
        }
        if(cnt>=a[i])
            ans+=(cnt-a[i]);
        else
            ans+=cnt;
        
    }
    cout << ans;
}


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

int main(){
string S;
cin >> S;

for(int i = 1; i < S.size(); i++){ 
     if(S[i - 1] == S[i]) {
         cout << "Bad" << endl;
         return 0;
     } 
}

cout << "Good" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int h,m,s,S;
    scanf("%d",&S);
h=S/3600;
m=(S-(h*3600))/60;
s=(S-(h*3600)-(m*60));
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int k, x;
    cin >> k >> x;
    ATYN(k*500 >= x)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
 
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  
  else if (N % 500 > A) {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	int main(){
		int A=read<int>(),B=read<int>(),C=read<int>();
		int tmp=A^B^C;
		int num=0;
		if(tmp==A) num++;
		if(tmp==B) num++;
		if(tmp==C) num++;
		if(num==1) puts("Yes");
		else puts("No");
		return 0;
	}
}
int main(){
#ifdef my
	freopen("poor.in","r",stdin);
	freopen("poor.out","w",stdout);
#endif
	return run::main();
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}




ll ans=0;
ll n;

bool f(ll t){
	
	int a3=0,a5=0,a7=0,m=t;
	while(m>0){
		if(m%10==3) a3++;
		if(m%10==5) a5++;
		if(m%10==7) a7++;
		m/=10;
	}
	if(a3 && a5 && a7) return true;
	return false;
}


void func(ll k){
	if(k > n) return;
	else{
		 if(f(k)) ans++;
		 func(k*10+3);
		 func(k*10+5);
		 func(k*10+7);
	}
}
int main(){
	startTime=clock();
	
	cin >> n;
	
	func(0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
  
int main() {
  int N,L;
  cin >>N>>L;
  vector<string> v(N);
  rep(i,N)cin>>v[i];
  sort(v.begin(),v.end());
  rep(i,N) cout<< v[i];
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	string s;
	int b, n;
	cin >>b>> s >> n;
	char mem = s[n-1];
	rep(i, s.size()) {
		if (s[i] != mem) {
			cout << "*";
		} else {
			cout << s[i];
		}
	}

	cout << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;
    for (int a = 0; a <= A; a++) {
        for (int b = 0; b <= B; b++) {
            for (int c = 0; c <= C; c++) {
                int s = a * 500 + b * 100 + c * 50;
                if (s == X) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    println!("{}", (a + b) % 24);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;
int a,b;
int main()
{
    cin>>a;
    while(a>0){
        b=a%10;
        if (b==7) {
            cout<<"Yes";
            return 0;
        }
        a/=10;
    }
    cout<<"No";

    return 0;
}


Measured memory_bytes: 3608
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

mono = [A,B,C,D,E]
amari = [A%10,B%10,C%10,D%10,E%10]
minamari = 9
jun = []
for i in range(5):
    if amari[i]==0:
        jun.insert(0,mono[i])
    elif amari[i]<minamari:
        jun.append(mono[i])
        minamari = amari[i]
    else:
        jun.insert(0,mono[i])
        
for i in range(4):
    if jun[i]%10>0:
        jun[i]=(jun[i]//10)*10+10

output = sum(jun)
print(int(output))

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

int main(){
    vector<int> pack(3);
    for(int i = 0;i < 3;i++){
        cin >> pack.at(i);
    }
    
    sort(pack.begin(), pack.end());
    if(pack.at(0) + pack.at(1) == pack.at(2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
        
    
}




Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long int N,x;
  long long int array[100001],tmp[100000];
  long long int i,ans,hoge;
  ans=0;
  scanf("%lld %lld",&N,&x);
  for(i=0;i<N;i++){
    scanf("%lld",&array[i]);
  }
  for(i=0;i<N-1;i++){
    tmp[i]=array[i]+array[i+1];
  }
  if(tmp[0]>x){
    hoge=tmp[0]-x;
    if(array[1]>hoge){
      ans+=hoge;
      tmp[1]-=hoge;
    }else{
      tmp[1]-=array[1];
      ans+=hoge;
    }
  }
  
  for(i=1;i<N;i++){
    if(tmp[i]>x){
      ans+=tmp[i]-x;
      tmp[i+1]-=(tmp[i]-x);
    }
  }

  printf("%lld\n",ans);

  return 0;
}


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

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    string s, t;
    cin >> s >> t;
    int ss, tt;
    cin >> ss >> tt;
    string st;
    cin >> st;
    if(st == s) ss--;
    else tt--;
    cout << ss << " " << tt;

    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	cout<<(k*2-1<=n?"YES":"NO")<<"\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
p = 0
for i in range(10):
    pi = s.find(str(i))
    if pi == -1:
        continue
    for j in range(10):
        pj = s.find(str(j), pi + 1)
        if pj == -1:
            continue
        for k in range(10):
            pk = s.find(str(k), pj + 1)
            if pk == -1:
                continue
            p = p + 1
print(p)

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    set<string> s;
    for (int i = 0; i < n; i++) {
        string t; cin >> t;
        s.emplace(t);
    }
    cout << s.size() << "\n";
    return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	int a = 0;
	int b = n;
	for (int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		a = max(a, l);
		b = min(b, r);
	}

	cout << (a <= b ? b-a+1 : 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

int main() {
  int N;
  std::cin >> N;

  std::map<std::string, int> dict;
  int max_votes = 0;

  for (int i=0; i<N; i++) {
    std::string S;
    std::cin >> S;
    dict[S]++;
    max_votes = std::max(max_votes, dict[S]);
  }

  for (auto const& p : dict) {
    if (p.second == max_votes) {
      std::cout << p.first << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 25216