akhauriyash/Code-Regression huggingface dataset:
s=input()
y=s[0:4]
m=s[5:7]
d=s[8:]
ans='Heisei'
if(int(y) < 2019):
    print(ans)
elif(int(y) == 2019):
    print(['TBD',ans][int(m)<=4])
else:
   print('TBD')

Measured memory_bytes: 3060
while 1:
    n=int(input())
    if n==0:break
    dp=[1]+[0]*3000
    for i in range(n):
        a,b=map(int,input().split())
        for j in range(1001,-1,-1):
            for k in range(1,b+1):
                dp[j+a*k]+=dp[j]
    for _ in range(int(input())):
        print(dp[int(input())])

Measured memory_bytes: 7592
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000
int dp(int now,int p,int q);
int gcd(int p,int q);
int n,x,y;
int a[49],b[49],c[49];
int memo[49][490][490];

int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n>>x>>y;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  int temp=dp(0,0,0);
  if(temp==INF)cout<<-1<<endl;
  else cout<<temp<<endl;
  return(0);
}

int dp(int now,int p,int q){
  int rec=INF;
  if(memo[now][p][q]!=-1)return memo[now][p][q];
  if(now==n){
    if(p==0&&q==0)return INF;
    int g=gcd(max(p,q),min(p,q));
    if(p/g==x&&q/g==y)return 0;
    else return INF;
  }
  rec=min(rec,dp(now+1,p,q));
  rec=min(rec,dp(now+1,p+a[now],q+b[now])+c[now]);
  return memo[now][p][q]=rec;
}

int gcd(int p,int q){
  if(q==0)return p;
  return gcd(q,p%q);
}


