akhauriyash/Code-Regression huggingface dataset:
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//grobal変数


int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			cout << 9;
		}
		else {
			cout << 1;
		}
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define PB              push_back
#define SIZE(x)         (int)x.size()
#define clr(x,y)        memset(x,y,sizeof(x))
#define MP(x,y)         make_pair(x,y)
#define RS(n)           scanf ("%s", n)
#define ALL(t)          (t).begin(),(t).end()
#define FOR(i,n,m)      for (int i = n; i <= m; i ++)
#define ROF(i,n,m)      for (int i = n; i >= m; i --)
#define IT              iterator
#define FF              first
#define SS              second

typedef long long               ll;
typedef unsigned int            uint;
typedef unsigned long long      ull;
typedef vector<int>             vint;
typedef vector<ll>              vll;
typedef vector<string>          vstring;
typedef pair<int, int>          PII;
typedef pair<ll, int>           PLLI;

void RI (int& x){
  x = 0;
  char c = getchar ();
  while (c == ' '||c == '\n')	c = getchar ();
  bool flag = 1;
  if (c == '-'){
      flag = 0;
      c = getchar ();
  }
  while (c >= '0' && c <= '9'){
      x = x * 10 + c - '0';
      c = getchar ();
  }
  if (!flag)	x = -x;
}
void RII (int& x, int& y){RI (x), RI (y);}
void RIII (int& x, int& y, int& z){RI (x), RI (y), RI (z);}

/**************************************END define***************************************/

const ll mod = 1e9+7;
const ll LINF = 1e18;
const int BINF = 0x7f;
const int INF = 1e9;
const double PI = acos(-1.0);
const double EPS = 1e-7;
const double eps = 1e-12;

