akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int A, B, K;

int main(void)
{

	cin >> A >>B >> K;

	for (int i = 1; i <= K; i++)
	{
		if (i % 2)
		{
			if (A % 2 == 1)
			{
				A--;

				A = A / 2;

				B += A;

			}
			else
			{
				A = A / 2;

				B += A;
			}
		}
		else if (i % 2==0)
		{
			if (B % 2 == 1)
			{
				B--;

				B = B / 2;

				A += B;

			}
			else
			{
				B = B / 2;

				A += B;
			}
		}
	}

	cout << A << " " <<  B << endl;

	return 0;
}

Measured memory_bytes: 256
for x in range(1, int(input()) + 1):
  if x % 3 == 0:
    print(f' {x}', end = '')
  else:
    y = x
    while (y):
      if y % 10 == 3:
        print(f' {x}', end = '')
        break
      else:
        y //= 10
print()


Measured memory_bytes: 5884
#include <iomanip>
#include <iostream>
#include <vector>
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(5);
    //-----------------------------------------------
    int n, m;
    std::cin >> n >> m;
    int kadaiDay = 0;
    for (int i = 0; i < m; ++i) {
        int a;
        std::cin >> a;
        kadaiDay += a;
    }

    if (kadaiDay > n) {
        std::cout << "-1\n";
    } else {
        std::cout << n - kadaiDay << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include<iostream>

int main(){
    int X;
    std::cin >> X;
    int target = X;
    int fx = 0;
    while(target > 0){
        fx += target % 10;
        target /= 10;
    }
    if(X % fx == 0) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  vector<int> a(3);
  rep (i, 3) cin >> a[i];
  sort(all(a));
  cout << a[0] + a[1] << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if(S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if(i == N - 1) {
      cout << "Three" << endl;
    }
  }
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string s;
    cin >> s;

    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,fa[200005],a[200005],c0[200005],c1[200005],Fa[200005];
ll ans;
struct node{
	int pos,g0,g1;
};
struct cmp{bool operator()(node u,node v){return 1ll*u.g0*v.g1<1ll*v.g0*u.g1;}};
priority_queue<node,vector<node>,cmp> Q;

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

int find(int x){
	if(Fa[x]==x) return x;
	return Fa[x]=find(Fa[x]);
}

int main(){
	n=read();
	for(int i=2;i<=n;i++) fa[i]=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++){
		Fa[i]=i,c1[i]=a[i],c0[i]=a[i]^1;
		if(i>1) Q.push((node){i,c0[i],c1[i]});
	}
	while(!Q.empty()){
		node u=Q.top();Q.pop();
		int Pos=find(u.pos);
		if(u.g0!=c0[Pos]||u.g1!=c1[Pos]) continue;
		int Pos1=find(fa[Pos]);
		ans+=1ll*c1[Pos1]*c0[Pos];
		Fa[Pos]=Pos1,c1[Pos1]+=c1[Pos],c0[Pos1]+=c0[Pos];
		if(Pos1!=1) Q.push((node){Pos1,c0[Pos1],c1[Pos1]});
	}
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 8560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
    int n;
    cin >> n;

    vector<int> d(n);
    for(int i = 0; i < n; ++i) {
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());

    cout <<  d[n/2] - d[n/2-1] << endl;
    return 0;

}

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

const ll INF = 1001001001;
const ll mod = 1000000007;

int main(){
    ll x; cin >> x;
    ll ans = x / 11 * 2;
    ll tmp = x % 11;
    if(tmp > 6) ans += 2;
    else if(tmp != 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3624
#約数の個数の和（１~N）約数そのものを求めないので「速い」
def yakusu_num(N):
    ans =0
    for i in range(1,N+1):
        ans +=N//i #項数
    return ans


# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない

N = int(input())
ans =yakusu_num(N-1)

print(ans)

Measured memory_bytes: 65612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int factorial(int n)
{
    if(n==0)
        return 1;
        else
        {
            return n * factorial(n - 1);
        }
}

int main()
{
    int N;
    cin >> N;
    vint P(N), Q(N),X(N);

    rep(i, N)
    {
        X[i] = i+1;
        cin >> P[i];
   }
   rep(i,N)
   {
       cin >> Q[i];
   }

   int ansP = 0, ansQ = 0;
   do
   {
       for (int i = 0; i < N;i++)
       {
           if(X[i] < P[i])
               {
                   ansP++;
                   break;
               }
               else if(X[i]>P[i])
               {
                   break;
               }
               else if(i==N-1 and X[i]==P[i])
               {
                   ansP++;
                   break;
               }
              }
       for (int i = 0; i < N; i++)
       {
           if (X[i] < Q[i])
               {
                   ansQ++;
                   break;
               }
               else if (X[i] > Q[i])
               {
                   break;
               }
               else if (i == N - 1 and X[i] == Q[i])
               {
                   ansQ++;
                   break;
               }
       }

       } while (next_permutation(all((X))));

       cout << abs(ansQ - ansP);
       return 0;
}

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


void solve(int r, int D, int x){
  for (int i=0; i<10; i++) {
    x = r * x - D;
    cout << x << endl;
  }
}

int main(){
  int r;
  scanf("%d",&r);
  int D;
  scanf("%d",&D);
  int x;
  scanf("%d",&x);
  solve(r, D, x);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<char, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<int> K(Q);
    for (auto& k : K) {
        cin >> k;
    }
    for (auto& k : K) {
        queue<P> que;
        ll ans = 0;
        ll stock = 0;
        ll d_cnt = 0, m_cnt = 0;
        rep(i, 0, N) {
            while (que.size()) {
                if (que.front().first == 'D' && que.front().second <= i - k) {
                    que.pop();
                    stock -= m_cnt;
                    --d_cnt;
                }
                else if (que.front().first == 'M') {
                    que.pop();
                    --m_cnt;
                }
                else {
                    break;
                }
            }
            if (S[i] == 'D') {
                que.push(P(S[i], i));
                ++d_cnt;
            }
            else if (S[i] == 'M') {
                que.push(P(S[i], i));
                ++m_cnt;
                stock += d_cnt;
            }
            else if (S[i] == 'C') {
                ans += stock;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 9384
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
   int n,m,x,y;cin>>n>>m>>x>>y;
   vector<int> v(n+1),vv(m+1);
   for(int i=0;i<n;i++)cin>>v[i];
   for(int i=0;i<m;i++)cin>>vv[i];
   v[n]=x;
   vv[m]=y;
   int yay=*max_element(v.begin(),v.end()),wow=*min_element(vv.begin(),vv.end());
   if(yay>=wow){cout<<"War";return 0;}
   else {cout<<"No War";}
   
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	vector<ll> b(n);
	map<ll,ll> mp;
	rep(i,n){
		b[i]=i+1-a[i];
		mp[b[i]]++;
	}
	ll ans=0;
	rep(i,n){
		ans+=mp[a[i]+i+1];
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 28972
cands = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def add_v(v):
  global cands
  global K
  v0 = v % 10
  if v0 == 0:
    cands += [v*10, v*10+1]
    K -=2
  elif v0 == 9:
    cands += [v*10+8, v*10+9]
    K -= 2
  else:
    cands += [v*10+v0-1, v*10+v0, v*10+v0+1]
    K -= 3

K = int(input())
idk = K
K -= 9
idx = 0
while K >= 0:
  add_v(cands[idx])
  idx += 1

print(cands[idk-1])

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int N, M;
    string str;
    map<string, int> mp;
    cin >> N;
    REP(i, N){
        cin >> str;
        mp[str]++;
    }
    cin >> M;
    REP(i, M){
        cin >> str;
        mp[str]--;
    }
    int m = 0;
    for(auto p : mp) m = max(m, p.second);
    PRINT(m);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define test int t;cin>>t;while(t--)
#define INF 10000000
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
#define pb push_back
//#include "debug.cpp"
//__builtin_popcount

int32_t main()
{
    fast
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int d,t,s;
    cin>>d>>t>>s;
    if(d<=s*t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3636
def search_pattern( n )
	sum = 0
	0.upto( 9 ){|a|
		0.upto( 9 ){|b|
			0.upto( 9 ){|c|
				0.upto( 9 ){|d|
					sum += 1 if a + b + c + d == n
				}
			}
		}
	}
	#print "sum #{sum}\n"
	return sum
end

answer = Array.new
while line = $stdin.gets
	n = line.to_i
	answer << search_pattern( n )
end
answer.each{ |a|
	puts a
}


Measured memory_bytes: 6080
#include"bits/stdc++.h"
using namespace std;
int n,d;
int c[11][11];
int main()
{
	int ans=0;
	scanf("%d%d",&n,&d);
	for(int i=0;i<n;i++)
		for(int j=0;j<d;j++)
			scanf("%d",&c[i][j]);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			if(i==j)
				continue;
			int tmp=0;
			for(int k=0;k<d;k++)
				tmp+=(c[i][k]-c[j][k])*(c[i][k]-c[j][k]);
			if(sqrt(tmp)-(int)sqrt(tmp)==0)
				ans++;
		}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch PopularVote | diff PopularVote.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address PopularVote.cpp && ./a.out

/*
 
 4/4/2020
 
 5:02-5:13 WA
 6:20-6:40 give up
 
 
 
 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N,M;

bool solve_wrong() {
  sort(A,A+N),reverse(A,A+N);
  int sum=accumulate(A,A+N,0);
  int t=(sum+4*M-1)/(4*M);
  int cnt=0;
  REP(i,N) if(A[i]>=t) ++cnt;
  dump(cnt,sum,M,t,1.0*sum/(4*M));
  dumpC(A,A+N);
  return cnt>=M;
}

bool solve() {
  int sum=accumulate(A,A+N,0);
  long double t=1.0*sum/(4*M);
  int cnt=0;
  REP(i,N) if(A[i]>=t) ++cnt;
  return cnt>=M;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,N) cin>>A[i];
  cout<<(solve_wrong()?"Yes":"No")<<endl;
  
  return 0;
}


Measured memory_bytes: 256
p = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(",")
k = int(input())
print(p[k-1])

Measured memory_bytes: 38384
import math
H,W=map(int,input().split())
A=max(H,W)
B=min(H,W)
mini=10000000
if A%3==0 or B%3==0:
    print(0)
    exit(0)

for i in range(1,A):
    X=B*i
    Y=math.floor((A-i)/2)*B
    Z = math.ceil((A - i) /2) * B
    if mini>max(X,Y,Z)-min(X,Y,Z):
        mini=max(X,Y,Z)-min(X,Y,Z)

for i in range(1,A):
    X=B*i
    Y=math.floor(B/2)*(A-i)
    Z = math.ceil(B/ 2) * (A-i)
    if mini>max(X,Y,Z)-min(X,Y,Z):
        mini=max(X,Y,Z)-min(X,Y,Z)

for i in range(1,B):
    X=A*i
    Y=math.floor((B-i)/2)*A
    Z = math.ceil((B - i) / 2) * A
    if mini>max(X,Y,Z)-min(X,Y,Z):
        mini=max(X,Y,Z)-min(X,Y,Z)

for i in range(1,B):
    X=A*i
    Y=math.floor(A/2)*(A-i)
    Z = math.ceil(A/ 2) * (A-i)
    if mini>max(X,Y,Z)-min(X,Y,Z):
        mini=max(X,Y,Z)-min(X,Y,Z)

print(mini)


Measured memory_bytes: 3188
#include <iostream>
#include<bits/stdc++.h>
#define rep(k,i,n) for(int i=k;i<n;++i)
using namespace std;


int main(void){
    // Your code here!
    int N;
    cin>>N;
    int d[N],sum=0;
    rep(0,i,N)cin>>d[i];
    rep(0,i,N){
        rep(i+1,j,N)sum+=d[i]*d[j];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<String,Integer> map = new HashMap<String,Integer>();
        map.put("S",0);
        map.put("H",1);
        map.put("C",2);
        map.put("D",3);
        char a[] = new char[4];
        a[0] = 'S';
        a[1] = 'H';
        a[2] = 'C';
        a[3] = 'D';
        int card[][] = new int[4][13];
        for(int i = 0 ; i < 4 ; i++)
        {
            for(int j = 0 ; j < 13 ; j++)
                card[i][j] = 0;
        }
        int n = sc.nextInt();
        for(int i = 0 ; i < n ; i++)
        {
            String key = sc.next();
            int num = sc.nextInt();
            card[map.get(key)][num-1]++;
        }
        for(int i = 0 ; i < 4 ; i++)
        {
            for(int j = 0 ; j < 13 ; j++)
            {
                if(card[i][j] == 0)
                    System.out.println(a[i] + " " + (j+1));
            }
        }
    }
}



Measured memory_bytes: 26292
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
// #include <cctype>


using namespace std;


int main()
{
    string str;
    int n;
    cin >> str >> n;

    while (n--)
    {
        string cmd, str_rep;
        cin >> cmd;
        int a, b;
        cin >> a >> b;
        if (cmd == "print")
        {
            cout << str.substr(a, b-a+1) << endl;
        }
        else if (cmd == "reverse")
        {
            reverse(&str[0]+a, &str[0]+b+1);
        }
        else
        {
            cin >> str_rep;
            str.replace(a, b-a+1, str_rep);
        }

    }

}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int len=s.size();
	if(len==2) cout<<s;
	else if(len==3){
		reverse(s.begin(),s.end());
		cout<<s;	
	} 
	return 0;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
listB = list(map(int, input().split()))
index=0
count=0
while index < n:
    listA = list(map(int, input().split()))
    index2=0
    sum=0
    while index2 < m:
        sum+=listA[index2]*listB[index2]
        index2+=1
    if sum + c > 0:
        count+=1
    index+=1
print(count)

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

print(count)

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

int main(){
  int d,w;
  int e[10][10]={};
  int ans=0;
  while(cin>>d>>w,d!=0||w!=0){
    for(int i=0; i<d; i++){
      for(int j=0; j<w; j++){
				cin>>e[j][i];
      }
    }
		ans=0;
    for(int x=0;x<=w-3;x++){
      for(int y=0;y<=d-3;y++){
				for(int sx=3;sx<=w-x;sx++){
					for(int sy=3;sy<=d-y;sy++){
						int inmax=0,outmin=10,sum=0;
						for(int s=x;s-x<sx;s++){
							for(int t=y;t-y<sy;t++){
								if(s==x||t==y||s-x==sx-1||t-y==sy-1){
									outmin=min(outmin,e[s][t]);
								}else{
									inmax=max(inmax,e[s][t]);
								}
							}
						}
						if(outmin>inmax){
							for(int s=x+1;s-x<sx-1;s++){
								for(int t=y+1;t-y<sy-1;t++){
									sum+=outmin-e[s][t];
								}
				      }
	    			  ans=max(ans,sum);
						}
					}
				}
      }
    }
    cout<<ans<<endl;
  }
}



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

void Main()
{
	int N; cin >> N;
	map<string, int> mp;
	rep(i,N) {
		vector<char> data;
		rep(_,10) {
			char tmp;
			cin >> tmp;
			data.push_back(tmp);
		}
		sort(data.begin(),data.end());
		string tmp = "";
		rep(j,10) {
			tmp += data[j];
		}
		mp[tmp] += 1;
	}
	ll res = 0;
	for (auto p : mp) {
		res += (ll)p.second * ((ll)p.second - (ll)1) / (ll)2;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 12800
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC

int main(){
    vector<int> vec(0);
    int n,k,tmp=0,ans=0;cin>>n>>k;
    string s;cin>>s;
    bool flag;if(s[0]=='1')flag=true;else flag=false;
    for(int i=0;i<n;i++){
        if(flag){
            if(s[i]=='1')tmp++;
            else{
                vec.pb(tmp);tmp=1;flag=false;
            }
        }
        else{
            if(s[i]=='0')tmp++;
            else{
                vec.pb(tmp);tmp=1;flag=true;
            }
        }
    }
    vec.pb(tmp);
    tmp=0;int sz=vec.size();
    if(s[0]=='1'){
        if(vec.size()/2<=k)ans=n;
        else{
            for(int i=0;i<2*k+1;i++)tmp+=vec[i];
            ans=max(ans,tmp);
            int pt=2*k+1;
            while(pt+1<sz){
                tmp-=vec[pt-2*k-1]+vec[pt-2*k];
                tmp+=vec[pt]+vec[pt+1];
                ans=max(ans,tmp);
                pt+=2;
            }
            if(s[n-1]=='0'){
                tmp-=vec[pt-2*k-1]+vec[pt-2*k];
                tmp+=vec[pt];
                ans=max(ans,tmp);
            }
        }
    }
    else{
        if((vec.size()+1)/2<=k)ans=n;
        else{
            for(int i=0;i<2*k;i++)tmp+=vec[i];
            ans=max(ans,tmp);
            int pt=2*k;
            bool fi=true;
            while(pt+1<sz){
                if(fi){
                    tmp-=vec[0];
                    fi=false;
                }
                else{tmp-=vec[pt-2*k]+vec[pt-2*k-1];}
                tmp+=vec[pt]+vec[pt+1];
                ans=max(ans,tmp);
                pt+=2;
            }
            if(s[n-1]=='0'){
                tmp-=vec[pt-2*k];
                if(pt-2*k-1>=0)tmp-=vec[pt-2*k-1];
                tmp+=vec[pt];
                ans=max(ans,tmp);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4032
from collections import defaultdict

n = int(input())
max_ = 0
dd = defaultdict(int)
for _ in range(n):
  s = input()
  dd[s] += 1
  max_ = max(max_, dd[s])
ans = []
for key, value in dd.items():
  if value == max_:
    ans.append(key)
ans.sort()
print(*ans, sep = "\n")

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll L;
  IN(L);
  double L3 = L;
  L3 /= 3;
  printf("%.12lf\n", L3*L3*L3);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
int ans = 0;
for(int i = 0; i <= n - 3; i++) {
if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
}
cout << ans << endl;
return 0;
}

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

#define mp make_pair
#define pb push_back

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



map<ll, int> cnt;
const int maxn = 2e5+1;
ll a[maxn];
int n;

int main()
{
  scanf("%d", &n);
  cnt[0] = 1;
  ll ans = 0;
  for (int i = 1; i <= n; ++i)
    {
      scanf("%lld", a+i);
      ans += cnt[a[i] += a[i-1]];
      ++cnt[a[i]];
    }
  printf("%lld\n", ans);
}


Measured memory_bytes: 14336
process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	"use strict"
	const N=+lines[0];
	const H=lines[1].split(" ").map(Number);
	
	var temp=0;
	var ans=0;
	
	for(var i=1;i<N;i++){
		if(H[i]<=H[i-1]){
			temp++;
			temp>ans && (ans=temp);
		} else {
			temp=0;
		}
	}
	console.log(ans);
});

Measured memory_bytes: 27468
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
//ll a[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	ll a,b,c,k;
	 cin>>a>>b>>c>>k;
	if(a>=k)cout<<k;
	else if(a<k&&a+b>=k)cout<<a;
	else {
		cout<<a-(k-(a+b));
	}	
 	
}

Measured memory_bytes: 3640
#include <stdio.h>

typedef long long lli;

int main() {
	lli n, a, b;
	scanf("%lld %lld %lld",&n,&a,&b);
	if(a>b) {
		puts("0");
		return 0;
	}
	if(n==1) {
		if(a==b) puts("1");
		else puts("0");
		return 0;
	}
	lli r1=(n-1)*a+b, r2=(n-1)*b+a;
	printf("%lld\n",r2-r1+1);
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)

def main():
    A,V = map(int,input().split())
    B,W = map(int,input().split())
    T = int(input())

    dx = abs(A-B)
    dv = V-W

    if dv*T >= dx:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

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

int64_t S(int64_t n) {
	int64_t ans = 0;
	while (n != 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

int main() {
	int K;
	cin >> K;
	int64_t n = 0, d = 1;
	for (int i = 0;i < K;i ++) {
		if ((n + d) * S(n + 10 * d) > (n + 10 * d) * S(n + d)) d *= 10;
		n += d;
		cout << n << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず式変形、nS(m) ≦ mS(n)な訳だ
ここでn < mなのは確定的に明らかだし、S(m)≧S(n)じゃないと反例が作れないね
ここでnを下から見て最初に9でない位置をaとして、m=n+10^aとして考えてみよう
この時、mS(n) - nS(m) = (n+10^a)S(n) - n(S(n) + 1) = 10^aS(n) - nとなるね
これが0未満になるとまずいことが分かるので、aは10^a・S(n)-nが0以上になる最小のaを考えれば良い

……厳密証明ができないので端折ります、ごめんね！！
*/

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    word = input().rstrip()
    len_w = len(word)
    if word[len_w-1]=="s":
        print(word+"es")
    else:
        print(word+"s") 
if __name__ == "__main__":
    main()

Measured memory_bytes: 9524
#include <stdio.h>
#include <stdlib.h>

#define swap(type,x,y) do{type t = x;x=y;y=t;} while(0)

void bubble(int a[],int n)
{
    int i,j;
    for(i=0;i<n-1;i++){
        for(j = n-1;j>i;j--)
            if(a[j-1] > a[j])
                swap(int,a[j-1],a[j]);
    }
}

int main (void)
{
    int i;
    int m[9] = {0};
    

    for(i=0;i<10;i++){
        scanf("%d",&m[i]);
    }
    bubble(m,10);
    printf("%d\n",m[9]);
    printf("%d\n",m[8]);
    printf("%d\n",m[7]);

    return 0;
}

Measured memory_bytes: 600
j = 0
while 1:
    m = int(input())
    if m == 0:
        break
    a = list(map(int,input().split()))
    min = 99999999999
    a.sort()
    for i in range(len(a)-1):
        num = a[i+1] - a[i]
        if min > num:
            min = num
    print(min)
    j += 1
    


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

using namespace std;

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s == "abc") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long n, m, sum;

int main() {
    cin >> n >> m;
    
    for (int i = 1; i <= m; i++) {
        long long nr;
        cin >> nr;
        sum += nr;
    }

    cout << max((long long) -1, n - sum);
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e;
    while(1){
        cin>>a>>b>>c;
        d=a+b;
        if(a==-1&&b==-1&&c==-1){
            break;
        }else if(d<30||a==-1||b==-1){
            cout<<"F"<<endl;
        }else if(d>=80){
            cout<<"A"<<endl;
        }else if(d>=65){
            cout<<"B"<<endl;
        }else if(d>=50||d>=30&&c>=50){
            cout<<"C"<<endl;
        }else if(d>=30){
            cout<<"D"<<endl;
        }
    }
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void){
  int N, X;
  cin >> N >> X;
  int D = 0;
  int ans = 1;
  for(int n = 0; n < N; ++n){
    int l;
    cin >> l;
    D += l;
    if(D <= X){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N,X;
  cin >> N >> X;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  for(int j = 0;j < N;j++) {
    vec.at(j) = vec.at(j) - X;
    if(vec.at(j) < 0) {
      vec.at(j) = vec.at(j) * -1;
    }
  }
  int answer = vec.at(0);
  for(int k = 0;k < N;k++) {
    int A = max(answer,vec.at(k));
    int B = min(answer,vec.at(k));
    int R = A % B;
    while(R != 0) {
      A = B;
      B = R;
      R = A % B;
    }
    answer = B;
  }
  cout << answer << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python

def main():
    N = int(input())
    d = [[] for _ in range(N)]

    for i in range(N):
        city, score = input().split()
        d[i] = [i+1, city, int(score)]

    d.sort(key = lambda x: (x[1], -x[2]))

    for item in d:
        print(item[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
//最大公約数
ll gcd(ll a, ll b){
        if(b == 0) return a;
        return gcd(b, a % b);
}
// 最小公倍数
ll lcm(ll a, ll b){
        return a / gcd(a, b) * b;
}


int main(int argc, char const *argv[]) {
  ll n,a[100010],ans=1,sum=0,ki=0,gu=0;
  std::cin >> n;
  for(int i=0; i<n; i++){
     std::cin >> a[i];
     sum+=a[i];
     if(a[i]%2==1) ki++;
     else gu++;
  }
  sort(a,a+n);
  ans=gcd(a[0],a[1]);
  for(int i=2; i<n; i++){
    ans=gcd(ans,a[i]);
  }
  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string g,ax;
  	cin>>g;
  	int f=g.size();
  	if(g[f-1]=='s')
    {
      ax="es";
      g.append(ax);
    }
  	else{
      ax='s';
      g.append(ax);}
  cout<<g;
  return 0;
}


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

int N;
int a[1010][1010];
int head[1001010];
struct Edge
{
    int to;
    int next;
}edge[1001010];
int cnt;

void add_edge(int from,int to)
{
    cnt++;
    edge[cnt].to=to;
    edge[cnt].next=head[from];
    head[from]=cnt;
}

int deg[1001010];
int exist[1001010];
int ans;

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

    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=N-2;j++)
        {
            int t1=i,t2=i;
            int x = a[i][j],y=a[i][j+1];
            if(t1>x) swap(t1,x);
            if(t2>y) swap(t2,y);
            x = t1*1000+x;
            y = t2*1000+y;
            add_edge(x,y);
            deg[y]++;
            exist[x]=exist[y]=true;
        }
    }
    queue<int> q;
    for(int i=1;i<=N*1000+N;i++)
        if(exist[i]&&deg[i]==0)
            q.push(i);

    while(!q.empty())
    {
        int cnt=q.size();
        for(int i=0;i<cnt;i++)
        {
            int t=q.front();
            q.pop();
            exist[t]=false;
            for(int e=head[t];e;e=edge[e].next)
            {
                int to=edge[e].to;
                deg[to]--;
                if(deg[to]==0) q.push(to);
            }
        }
        ans++;
    }
    for(int i=1;i<=N*1000+N;i++)
        if(exist[i])
        {
            cout<<-1;
            return 0;
        }
    cout<<ans;
}


Measured memory_bytes: 23808
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d, time float64
	fmt.Scan(&a, &b, &c, &d)

	time = math.Min(b, d) - math.Max(a, c)

	if time < 0 {
		time = 0
	}

	fmt.Println(time)
}


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

typedef long long ll;

vector<vector<bool> > make_comb(vector<vector<bool> > v, int depth, int k){
    vector<vector<bool> > res;
    while (!v.empty())
    {
        vector<bool> comb1 = v.back();
        vector<bool> comb2 = v.back();
        v.pop_back();
        comb1.push_back(true);
        comb2.push_back(false);
        res.push_back(comb1);
        res.push_back(comb2);
    }

    if(k < depth){
        res = make_comb(res, depth, k+1);
    }
    return res;
}

int main(){
    int D, G;
    cin >> D >> G;

    int point_map[10][2];
    int ans = 0;
    for(int i=0;i<D;i++){
        cin >> point_map[i][0] >> point_map[i][1];
        ans += point_map[i][0];
    }

    vector<vector<bool> > comb;
    vector<bool> seed;
    comb.push_back(seed);
    comb = make_comb(comb, D, 1);

    for(int i=0;i<comb.size();i++){
        int num = 0;
        ll point = 0;
        for(int j=0;j<comb[i].size();j++){
            if(comb[i][j]){
                num += point_map[j][0];
                point += (j+1)*100*point_map[j][0]+point_map[j][1];
            }
        }

        if(point < G){
            ll diff = G - point;
            for(int j=comb[i].size()-1;j>=0;j--){
                if(!comb[i][j]){
                    int n = 0;
                    while((j+1)*100*n<diff && n<=point_map[j][0]){
                        n++;
                    }

                    num += n;
                    point += (j+1)*100*n;
                    break;
                }
            }
        }

        if(point >= G){
            if(num < ans){
                ans = num;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int greedy_bit_fs(vector<pii>& item, vi& bonus, int LowLimit) {
    int N = item.size();
    int res = INF;
    REP(p, 1<<N) {
        int ptn = p;
        int scr = 0;
        int cnt = 0;
        int lv = -1;
        REP(i,N) {
            int vi = item[i].first;
            int ci = item[i].second;
            if (ptn & 0b01) {
                scr += vi * ci + bonus[i];
                cnt += ci;
                if (scr >= LowLimit)
                    res = min(res, cnt);
            } else {
                lv = max(lv, i);
            }
            ptn >>= 1;
        }

        if (scr < LowLimit) {
            if (lv >= 0){
                int v = item[lv].first;
                int c = item[lv].second;
                for(int j = c; j > 0; j--) {
                    if (scr + v * j >= LowLimit) {
                        res = min(res, cnt + j);
                    }
                }
            }
        }
    }
    return res;
}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int D, G; cin>>D>>G;
    vi P(D), C(D); REP(i,D) cin>>P[i]>>C[i];

    vector<pii> item(D);
    REP(i,D)
        item[i] = mkpr((i+1)*100, P[i]);

    int ans = greedy_bit_fs(item, C, G);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

vector<long long> dp(50, -1);
int fib(int x) {
    if(dp[x] != -1) return dp[x];
    if(x == 0 || x == 1) return dp[x] = 1;
    return dp[x] = fib(x-1) + fib(x-2);
}

int main() {
    int n;
    cin >> n;
    cout << fib(n) << endl;
}


Measured memory_bytes: 3092
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

int main(){
	string s;
	while(cin>>s,s!="0"){
		vvi dp(s.size()+1,vi(11));
		REP(i,s.size()){
			REP(j,11){
				dp[i+1][(j*10+(s[i]-'0'))%11]=dp[i][j];
			}
			if(s[i]-'0'){
				dp[i+1][s[i]-'0']++;
			}
		}
		int ans=0;
		REP(i,s.size()){
			ans+=dp[i+1][0];
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 8136
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define LL long long
#define ULL unsigned long long 
#define y second
#define sqr(x) ((x)*(x))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define MEM(x) memset(x,0,sizeof(x))
#define pi acos(-1)
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
LL dp[6005][2005];
int mod;
LL DP(int x,int hole){
    if(x==0)return 1;
    if(dp[x][hole]!=-1)return dp[x][hole];
    dp[x][hole]=0;
    if(x>=3&&hole){
        dp[x][hole]+=DP(x-3,hole-1)*(x-2)%mod*(x-1)%mod;
    }
    if(x>=2&&hole){
        dp[x][hole]+=DP(x-2,hole-1)*(x-1)%mod;
    }
    dp[x][hole]+=DP(x-1,hole);
    dp[x][hole]%=mod;
    return dp[x][hole];
}

int main(){ 
 //   dp[0][0][0]=1;
    int n;
    scanf("%d %d",&n,&mod);
    MEMS(dp);
    printf("%lld\n",DP(3*n,n));

}
/*

5
AACCMMAA
A
AA
MM
ACA
ACMAA


5
0 9 7 1 100
-1 0 -1 -1 91
-1 5 0 -1 96
-1 8 9 0 99
-1 -1 -1 -1 0
3 4
3 5
5 6
5 7
3 or 4
3 or 5
5 or 6
5 or 7

dp[x]=max(dp[x-w_i*j]+j*t_i-delta t_i*j*(j-1)/2)
dp[x]=max(dp[j]+x*t_i-j*t_i-delta t_i*(x-j)*(x-j-1)/2)
dp[x]=max(dp[j]-j*t_i-delta t_i *(j^2/2+j/2) - 
        delta t_i * xj + x*t_i + delta t_i * (x^2/2-x/2))
dp[x]=max(dp[j] + g(j) - delta t_i *xj + w(i) )
g(j)= dp[j]-j*t_i-delta t_i *(j^2/2+j/2)
w(i)=  x*t_i + delta t_i * (x^2/2-x/2)
x^2/2 -xj -x/2  +j^2/2 +j/2
*/

/*
 

*/

Measured memory_bytes: 94720
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	ll A, B, K;
  	cin >> A >> B >> K;
  	if(A>K){
      	A -= K;
    }
  	else{
      	K -= A;
      	A = 0;
      	if(B > K){ B -= K;}
      	else{ B = 0; }
    }
    cout << A << " " << B << endl;       
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

const int nax = 303 ;

double dp[nax][nax][nax] ;

int main()
{
    int n ;
    scanf("%d",&n) ;
    vector<int> cnt(4,0) ;
    for(int i = 0 ; i < n ; ++i)
    {
        int x ;
        scanf("%d",&x) ;
        ++cnt[x] ;
    }
    for(int k = 0 ; k <= n ; ++k)
    {
        for(int j = 0 ; j <= n ; ++j)
        {
            for(int i = 0 ; i <= n ; ++i)
            {
                if(i==0 && j==0 && k==0) continue ;

                if((i+j+k)>n) continue ;

                double sum = 1.0*(i+j+k) ;

                if(i)
                {
                    dp[i][j][k] += ((1.0*i)/sum) * dp[i-1][j][k] ;
                }

                if(j)
                {
                    dp[i][j][k] += ((1.0*j)/sum)*dp[i+1][j-1][k] ;
                }

                if(k)
                {
                    dp[i][j][k] += ((1.0*k)/sum)*dp[i][j+1][k-1] ;
                }

                dp[i][j][k] += (1.0*n)/sum ;
            }
        }
    }

    printf("%.15lf\n",dp[cnt[1]][cnt[2]][cnt[3]]) ;
}


Measured memory_bytes: 217344
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ll n,k;
    cin>>n>>k;
    n=n%k;
    ll m=abs(n-k);
    //cout<<n<<m<<" ";
    cout<<min(n,m)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define mii map<int,int>
#define inf 1000000007 //10^9+7
#define for(i,n) for(int i=0;i<n;i++)
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define in(a,b,vec,n) a n; cin>>n; vector<b>vec(n);
#define gcd __gcd
using namespace std;

signed main() {
  int n;
  cin>>n;
  int a=n%11;
  if(6<a) {
    cout<<2*(n/11)+2<<endl;
  }
  else if(a) {
    cout<<2*(n/11)+1<<endl;
  }
  else {
    cout<<2*(n/11)<<endl;
  }
}

Measured memory_bytes: 256