Measured memory_bytes: 46208
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
  int H, W;
  cin >> H >> W;
  string A[H];
  for (int i = 0; i < H; ++i) {
    cin >> A[i];
  }
  ll Q=1000000007;
  // ll dp[H][W];
  // for (int i = 0; i < H; ++i) {
  //   for (int j = 0; j < W; ++j) {
  //     dp[i][j] = 0;
  //   }
  // }
  vector<vector<ll>> dp(H, vector<ll>(W,0));
  dp[0][0] = 1;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (i != H-1) {
        if (A[i+1][j] == '.') {
          dp[i+1][j] = (dp[i+1][j] + dp[i][j])%Q;
        }
      }
      if (j != W-1) {
        if (A[i][j+1] == '.') {
          dp[i][j+1] = (dp[i][j+1] + dp[i][j])%Q;
        }
      }
    }
  }
  cout << dp[H-1][W-1] << "\n";
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

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

    vector<ll> dp(N);
    dp[0] = 1000;
    for (int i = 1; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            dp[i] = max(dp[j], dp[i]);
            dp[i] = max(dp[j] / A[j] * A[i] + dp[j] % A[j], dp[i]);
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int f(int a, int b) {
  return abs(a - b);
}

int main(int argc, char const* argv[])
{
  int n;
  cin>>n;
  int dp[n+1];
  vector<int> hs(n+1);
  REP(i,n) cin>>hs[i+1];

  dp[1] = 0;
  dp[2] = f(hs[1], hs[2]);

  REP(i,n-2) {
    dp[i+3] = min(dp[i+1]+f(hs[i+3], hs[i+1]), dp[i+2]+f(hs[i+3], hs[i+2]));
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
typedef pair<int,int> P;	//現在コスト、島の番号

int n,k;
int cost[101][101];
int Dijkstra(int left,int get){
	int done[101] = {0};	//確定後のコストを格納
	int mincost[101];
	for(int i = 0;i < 101;i++)
		mincost[i] = 500000000;
	priority_queue<P,vector<P>,greater<P> >que;
	P edge;
	que.push(P(0,left));
	while(done[get] == 0 && !que.empty()){
		edge.first = que.top().first;
		edge.second = que.top().second;
		que.pop();
		//何度も同じ頂点にコストが更新される(pushされる)ことがあるので、確定後に残りのケースが作動しないようにする。
		if(done[edge.second])
			continue;
		//確定後のコスト
		done[edge.second] = edge.first;
		//確定した頂点から枝を伸ばす(今までの最小を記録することで重複探索を減らす)
		for(int i = 1;i <= n;i++){
			if(cost[edge.second][i] > 0 && done[i] == 0 && mincost[i] > edge.first+cost[edge.second][i]){
				mincost[i] = edge.first+cost[edge.second][i];
				que.push(P(edge.first+cost[edge.second][i],i));
			}
		}
	}
	if(done[get])
		return done[get];
	return -1;
}
int mincost[50000],mcor = 0;
int main(){
	int i,j,a,b,c,d;
	while(true){
		cin >> n >> k;
		if(n == 0 && k == 0)
			break;
		for(i = 0;i < 101;i++){
			for(j = 0;j < 101;j++){
				cost[i][j] = 0;
			}
		}
		for(i = 0;i < k;i++){
			cin >> a;
			if(a == 0){
				cin >> b >> c;
				mincost[mcor] = Dijkstra(b,c);
				mcor++;
			}
			else{
				cin >> b >> c >> d;
				if(cost[b][c] == 0 || cost[b][c] > d)
					cost[b][c] = d;
				if(cost[c][b] == 0 || cost[c][b] > d)
					cost[c][b] = d;
			}
		}
	}
	for(i = 0;i < mcor;i++){
		cout << mincost[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
import java.util.*;

class Main {
    // ABC152D
    static final long MOD = 1_000_000_007;
    // 10^9+7
    static final int MAX = 2_147_483_646;
    // intの最大値
    static final int INF = 1_000_000_000;

    // 10^9
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int ans = h/a + (h%a == 0?0:1);
        System.out.println(ans);
    }
   
}


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



int main(){
  
  int a[3];

  for(int i=0;i<3;i++){
    cin >>a[i];
  }
  sort(a,a+3);
  int ans;
  ans=a[2]-a[0];
 
  
  cout <<ans<<endl;
  return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
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()
{
  //input
  string S;
  cin >> S;
  
  //main
  string ans = "Good";
  for(int i=0; i<S.length()-1; i++){
    if(S[i] == S[i+1]){
      ans = "Bad";
    }
  }
  
  // output
  cout << ans << endl;
    
  return 0;
}


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

typedef int64_t s64;
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}
int main() {
	char c[2][2] = {{'R', 'Y'}, {'G', 'B'}};
	int h = ri(), w = ri(), d = ri();
	std::pair<int, int> a[h][w];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) a[i][j] = {(i + j) / d, (i - j + w) / d};
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) putchar(c[a[i][j].first % 2][a[i][j].second % 2]);
		std::cout << std::endl;
	}
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    cout << (int)sqrt(N)*(int)sqrt(N) << endl;
    
    return 0;
}


/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

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

int main() {
    int64_t N ;
    cin >> N;
    int64_t X=N;
    int ttl=0;
    for (int i = 2; i <= sqrt(X); i++)
    {
        int cnt=0;
        //cout << N/i << endl;
        while (N%i==0)
        {
            N/=i;
            cnt++;
        }
        for (int j= 1; j < 10; j++)
        {
            cnt-=j;
            if(cnt>=0) ttl++;
            else break;
        }
    }
    if(N!=1) cout << ttl+1 << endl;
    else cout << ttl << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end() 

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

long long INF=numeric_limits<long long>::max();

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
  int a,b,c; cin >> a >> b >> c;
  int d = max(a,max(b,c));
  int t = a+b+c - d;
  cout << t << endl;
}	

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    string s, t, ans;
    cin >> s >> t;
    int i, j, cnt=0;
    
    for(i=(int)(s.size()-t.size()); i>=0; i--) {
        cnt=0;
        if(s[i]==t[0] || s[i]=='?') {
            for(j=0; j<t.size(); j++) {
                if(s[i+j]==t[j] || s[i+j]=='?')
                    cnt++;
            }
        }
        if(cnt==t.size()) {
            for(j=0; j<t.size(); j++)
                s[i+j]=t[j];
            for(j=0; j<s.size(); j++) {
                if(s[j]=='?')
                    s[j]='a';
            }
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
S = list(input())
L = len(S)
Slist = set()
for i in range(L):
    Slist.add(ord(S[i]))
Slist = list(Slist)
Slist.sort()
ans = "None"
j = 0
L = len(Slist)
for i in range(97, 123):
    if Slist[j] == i:
        j += 1
        if j >= L and i+1 < 123:
            ans = chr(i+1)
            break
        continue
    ans = chr(i)
    break
print(ans)


Measured memory_bytes: 9748
#include <iostream>
#include <vector>

const int MAX_N = 5050;
const int MAX_K = 5050;

int main() {
	int n, k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}

	std::vector<std::vector<bool>> dpl(MAX_N, std::vector<bool>(MAX_K, false));
	std::vector<std::vector<bool>> dpr(MAX_N, std::vector<bool>(MAX_K, false));
	dpl[0][0] = true;
	dpr[n][0] = true;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < MAX_K; j++) {
			if (dpl[i][j]) dpl[i + 1][j] = true;
			if (j + a[i] < MAX_K and dpl[i][j]) {
				dpl[i + 1][j + a[i]] = true;
			}
			if (dpr[n - i][j]) dpr[n - i - 1][j] = true;
			if (j + a[n - 1 - i] < MAX_K and dpr[n - i][j]) {
				dpr[n - i - 1][j + a[n - 1 - i]] = true;
			}
		}
	}

	std::vector<std::vector<int>> sl(MAX_N, std::vector<int>(MAX_K, 0));
	std::vector<std::vector<int>> sr(MAX_N, std::vector<int>(MAX_K, 0));
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j + 1 < MAX_K; j++) {
			sl[i][j + 1] = sl[i][j] + (dpl[i][j] == true);
			sr[i][j + 1] = sr[i][j] + (dpr[i][j] == true);
		}
	}

	int ans = n;
	for (int i = 0; i < n; i++) {
		bool need = false;
		for (int j = 0; j < k; j++) {
			int vl = std::max(0, k - a[i] - j), vr = k - j;
			if (dpl[i][j]) need |= (sr[i + 1][vr] - sr[i + 1][vl] > 0);
			if (dpr[i + 1][j]) need |= (sl[i][vr] - sl[i][vl] > 0);
		}
		if (need) ans--;
	}
	
	std::cout << ans << '\n';

	return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    if (n == k) { cout << "0\n"; return 0; }
    int h[n]; for (int i = 0; i < n; i++) cin >> h[i];
    long long dp[n+1][n+1];
    const long long INF = 1LL<<60;
    long long ans = INF;
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) dp[i][0] = INF;
    for (int i = 1; i <= n; i++) {
        dp[i][1] = h[i-1];
        for (int j = 2; j <= n; j++) {
            dp[i][j] = INF;
            for (int x = 1; x < i; x++)
                dp[i][j] = min(dp[i][j], dp[x][j-1] + max(0, h[i-1]-h[x-1]));
            if (j >= n-k) ans = min(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] arg) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		boolean[] res = new boolean[n];
		int result = 0;
		for(int i = 0; i < k; i++){
			int d = scan.nextInt();
			for(int j = 0; j < d; j++){
				int a = scan.nextInt();
				res[a-1] = true;
			}
		}
		for(int i = 0; i < n; i++){
			if(res[i] == false)result++;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 46060
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	int W; cin >> W;
	vector<pair<ll,ll>>vec(N);
	rep(i, N) {
		ll a, b; cin >> a >> b;
		vec[i] = make_pair(a, b);
	}
	vector<vector<ll>>dp(N + 1, vector <ll>(100001, 1e16));
	dp[0][0] = 0;
	rep(i, N) {
		ll weight = vec[i].first, value = vec[i].second;
		rep(j, 100001) {
			chmin(dp[i + 1][j], dp[i][j]);
			if (j >= value) {
				chmin(dp[i + 1][j], dp[i][j - value] + weight);
			}
		}
	}
	int ans = 0;
	rep(i, dp[N].size()) {
		if (dp[N][i] <= W)chmax(ans, i);
	}
	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  lint n, k;
  cin >> n >> k;
  vector< lint > ap, am;
  lint mod = 1e9+7;
  lint p=0, m=0, z=0;
  for (lint i=0; i<n; ++i) {
    lint ai;
    cin >> ai;
    if (ai==0) z++;
    if (ai>0) {p++; ap.push_back(ai);}
    if (ai<0) {m++; am.push_back(ai);}
  }
  sort(ap.rbegin(), ap.rend());
  sort(am.begin(), am.end());
  if (p+m < k) {
    cout << 0 << endl;
    return 0;
  }
  if (m/2*2 + p >= k && (p>0 || k%2==0)) {
    lint ans = 1;
    lint pi=0, mi=0;
    for (lint i=0; i<k; ++i) {
      if (mi == m) {
	ans *= ap[pi];
	pi++;
      } else if (pi == p) {
	ans *= (am[mi]+mod);
	mi++;
      } else if (ap[pi] > -am[mi]) {
	ans *= ap[pi];
	pi++;
      } else {
	ans *= (am[mi]+mod);
	mi++;
      }
      ans %= mod;
    }
    if (mi%2 == 1) {
      /*
	a*c -> a*b or c*d
	a b
	c d
       */
      ans = 1;
      bool flg;
      if (pi == p) flg = false;
      else if (mi == m) flg = true;
      else if (pi==0) flg = true;
      else if (mi==0) flg = false;
      else if (ap[pi]*ap[pi-1] > am[mi]*am[mi-1]) flg=true;
      else flg=false;
      if (flg) {
	for (lint i=0; i<=pi; ++i) {ans *= ap[i]; ans %= mod;}
	for (lint i=0; i<mi-1; ++i) {ans *= (am[i]+mod); ans %= mod;}
      } else {
	for (lint i=0; i<pi-1; ++i) {ans *= ap[i]; ans %= mod;}
	for (lint i=0; i<=mi; ++i) {ans *= (am[i]+mod); ans %= mod;}
      }
    }
    cout << ans << endl;
    return 0;
  }
  sort(ap.begin(), ap.end());
  sort(am.rbegin(), am.rend());
  lint pi=0, mi=0;
  lint ans = 1;
  for (lint i=0; i<k; ++i) {
    if (mi == m) {
      ans *= ap[pi];
      pi++;
    } else if (pi == p) {
      ans *= (am[mi]+mod);
      mi++;
    } else if (ap[pi] < -am[mi]) {
      ans *= ap[pi];
      pi++;
    } else {
      ans *= (am[mi]+mod);
      mi++;
    }
    ans %= mod;
  }
  if (z>0) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5576
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 3e5 + 7;
const int maxm = 1e7 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

int H,W,A,B;

int cnt[2];
int ans[1007][1007];

bool check()
{
	for(int i=1;i<=H;i++)
	{
		memset(cnt,0,sizeof(cnt));
		for(int j=1;j<=W;j++)
			cnt[ans[i][j]]++;
		if(min(cnt[0],cnt[1])!=A)
		{
			return false;
		}
	}
	for(int j=1;j<=W;j++)
	{
		memset(cnt,0,sizeof(cnt));
		for(int i=1;i<=H;i++)
			cnt[ans[i][j]]++;
		if(min(cnt[0],cnt[1])!=B)
			return false;
	}
	return true;
}

int main()
{
	//freopen("1.in","r",stdin);
	scanf("%d%d%d%d",&H,&W,&A,&B);
	
	for(int i=1;i<=B;i++)
	{
		for(int j=1;j<=W;j++)
			ans[i][j]=(j>A);
	}
	for(int i=B+1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
			ans[i][j]=(j<=A);
	}
	if(check())
	{
		for(int i=1;i<=H;i++)
		{
			for(int j=1;j<=W;j++)
				printf("%d",ans[i][j]);
			printf("\n");
		}
	}
	else
	{
		printf("-1\n");
	}
	
	return 0;
}


Measured memory_bytes: 5120
// AOJ DPL_5_F Balls and Boxes 6
// n 個の区別できないボールを k 個の区別できる箱に入れる
// とき、可能な入れ方の総数を求めてください。
// ただし、
//    どのボールも、必ずいずれかの箱に入れる。
//    どの箱にも、1つ以上のボールを入れる。
// 答えは組み合わせ combi(n-1, k-1)
// 2019.3.11 bal4u

#include <stdio.h>
#include <stdlib.h>

#define MOD 1000000007
int tbl[1001][1001];

int combi(int n, int k)
{
	int ans;

	if (tbl[n][k]) return tbl[n][k];
	if ((k << 1) > n) k = n - k;
	if (k == 0) ans = 1;
	else if (k == 1) ans = n;
	else ans = combi(n - 1, k) + combi(n - 1, k - 1);
	return tbl[n][k] = ans % MOD;
}

int main()
{
	int n, k;

	scanf("%d%d", &n, &k);
	if (n < k) puts("0");
	else printf("%d\n", combi(n-1, k-1));
	return 0;
}


Measured memory_bytes: 5640
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int h, w;
	char a;
	int count = 0;

	cin >> h >> w;

	for (int i = 0; i < h * w; i++) {
		cin >> a;
		if (a == '#') {
			count++;
		}
	}

	if (count == (h + w - 1)) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;
}


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

int main()
{
	int n,k;
	cin>>n>>k;
	char A[n];
	for(int i=0;i<n;i++)
	cin>>A[i];
	char x=A[0];
	int h=0,c=0;
	for(int i=1;i<n;i++)
	{
		if(A[i]==x)h++;
		else c++;
		x=A[i];
	}	
	int ans=min(n-1,h+2*min(c,k));	
	cout<<ans;
	return 0;
}

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

int main()
{
    int N, K, count=0;

    cin >> N >>K;
    vector<int> h(N);

    for (int i = 0; i < N; i++){
        cin >> h.at(i);
        if(h.at(i)>=K){
            count++;
        }
    }


    cout << count << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+1;

int k, a[N];
int main() {
	cin >> k;
	for(int i = 1; i <= k; i++) cin >> a[i];
	int64_t l = 2, r = 2;
	for(int i = k; i >= 1; i--) {
		// normalize
		l = (l+a[i]-1) / a[i] * a[i];
		r = (r / a[i]) * a[i];
		// get upper bound
		r += a[i] - 1;
		if(l > r) cout << -1, exit(0);
	}
	cout << l << ' ' << r;
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c;
    while(true){
        if(a > b){
             d=a;
             a=b;
             b=d;
        }else if(b>c){
             d=b;
             b=c;
             c=d;
        }/*else if(a>b){
             d=a;
             a=b;
             b=d;
        }*/else{
        break;
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 3124
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    l, r, d = LI()
    count = 0
    for i in range(l, r+1):
        if i % d == 0:
            count += 1
        else:
            pass
    print(count)
    return


if __name__ == "__main__":
    solve()


Measured memory_bytes: 65748
//
// Created by HDawn on 2020/7/2.
//
#include <bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MAX = 500010;
const int SENTINEL = 2000000000;
int n, cnt;
int A[MAX];
int L[MAX / 2 + 2], R[MAX / 2 + 2];

void Merge(int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; ++i)
        L[i] = A[left + i];
    for (int i = 0; i < n2; ++i)
        R[i] = A[mid + i];
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j])
            A[k] = L[i++];
        else
            A[k] = R[j++];
    }
}

void MergeSort(int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        MergeSort(left, mid);
        MergeSort(mid, right);
        Merge(left, mid, right);
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &A[i]);
    }
    MergeSort(0, n );
    printf("%d", A[0]);
    for (int i = 1; i < n; ++i) {
        printf(" %d", A[i]);
    }
    printf("\n%d\n", cnt);
    return 0;
}




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

