akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {

	ll H,W,h,w;
        in(H);
        in(W);
        in(h);
        in(w);
        outn((H-h)*(W-w));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
	
#define ll long long
#define endl '\n'
 
template < typename T >
void self_max(T &a, T b){a = max(a, b);}
// template < typename T >
// void self_min(T &a, T b){a = min(a, b);}

void solve(){
	ll ans = -1e18 - 7;
	ll a, b, c, d; cin>>a>>b>>c>>d;
	self_max(ans, max(a * c, b * d));
	self_max(ans, max(a * d, b * c));
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1; //cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N;
LL s[MAXN];

void work(){
    N=1000000;
    for(int i=1;i<=N;i++){
        if(i%3==0||i%5==0) s[i]=0;
        else s[i]=i;
    }
    for(int i=1;i<=N;i++) s[i]+=s[i-1];
    scanf("%d",&N);
    printf("%lld\n",s[N]);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






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

int main(){
    int n;
    cin>>n;
    vector<int> a;
    while(n--){
        int x,y;cin>>x>>y;
        if(x==y)a.push_back(1);
        else a.push_back(0);
    }
    int flag=0;
    for(int i=0;i<=a.size()-3;++i){
        if(a[i]==1 && a[i+1]==1 && a[i+2]==1){
            flag=1;break;
        }
    }
    if(flag==1)cout<<"Yes";
    else cout<<"No";
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long ans = 0;
  for(int i = 1; i <= n; ++i){
    if(i % 3 != 0 && i % 5 != 0) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
#ifdef _WIN32
    #define gx getchar
    #define px putchar
    #define ps putchar(' ')
    #define pn putchar('\n')
    #define DEBUG 1
#else
    #define gx getchar_unlocked
    #define px putchar_unlocked
    #define ps putchar_unlocked(' ')
    #define pn putchar_unlocked('\n')
    #define DEBUG 0
#endif
 
#define rep(i,j,k) for(ll i=0;i<j;i+=k)
//input
void scan(int &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' ) sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * sign;
}
void lscan(ll &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' )
        sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * (ll)(sign);
}
int sscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
int wscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n' && c!=' ')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
 
//output
void print(int n)
{
    if(n<0)
    {
        n=-n;
        px('-');
    }
    int i=10;
    char o[10];
    do{o[--i] = (n%10) + '0'; n/=10;}while(n);
    do{px(o[i]);}while(++i<10);
}
void lprint(ll n)
{
    if(n<0LL)
    {
        n=-n;
        px('-');
    }
    int i=21;
    char o[21];
    do{o[--i] = (n%10LL) + '0'; n/=10LL;}while(n);
    do{px(o[i]);}while(++i<21);
}
void sprint(const char a[])
{
    const char *p=a;
    while(*p)px(*p++);
}
 
 
ll po(ll a, ll b, ll m)
{
	ll x=1,y=a;
	while(b > 0)
	{
		if(b%2 == 1)
		{
			x=(x*y);
			if(x>m) x%=m;
		}
		y = (y*y);
		if(y>m) y%=m;
		b /= 2;
	}
	return x;
}
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
	ll sum = 0;
	for(ll i=0;i<5;i++)
	{
		ll temp;
		cin>>temp;
		sum += temp;
	}
	cout<<15-sum<<endl;	
	return 0;
}

Measured memory_bytes: 3588
H,W,M=map(int,input().split())

X=[0]*(H+1)
Y=[0]*(W+1)

B=set()
for _ in range(M):
    x,y=map(int,input().split())
    B.add((x,y))
    X[x]+=1
    Y[y]+=1

x_max=max(list(range(1,H+1)),key=lambda x:X[x])
P=X[x_max]
Alpha=[x for x in range(1,H+1) if X[x]==P]

y_max=max(list(range(1,W+1)),key=lambda x:Y[x])
Q=Y[y_max]
Beta=[y for y in range(1,W+1) if Y[y]==Q]


if len(Alpha)*len(Beta)<=M:
    Flag=False
    for p in Alpha:
        for q in Beta:
            if (p,q) not in B:
                Flag=True
                break
        if Flag:
            break
else:
    Flag=True

print(P+Q-(not Flag))


assert 1

Measured memory_bytes: 181516
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	

	int n = s.size();
	s += 'x';
	vector<int> num(n + 1, 0);

	int cnt = 1;
	rep (i, n) {
		if (s[i] == s[i + 1]) cnt++;
		else {
			if (s[i] == 'R') num[i] = cnt;
			else num[i - (cnt - 1)] = cnt;
			cnt = 1;
		}
	}

	vector<int> ans(n, 0);
	rep (i, n) {
		if (!num[i]) continue;
		if (num[i] % 2 == num[i + 1] % 2) {
			ans[i] = ans[i + 1] = (num[i] + num[i + 1]) / 2;
		}
		else {
			if (num[i] > num[i + 1]) {
				if (num[i] % 2 == 1) {
					ans[i] = (num[i] + num[i + 1]) / 2 + 1;
					ans[i + 1] = (num[i] + num[i + 1]) / 2;
				}
				else {
					ans[i] = (num[i] + (num[i + 1])) / 2;
					ans[i + 1] = (num[i] + num[i + 1]) / 2 + 1;
				}
			}
			else {
				if (num[i] % 2) {
					ans[i] = (num[i] + num[i + 1]) / 2 + 1;
					ans[i + 1] = (num[i] + num[i + 1]) / 2;
				}
				else {
					ans[i] = (num[i] + (num[i + 1])) / 2;
					ans[i + 1] = (num[i] + num[i + 1]) / 2 + 1;
				}
			}
		}
		i++;
	}
	rep (i, n) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pip         pair<int,pii>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

typedef tuple<ll, int ,int ,int> tp;

const int N = 110;
string s[N];
ll n , dist[N][N][2] , cst[N];
ll ans = INF;

bool isPal(string tgt) {
    
    string tmp = tgt;
    reverse(tmp.begin() , tmp.end());
    return tmp == tgt;
}


void dijk() {

    priority_queue<tp , vector<tp> , greater<tp> > pq;

    for(int i =0 ; i < n ; i++ ) {

        dist[ i ] [s[i].size() ][1] = min( dist[ i ][ s[i].size() ][1], cst[i]);
        pq.push({cst[i] , i , s[i].size() , 1} );
    }

    while(!pq.empty()) {
        ll id , val , len , side;
        tie(val , id , len , side) = pq.top();
        pq.pop();

        // cout<<id<<" "<<val<<" "<<len<<" "<<side<<'\n';


        if(val != dist[id][len][side]) continue;

        string tgt = "";

        for(int i = 0 ; i < len && side == 0; i++ ) tgt += s[id][i];
        for(int i = 0 , j = s[id].size() - 1 ; i < len && side ;i++ , j-- ) tgt += s[id][j];

        if(side) reverse(tgt.begin() , tgt.end());

        // cout<<id<<" -- "<<side<<" -- "<<tgt<<'\n';
        if(isPal(tgt)) {
            ans = min(ans , val);
            continue;
        }

        


        for(int i =0 ; i < n ; i++ ) {
            
            int cnt = 0;

            for(int j = len-1 , k = 0 ;side == 0 && j >=0 && k < s[i].size() && tgt[j] == s[i][k] ; j-- , k++) cnt++;

            for(int j = 0 , k = s[i].size() -1 ; side && j < len && k >= 0 && tgt[j] == s[i][k] ; j++ , k--) cnt++;


            //// cout<<" "<<i<<" "<<cnt<<'\n';

            if(cnt == len ) {
                
                ll nwval = val + cst[i];
                ll nwlen = s[i].size() - cnt;
                ll nwside = side ^1;

                if(dist[i][nwlen][nwside] > nwval) {
                    dist[i][nwlen][nwside] = nwval;
                    pq.push({nwval , i , nwlen , nwside});
                }
            }
            else if(cnt == s[i].size()) {
                ll nwval = val + cst[i] ;
                ll nwlen = len - cnt;
                ll nwside = side;

                if(dist[id][nwlen][nwside] > nwval) {
                    dist[id][nwlen][nwside] = nwval;
                    pq.push({nwval , id , nwlen , nwside});
                }
            }

        }

    }

}


int main()  {
    fastio;
    
    cin>>n;
    for(int i =0 ; i < n ; i++ ) cin>>s[i]>>cst[i];

    for(int i =0 ; i < N ; i++ ) {

        for(int j =0 ; j < N ; j++ ) dist[i][j][0] = dist[i][j][1] = INF;
    }

    dijk();
    cout<<(ans >= INF ? -1 : ans)<<'\n';
    return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <cmath>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>

//g++ -std=c++11 IPL.cpp -o IPL
using namespace std;


int main(){
string one;
string two;
cin >> one;
cin >> two;
string best = one;



bool unable = true;
bool exists = false;
bool gg = false;
unsigned i = 0;
list<string> theBests;

for(i = 0; i < one.size();){

if(one[i] == two[0] || one[i] == '?'){

  unsigned temp = i;

  for(unsigned j = 0; j < two.size() && temp < one.size();){

    if((one[temp] != two[j]) && ((one[temp]!= '?' ))){
//    i = temp-1;
    break;
    }
    j++;
    temp++;

    if(j == two.size()){
      int start = i;
      int end = temp;
      // if (exists && ((one[i] != '?') || (one[temp] != 'a' ))){
      //    gg = true;
      //   break;
      //
      // }

      string oneBest = one;

        for(unsigned a = start; a < end; a++ ){
          oneBest[a] = two[a - start];


        }
        for(unsigned a = 0; a < one.size() ;a++ ){
          if(oneBest[a] == '?' ){
            oneBest[a] = 'a';

          }
        //  cout << one[a] << endl;
        }

      theBests.push_back(oneBest);
      exists = true;
      break;
    }

  }


}


i++;


}




if(!theBests.empty()){
  theBests.sort();

  best = theBests.front();
  unable = false;
}
//
// while(!theBests.empty()){
//   cout << theBests.front() << endl;
//   theBests.pop_front();
// }


if(unable){
  cout << "UNRESTORABLE";

}else{
  cout << best;
}


  return 0;
}

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

using namespace std;

using vvi = vector<vector<int>>;

int main()
{
   int n;
   cin >> n;
   vvi a(n, vector<int>(3)), dp(n, vector<int>(3, -1));
   for (int i = 0; i < n; i++)
   {
      cin >> a[i][0] >> a[i][1] >> a[i][2];
   }
   dp[0] = a[0];
   for (int i = 1; i < n; i++)
   {
      for (int k = 0; k < 3; k++)
      {
         dp[i][k] = max(dp[i - 1][(k + 1) % 3], dp[i - 1][(k + 2) % 3]) + a[i][k];
      }
   }
   cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
   return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K - 1] += 'a' - 'A';
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	char a[10], b[10], c[10];
	cin >> a >> b >> c;
	a[0] -= 32;
	b[0] -= 32;
	c[0] -= 32;
	cout << a[0] << b[0] << c[0] << endl;
	return(0);
}

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

int main() {
  int n;
  cin >> n;
  if(n%10 == 3){
    cout << "bon" << endl;
  }
  else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8 ){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
  
	return 0;
}


Measured memory_bytes: 3592
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-03 21:59:52
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<int> d(n); cin >> d;

  sort(all(d));
  debug(d);

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

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=a;i<=b;i++)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
using namespace std;
typedef long long ll;
int n,d,len,Ans;
int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	n=read(),d=read();
	len=d*2+1;
	Ans=n/len;
	if (n%len) Ans++;
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 256
//vector には.find() がなぜかないのでアルゴリズムを使う (線形？　オーダー不明)
//set map のメンバのfind はlogn保障らしい。

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main() {
    int i,j;
    int n,q,C=0;
    int buf;
    set<string> dictionary;
	set<string>::iterator itr;
	char com[7],str[13];
    
    //入力
    cin >> n;
	for(i=0; i<n; i++){
		scanf("%s %s", com, str);

		if(com[0] == 'i'){
			dictionary.insert(str);
		}
		else { //"find"の場合
			if( dictionary.find(str) != dictionary.end() ) printf("yes\n");
			else printf("no\n");
		}
	}

    
	return 0;
}

Measured memory_bytes: 27056
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;


int main(){
  ll n;cin>>n;
  vll d(13,0);
  rep(i,0,n){
    ll t;cin>>t;
    d[t]++;
  }
  rep(i,0,13){
    if(d[i]>=3||d[12]>=2||d[0]>0){
      cout<<0<<endl;return 0;
    }
  }
  ll ans=0;
  rep(i,0,1<<11){
    vll tmp(25,0);
    tmp[24]++;
    if(d[12])tmp[12]++;
    rep(j,0,11){
      if(d[j+1]==0)continue;
      if(d[j+1]>1){
        tmp[j+1]++;tmp[24-j-1]++;
      }
      if(d[j+1]==1){
        if(i>>j&1)tmp[j+1]++;
        else tmp[24-j-1]++;
      }
    }
    ll cnt=24,now=0;
    rep(j,0,25){
      if(tmp[j]){
        cnt=min(cnt,j-now);
        now=j;
      }
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}



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

int main() {
  std::string str;
  std::cin >> str;
  
  int n_pat = 1;
  for (int i=0; i<str.length()-1; i++) n_pat *= 2;
  
  long long res = 0;
  for (int pat=0; pat<n_pat; pat++) {
    long long tmp = str[0] - '0';
    for (int i=1; i<str.length(); i++) {
      if ((pat >> (i-1)) & 1) {
        res += tmp;
        tmp = str[i] - '0';
      } else {
        tmp *= 10;
        tmp += (str[i] - '0');
      }
    }
    res += tmp;
  }
  std::cout << res << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(input()) #１文字ずつ
# print(a)

allW=0
allR=0
for i in range(N):
    if a[i]=='W':
        allW+=1
    elif a[i]=='R':
        allR+=1
# print('allW,allR:',allW,allR)

W=0
R=allR
out = max(W,R)
ans = out
for shikiri in range(N):
    if a[shikiri] =='W':
        W+=1
    elif a[shikiri]=='R':
        R-=1
    out = max(W,R)
    ans = min(ans,out)
    # print('out,ans:',out,ans)

print(ans)


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string a, b, c;
    int n; cin >> n;
    cin >> a >> b >> c;
    int ans = 0;
    rep(i, n) {
        map<char, int> mp;
        mp[a[i]]++;
        mp[b[i]]++;
        mp[c[i]]++;
        int ma = 0;
        for (auto tmp : mp) ma = max(ma, tmp.second);
        ans += 3 - ma;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
using namespace std;
ll n, k, h[100005], dp[100005];
ll solve(ll i)
{
    if(i == n - 1)  return 0;
    if(~dp[i])      return dp[i];
    ll ans = 1e18;
    for(int j = 1;j <= k && i + j < n;j++)
        ans = min(ans, solve(i + j) + abs(h[i] - h[i + j]));
    return dp[i] = ans;
}
int main()
{
    IO
    cin >> n >> k;
    memset(dp, -1, sizeof dp);
    REP(i, 0, n)    cin >> h[i];
    cout << solve(0);
    return 0;
}


Measured memory_bytes: 6528
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>

#if __cplusplus >= 201103 //C++11~
#include <tuple>

#endif



using namespace std;

typedef pair<int,int> Paint;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD 1000000007

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout<< (char)数値 //数値にあった文字に置き換えられる
cout<< (double)int型/(2など)//小数になる
YesNo大文字小文字間違えてないか
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
sqrt(数値型)でrootが取れる
vector.unique()は隣接した同じ要素を削除するので先にソートをする
tupleはC++11以降

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int n;cin>>n;
  vector<int> a(n);
  for(int i= 0; n > i; i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int ans = 0;
  for(int i = 0; n > i; i++){
    for(int j = i+1;n-1 > j; j++){
      int mx = a[i]+a[j]-1;
      int mn = max(a[i],a[j])-min(a[i],a[j])+1;
      if(mx < a[0] || mn > a[a.size()-1] || mx < mn)continue;
      auto itmx = lower_bound(a.begin()+j+1,a.end(),mn);
      auto itmn = upper_bound(a.begin()+j+1,a.end(),mx);
      if(*itmx)
      ans += (itmn-a.begin())-(itmx-a.begin());
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=998244353;
int main(){
  int64_t N; string s;
  cin>>N>>s;
  int64_t R=0;
  int64_t G=0;
  int64_t B=0;
  int64_t M=0;
  int64_t m=0;
  vector<int64_t>A(3*N);
  for(int i=0;i<3*N;i++){
  if(s.at(i)=='R') R++;
    if(s.at(i)=='G')G++;
    if(s.at(i)=='B')B++;
    int64_t M1=max(R,max(G,B));
    int64_t m1=min(R,min(G,B));
    if(M!=M1){
    A.at(i)=0; M=M1;
    }else if(m!=m1){
    A.at(i)=2; m=m1;
    }else{
    A.at(i)=1;
    }
  }int64_t ans=1; int64_t a=0;int64_t b=0;
  for(int i=0;i<3*N;i++){
  if(A[i]==0)a++;
    if(A[i]==1){ans=(ans*a)%mod; a--;}
  }for(int i=3*N-1;0<=i;i--){
  if(A[i]==2)b++;
    if(A[i]==1){ans=(ans*b)%mod; b--;}
   }for(int64_t i=1;i<=N;i++)
    ans=(ans*i)%mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6092
using System;
using System.Collections;
using System.Linq;
class Program
{
    static int Main()
    {
        //int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        int n, m, x;
        n = int.Parse(s[0]);
        m = int.Parse(s[1]);
        x = int.Parse(s[2]);
        int[] a = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();
        int ans1 = 0;
        for (int i = x + 1; i < n; i++)
            ans1 += a.Count(p => p == i);
        int ans2 = 0;
        for (int i = 1; i < x; i++)
            ans2 += a.Count(p => p == i);
        Console.WriteLine(Math.Min(ans1, ans2));

        return 0;
    }
}

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

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

    ll x, y; cin >> x >> y;

    for (ll i=0; i<=x; i++)
    {
        ll t = i*2;
        ll r = (x-i)*4;

        if (t+r==y) {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    
    cout << "No" << "\n";

    return 0;
}

Measured memory_bytes: 3644
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int x,y;
int o[52][52];
queue<int> q;
void tansaku(int j,int i){
	if(j<1||j>x||i<1||i>y||o[i][j]==0||o[i][j]==2){
		return ;
	}
	if(o[i][j]==1){
		if(q.empty())
		q.push(1);
		o[i][j]=2;
	}
	
	tansaku(j+1,i);
	tansaku(j-1,i);
	tansaku(j,i+1);
	tansaku(j,i-1);
	tansaku(j+1,i+1);
	tansaku(j-1,i-1);
	tansaku(j+1,i-1);
	tansaku(j-1,i+1);
}
int main(){

	while(cin>>x>>y,x!=0||y!=0){
		int count=0;
		for(int i=1;i<=y;i++){
			for(int j=1;j<=x;j++){
				cin>>o[i][j];
			}
		}
		for(int i=1;i<=y;i++){
			for(int j=1;j<=x;j++){
				tansaku(j,i);
				if(!q.empty()){
				count+=q.front();
				
				q.pop();
				}
			}
		}
		
		cout<<count<<endl;
	}

}

Measured memory_bytes: 1312
require 'date'

while line = gets
  y, m, d = line.chomp.split.map(&:to_i)
  the_day = Date.new(y, m, d)

  if the_day.to_time.to_i < Date.new(1868, 9, 8).to_time.to_i
    puts "pre-meiji"
  elsif the_day.to_time.to_i <= Date.new(1912, 7, 29).to_time.to_i
    puts "meiji #{y - 1868 + 1} #{m} #{d}"
  elsif the_day.to_time.to_i <= Date.new(1926, 12, 24).to_time.to_i
    puts "taisho #{y - 1912 + 1} #{m} #{d}"
  elsif the_day.to_time.to_i <= Date.new(1989, 1, 7).to_time.to_i
    puts "showa #{y - 1926 + 1} #{m} #{d}"
  else
    puts "heisei #{y - 1989 + 1} #{m} #{d}"
  end
end

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

using namespace std;

int main()
{
    int n, k, x, y, ans=0;
    cin>>n>>k>>x>>y;
    for(int i=1; i<=n; i++)
    {
        if(i<=k)
        {
            ans+=x;
        }
        else
        {
            ans+=y;
        }

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





Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

type Point struct {
	x float64
	y float64
}

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	
	points := make([]Point, n)
	
	for c := 0; c < n; c++ {
		var x, y float64
		_, _ = fmt.Scan(&x, &y)
		points[c] = Point{x, y}
	}
	
	var m float64 = 0
	
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			m += math.Pow(math.Pow(points[j].x-points[i].x, 2)+math.Pow(points[j].y-points[i].y, 2), 0.5) * 2 / float64(n)
		}
	}
	
	fmt.Println(m)
}


Measured memory_bytes: 512
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
MOD = 10**9+7
fac = [0]*(N+1) # 階乗テーブル
fac[0] = fac[1] = 1
inv = [0]*(N+1) # 逆元テーブル
inv[1] = 1
facinv = [0]*(N+1) # 階乗の逆元テーブル
facinv[0] = facinv[1] = 1
for i in range(2,N+1):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
    facinv[i] = facinv[i-1] * inv[i] % MOD

def nCr(n,r):
    if n < r or n < 0 or r < 0:return 0
    else:return fac[n] * (facinv[r] * facinv[n-r] % MOD) % MOD

# 各要素が最大値、最小値として何回使われるか考える
maxsum = 0
minsum = 0
for i,a in enumerate(A):
    maxsum += nCr(i,K-1)*a
    maxsum %= MOD
    minsum += nCr(N-i-1,K-1)*a
    minsum %= MOD
ans = (maxsum-minsum)%MOD

print(ans)

Measured memory_bytes: 18776
# -*- encoding: utf-8 -*-
import sys
import re
import random
import numpy as np
from math import sqrt,log
from fractions import gcd  # python<=3.4
from collections import Counter, defaultdict

# st = Counter(raw_input())

MOD=1000000007

def lcm(a,b):
  return a/gcd(a,b)*b


def read_ints():
  return map(int, input().split())


def calc_kmax(az,bz):
    assert az < bz

    lo = 0    # ng
    hi = az # ok
    while lo+1 < hi:
        k = (lo + hi)//2
        if k * bz >= (k+1) * az:
            hi = k
        else:
            lo = k
    return hi


def solve(T1,T2,A1,A2,B1,B2):
    T = T1 + T2
    az = T1*A1 + T2*A2
    bz = T1*B1 + T2*B2
    if az == bz:
        print('infinity')
        return False
    if az > bz:
        A1,A2,B1,B2 = B1,B2,A1,A2
        az,bz = bz,az

    numer = T1*(A1-B1)
    denom = (bz-az)

    g = numer / denom
    gi = int(g)
    gr = gi - g

    if (g > 0):
        if gr == 0:
            ans = -1 + gi*2 + 1
        else:
            ans = -1 + (gi+1)*2
    else:
        ans = 0

    print(ans)


T1,T2 = read_ints()
A1,A2 = read_ints()
B1,B2 = read_ints()
solve(T1,T2, A1,A2, B1,B2)


Measured memory_bytes: 14248
#include<iostream>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    bool ans[m+1];
    for(int i=0;i<m;i++){
        ans[i] = true;
    }
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        bool tmp[m+1];
        for(int i=0;i<m;i++){
            tmp[i] = false;
        }
        for(int i=0;i<k;i++){
            int a;
            cin >> a;
            a--;
            tmp[a] = true;
        }
        for(int i=0;i<m;i++){
            ans[i] &= tmp[i];
        }
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        if(ans[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N,M;

int main(){
    cin>>N>>M;

    ll ans=0;
    ans+=min(N,M/2);
    ans+=(M-ans*2)/4;

    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
    int n,l=0,m=0,h[2];
    scanf("%d",&n);
    scanf("%d",&h[0]);
    for(int i=1;i<n;i++){
        scanf("%d",&h[1]);
        if(h[0]>=h[1]){
            m++;
        }
        else{
            if(l<m){
                l=m;
            }
            m=0;
        }
        h[0]=h[1];
    }
    if(l<m){
        l=m;
    }
    printf("%d\n",l);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int p = 0;
  string s;
  cin >> s;
  vector<char> ans(10,' ');
  int l = s.size();
  for (int i = 0; i < l; i++){
    if (s[i] == '0'){
      ans[p] = '0';
      p++;
    }
    if (s[i] == '1'){
      ans[p] = '1';
      p++;
    }
    if (s[i] == 'B'){
      if (ans[0] != ' '){
        ans[p - 1] = ' ';
        p--;
      }
    }
  }
  for (int i = 0; i < p; i++){
    cout << ans[i];
  }
  cout << '\n';
return 0;   
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct State { int x[20][20]; };
int H, W;
int solve(State S, int cx, int cy, int depth) {
	if (cx == 30)return 1;
	int cnt = 0;
	//------------Yoko ni oku-------------
	if (cy < W - 1) {
		bool flag = true;
		if (cx >= 1 && cy >= 1 && S.x[cx][cy - 1] != S.x[cx - 1][cy] && S.x[cx - 1][cy - 1] != S.x[cx - 1][cy] && S.x[cx - 1][cy - 1] != S.x[cx][cy - 1])flag = false;
		if (cx >= 1 && cy <= W - 3 && S.x[cx][cy + 2] != S.x[cx - 1][cy + 1] && S.x[cx - 1][cy + 2] != S.x[cx - 1][cy + 1] && S.x[cx - 1][cy + 2] != S.x[cx][cy + 2])flag = false;
		if (cy == W - 1 || S.x[cx][cy + 1] >= 1)flag = false;
		if (flag == true) {
			State T = S; T.x[cx][cy] = depth; T.x[cx][cy + 1] = depth;
			int dx = cx, dy = cy;
			while (T.x[dx][dy] >= 1) {
				dy++; if (dy == W) { dy = 0; dx++; }
				if (dx == H) { dx = 30; break; }
			}
			cnt += solve(T, dx, dy, depth + 1);
		}
	}
	//------------Tate ni oku--------------
	if (cx < H - 1) {
		bool flag = true;
		if (cx >= 1 && cy >= 1 && S.x[cx][cy - 1] != S.x[cx - 1][cy] && S.x[cx - 1][cy - 1] != S.x[cx - 1][cy] && S.x[cx - 1][cy - 1] != S.x[cx][cy - 1])flag = false;
		if (cx >= 1 && cy <= W - 2 && S.x[cx][cy + 1] != S.x[cx - 1][cy] && S.x[cx - 1][cy + 1] != S.x[cx - 1][cy] && S.x[cx - 1][cy + 1] != S.x[cx][cy + 1])flag = false;
		if (cx == H - 1 || S.x[cx + 1][cy] >= 1)flag = false;
		if (flag == true) {
			State T = S; T.x[cx][cy] = depth; T.x[cx + 1][cy] = depth;
			int dx = cx, dy = cy;
			while (T.x[dx][dy] >= 1) {
				dy++; if (dy == W) { dy = 0; dx++; }
				if (dx == H) { dx = 30; break; }
			}
			cnt += solve(T, dx, dy, depth + 1);
		}
	}
	return cnt;
}
int main() {
	while (true) {
		cin >> H >> W; if (H == 0 && W == 0)break;
		State r; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++)r.x[i][j] = 0; }
		int ans = solve(r, 0, 0, 1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3732
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int t[100000];
    fill(t, t + 100000, -1);
    int h, w, d;
    int q;
    map<int, pair<int, int>> mp;
    cin >> h >> w >> d;
    imfor(i, h) {
        imfor(j, w) {
            int a;
            cin >> a;
            mp[a] = make_pair(i, j);
        }
    }
    imfor(i, h * w) {
        if (i == 0) {
            continue;
        }
        if (t[i] != -1) {
            continue;
        }
        int j = i;
        while (j <= h * w) {
            if (j - d < 1) {
                t[j] = 0;
            }
            else {
                t[j] = t[j - d];
                t[j] += abs(mp[j].first - mp[j - d].first) + abs(mp[j].second - mp[j - d].second);
            }
            j += d;         
        }
    }
    // imfor(i, h * w) {
    //     cout << t[i] << " ";
    // }
    // cout << endl;
    // return 1;

    cin >> q;
    imfor(i, q) {
        int ans = 0;
        int l, r;
        cin >> l >> r;
        cout << t[r] - t[l] << endl;
    }
    
}

Measured memory_bytes: 7168
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, H, W;
	cin >> N >> H >> W;
	cout << (N - H + 1) * (N - W + 1) << endl;
}


Measured memory_bytes: 256
import sys

#+++++

def isp(v):
	max_v = int(v**(0.5))
	for i in range(2,max_v+1):
		if v % i ==0:
			return False
	return True

def mmp(n):
	ret=[]
	val=11
	while len(ret) < n:
		if isp(val):
			ret.append(val)
		val += 10
	return ret
		
def main():
	#l=[11,31,61,71,91,101]
	n = int(input())
	l=mmp(n)
	#print(l)
	print(' '.join([str(v) for v in l]))
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
def main():
    A, B, K = map(int, input().split())

    if A < K:
        K -= A
        A = 0
    else:
        A -= K
        K = 0

    if B < K:
        K -= B
        B = 0
    else:
        B -= K
        K = 0

    print("{} {}".format(A, B))


main()


Measured memory_bytes: 2940
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		char[] a = incharar();
		int ans = 0;
		for (int i=0; i<a.length; i++) {
			if (a[i] == '1') ans++;
		}
		out.println(ans);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}
	
	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

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

int main(){
	while(1){

	int n;
	cin>>n;
	if(n==0)break;

	string f[n];
	int u=0,subu=0,d=0,subd=0,sum=0;
	
	for(int i=0;i<n;i++){

	cin>>f[i];

}

	for(int i=0;i<n;i++){
	
	if(f[i]=="lu"&&subu==0&&subd==0){
	subu++;
	}
	else if(f[i]=="ru"&&subu==0&&subd==0){
	subu--;
	}
	else if(f[i]=="ru"&&subu==1&&subd==0){
	u++;
	subu=0;
	}
	else if(f[i]=="lu"&&subu==-1&&subd==0){
	u++;
	subu=0;
	}

	else if(f[i]=="ld"&&subd==0&&subu==0){
	subd++;
	}
	
	else if(f[i]=="rd"&&subd==0&&subu==0){
	subd--;
	}
	
	else if(f[i]=="rd"&&subd==1&&subu==0){
	d++;
	subd=0;
	}
	else if(f[i]=="ld"&&subd==-1&&subu==0){
	d++;
	subd=0;
	}
	
	else{
	subd=0;
	subu=0;
	}
	}
	cout<<u+d<<endl;



}
	
}



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

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


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
h=li()
dp = [0]*n
for i in range(1,n):
    if i ==1:
        dp[i] = abs(h[0] - h[1])
    else:
        dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]), dp[i-2]+abs(h[i] - h[i-2]))
print(dp[n-1])

Measured memory_bytes: 14260
# 129a

def atc_129a(input_value: str) -> int:
    PQR = input_value.split(" ")
    P = int(PQR[0])
    Q = int(PQR[1])
    R = int(PQR[2])

    return min(P + Q, P + R, Q + R)

input_value = input()
print(atc_129a(input_value))


Measured memory_bytes: 9096
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = readline().decode('utf8')

ans = 0
cnt=0
for i in S:
    
    if i == 'I':
        cnt += 1
    else:
        cnt -= 1

    ans=max(ans, cnt)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll res = 1;
  for (ll i = 1; i*i <= m; i++) {
    if (m%i == 0) {
      if (n*i <= m) res = max(res, i);
      if (i != m/i) {
        if (n*(m/i) <= m) res = max(res, m/i);
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
using System;

class abc
{
    static void Main()
    {
        string[] A = Console.ReadLine().Split('/');
        int Y = int.Parse(A[0]);
        int M = int.Parse(A[1]);
        int D = int.Parse(A[2]);

        if (Y >= 2019 && M >= 5) Console.WriteLine("TBD");
        else Console.WriteLine("Heisei");

    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    vector<int>a(5);
    REP(i,5)IN(a[i]);
    int k;
    cin>>k;
    bool f=true;
    REP(i,4){
        for(int j=i+1;j<5;j++){
            if(a[j]-a[i]>k){
                f=false;
                break;
            }
        }
    }
    if(f)OUT("Yay!");
    else OUT(":(");
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,a,b;
    cin>>n>>a>>b;
    in ans=n/(a+b)*a;
    n %=(a+b);
    if(n>=a) ans +=a;
    else ans +=n;
    cout<<ans<<endl;
}

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

int main(int argc, char* argv[]) {
    int n, q, cnt = 0;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; i++) cin >> s[i];
    cin >> q;
    int t[q];
    for (int i = 0; i < q; i++) cin >> t[i];

    for (int i = 0; i < q; i++){
        for (int j = 0; j < n; j++){
            if (t[i] == s[j]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt << "\n";
    return 0;
}



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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int mod=A%B;
  bool ans=false;
  for(int i=1;i<B;i++){
    if((mod*i)%B==C)ans=true;
  }
  if(ans)cout <<"YES";
  else cout << "NO";
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    static int max(int a, int b){
        if( a > b)
            return a;
        return b;
    }

    static int[] dp;
    static int calculate(List<Integer>[] graph,int i){
        if(dp[i] != -1){
            return dp[i];
        }
        int path = 0;
        if(graph[i] != null){
            for(Integer ii : graph[i]){
                path = max(path,1+calculate(graph,ii));
            }
        }
        dp[i] = path;
        return dp[i];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer>[] graph = new ArrayList[n];
        dp = new int[n];

        int[] dist = new int[n];

        for(int i = 0; i < n; i++){
            dist[i] = Integer.MIN_VALUE;
            dp[i] = -1;
        }

        for(int i = 0; i < m; i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(graph[x-1] == null)
                graph[x-1] = new ArrayList<Integer>();
            graph[x-1].add(y-1);
        }

        int max = 0;
        for(int i = 0; i < n; i++){
            max = max(max,calculate(graph,i));
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 103440
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100000+10;
int n;
int sz[26][N],a[N];
map<int,int>mmp;
int main(){
    mmp['M'-'A']=0;
    mmp['A'-'A']=1;
    mmp['R'-'A']=2;
    mmp['C'-'A']=3;
    mmp['H'-'A']=4;
    while(~scanf("%d",&n)){
        memset(sz,0,sizeof(sz));
        string c;
        for(int i=1;i<=n;i++){
            cin>>c;
            if(c[0]=='M'||c[0]=='A'||c[0]=='R'||c[0]=='C'||c[0]=='H') {
                int x=mmp[c[0]-'A'];
                a[i]=x;

                sz[x][i]=sz[x][i-1]+1;
                for(int j=0;j<5;j++){
                    if(j!=x) sz[j][i]=sz[j][i-1];
                }
            }
            else {
                a[i]=-1;
                for(int j=0;j<5;j++){
                    sz[j][i]=sz[j][i-1];
                }
            }


        }
        ll sum=0;
        for(int i=2;i<=n-1;i++){
            if(a[i]!=-1)
                for(int j=0;j<5;j++){
                    if(j!=a[i]&&sz[j][i-1]-sz[j][0]){
                        for(int k=0;k<5;k++){
                            if(k!=a[i]&&k!=j&&sz[k][n]-sz[k][i]){
                                sum+=(sz[k][n]-sz[k][i])*(sz[j][i-1]-sz[j][0]);
                            }
                        }
                    }
                }
        }
        printf("%lld\n",sum);

    }
    return 0;
}


Measured memory_bytes: 10752
import java.util.*;
public class Main{
	static long mod=998244353;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] d=new int[n];
		long count1=0;
		for(int i=0; i<n; i++){
			d[i]=sc.nextInt();
			if(d[i]==1){
				count1++;
			}
		}
		if(d[0]!=0){
			System.out.println(0);
			return;
		}
		Arrays.sort(d);
		long ans=1;
		int cc=2;
		long count=0;
		long count2=0;
		if(count1==0 && n>1){
			System.out.println(0);
			return;
		}
		for(int i=1; i<n; i++){
			if(d[i]==0){
				System.out.println(0);
				return;
			}
			if(cc==d[i]){
				count++;
			}else if(cc+1==d[i]){
				
				count2=count;
				while(count>0){
					if((count & 1)==1){
						ans*=count1;
					}
					count>>=1;
					ans%=mod;
					count1*=count1;
					count1%=mod;
				}
				count1=count2;
				count=1;
				cc++;
			}
			if(d[i]>cc+1){
				System.out.println(0);
				return;
			}
		}
		while(count>0){
			if((count & 1)==1){
				ans*=count1;
			}
			count>>=1;
			ans%=mod;
			count1*=count1;
			count1%=mod;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 51236
s = input()

n = len(s)
mid = int((n - 1)/2)
r = s[::-1]

for i in range(mid):
    if s[i] != r[i] or s[i] != s[mid-i-1] or r[i] != r[mid-i-1]:
        print("No")
        exit()

print("Yes")



Measured memory_bytes: 2940
N,K = map(int,input().split())
S = input()
S = [S[i] for i in range(len(S))]
x = S[K-1]

if x == "A":
  S[K-1] = "a"
elif x == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
  
print("".join(S))

Measured memory_bytes: 3064