const int MAXN = 105;
const int MOVE[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int m, n;

string line;
int pos[MAXN];
int len;

void update(ll &a, ll b) {
  b = (b % mod + mod) % mod;
  a += b;
  a %= mod;
}

void read() {
  return;
}

string str;

void solve() {
  static bool vis[5];
  clr(vis, false);
  FOR (i, 0,int(str.size())-1) {
    int d = 0;
    if (str[i] == 'E') d = 1;
    if (str[i] == 'S') d = 2;
    if (str[i] == 'W') d = 3;
    vis[d] = true;
  }
  puts(!(vis[0] ^ vis[2]) && !(vis[1] ^ vis[3]) ? "Yes" : "No");
  return;
}

int main () {
  //freopen("D-small-attempt1.in", "r", stdin);
  //freopen("D-large.in", "r", stdin);
  //freopen("data.out", "w", stdout);
  //int cas;
  //RI(cas);
  //FOR (i,1,cas) {
  //while (cas--) {
  //while (cin >> n >> m) {
  while (cin >> str) {
    //printf("Case #%d: ", i);
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	static int SomeSums(int k, int p, int q){
		int sum = 0;
		for(int i=1; i<=k; i++){
			String is = String.valueOf(i);
			int d = 0;
			for(int j=0; j<is.length(); j++){
				d += Character.getNumericValue(is.charAt(j));
			}
			if(p<=d && d<=q)sum+=i;
		}
		return sum;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(SomeSums(n, a, b));
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    cout<<lcm(a,b)<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <utility>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

#define all(a) (a).begin(),(a).end()
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"
const int MOD = 1e9+7;
const int INF = numeric_limits<int>::max();
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; }
template<typename Iterator>void print(const Iterator s, const Iterator t) { for(auto it=s;it+1!=t;++it)cout<<*it<<" ";cout<<*(t-1)<<"\n"; }
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, M; in(N); in(M);

  vi L[N];
  rep(i, N) {
    int k; in(k);
    rep(j, k) {
      int l; in(l);
      L[i].push_back(l);
    }
    sort(all(L[i]));
  }

  queue<int> q;
  set<int> s;
  iter(it, L[0]) {
    s.insert(*it);
  }
  bool is_friend[N]; // コミュニティーに属している=0番の人としゃべれる
  fill(is_friend, is_friend+N, false);
  is_friend[0] = true;

  while (true) {
    bool changed = false;
    rep(i, N) {
      if (is_friend[i])
        continue;
      bool has_common = false;
      iter(it, L[i]) {
        if (s.find(*it) != s.end()) {
          has_common = true;
          break;
        }
      }
      if (has_common) {
        is_friend[i] = true;
        changed = true;
        iter(it, L[i]) s.insert(*it);
      }
    }
    if (!changed)
      break;
  }
  rep(i, N) {
    if (!is_friend[i]) {
      out("NO");
      return 0;
    }
  }
  out("YES");

  return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int calcGCM(int,int);
int main(void){
	int i,val[2];
	char buf[32],*ch;
	
	fgets(buf,sizeof(buf),stdin);
	ch = strtok(buf," ");
	for (i = 0;i < 2;i++) {
		if (ch == NULL) {
			break;
		} else {
			val[i] = atoi(ch);
		}
		ch = strtok(NULL," ");
	}

	printf("%d\n", calcGCM(val[0], val[1]));
}

int calcGCM(int x, int y){
	if (y == 0){
		return x;
	} else{
		calcGCM(y, x % y);
	}
}


Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;

int main(){

  int N,X,T;

  cin >> N >> X  >> T ;

  if(N%X==0){

      cout << N/X*T << endl;

  }else{

      cout << (N/X*T+T) << endl;

  }

    
 
 }

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

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<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    vector<ll> S(N, 0);
    rep(i,K ){
        ll d;
        cin >> d;
        rep(j, d) {
            ll a;
            cin >> a;
            a--;
            S[a]  ++;
        }

    }
    rep(i, N) {
        if (S[i] == 0) ans++;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 3660
/*
    g++ -std=c++14 -O2 -Wall a.cpp -o a && a
    g++ -std=c++14 -O2 -Wall a.cpp -o a && a < in.txt > out.txt
*/
//  io
#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
#include <iostream>
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <algorithm>
#include <cstring>
#include <string>
#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <queue>
#include <stack>
#include <vector>
//#include <set>
#include <map>
#include <tuple>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<int, int> vii;
typedef long long ll;
typedef long double ld;
constexpr int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod); }

int a[25][25];
int dp[25][1 << 21];
int n;

int f(int i, int mask)
{
    if (mask == 0)
        return 1;
    else if (i == 21)
        return 0;

    if (dp[i][mask] != -1)
        return dp[i][mask];

    int sol = 0;
    for (int j = mask; j > 0; j -= (j & (-j)))
    {
        int k = __builtin_ctz(j & (-j));
        if (a[i][k] == 0)
            continue;
        sol = modadd(sol, f(i + 1, mask ^ (1 << k)));
    }
    return dp[i][mask] = sol;
}

int main()
{
    cin >> n;
    memset(dp, -1, sizeof(dp));

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];

    cout << f(0, (1 << n) - 1);
}

Measured memory_bytes: 208336
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val n = br.readLine().toInt()
    println(48 - n)
}