int main(){
long long int N;
cin >>N; long long int M[N];
for(long long int i=0;i<N;i++){
cin >> M[i];
}
if(N==1)cout <<"Yes";
for(long long int i=N-2;i>=0;i--){
   if(M[i]-1==M[i+1]){
      M[i]-=1;
       if(i==0)cout <<"Yes";
      continue;
   } else if(M[i]-1>M[i+1]){
      cout <<"No";
      break;
   }
   if(i==0)cout <<"Yes";
}
 }



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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll ruiseki(vector<ll> &sum, int l, int r){
	ll ret = sum[r];
	if(l)ret -= sum[l-1];
	return ret;
}

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

	ll n, m, v, p;cin >> n >> m >> v >> p;
	vector<ll> a(n);
	REP(i, n){
		cin >> a[i];
	}
	sort(ALL(a));

	vector<ll> sum(n);
	REP(i, n){
		sum[i] = a[i];
		if(i)sum[i] += sum[i-1];
	}

	//SHOW1d(a, n);

	ll ans = 0;
	REP(i, n){
		//cout << i << endl;
		if(i >= n - p){
			ans++;
			continue;
		}

		ll pla = lower_bound(ALL(a), a[i] + m + 1) - a.begin();
		//cout << "  " << pla << endl;
		if(pla < n - (p - 1))continue;
		pla = min(pla, n - p);
		ll cou = lower_bound(ALL(a), a[i]+1) - a.begin();
		ll seica = max(0LL, (pla - cou + 1)) * (a[i] + m) - ruiseki(sum, cou, pla);
		//cout << "  " << cou << " " << seica << " " << (v - p) * m << endl;
		if(cou * m + seica >= (v - (p - 1)) * m)ans++;
	}

	cout << ans << endl;

	return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    double a, b;
    cin >> a >> b;
    for( int i = 1; i <= 1000; ++i ) {
        if( (int)(i * 1.08) - i == a && int(i * 1.1) - i == b ) {
            cout << i << endl;
            return 0;

        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#! /usr/bin/python3
# ABC044_A
# A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit)

"""
制約
    1 ≤ N,K ≤ 10000
    1 ≤ Y < X ≤10000
    N, K ,X ,Y はいずれも整数である
"""


def main():
    """
    全体の処理を実行するmain関数
    """
    N = int(input())  # 宿泊日程 N泊
    K = int(input())  # 価格の変わる基準
    X = int(input())  # K泊までの宿泊費
    Y = int(input())  # K+1泊目以降の宿泊費

    charges = 0 # 宿泊費の合計

    if N <= K:
        charges += N*X
    else:
        charges += K*X + (N-K)*Y
    # 宿泊費の算出

    print(charges)
    # 宿泊費の出力

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
double PI=atan(1.)*4;
double F(int n,double*x,double*y)
{
	double res=0;
	for(int i=1;i+1<n;++i)
		res+=((x[i]-x[0])*(y[i+1]-y[0])-(y[i]-y[0])*(x[i+1]-x[0]))/2;
	return res;
}
void I(int n,double*x,double*y)
{
	int a,i,t;
	for(i=a=0;i<n;)
	{
		x[i]=cos(a*PI/180);
		y[i]=sin(a*PI/180);
		if(++i<n)scanf("%d",&t),a+=t;
	}
}
int main()
{
	int n;
	double s,t,x[360],y[360];;
	while(scanf("%d",&n),n)
	{
		I(n,x,y);
		s=F(n,x,y);
		scanf("%d",&n);
		I(n,x,y);
		t=F(n,x,y);
		puts(fabs(s-t)<1e-9?"0":s>t?"1":"2");
	}
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        long[] sum = new long[n + 1];

        sum[0] = 0;
        long max = 0;
        for (long i = 1; i <= n; i++)
        {
            sum[i] = sum[i - 1] + i;
            if (sum[i] >= n)
            {
                max = i;
                break;
            }
        }

        for (long i = max; i > 0; i--)
        {
            if (n >= i)
            {
                Console.WriteLine(i);
                n -= i;
            }
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

ll INF = LONG_LONG_MAX;

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  int sx, sy, gx, gy;
  cin >> sy >> sx >> gy >> gx;
  sx--;
  sy--;
  gx--;
  gy--;
  vector<string> c(h);
  rep(i, h)
    cin >> c[i];
  vector<vector<vector<ll>>> dp(h, vector<vector<ll>>(w, vector<ll>(4, INF)));
  priority_queue
  <
    tuple<ll, int, int, int>,
    vector<tuple<ll, int, int, int>>,
    greater<tuple<ll, int, int, int>>
  > q;
  q.emplace(0, sy, sx, 0);
  while (!q.empty())
  {
    ll dist;
    int x, y, dir;//dir 0:U, 1:R, 2:D, 3:L
    tie(dist, y, x, dir) = q.top();
    q.pop();
    if (dp[y][x][dir] != INF)
      continue;
    dp[y][x][dir] = dist;
    if (dir == 0)
    {
      if (y > 0 && c[y-1][x] == '.')
        q.emplace(dist + 1, y - 1, x, 0);
      q.emplace((dist + k - 1) / k * k, y, x, 1);
      q.emplace((dist + k - 1) / k * k, y, x, 2);
      q.emplace((dist + k - 1) / k * k, y, x, 3);
    }
    else if (dir == 1)
    {
      if (x < w - 1 && c[y][x+1] == '.')
        q.emplace(dist + 1, y, x + 1, 1);
      q.emplace((dist + k - 1) / k * k, y, x, 0);
      q.emplace((dist + k - 1) / k * k, y, x, 2);
      q.emplace((dist + k - 1) / k * k, y, x, 3);
    }
    else if (dir == 2)
    {
      if (y < h - 1 && c[y+1][x] == '.')
        q.emplace(dist + 1, y + 1, x, 2);
      q.emplace((dist + k - 1) / k * k, y, x, 0);
      q.emplace((dist + k - 1) / k * k, y, x, 1);
      q.emplace((dist + k - 1) / k * k, y, x, 3);
    }
    else
    {
      if (x > 0 && c[y][x-1] == '.')
        q.emplace(dist + 1, y, x - 1, 3);
      q.emplace((dist + k - 1) / k * k, y, x, 0);
      q.emplace((dist + k - 1) / k * k, y, x, 1);
      q.emplace((dist + k - 1) / k * k, y, x, 2);
    }
  }
  ll ans = min({dp[gy][gx][0], dp[gy][gx][1], dp[gy][gx][2], dp[gy][gx][3]});
  if (ans == INF)
  {
    puts("-1");
    return 0;
  }
  ans = (ans + k - 1) / k;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 144936
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

char S[5];
bool a, b, c;

int main(void) {
    scanf("%s", S);
    
    REP (i, 0, 3) {
      if (S[i] =='a') a = true;
      else if (S[i] == 'b') b = true;
      else c = true;
    }
   
    
    if (a && b && c) puts("Yes");
    else puts("No");
    

	return 0;
}


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

#define MAX 100002

int n;

long long int a[MAX];

char buf[2];

long long int dp[MAX][3];

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 3; j++){
			dp[i][j] = LLONG_MIN;
		}
		if (i){
			scanf("%s", buf);
		}
		scanf("%lld", &a[i]);
		if (i){
			if (buf[0] == '-'){
				a[i] *= -1;
			}
		}
	}
	dp[0][0] = a[0];
	for (int i = 0; i+1 < n; i++){
		for (int j = 0; j < 3; j++){
			if (dp[i][j] == LLONG_MIN)continue;
			long long int val = 1;
			if (j % 2){
				val *= -1LL;
			}
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]+a[i+1]*val);
			val *= -1LL;
			if (j){
				dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + a[i+1] * val*-1LL);
			}
			if (j + 1 < 3&&a[i+1]<0){
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i+1] * val*-1LL);
			}
		}
	}
	long long int ans = dp[n-1][0];
	ans = max(ans, dp[n - 1][1]);
	ans = max(ans, dp[n - 1][2]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 1e6+1 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
//const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}

void solve(){
	int x , y , n , m ;
	cin >> x >> y ;
	if((x+y) %3){
		cout << "0\n" ;
		return ;
	}
	n = (2*y-x) / 3 ;
	m = (2*x-y) / 3 ;
	if(n<0 || m < 0){
		cout << "0\n" ;
		return ;
	}
	init(N) ;
	cout <<choose(n+m,n) << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 31488
#include <stdio.h>
int main(){
 int A1, A2, A3;
 scanf("%d %d %d", &A1, &A2, &A3);
 if(A1+A2+A3<22){
  printf("win\n");
 }else if(A1+A2+A3>=22){
  printf("bust\n");
 }
 return 0;
}

Measured memory_bytes: 1628
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    string s;
    getline(cin, s);
    int k;
    scanf("%d", &k);
    unordered_set<string> subs;
    vector<string> vec;
//    cout << s << k << endl;
    for (int x = 0; x <= s.size(); x++) {
        string q = "";
        for (int y = 0; y < k && x + y < s.size(); y++) {
            q += s[x + y];
            if (!subs.count(q)) {
//                cout << q << endl;
                subs.insert(q);
                vec.push_back(q);
            }
        }
    }
    sort(all(vec));
    printf("%s\n", vec[k - 1].c_str());
    return 0;
}


Measured memory_bytes: 1664
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string s;
    cin >> s;
    int a[4] = {};
    for (int i = 0; i < 4; i++) {
        a[i] = s[i] - '0';
    }

    string ans;
    for (int i = (1 << 3) - 1; i >= 0; --i) {
        int tem = i, se = a[0];
        for (int j = 0; j < 3; j++) {
            if (tem & 1) {
                se += a[j + 1];
            } else {
                se -= a[j + 1];
            }

            tem = tem >> 1;
        }

        tem = i;
        if (se == 7) {
            ans += s[0];
            for (int j = 0; j < 3; j++) {
                if (tem & 1) {
                    ans.push_back('+');
                    ans.push_back(s[j + 1]);
                } else {
                    ans.push_back('-');
                    ans.push_back(s[j + 1]);
                }

                tem = tem >> 1;
            }

            ans += "=7";

            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e18+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 1010000
#define offset 200
#define ptr tree*


using namespace std;
struct nodo
{
	ll valor;
	ll totbarrera,inicial;
	nodo(){}
};
nodo tree[tam];

void push(nodo &algo,ll &pnodo,ll &iz,ll &der)
{
	assert(iz<=der);
	if (algo.totbarrera+algo.inicial!=0)
	{
		if (iz!=der)
		{
			nodo &hijo1=tree[pnodo*2];
			nodo &hijo2=tree[pnodo*2+1];

			hijo1.totbarrera+=algo.totbarrera;
			hijo2.totbarrera+=algo.totbarrera;

			ll m=(iz+der)/2;
			hijo1.inicial+=algo.inicial;
			hijo2.inicial+=algo.inicial+(m-iz+1)*algo.totbarrera;
		}
		else
		{
			algo.valor+=algo.totbarrera+algo.inicial;
		}
		algo.inicial=algo.totbarrera=0;
	}else assert(algo.totbarrera==0 && algo.inicial==0);
	algo.inicial=algo.totbarrera=0;
}
void clr()
{
	forr(i,0,tam)
	{
		tree[i].valor=tree[i].totbarrera=tree[i].inicial=0;
	}
}

ll v[tam];
ll N,M;


void query(ll pnodo,ll iz,ll der,ll li,ll ri,nodo &cambio)
{
	
	push(tree[pnodo],pnodo,iz,der);
	if (der<li|| iz>ri)return;
	if (iz>=li && der<=ri)
	{
		//<<"entro "<<iz<<' '<<der<<endl;
		tree[pnodo].totbarrera+=cambio.totbarrera;
		tree[pnodo].inicial+=cambio.inicial;
		cambio.inicial+=(der-iz+1);
		return;
	}
	if (iz==der)return;
	initseg;
	query(new_nodo,iz,mid,li,ri,cambio);
	query(new_nodo+1, mid+1,der,li,ri,cambio);
}
ll buscar(ll pnodo,ll iz,ll der)
{
	push(tree[pnodo],pnodo,iz,der);
	if (iz==der)
	{
		return tree[pnodo].valor;
	}
	initseg;
	return max(buscar(new_nodo,iz,mid)
		,		buscar(new_nodo+1,mid+1,der));

}
void change(ll pos1,ll pos2)
{
	pos1++,pos2++;
	nodo cambio;
	cambio.totbarrera=1;
	cambio.inicial=0;
	if (pos1>pos2)
	{
		//<<"camibol 2";
		//<<pos1<<' '<<M<<' '<<1<<' '<<pos2<<endl;
		query(1,1,M,pos1,M,cambio);
		//cambio.inicial++;
		query(1,1,M,1,pos2,cambio);
	}
	else
	{
		query(1,1,M,pos1,pos2,cambio);
	}
}
int main()
{
	clr();
	cin>>N>>M;
	forr(i,0,N){
		cin>>v[i];
		v[i]--;
	}
	ll tot=0;
	forr(i,1,N)
	{
		tot+=(v[i]-v[i-1]+M)%M;
		if (((v[i]-v[i-1]+M)%M)<=1)continue;
		change((v[i-1]+2)%M,v[i]);
		
	}
	tot-=buscar(1,1,M);

	assert(tot>=0);
	cout<<tot<<endl;
}

Measured memory_bytes: 28084
#include <bits/stdc++.h>
using namespace std;
int main( ) {
    //freopen("A.01.inp","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    char op;
    cin >> a >> op >> b;
    int ret = a+b;
    if (op=='-') ret = a-b;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long lnt;
#define REP(i, n) for (lnt i = 0; i < (n); i++)
#define FOR(i, a, b) for (lnt i = (a); i < (b); i++)
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define BIT(i) POW(2, i)
#define INF 2e18 // cf. LLONG_MAX ≒ 9x10^18
#define START int main
#define SET unordered_set
#define MAP unordered_map
#define COUNT (lnt) count
#define SIZE (lnt) size
#define F first
#define S second
#define LOWER lower_bound
#define UPPER upper_bound
#define PB push_back

lnt POW(const lnt x, const int y) {
  lnt init = 1;
  for (int i = 0; i < y; i++) {
    init *= x;
  }
  return init;
}

START() {
  lnt n;
  cin >> n;
  vector<lnt> v;
  REP(i, n) {
    lnt w;
    cin >> w;
    v.push_back(w);
  }

  vector<lnt> vEven, vOdd; // 0-based
  REP(i, n) {
    if (i % 2 == 0) {
      vEven.push_back(v[i]);
    } else {
      vOdd.push_back(v[i]);
    }
  }

  sort(ALL(vEven));
  sort(ALL(vOdd));

  pair<pair<lnt, lnt>, lnt> trMax0(pair<lnt, lnt>(0, 0), 0),
      trMax1(pair<lnt, lnt>(0, 0), 0); //((nMostNum, MostNum), n2ndMostNum)
  FOR(i, 1, POW(10, 5)) {
    lnt nNum0 = distance(LOWER(ALL(vEven), i), UPPER(ALL(vEven), i)),
        nNum1 = distance(LOWER(ALL(vOdd), i), UPPER(ALL(vOdd), i));
    if (nNum0 >= trMax0.F.F) {
      trMax0.S = trMax0.F.F;
      trMax0.F.F = nNum0;
      trMax0.F.S = i;
    } else if (nNum0 >= trMax0.S) {
      trMax0.S = nNum0;
    }
    if (nNum1 >= trMax1.F.F) {
      trMax1.S = trMax1.F.F;
      trMax1.F.F = nNum1;
      trMax1.F.S = i;
    } else if (nNum1 >= trMax1.S) {
      trMax1.S = nNum1;
    }
  }

  if (trMax0.F.S != trMax1.F.S) {
    cout << n - trMax0.F.F - trMax1.F.F << endl;
  } else {
    cout << n - max(trMax0.F.F + trMax1.S, trMax1.F.F + trMax0.S) << endl;
  }
}


Measured memory_bytes: 2800
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string s, t;

int main() {
	cin >> s >> t;
	cout << t + s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 10000000000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=3005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	int n;
	cin>>n;
	lli a[n+4],sum=0;
	FOR0(n){
		cin>>a[i];
		sum+=a[i];
	}
//	dp[0][0]=0;
	lli dp[N+5][N+5];
	mem(dp,0);
//	FOR0(N+5){
//		for(int j=0;j<N+5;j++){
//			dp[i][j][0]=0;
//			dp[i][j][1]=-1*inf;
//		}
//	}
//	for(int i=1;i<=n;i++){
//		int pr=i%2;
//		int dpr=1-pr;
//		for(int j=i;j>=0;j--){
//			int bk=n-(i-j)+1;
//			if(pr==0)
//			dp[i][j][pr]=max(dp[i-1][j-1][dpr]+a[j],dp[i-1][j][dpr]+a[bk]);
//			else
//			dp[i][j][dpr]=min(dp[i-1][j-1][pr]-a[j],dp[i-1][j][pr]-a[bk]);
//		}
//	}
//	lli ans=0;
//	if(n%2==0){
//		FOR0(n+1){
//			ans=max(ans,dp[n][i][0]);
//		}
//		cout<<ans;
//		return 0;
//	}
//	ans=-1*inf;
//	FOR0(n+1){
//			ans=min(ans,dp[n][i][1]);
//		}
//		cout<<ans;
	for(int i=n-1;i>=0;i--){
		for(int j=i;j<n;j++){
			if(i==j) dp[i][j]=a[i];
			else dp[i][j]=max(-dp[i+1][j]+a[i],-dp[i][j-1]+a[j]);
		}
	}
	cout<<dp[0][n-1];
}



Measured memory_bytes: 71040
#include <stdio.h>
int max(int a,int b){ return a<b?b:a;}
int min(int a,int b){ return a>b?b:a;}
int n,xs=1e9,ys=1e9,xb=-1e9,yb=-1e9,ret=1e9,x[100005],y[100005],v;
int main(){
	scanf("%d",&n);
	for(int i=0,a,b;i<n;i++){
		scanf("%d%d",&a,&b);
		x[i]=a-b; y[i]=a+b;
		xs=min(xs,x[i]); xb=max(xb,x[i]);
		ys=min(ys,y[i]); yb=max(yb,y[i]);
	}
	for(int i=0;i<n;i++) v=max(v,min(max(x[i]-xs,y[i]-ys),max(xb-x[i],yb-y[i]))); ret=min(ret,v);v=0;
	for(int i=0;i<n;i++) v=max(v,min(max(x[i]-xs,yb-y[i]),max(xb-x[i],y[i]-ys)));
	ret=min(ret,v);
	printf("%d\n",ret);
}

Measured memory_bytes: 1808
#include <stdio.h>

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

Measured memory_bytes: 256
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                for(int i=1; i<=5;i++){
                    int x = scan.nextInt();
                    if(x==0){
                        System.out.println(i);
                    }
                }
                
                
                
                
        }
}

Measured memory_bytes: 35740