akhauriyash/Code-Regression huggingface dataset:
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadLine();
            bool flag = true;
            for (int i = 0; i < s.Length; i++)
            {
                //奇数
                if (i % 2 == 0)
                {
                    if (s[i] == 'L')
                    {
                        flag = false;
                    }
                }
                else
                {
                    if (s[i] == 'R')
                    {
                        flag = false;
                    }
                }
            }
            WriteLine(flag ? "Yes" : "No");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const char nl = '\n';

// INT VS LL

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

    int x;
    cin>>x;
    vector<bool> prime(x+101, true);
    prime[0]=prime[1]=0;
    for (int i=2; i<=x+100; ++i){
    	if (!prime[i]) continue;
    	for (int j=2*i; j<=x+100; j+=i){
    		prime[j]=0;
    	}
    }
    for (int i=x; i<=x+100; ++i){
    	if (prime[i]){
    		cout<<i<<nl;
    		return 0;
    	}
    }
    assert(1==2);

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll; 
//vector<vector<int>> vec(50,vector<int>(4,0));
vector<vector<int>> vec;

	

int main() {
	int X;
	cin >> X;
	rep(i,-120,120){
		rep(j, -120, 120) {
			if (pow(i, 5) - pow(j, 5) == X) {
				cout << i << " " << j << '\n';
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main() {
  string S;
  cin >> S;
  ll ans = 0;
  rep(i, 1<<(S.size()-1)) {
    ll add = 0, sum = 0;
    rep(j, S.size()-1) {
      if(i & 1<<(S.size()-2-j)) {
        sum += add*10+(S[j]-'0');
        add = 0;
      }
      else
        add = add*10+(S[j]-'0');
    }
    sum += add*10+(S[S.size()-1]-'0');
    ans += sum;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000;

typedef long long ll;
typedef unsigned long long ull;

ll dp[1010][3][1010];

int main(void) {

  string s, t;
  cin >>s >> t;
  cout << t << s << endl;
  return 0
    ;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;
int main()
{
	int n,i;
	long long sum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++) sum+=i;
	printf("%lld\n",sum); 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;
int n, m;
long long int ans;

char x[16];

bool prime(long long int x)
{
	for (long long int i = 2; i * i <= x; i++){
		if (x % i == 0) return (false);
	}
	return (x != 1);
}

void dfs(int idx)
{
	if (idx == n){
		if (prime(atoll(x))) ans = max(ans, atoll(x));
		return;
	}
	for (int i = '0'; i <= '9'; i++){
		if (idx == 0 && (i != '1' && i != '3' && i != '7' && i != '9')) continue;
		x[idx] = i; x[2 * n - idx] = i;
		dfs(idx + 1);
	}
}

int main()
{	
	scanf("%d %d", &n, &m);
	if (m < 0){
		if (n != 1) for (int i = 0; i < 2 * n; i++) printf("9");
		else printf("11");
		printf("\n");
	}
	else {
		x[2 * n + 1] = 0;
		x[n] = m + '0';
		dfs(0);
		printf("%lld\n", ans);
	}
	return (0);
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
// ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


int main() {
    int N; cin>>N;
    using P = pair<string,ii>;
    vector<P> a(N);
    rep(i,N){
        string s; int t;
        cin >> s >> t;
        a[i] = P(s, ii(-t, 1+i));
    }
    sort(ALL(a));
    rep(i,N){
        cout << a[i].second.second << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int midterm[50],termend[50],retest[50],sum[50];
	int i,n,stop=0;
	
	for(i=0;i<50;i++){
		scanf("%d %d %d",&midterm[i],&termend[i],&retest[i]);
		sum[i]=midterm[i]+termend[i];
		if(midterm[i]==-1&&termend[i]==-1&&retest[i]==-1){
		stop=i;
		break;
		}
	}
	for(n=0;n<stop;n++){
		if(midterm[n]==-1||termend[n]==-1){
			printf("F\n");
		}
		else if(sum[n]>=80){
			printf("A\n");
		}
		else if(sum[n]<80&&sum[n]>=65){
			printf("B\n");
		}
		else if(sum[n]<65&&sum[n]>=50){
			printf("C\n");
		}
		else if(sum[n]<50&&sum[n]>=30&&retest[n]>=50){
			printf("C\n");
		}
		else if(sum[n]<50&&sum[n]>=30&&retest[n]<50){
			printf("D\n");
		}
		else if(sum[n]<30){
			printf("F\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2052
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());

		System.out.println(C-(A-B) > 0 ? C-(A-B) : 0);


	}

}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;

    if(N==1){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3644
object Main {
  def main(args: Array[String]): Unit = {
    val factors      = io.StdIn.readLine().split(" ").map{_.toInt}
    var store_info   = Vector.empty[Vector[Int]]
    var total_fee    = 0l
    var purchase_num = 0

    (0 until factors(0)).foreach { i =>
      store_info = store_info :+ io.StdIn.readLine().split(" ").map{_.toInt}.toVector
      
    }

    store_info = store_info.sortWith(_(0) < _(0))

    (0 until factors(0)).foreach { i =>
      var buy_num = 0
      if(purchase_num >= factors(1)) buy_num = 0
      else if(purchase_num + store_info(i)(1) >= factors(1)) buy_num = factors(1) - purchase_num
      else buy_num = store_info(i)(1)

      total_fee    += (store_info(i)(0).toLong*buy_num).toLong
      purchase_num += buy_num
    }
    println(total_fee)
  }
}

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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> S(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      S.at(i).at(j) = c - '0';
    }
  }
  int ans = 1e9;
  for (int bit = 0; bit < 1 << (H - 1); bit++) {
    vector<int> div(H);
    int tmp = 0;
    div.at(0) = tmp;
    for (int i = 1; i < H; i++) {
      if (bit >> (i - 1) & 1) tmp++;
      div.at(i) = tmp;
    }
    vector<int> cnt(tmp + 1);
    int cut = __builtin_popcount(bit);
    for (int w = 0; w < W; w++) {
      vector<int> chk(tmp + 1);
      for (int h = 0; h < H; h++) {
        if (S.at(h).at(w)) chk.at(div.at(h))++;
      }
      int mx = *max_element(chk.begin(), chk.end());
      if (mx > K) goto NG;
      for (int h = 0; h < H; h++) {
        if (S.at(h).at(w)) cnt.at(div.at(h))++;
      }
      mx = *max_element(cnt.begin(), cnt.end());
      if (mx > K) {
        cut++;
        for (auto &c : cnt) c = 0;
        w--;
      }
    }
    ans = min(ans, cut);
    NG:;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>

int main()
{
    int n;
    while (std::cin >> n) {
    
        if (n == 0) break;

        int** p;
        p = new int* [n + 1];
        for (int i = 0; i < n + 1; ++i) {
            p[i] = new int [n + 1];
        }
        
        for (int i = 0; i < n + 1; ++i) {
            for (int j = 0; j < n + 1; ++j) {
                p[i][j] = 0;
            }
        }

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                std::cin >> p[i][j];
            }
        }

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                p[i][n] += p[i][j];
                p[n][j] += p[i][j];
            }
        }

        for (int i = 0; i < n; ++i) {
            p[n][n] += p[i][n];
        }

        for (int i = 0; i < n + 1; ++i) {
            for (int j = 0; j < n + 1; ++j) {
                printf("%5d", p[i][j]);
                if (j == n) std::cout << std::endl;
                
            }
        }

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

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  rep2(i, 1, 3501){
    rep2(j, 1, 3501){
      double d = (double)n*i*j / (double)(4*i*j-n*(i+j));
      int k = d;
      if(k != d || k < 0 || k > 3500) continue;
      cout << i << " " << j << " " << k << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int a[1005];
int main()
{
    int k=0;
    for(int i=2;i<=40;i++)
    {
        for(int j=2;j<=20;j++)
        {
            int t=i;
            for(int ii=2;ii<=j;ii++) t*=i;
            if(t<=1000) a[k++]=t;
        }
    }
    sort(a,a+k);
    int x;
    scanf("%d",&x);
    if(x==1) printf("1\n");
    else if(x<4) printf("2\n");
    else
    {
        int h=upper_bound(a,a+k,x)-a;
        printf("%d\n",a[h-1]);
    }
    return 0;
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,x,t;
	cin>>n>>x>>t;
	cout<<((n+x-1)/x)*t<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 3568
N = int(input())
p = list(map(int,input().split()))

list_p = [i for i in range(1,N+1) ]
flag = 0

if p == list_p:
    print("YES")

else:
    for i in range(N):
        for j in range(i+1,N):
            p[i],p[j] = p[j],p[i]

            if p == list_p:
                flag = 1
                break

            p[i],p[j] = p[j],p[i]
    
        if flag == 1:
            break

    print("YES" if flag == 1 else "NO")


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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}
template<typename T> inline T dmax(T x, T y){return x > y ? x : y;}
template<typename T> inline T dmin(T x, T y){return x < y ? x : y;}

const int MAXN = 2e5 + 5;

int N, a[MAXN];

ll calc(int ss){
	ll sum = 0;
	up (i, 1, N) sum += abs(ss + i - a[i]);
	return sum;
}

int main(){
#ifdef cydiater
	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &N);	
	up (i, 1, N) scanf("%d", &a[i]);
	int le = -1e5, ri = 1e9, mi1, mi2;
	while (le + 4 < ri) {
		mi1 = le + (ri - le) / 3;
		mi2 = ri - (ri - le) / 3;
		if (calc(mi1) > calc(mi2)) le = mi1;
		else ri = mi2;
	}
	ll ans = 1e18;
	up (i, le, ri) cmin(ans, calc(i));
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 2100 + 10;
const double EPS = 1e-8;

//max{cx | Ax <= b, x >= 0}
//无解或无&#31351;返回空vector
vector<double> simplex(vector<vector<double> > A, vector<double> b, vector<double> c)
{
	int n = A.size(), m = A[0].size() + 1, r = n, s = m - 1;
	vector<vector<double> > D(n + 2, vector<double>(m + 1, 0));
	vector<int> ix(n + m);
	for (int i = 0; i < n + m; ++ i) ix[i] = i;
	for (int i = 0; i < n; ++ i) {
		for (int j = 0; j < m - 1; ++ j) D[i][j] = -A[i][j];
		D[i][m - 1] = 1;
		D[i][m] = b[i];
		if (D[r][m] > D[i][m]) r = i;
	}
	for (int j = 0; j < m - 1; ++ j) D[n][j] = c[j];
	D[n + 1][m - 1] = -1;
	for (double d; ; ) {
		if (r < n) {
			int t = ix[s]; ix[s] = ix[r + m]; ix[r + m] = t;
			D[r][s] = 1.0 / D[r][s];
			for (int j = 0; j <= m; ++ j) if (j != s) D[r][j] *= -D[r][s];
			for (int i = 0; i <= n + 1; ++ i) if (i != r) {
				for(int j = 0; j <= m; ++ j) if (j != s) D[i][j] += D[r][j] * D[i][s];
				D[i][s] *= D[r][s];
			}
		}
		r = -1; s = -1;
		for (int j = 0; j < m; ++ j) if (s < 0 || ix[s] > ix[j]) {
			if (D[n + 1][j] > EPS || (D[n + 1][j] > -EPS && D[n][j] > EPS)) s = j;
		}
		if (s < 0) break;
		for (int i = 0; i < n; ++ i) if (D[i][s] < -EPS) {
			if (r < 0 || (d = D[r][m] / D[r][s] - D[i][m] / D[i][s]) < -EPS || (d < EPS && ix[r + m] > ix[i + m]))
				r = i;
		}
		if (r < 0) return vector<double>(); // 非有界
	}
	if (D[n + 1][m] < -EPS) return vector<double>(); // 无解
	vector<double> x(m - 1);
	for (int i = m; i < n + m; ++ i) if (ix[i] < m - 1) x[ix[i]] = D[i - m][m];
	return x; // &#20540;&#20026;D[n][m]
}

int n, m;
int from[N], to[N], w[N];
int dist[N], deg[N];
vector<pair<int, int> > adj[N];

void bfs()
{
	queue<int> que;
	que.push(0);
	dist[0] = 0;
	for( ; que.size(); ) {
		int u = que.front();
		que.pop();
		for(int e = 0; e < adj[u].size(); ++ e) {
			int v = adj[u][e].first;
			dist[v] = max(dist[v], dist[u] + adj[u][e].second);
			-- deg[v];
			if (deg[v] == 0) {
				que.push(v);
			}
		}
	}
}

void solve()
{
	for(int i = 0; i < n; ++ i) {
		adj[i].clear();
		dist[i] = -1;
		deg[i] = 0;
	}
	for(int i = 0; i < m; ++ i) {
		scanf("%d%d%d", from + i, to + i, w + i);
		adj[from[i]].push_back(make_pair(to[i], w[i]));
		++ deg[to[i]];
	}
	bfs();
	
	int col = n + m;
	int row = 2 * m + n + 2;
	vector<vector<double> > A(row, vector<double>(col));
	vector<double> b(row), c(col);
	for(int i = 0; i < col; ++ i) {
		if (i < n) c[i] = 0;
		else c[i] = 1;
	}
	int cur = 0;
	for(int i = 0; i < m; ++ i) {
		A[cur][i + n] = -1;
		b[cur] = -w[i];
		cur++;
	}
	for(int i = 0; i < n; ++ i) {
		A[cur][i] = -1;
		b[cur] = -dist[i];
		cur++;
	}
	A[cur][0] = 1;
	b[cur++] = 0;
	A[cur][n - 1] = 1;
	b[cur++] = dist[n - 1];
	for(int i = 0; i < m; ++ i) {
		A[cur][from[i]] = 1;
		A[cur][to[i]] = -1;
		A[cur][i + n] = 1;
		b[cur++] = 0;
	}
	vector<double> ret = simplex(A, b, c);
	double answer = 0;
	for(int i = 0; i < m; ++ i) {
		answer += ret[i + n] - w[i];
	}
	printf("%d\n", (int)(answer+1e-2));
}

int main()
{
	for( ; cin >> n >> m; ) {
		solve();
	}
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int A, B, C, D;
    A = S[0] - '0'; B = S[1] - '0'; C = S[2] - '0'; D = S[3] - '0';
    //+++
    if(A+B+C+D == 7)
        cout << A << '+' << B << '+' << C << '+' << D << "=7" << endl;
    //++-
    else if(A+B+C-D == 7)
        cout << A << '+' << B << '+' << C << '-' << D << "=7" << endl;
    //+-+
    else if(A+B-C+D == 7)
        cout << A << '+' << B << '-' << C << '+' << D << "=7" << endl;
    //+--
    else if(A+B-C-D == 7)
        cout << A << '+' << B << '-' << C << '-' << D << "=7" << endl;
    //-++
    else if(A-B+C+D == 7)
        cout << A << '-' << B << '+' << C << '+' << D << "=7" << endl;
    //-+-
    else if(A-B+C-D == 7)
        cout << A << '-' << B << '+' << C << '-' << D << "=7" << endl;
    //--+
    else if(A-B-C+D == 7)
        cout << A << '-' << B << '-' << C << '+' << D << "=7" << endl;
    //---
    else if(A-B-C-D == 7)
        cout << A << '-' << B << '-' << C << '-' << D << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    String S = sc.next();
    String C = sc.next();
    String[] A_array = A.split("");
    String[] S_array = S.split("");
    String[] C_array = C.split("");
    System.out.println(A_array[0]+S_array[0]+C_array[0]);
  }
}


Measured memory_bytes: 23892
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
char a[100],b[100];
int main(void)
{
     int i,j,k,n,m;
     scanf("%s%s",a,b);
     int l1=strlen(a);
     int l2=strlen(b);
     m=0;
     for(i=0;i<l1;i++)
     {
          if(a[i]==b[0]||a[i]=='?')
          {
               k=0;
               for(j=0;j<l2;j++)
               {
                    if(a[i+k]==b[j]||a[i+k]=='?')
                    {
                         k++;
                    }
                    else
                         break;
               }
               if(k==l2)
                    m=1,n=i;
          }
     }
     if(m==0)
          printf("UNRESTORABLE\n");
     else
     {
          k=0;
          for(i=n;i<n+l2;i++)
          {
               a[i]=b[k++];
          }
          for(i=0;i<l1;i++)
          {
               if(a[i]=='?')
                    a[i]='a';
          }
          puts(a);
     }
     return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      l: usize,
      aa: [usize; n],
    }

    let mut idx = n;
    for i in 0..n-1 {
        let len = aa[i] + aa[i+1];
        if len >= l {
            idx = i;
            break;
        }
    }
    if idx == n {
        return puts!("{}\n", "Impossible");
    }

    puts!("{}\n", "Possible");
    for i in 0..idx {
        puts!("{}\n", i+1);
    }
    for i in (idx+1..n-1).rev() {
        puts!("{}\n", i+1);
    }
    puts!("{}\n", idx+1);
}


Measured memory_bytes: 4860
using System;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            string S = Console.ReadLine();

            string firstreplaced = S.Replace("dream", "A").Replace("erase", "T");
            string secondreplaced = firstreplaced.Replace("Aer", "G").Replace("Tr", "C");
            string final = secondreplaced.Replace("A", "").Replace("T", "").Replace("G", "").Replace("C", "");

            if(final == "")
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

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

int main() {
	long S;
	cin >> S;
	//	X1 = Y1 = 0
	//	S = X2 * Y3 - X3 * Y2
	//	X2 = 10^9, X3 = 1
	//	S = 10^9 * Y3 - Y2
	long Y3 = (S + 1000000000 - 1) / 1000000000;
	long Y2 = 1000000000 * Y3 - S;
	cout << "0 0 1000000000 " << Y2 << " 1 " << Y3;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int X, i;
  string S;
  string ANS;
  ANS = "";
  cin >> X >> S;

  if (S.size() <= X){
    cout << S << endl;
  } else {
    for (i = 0; i < X; i++){
      ANS += S[i];
    }
    cout << ANS << "..." << endl;
  } 
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL << 25) // 33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void) {
  int n, k;
  string s, t;
  cin >> n >> k >> s;
  bool b = false;
  deque<char> d;
  REP(i, n) d.push_back(s[i]);

  REP(i, 2 * n + 1) {
    if (!b) {
      if (d[0] == 'A')
        d[0] = 'B';
      else {
        d.pop_front();
        d.push_back('B');
        b = true;
      }
    } else {
      if(d[0] == 'B') d[0] = 'A';
      else {
        d.pop_front();
        d.push_back('A');
        b = false;
      }
    }
    if(i == k-1) {
      for(char c: d) {
        if(!b) t += c;
        else {
          if(c == 'A') t += 'B';
          if(c == 'B') t += 'A';
        }
      }
      cout << t << endl;
      return 0;
    }
    if(i == 2*n-1) {
      for(char c: d) {
        if(!b) t += c;
        else {
          if(c == 'A') t += 'B';
          if(c == 'B') t += 'A';
        }
      }
    }
  }
  string r;
  for(char c: d) {
    if(!b) r += c;
    else {
      if(c == 'A') r += 'B';
      if(c == 'B') r += 'A';
    }
  }
  //周期1
  if(t == r) {
    cout << t << endl;
    return 0;
  //周期2
  } else {
    int tmp = k - 2*n + 1;
    if(tmp%2) cout << t << endl;
    else cout << r << endl;
  }

  return 0;
}


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

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

    int counter;
    for (int i=0; i<4; ++i) {
        counter = 0;
        for (int j=0; j<4; ++j) {
            if (i == j) {
                continue;
            }
            if (S[i] == S[j]) {
                ++counter;
            }
        }
        if (counter != 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)

// -----



int main()
{
    int n, k;
    cin >> n >> k;
    
    int snk[101] = {};
    rep(i, k)
    {
        int d;
        cin >> d;
        rep(j, d)
        {
            int a;
            cin >> a;
            ++snk[a - 1];
        }
    }
    int ans = 0;
    rep(i, n)
    {
        if(snk[i] == 0) ++ans;
    }
    pl(ans);
}

Measured memory_bytes: 3632
const main = (lines: string) => {
  const data = lines.split(" ");
  const treeSize = parseInt(data[0], 10);
  const coverableRange = parseInt(data[1], 10) * 2 + 1;

  console.log(Math.ceil(treeSize / coverableRange));
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
using namespace std;
int main(){
    int n,x;
    int i,j,k;
    int count = 0;
    while(1){
        cin>>n>>x;
        if(n==0&&x==0)break;
        for(i=1;i<=n;i++){
            for(j=1;j<=n;j++){
                for(k=1;k<=n;k++){
                    if(i+j+k==x&&i!=j&&j!=k&&i!=k){
                        count++;
                    }
                }
            }
        }
    cout<<count/6<<endl;
    count = 0;
    }

    return 0;
}


Measured memory_bytes: 3096
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki,-kj)
            exit()



Measured memory_bytes: 63928
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <utility>
#include <vector>

#define MAX_N (100000)

using namespace std;

void bfs(const vector<vector<int>> &adj_lists, int s, vector<int> &distances) {
  queue<int> que;
  que.push(s);
  distances[s] = 0;
  while (!que.empty()) {
    const int v = que.front();
    que.pop();
    for (int u : adj_lists[v]) {
      if (distances[u] < 0) {
        que.push(u);
        distances[u] = distances[v] + 1;
      }
    }
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  int N, as[MAX_N - 1], bs[MAX_N - 1];
  scanf("%d", &N);
  for (int i = 0; i < N - 1; i++) {
    scanf("%d %d", &as[i], &bs[i]);
    as[i]--;  // NOTE modified input
    bs[i]--;  // NOTE modified input
  }

  // create graph
  vector<vector<int>> adj_lists;
  // add nodes
  for (int i = 0; i < N; i++) {
    adj_lists.push_back(vector<int>());
  }
  // add edges
  for (int i = 0; i < N - 1; i++) {
    const int a = as[i], b = bs[i];
    adj_lists[a].push_back(b);
    adj_lists[b].push_back(a);
  }

  // calculate distances
  vector<int> d_from_fs(N, -1), d_from_ss(N, -1);
  bfs(adj_lists, 0, d_from_fs);
  bfs(adj_lists, N - 1, d_from_ss);

  // solve
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que_f, que_s;
  vector<int> used(N, 0);
  que_f.push(pair<int, int>(d_from_ss[0], 0));
  que_s.push(pair<int, int>(d_from_fs[N - 1], N - 1));
  while (1) {
    // fennec's turn
    // choose square closest to snuke not yet taken
    int node_taken_f = -1;
    while (!que_f.empty()) {
      const pair<int, int> p = que_f.top();
      const int d = p.first, v = p.second;
      que_f.pop();
      if (!used[v]) {
        used[v] = 1;
        node_taken_f = v;
        for (int u : adj_lists[v]) {
          que_f.push(pair<int, int>(d_from_ss[u], u));
        }
        // printf("Fennec took %d\n", v);
        break;
      }
    }
    if (node_taken_f < 0) {
      printf("Snuke\n");
      break;
    }

    // snuke's turn
    // choose square closest to fennec not yet taken
    int node_taken_s = -1;
    while (!que_s.empty()) {
      const pair<int, int> p = que_s.top();
      const int d = p.first, v = p.second;
      que_s.pop();
      if (!used[v]) {
        used[v] = 1;
        node_taken_s = v;
        for (int u : adj_lists[v]) {
          que_s.push(pair<int, int>(d_from_fs[u], u));
        }
        // printf("Snuke took %d\n", v);
        break;
      }
    }
    if (node_taken_s < 0) {
      printf("Fennec\n");
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 8944
#include <bits/stdc++.h>
using namespace std;
using Graph= vector<vector<int>>;

vector<bool> seen;
void dtf(const Graph G, int v){
  seen[v]=true;
  for(auto next_v: G[v]){
    if(seen[next_v-1]) continue;
    dtf(G, next_v-1);
  }
}
int main(){
  int N, M;
  cin >> N >> M;
  Graph G(N), H(M);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    G[a-1].push_back(b);
    G[b-1].push_back(a);
    H[i].push_back(a);
    H[i].push_back(b);
  }
  int ans=0;
  for(int i=0; i<M; i++){
    int a=H[i][0], b=H[i][1];
    for(int j=0; j<G[a-1].size(); j++){
      if(G[a-1][j]==b){
        G[a-1].erase(G[a-1].begin()+j);
        j--;
      }
    }
    for(int j=0; j<G[b-1].size(); j++){
      if(G[b-1][j]==a){
        G[b-1].erase(G[b-1].begin()+j);
        j--;
      }
    }
    seen.assign(N, false);
    dtf(G, 0);
    int num=0;
    for(auto j: seen){
      if(j) num++;
    }
    if(num!=N) ans++;
    G[a-1].push_back(b);
    G[b-1].push_back(a);   
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

long long combination(int n) {
    long long n_long = (long)n;
    return (n_long > 0) ? n_long * (n_long - 1) / 2 : 0;
}

int main() {
    int N;
    cin >> N;
    vector<int> a = vector<int>();
    for (int i = 0; i < N; ++i) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }

    map<int, int> ballNum2IndexNum = map<int, int>();
    map<int, vector<int> > ballNum2Indexes = map<int, vector<int> >();
    for (int i = 0; i < N; ++i) {
        int ai = a[i];
        if (ballNum2IndexNum.count(ai) == 0) {
            ballNum2IndexNum.insert(make_pair(ai, 1));
            ballNum2Indexes.insert(make_pair(ai, vector<int>({ i })));
        }
        else {
            ballNum2IndexNum.at(ai) += 1;
            ballNum2Indexes.at(ai).push_back(i);
        }
    }
    map<int, long long> ballNum2NumOfCombinations = map<int, long long>();
    for (map<int, int>::const_iterator it = ballNum2IndexNum.begin(); it != ballNum2IndexNum.end(); ++it) {
        int ballNum = it->first;
        ballNum2NumOfCombinations.insert(make_pair(ballNum, combination(it->second)));
    }
    long long totalCombination = 0;
    for (map<int, long long>::const_iterator it = ballNum2NumOfCombinations.begin(); it != ballNum2NumOfCombinations.end(); ++it) {
        totalCombination += it->second;
    }

    vector<long long> res = vector<long long>();
    for (int i = 0; i < N; ++i) {
        int ai = a[i];
        int indexNum = ballNum2IndexNum.at(ai);
        if (indexNum == 1) {
            res.push_back(totalCombination);
        }
        else { // if (indexNum >= 2) {
            res.push_back(totalCombination - combination(indexNum) + combination(indexNum - 1));
        }
    }

    for (int i = 0; i < N; ++i) {
        cout << res[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 31728
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

struct kukan {
    int L, R; ll C;
    bool operator<(const kukan a) {
        return (L < a.L) || (L == a.L && R < a.R);
    }
};

template<class Monoid> struct SegmentTree {
private:
    using Func = std::function<Monoid(Monoid, Monoid)>;
    Func F;
    Monoid UNITY;
    int n;
    std::vector<Monoid> node;
public:
    SegmentTree() {}

    //m=size, f=[](M a,M b){return ;}
    // size : m
    SegmentTree(int m, const Func f, const Monoid &unity) {
        build(m, f, unity);
    }

    SegmentTree(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        build(v, f, unity);
    }

    void build(int m, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        n = 1; while (n < m) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
    }

    void build(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        int sz = v.size();
        n = 1; while (n < sz) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        REP(i, sz) node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) node[i] = F(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(int x, Monoid val) {
        if (x >= n || x < 0) return;
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) >> 1;
            node[x] = F(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    // [a,b)
    Monoid get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return UNITY;
        if (a <= l && r <= b) return node[k];
        Monoid vl = get(a, b, 2 * k + 1, l, (r - l) / 2 + l);
        Monoid vr = get(a, b, 2 * k + 2, (r - l) / 2 + l, r);
        return F(vl, vr);
    }

    Monoid operator[](int x)const {
        return node[n + x - 1];
    }

    int size() {
        return n;
    }

    void print() {
        REP(i, n) {
            std::cout << i << "\t: " << node[n + i - 1] << std::endl;
        }
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<kukan> LR(m);
    REP(i, m) {
        scanf("%d %d %lld", &LR[i].L, &LR[i].R, &LR[i].C);
    }
    SegmentTree<ll> seg(n + 1, [](ll a, ll b) {return min(a, b); }, LLINF);// LR[i]の区間を使うときまでの最小コスト
    sort(LR.begin(), LR.end());
    seg.update(1, 0);
    REP(i, m) {
        if (seg.get(LR[i].L, LR[i].R) != LLINF) {
            seg.update(LR[i].R, min(seg.get(LR[i].L, LR[i].R) + LR[i].C, seg.get(LR[i].R, LR[i].R+1)));
        }
    }
    if (seg.get(n, n + 1) == LLINF) {
        cout << -1 << endl;
    }
    else {
        cout << seg.get(n, n + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

typedef long long ll;
#define fi first
#define se second

using namespace std;

///////////////////////////////////////
//
//
///////////////////////////////////////
//

int N;

int a[112345];

int main(){
	
	cin>>N;
	
	int i;
	int j;
	
	for( i = 0; i < N; i++ ){
		scanf("%d", a+i );
	}
	
	int big = 0;
	int sml = 112345;
	ll wa = 0;
	int ans = 0;
	
	for( i = 0; i < N; i++ ){
		wa += a[i];
		big = max( big, a[i] );
		sml = min( sml, a[i] );
	}
	
	ll jdg = N;
	jdg *= (ll)big;
	
	if( big - sml < 2 ){
		if( big == sml ){
			if( big+1 == N ) ans = 1;
			if( big*2 <= N ) ans = 1;
		}
		else{
			if( sml*2 < N ){
				if( wa+1 == jdg ) ans = 1;
			}
			else{
				jdg = N;
				jdg *= (ll)sml;
				if( (wa-jdg)%2 == 0 && (wa-jdg)/2 == N-big) ans = 1;
			}
		}	
	}
	
	if( ans ) puts("Yes");
	else{     puts("No");}
	
	
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  char str[4];
  int i;
  int count=0;
  scanf("%s",str);
   for(i=0;str[i]!='\0';i++){
     if(str[i]=='1'){
       count++;
     }
   }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n;
	const int M = 1000099;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> cnt(M);
	for(int x : a){
		if(cnt[x] != 0){
			cnt[x] = 2;
			continue;
		}
		for(int k = x; k<M; k+=x) cnt[k]++;
	}
	int ans = 0;
	for(int x : a){
		if(cnt[x] == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

vector<ll> h,p;

ll patty(int n, ll x) {
    if ( n == 0 ) return x;
    ll r = 0;
    if ( x <= 1 ) {
    } else if ( x <= 1 + h[n-1] ) {
        r += patty(n-1, x-1);
    } else if ( x == 2 + h[n-1] ) {
        r += p[n-1] + 1;
    } else if ( x <= 2 + h[n-1]*2 ) {
        r += p[n-1] + 1 + patty(n-1, x - h[n-1] - 2);
    } else {
        r += p[n-1]*2 + 1;
    }
    return r;
}

int main() {
    ll N, X;
    cin >> N >> X;
    h.resize(N+1);
    p.resize(N+1);
    h[0] = 1;
    p[0] = 1;
    for ( int i = 1; i <= N; i++ ) {
        h[i] = 2*h[i-1]+3;
        p[i] = 2*p[i-1]+1;
    }
    ll ans = patty(N, X);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N, H = [int(x) for x in input().split()]
    A = []
    B = []
    for _ in range(N):
        a, b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)

    ma = max(A)
    B.sort(reverse=True)

    ans = 0
    total = 0
    for b in B:
        if b >= ma:
            ans += 1
            total += b
        else:
            break

        if total >= H:
            break

    if total < H:
        ans += -(-(H - total) // ma)

    print(ans)



    


if __name__ == '__main__':
    main()



Measured memory_bytes: 11360
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int n;
  char s[1001];
  cin >> s;
  n = strlen(s);

  for( int i=0 ; i<n ; i++ ){
    if( s[i] > 'C' ){
      s[i] -= 3;
    }
    else{
      s[i] += 26;
      s[i] -= 3;
    }
  }

  cout << s << endl;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mkp make_pair
  #define pb push_back
  #define inf INT_MAX

  int32_t main()
  { 
  
    
    IOS
    int n;
    cin>>n;
    std::vector<int> v (n,0);
    for(int i=0;i<n;i++)
      cin>>v[i];
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<n-1;i++)
      sum+=v[i];
    sum+=(v[n-1]/2);
    cout<<sum;
    return 0;
   
}

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

using namespace std;

int const MAX = 1e5+2;

int N;
long long A[MAX], B[MAX], C[MAX];
long long ans = 0;

int main(){
    cin >> N;
    for (int i = 0; i < N; i++){cin >> A[i];}
    for (int i = 0; i < N; i++){cin >> B[i];}
    for (int i = 0; i < N; i++){cin >> C[i];}
    sort(A, A + N);
    sort(C, C + N);

    for (int i = 0; i < N; i++){
            ans 
            += (lower_bound(A, A+N, B[i]) - A)
            * (C + N - upper_bound(C, C+N, B[i]));
    }

    cout << ans;
}

Measured memory_bytes: 2560
use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        a: [u64; n],
    }

    let mut t = FenwickTree::from_vec(a);
    for _ in 0..q {
        input! { f: usize };
        if f == 1 {
            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
            input! { p: usize, x: u64 }
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};

impl<T: Copy + AddAssign + Integer> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            v: vec![zero(); n],
        }
    }

    fn from_vec(v: Vec<T>) -> Self {
        let n = v.len();
        let mut t = Self::new(n);
        for i in 0..n {
            let v = t.v[i] + v[i];
            t.v[i] = v;
            let p = i + Self::lsb(i + 1);
            if p < n {
                t.v[p] += v;
            }
        }
        t
    }

    fn add(&mut self, mut i: usize, v: T) {
        while i < self.v.len() {
            self.v[i] += v;
            i += Self::lsb(i + 1);
        }
    }

    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= Self::lsb(i);
        }
        v
    }

    #[inline]
    fn lsb(i: usize) -> usize {
        i & i.wrapping_neg()
    }
}


Measured memory_bytes: 23048
/*
Uneven Numbers
https://atcoder.jp/contests/abc136/tasks/abc136_b
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,cnt=0;
    string buff;

    cin >> N;
    for(int i=1; i<=N; i++){
        buff = to_string(i);
        if( buff.size() % 2 == 1 ){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  string s;cin>>s;
  if(s=="hi" or s=="hihi" or s=="hihihi" or s=="hihihihi" or s=="hihihihihi"){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
int n;
char ch[2];
set<char> st;

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        st.clear();
        for(int i = 0; i < n; ++i) {
            scanf("%s", ch);
            st.insert(ch[0]);
        }
        if(st.size() == 3) {
            printf("Three\n");
        } else {
            printf("Four\n");
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	long long int n,m;
	scanf("%lld%lld",&n,&m);
	if(n==1 && m==1){
		printf("1\n");
	}else if(n>=2 && m>=2){
		printf("%lld\n",(n-2)*(m-2));
	}else if(n==1 || m==1){
		printf("%lld\n",n*m-2);
	}
	return 0;
}

Measured memory_bytes: 128