fun err(print: Any) {
    System.err.println(print)
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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 dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

const int inf=100000000;



int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s;
    cin>>s;
    int front=(s[0]-'0')*10+(s[1]-'0');
    int sec=(s[2]-'0')*10+(s[3]-'0');

    string ans="NA";

    if(front>12||front<1)
    {
        if(sec>0&&sec<13) ans="YYMM";
    }
    if(front<13&&front>0)
    {
        if(sec>12||sec<1){ans="MMYY";}
        else ans="AMBIGUOUS";
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <iostream>

int main() {
    std::string s; std::cin >> s;
    int cnt=0, ans=0;
    for(int i=0; i<3; ++i) {
        if(s[i]=='R')++cnt;
        if(s[i]=='S'){
            ans=std::max(ans,cnt);
            cnt=0;
        }
    }
    ans=std::max(ans,cnt);
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll ret = 0;
  if(K % 2 == 0)
    ret = A - B;
  else
    ret = B - A;
  if(abs(ret) >= 1e+18)
    cout << "Unfair" << endl;
  else
    cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		while(true){
			int n = in.nextInt();
			if(n==0)break;
			for(int i=0;i<n;i++)new AOJ0241().doIt();
		}
	}
	class AOJ0241{
		void doIt(){
			int x1 = in.nextInt();//1
			int y1 = in.nextInt();//i
			int z1 = in.nextInt();//j
			int w1 = in.nextInt();//k
			int x2 = in.nextInt();
			int y2 = in.nextInt();
			int z2 = in.nextInt();
			int w2 = in.nextInt();
			int x3 = (x1*x2)-(y1*y2)-(z1*z2)-(w1*w2);
			int y3 = (x1*y2)+(x2*y1)+(z1*w2)-(w1*z2);
			int z3 = (x1*z2)+(x2*z1)-(y1*w2)+(w1*y2);
			int w3 = (x1*w2)+(x2*w1)+(y1*z2)-(z1*y2);
			System.out.println(x3+" "+y3+" "+z3+" "+w3);
			
			
		}
	}
	
}

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

int main(){
    long long N;
    string name = "";
    cin >> N;
    while(N > 0){
        N-=1;
        name.push_back('a' + N%26);
        N /= 26;
    }
    reverse(name.begin(), name.end());
    cout << name << endl;
}

Measured memory_bytes: 3588
/* C/C++ program to remove invalid parenthesis */
#include <bits/stdc++.h> 
using namespace std; 


int main() 
{ 
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
    { 
        for(int j=1; j<=k && j<=i;j++)
        {
        dp[i]=min((dp[i-j]+abs(arr[i]-arr[i-j])),dp[i]);
        }
    }
  //  divide(n1,n2);
    cout<<dp[n-1];
	return 0; 
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll x,k,d;
    cin >> x >> k >> d;
    x=abs(x);
    ll ans=x;
    ll kcopy=k;
    ll dcopy=d;
    ll kketa=0;
    ll dketa=0;
    while(kcopy>0){
        kketa++;
        kcopy/=10;
    }
    while(dcopy>0){
        dketa++;
        dcopy/=10;
    }
    if(dketa+kketa>15){
        ll cnt=ans/d;
        if(cnt>k){
            ans-=d*k;
            cout << ans << endl;
            return 0;
        }
        ans-=d*cnt;
        k-=cnt;
        if(k%2==0){
            ans=abs(ans);
            cout << ans << endl;
            return 0;
        }
        else {
            if(ans<0) ans+=d;
            else ans-=d;
            ans=abs(ans);
            cout << ans << endl;
            return 0;
        }
    }
    else if(x>=k*d){
        ans-=k*d;
        cout << ans << endl;
        return 0;
    }
    else {
        ll cnt=x/d;
        ans-=d*cnt;
        k-=cnt;
        if(k%2==0){
            ans=abs(ans);
            cout << ans << endl;
            return 0;
        }
        else {
            if(ans<0) ans+=d;
            else ans-=d;
            ans=abs(ans);
            cout << ans << endl;
            return 0;
        }
    }
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define an size()

using namespace:: std;

const ll maxn=5005;

int main()
{
    ll a,b,n;
    cin>>n>>a>>b;
    if(a>b)
    {
          cout<<0;
          return 0;
    }
    if(n<2)
    {
          if(a==b)
          {
                cout<<1;
          }
          else
          {
                cout<<0;

          }
          return 0;
    }
    cout<<(n-2)*(b-a)+1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a, b;
int main() {
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else{
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

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

ll cost[1<<16];
ll dp[1<<16];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int n;
    cin>>n;
    ll a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                for(int k=j+1;k<n;k++){
                    if(i&(1<<k)) cost[i] += a[j][k];
                }
            }
        }
    }
    for(int bit=0;bit<(1<<n);bit++){
        vector<int> v;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)) v.push_back(i);
        }
        int m = v.size();
        for(int b=0;b<(1<<m);b++){
            int s = 0;
            for(int j=0;j<m;j++){
                if(b&(1<<j)) s += (1<<v[j]);
            }
            dp[bit] = max(dp[bit],dp[bit^s]+cost[s]);
            //cerr << s << " "<<cost[s] << endl;
        }
    }
    cout << dp[(1<<n)-1] << endl;
}

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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<int> ret(11);
	int r,d; cin >> r >> d >> ret[0];
	for (int i = 1; i<=10; i++) {
		ret[i] = ret[i-1] * r - d;
		cout << ret[i] << '\n';
	}
	
	
}



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

int main(){
    string s;
    cin >> s;
    bool dif = true;
    int n = s.size();
    rep(i,n){
        for(int j = i+1;j < n;j++){
            if(s[i] == s[j])dif = false;
        }
    }
    if(dif)cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

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

int main()
{
	std::vector<int> vec;
	int N, x;
	std::cin >> N >> x;
	for (int i{};i < N;++i)
	{
		int a{};
		std::cin >> a;
		vec.emplace_back(a);
	}
	long long count{};
	if (vec.front() + vec[1] <= x)
	{

	}
	else if (vec.front() > x)
	{
		count += vec[1];
		count += vec.front() - x;
		vec.front() = x;
		vec[1] = 0;
	}
	else
	{
		count += vec[1] - (x - vec.front());
		vec[1] = x - vec.front();
	}
	for (int i = 1;i < N - 1;++i)
	{
		if (vec[i] + vec[i + 1] <= x)
		{

		}
		else if (vec[i] > x)
		{
			count += vec[i + 1];
			count += vec[i] - x;
			vec[i + 1] = 0;
			vec[i] = x;
		}
		else
		{
			count += vec[i + 1] - (x - vec[i]);
			vec[i + 1] = x - vec[i];
		}
	}
	std::cout << count << std::endl;
}

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

int main() {

  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int left = A+B;
  int right = C+D;

  if(left > right)
    cout << "Left" << endl;
  
  if(left == right)
    cout << "Balanced" << endl;

  if(left < right)
    cout << "Right" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 505;
ll n, dp[maxn][maxn], a[maxn][maxn], b[maxn][maxn];
ll get(ll i, ll l, ll r) {
	return r >= l ? a[i][r] - a[i][l - 1] : 0;
}
ll rget(ll i, ll l, ll r) {
	return r >= l ? b[i][r] - b[i][l - 1] : 0;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) {
			if(i != j) cin >> a[i][j];
			b[j][i] = a[i][j];
		}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) {
			a[i][j] += a[i][j-1];
			b[i][j] += b[i][j-1];
		}
		
	memset(dp, 0x3f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 0; i <= n; i++)
		for(int j = i; j <= n; j++)
			if(dp[i][j] < 1ll<<60) {
				ll cur = 0;
				for(int k = j+1; k <= n; k++) {
					cur += get(k, 1, i-1);
					cur += rget(k, j+1, k);
					dp[j+1][k] = min(dp[j+1][k], dp[i][j] + cur);
				}
			}
	ll ans = 1ll<<60;
	for(int i = 1; i <= n; i++) ans = min(ans, dp[i][n]);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 9604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	ll a,b,c,x,y;
	ll ans=0;
	
	cin>>a>>b>>c>>x>>y;
	if(c*2<a+b){
		ans += min(x,y)*c*2;
		if(x>y)
		{
			if(c*2<a)
				ans+=(x-y)*c*2;
			else
				ans+=(x-y)*a;
		}else{
			if(c*2<b)
				ans+=(y-x)*c*2;
			else
				ans+=(y-x)*b;
		}
	}else{
		ans+=x*a;
		ans+=y*b;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int N, ans = 0, cnt = 0;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    rep(i, N){
        cnt = 1;
        while(A[i] == A[i + 1]){
            cnt++;
            i++;
        }
        if(cnt % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const XN = input[0].split(' ').map(str => Number(str));
  const X = XN[0], N = XN[1];
  let result;

  if(N === 0){
      result = X;
  } else {
    let PN = input[1].split(' ').map(str => Number(str));
        for(let i = 0; i <= N; i++){
            let pl = 200;
            let mai = 200;
            if(PN.indexOf(X+i) < 0){
                pl = X + i;
            }
            if(PN.indexOf(X-i) < 0){
                mai = X - i;
            }
            if(pl !== 200 || mai !== 200){
                if(mai < pl){
                    result = mai;
                    break;
                } else{
                    result = pl;
                    break;
                }
            }
        }
    }
  console.log(result);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int N = 200005;

int n, a[N];
long long sum[N], minL1[N], minL2[N], minR1[N], minR2[N];

int get1(int x) {
	return !(x & 1);
}

int get2(int x) {
	if (x == 0) return 2;
	if (x == 1) return 1;
	return (x & 1);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i], sum[i] = sum[i - 1] + a[i];
	
	minL1[0] = minL2[0] = 0;
	for (int i = 1; i <= n; ++i) {
		int t1 = get1(a[i]), t2 = get2(a[i]);
		minL1[i] = minL1[i - 1] + t1;
		minL2[i] = minL2[i - 1] + t2;
		minL1[i] = min(minL1[i], sum[i]);
		minL2[i] = min(minL2[i], sum[i]);
		minL1[i] = min(minL1[i], minL2[i]);
	}
	
	minR1[n + 1] = minR2[n + 1] = 0;
	for (int i = n; i >= 1; --i) {
		int t1 = get1(a[i]), t2 = get2(a[i]);
		minR1[i] = minR1[i + 1] + t1;
		minR2[i] = minR2[i + 1] + t2;
		minR1[i] = min(minR1[i], sum[n] - sum[i - 1]);
		minR2[i] = min(minR2[i], sum[n] - sum[i - 1]);
		minR1[i] = min(minR1[i], minR2[i]);
	}
	
	long long res = 1e18;
	for (int i = 0; i <= n; ++i) {
		res = min(res, minL1[i] + minR2[i + 1]);
		res = min(res, minL2[i] + minR1[i + 1]);
	}
	cout << res << endl;
}


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

int di(int a, int b, int n);

int main() {
    int r, g, b, n,cnt;
    cnt=0;
    std::cin >> r >> g >> b >> n;
    for(int i=0; i<=n/r;i++){
        for(int j=0;j<=(n-i*r)/g;j++){
            if((n-r*i-g*j)%b==0){
                cnt=cnt+1;
            }
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx, dy = ty - sy;

	// part 1
	cout << string(dy, 'U') << string(dx, 'R');
	// part 2
	cout << string(dy, 'D') << string(dx, 'L');
	// part 3
	cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
	// part 4
	cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';

	cout << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<iomanip>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef double D;
typedef pair<D,int> pdi;
 
struct edge{
  D d,v;
  int to;
  edge(D a=0,D b=0,int c=0):d(a),v(b),to(c){}
  bool operator<(edge a)const{
    return d/v > a.d/a.v;
  }
};
 
int main(){
  int n,m;
  D d;
 
  while(cin >> n >> m >> d){
    if(n==0)break;
 
    vector< vector<edge> > g(n); 
    rep(i,m){
      int s,t;
      D dis, num;
      cin >> s >> t >> dis >> num; s--; t--;
      g[s].push_back( edge(dis,num,t) );
      g[t].push_back( edge(dis,num,s) );
    }
 
    D res = 0;
    rep(i,n){
      D maxv = 0;
      for(edge e : g[i])maxv = max(maxv, e.v/e.d);
 
      vector<D> dis(n,1e15);
      dis[0] = 0;
      priority_queue< pdi, vector<pdi>, greater<pdi> > q;
      q.push( pdi(0,0) );
 
      while(q.size()){
	pdi p = q.top(); q.pop();
	D cost = p.first, cur = p.second;
	if(dis[cur]+1e-8 < cost)continue;
 
	for(edge e : g[cur]){
	  D cospa = e.v/e.d;
	  if(cospa > maxv+1e-8)continue;
	  D ncost = cost + (maxv-cospa)*e.d;
	  if(dis[e.to] > ncost + 1e-8){
	    dis[e.to] = ncost;
	    q.push( pdi(ncost,e.to) );
	  }
	}
      }
 
      res = max(res, maxv*d - 2*dis[i]);
    }
 
    cout << fixed << setprecision(10) << res << endl;
  }
}

Measured memory_bytes: 4488
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
char conversion(int n){
  if(n%2) return '1';
  else return '0';
}

int main(){
  string str;
  cin >> str;
  int ans = 1000000;
  int N = str.length();

  //左端を0にする
  int count = 0;
  for(int i=0;i<N;i++){
    if(str[i]!=conversion(i)) count++;
  }
  ans = min(ans, count);
  count = 0;

  for(int i=0;i<N;i++){
    if(str[i]==conversion(i)) count++;
  }
  ans = min(ans, count);

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

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {



    // int a,b,c,d;
    // cin>>a>>b>>c>>d;
    // int turn=0;
    // while(a>0&&c>0){
    //     if(!turn){
    //         c-=b;
    //     } else {
    //         a-=d;
    //     }
    //     turn = 1-turn;
    //     // cout<<a<<" "<<c<<endl;
    // }
    // if(a<=0)fin("No");
    // else fin("Yes");

    int n;
    cin>>n;
    vs v(n);
    set<string> s;
    rep(i,n){
        string v;
        cin>>v;
        s.insert(v);
    }
    fin(s.size());
}

Measured memory_bytes: 25172
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val V, E, R = sc.nextInt()
    val r = Array.fill(R)(sc.nextInt()).map(_ - 1)

    val INF = Int.MaxValue
    val G = Array.fill(V, V)(INF)
    var D = Array.fill(V, V)(INF)
    (0 until E) foreach { _ =>
      val u, v, w = sc.nextInt()
      G(u-1)(v-1) = w
      G(v-1)(u-1) = w
      D(u-1)(v-1) = w
      D(v-1)(u-1) = w
    }
    (0 until V) foreach { i =>
      D(i)(i) = 0
    }

    var k = 0
    while (k < V) {
      var u = 0
      val Dn = Array.fill(V, V)(INF)
      while (u < V) {
        var v = 0
        while (v < V) {
          if (D(u)(k) != INF && D(k)(v) != INF)
            Dn(u)(v) = D(u)(v) min (D(u)(k) + D(k)(v))
          else
            Dn(u)(v) = D(u)(v)
          v += 1
        }
        u += 1
      }
      D = Dn
      k += 1
    }

    val result = r.permutations.map { permutation =>
      permutation.sliding(2).foldLeft(0)((b, n) => {
        b + D(n(0))(n(1))
      })
    }. min

    println(result)
  }

}


Measured memory_bytes: 121484
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
// #pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);





// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(n) read(m)
    readarr(a,m)
    ll su = 0;
    f(i,0,m) su += a[i];
    ll del = n - su;
    if(del<0) cout<<-1<<endl;
    else cout<<del<<endl;

}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 3724
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
        String s = sc.next();
        List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
        //0スタート
        int zero=0;
        for(int i=0;list.size()>i;i++) {
        	if(i%2==0) {
        		if(!list.get(i).equals("0"))
        			zero++;
        	}
        	else {
        		if(!list.get(i).equals("1"))
        			zero++;
        	}
        }
        //1スタート
        int one =0;
        for(int i=0;list.size()>i;i++) {
        	if(i%2==0) {
        		if(!list.get(i).equals("1"))
        			one++;
        	}
        	else {
        		if(!list.get(i).equals("0"))
        			one++;
        	}
        }
        if(zero<=one)
        	System.out.println(zero);
        else
        	System.out.println(one);
	}
}

Measured memory_bytes: 33876
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)
plusOrMinus = 0
num = arrA[0]
ans = 0
for i in range(N-1):
    if plusOrMinus == "+":
        if arrA[i]>arrA[i+1]:
            ans += 1
            plusOrMinus = 0
    elif plusOrMinus == "-":
        if arrA[i]<arrA[i+1]:
            ans += 1
            plusOrMinus = 0
    else:
        if arrA[i]<arrA[i+1]:
            plusOrMinus = "+"
        elif arrA[i]>arrA[i+1]:
            plusOrMinus = "-"
        else:
            pass

print(ans+1)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

int main()
{

    while (1)
    {
        int h, w;
        cin >> h >> w;

        if (h == 0 && w == 0)
            break;

        string wid = "";
        for (int i = 0; i < w; i++)
        {
            wid += "#";
        }
        for (int i = 0; i < h; i++)
        {
            cout << wid << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3132
#pragma comment (linker, "/STACK:256000000")
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

string S;

int main() {
    cin >> S;
    int size = S.size();

    if (size % 2) {
        int icenter = size / 2;
        char center = S[icenter];
        int i;
        for (i = 0; i <= icenter; ++i) {
            if (center != S[icenter + i] || center != S[icenter - i]) {
                break;
            }
        }
        write(icenter + i);
        return 0;
    }
    else {
        int icenter = size / 2; // icenter - 1 & icenter
        char center = S[icenter];
        int i;
        for (i = 0; i < icenter; ++i) {
            if (center != S[icenter + i] || center != S[icenter - 1 - i]) {
                break;
            }
        }
        write(icenter + i);
        return 0;
    }
}

Measured memory_bytes: 512
// finish date: 2018/01/06
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <limits>
#include <map>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int main() {
    string S;
    cin >> S;
    S.replace(0,4,"2018");
    cout << S << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    int maxv,minv;
    cin>>n;
    int lst[200000];
    for(int j=0;j<n;j++){
        cin>>lst[j];
    }
    maxv=-1000000000;
    minv=lst[0];
    for(int i=1;i<n;i++){
        maxv=max(maxv,lst[i]-minv);
        minv=min(minv,lst[i]);
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3880
for  i in range(1000000):
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    else:
        s = 0
        for j in range(1,n-1):
            for k in range(j+1,n):
                for l in range(k+1,n+1):
                    if j + k + l == x:
                        s += 1
        print(s)


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

int main(){
  int i,j,n;
  char s[15];

  scanf("%s", s);

  n = strlen(s);

  ll ans = 0;
  ll sum;

  for(i = 0;i < (1 << (n - 1));i++){
    sum = 0;
    for(j = 0;j < n;j++){
      sum = sum*10 + (s[j] - '0');
      if((i >> j) & 1){
        ans += sum;
        sum = 0;
      }
    }

    ans += sum;
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
S=input()

a1=('01'*len(S))[:len(S)]
a2=('10'*len(S))[:len(S)]

answer1 = 0
for s, a in zip(S,a1):
  if s!=a:
    answer1 +=1
  
answer2 = 0
for s, a in zip(S,a2):
  if s!=a:
    answer2 +=1
    
print(min(answer1,answer2))

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

int main(){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;

  int ans = A1 + A2 + A3;

  if(ans>=22){
    cout << "bust";
    return 0;
  }

  else cout << "win";
   
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    char prev = '_';
    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] != prev) {
            count++;
            prev = s[i];
        }
    }
    cout << count << endl;
}


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

namespace AtCorder1
{
    class AtCorder163B
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');

            int vacDays = int.Parse(line[0]);
            int hw = int.Parse(line[1]);


            string[] lines = System.Console.ReadLine().Split(' ');
            int[] necDays = Array.ConvertAll(lines, int.Parse);

            int sum = necDays.Sum();
            int days = 0;
            if (sum > vacDays)
            {
                days = -1;
            }
            else
            {
                days = vacDays - sum;
            }


            Console.WriteLine(days);
        }


    }
}


Measured memory_bytes: 28664
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint n;
llint a[2005];
bitset<4000005> bs;

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint sum = 0;
	for(int i = 1; i <= n; i++) sum += a[i];
	
	bs[0] = true;
	for(int i = 0; i < n; i++) bs |= bs<<a[i+1];
	
	for(int i = (sum+1)/2; ; i++){
		if(bs[i]){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}


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

int main()
{
	int array[5];

	for (int i = 0; i < 5; i++){
		cin >> array[i];
	}

	sort(array, array + 5);

	for (int i = 4; i >= 0; i--){
		if (i == 0){
			cout << array[0] << endl;
		}
		else {
			cout << array[i] << " ";
		}
	}

	return (0);
}

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


int main(void) {
  double pi = 3.14159265358979;
  double a, b, c;
  cin >> a >> b >> c;

  double s = a * b * sin( c*pi / 180  ) / 2;
  double l = a + b + sqrt( a*a + b*b - 2*a*b*cos(c*pi / 180) );
  double h = b * sin( c * pi / 180 );

  printf("%.8lf\n", s);
  printf("%.8lf\n", l);
  printf("%.8lf\n", h);

  return 0;
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
//#define all(v) v.begin(), v.end()
//bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
//bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
//const ll MAX_N=500010;
ll a, b, c, d, e, f, h, k, l, m, n, r, t, w, x, y, z, ans;
int main() {
  cin >> a >> b;
  double p, q;
  if(5*a<=4*b) p=10.0*b;
  else p=12.5*a;
  if(5*a+1<=4*b) q=12.5*(a+1);
  else q=10.0*(b+1);

  n=13;
  while(n<=2000){
    if(p<=n && n<q) {
      cout << n << endl;
      return 0;
    }
    n++;
  }
  
  cout << "-1" << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < n; i++)
//#define sum(start, end) accumulate(start, end, 0)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

using namespace std;
template <class T = ll> T in() { T _in; cin >> _in; return (_in); }


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

    string S = in<string>();
    cout << S[0] << S.size()-2 << S[S.size()-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#define MOD 1000000007
using namespace std;

int main(){
    string s;
    cin >> s;
    int count=0;


    for(int i=1;i<s.length();i++){
        if(s[i]==s[i-1]){
            count++;
            if(s[i]=='0') s[i]='1';
            else s[i]='0';
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
  int x,y;
  while(1) {
    cin >> x >> y;
    if(x==0 && y==0) break;
    if(x<y) cout << x << " " << y << "\n";
    else cout << y << " " << x << "\n";
  }
}


Measured memory_bytes: 3004
require 'pp'

n = gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map(&:to_i)

memo = {}
min = 10 ** 10
min_id = -1
a_n.each_with_index do |a, i|
    memo[i] = a
    if a < min
        min = a
        min_id = i
    end 
end

#pp min
#pp min_id

while memo.size > 1
    del_list = []
    now_min = min
    now_min_id = min_id

    memo.each do |id, v|
        next if id == now_min_id

        memo[id] = memo[id] % now_min
        if memo[id] == 0
            del_list << id
        elsif memo[id] < min
            min = memo[id]
            min_id = id
        end
    end

    del_list.each {|id| memo.delete(id) }
end 

puts memo.values.first


Measured memory_bytes: 16132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a-c)<=d){
        cout << "Yes" << endl;
    }else if(abs(a-b)<=d && abs(b-c)<=d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256