akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define ipair pair<int,int>
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	int a, b, c, N;
	while (cin >> a >> b >> c) {
		cin >> N;
		int A[100], B[100], C[100], R[1000][4];
		bool bb = 0, ch[1000] = {};
		TFOR(i, a)A[i] = 2;
		TFOR(i, b)B[i] = 2;
		TFOR(i, c)C[i] = 2;
		TFOR(i, N) {
			cin >> R[i][0] >> R[i][1] >> R[i][2] >> R[i][3];
			R[i][0] -= 1; R[i][1] -= a + 1; R[i][2] -= b + a + 1;
			if (R[i][3]) { A[R[i][0]] = 1; B[R[i][1]] = 1; C[R[i][2]] = 1; bb = 1; ch[i] = 1; }
		}
		while (bb) {
			//cout << "<" << endl;
			bb = 0;
			TFOR(i, N) {
				if (!ch[i]) {
					int zero;
					int ct = 0;
					if (A[R[i][0]] == 1)++ct; else zero = 0;
					if (B[R[i][1]] == 1)++ct; else zero = 1;
					if (C[R[i][2]] == 1)++ct; else zero = 2;
					if (ct == 2 && R[i][3] == 0) {
						if (zero == 0)A[R[i][0]] = 0;
						if (zero == 1)B[R[i][1]] = 0;
						if (zero == 2)C[R[i][2]] = 0;
						bb = 1;
						ch[i] = 1;
					}
				}
			}
		}
		TFOR(i, a)cout << A[i] << endl;
		TFOR(i, b)cout << B[i] << endl;
		TFOR(i, c)cout << C[i] << endl;
	}
	return 0;
}

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

ans = [0]*n

for x in range(1,int(n**0.5)):
    for y in range(1,int(n**0.5)):
        for z in range(1,int(n**0.5)):
            left = x*x + y*y + z*z + x*y + y*z + z*x
            if left<=n:
                ans[left-1] += 1

print("\n".join(map(str,ans)))

Measured memory_bytes: 9864
#include <bits/stdc++.h>
using namespace std;
char x,y;
int a,b;
int main(){
	cin>>x>>y;
	if(x=='A'){
		a=10;
	}
	if(x=='B'){
		a=11;
	}
	if(x=='C'){
		a=12;
	}
	if(x=='D'){
		a=13;
	}
	if(x=='E'){
		a=14;
	}
	if(x=='F'){
		a=15;
	}
	if(y=='A'){
		b=10;
	}
	if(y=='B'){
		b=11;
	}
	if(y=='C'){
		b=12;
	}	
	if(y=='D'){
		b=13;
	}
		if(y=='E'){
		b=14;
	}
		if(y=='F'){
		b=15;
	}
    if(a>b){
    	cout<<">";
	}
	if(a<b){
		cout<<"<";
	}
	if(a==b){
		cout<<"=";
	}
}

Measured memory_bytes: 256
from numpy import*
a,b=loadtxt(open(0),'i',skiprows=1)
c=0
l=1<<29
while l:u=l;l>>=1;c+=sum(diff(searchsorted(sort(hstack((b%u-u,b%u))),([u],[l])-a%u).T))%2*l
print(c)

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

string t[4]={"dream","dreamer","erase","eraser"};

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

    int r=S.size();
    while(r){
        int x=-1;
        rep(i,4){
            if(r<t[i].size())continue;
            if(S.substr(r-t[i].size(),t[i].size())==t[i])x=i;
        }
        if(x==-1){
            cout<<"NO"<<endl;
            return 0;
        }
        r-=t[x].size();
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 512
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    int n;
    int b[110];
    cin >> n;
    rep(i, n - 1) cin >> b[i];

    int a[110] = {0};

    a[0] = b[0];
    a[n - 1] = b[n - 2];
    rep(i, n - 2) {
        a[i + 1] = min(b[i], b[i + 1]);
    }

    int ans = 0;
    rep(i, n) ans += a[i];
    print(ans);

    rep(i, n) debug(a[i]);

    return 0;
}



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

#define N (100000 + 1)

// beginsWith 
// srcがstrから始まる文字列かどうかを調べる
int beginsWith(char* src, char* str){
	int len_of_str = strlen(str);
	int i;
	if(strlen(src) < len_of_str)
		return 0;

	for(i=0; i < len_of_str; i++){
		if(*(src + i) != *(str + i)){
			return 0;
		}
	}
	return 1;

}

int inductive_search(char* S, int i){
	int L = strlen(S);
	//printf("%s\n",S+i);
	if(i == L) 
		return 1;
	else if(beginsWith(S+i, "dreamer")){
		return (inductive_search(S, i+5) || inductive_search(S, i+7));
	}else if(beginsWith(S+i, "dream")){
		return inductive_search(S, i+5);
	}else if(beginsWith(S+i, "eraser")){
		return (inductive_search(S, i+6));
	}else if(beginsWith(S+i, "erase")){
		return inductive_search(S, i+5);
	}else{
		return 0;
	}
}

int main(){

	char *str;
	str = (char*)malloc(sizeof(char) * N);

	scanf("%s", str);

	if(inductive_search(str, 0)){
		printf("YES\n");
	}else{
		printf("NO\n");
	}


	return 0;

}


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

ll limit = 1000000007;

ll factorial(int i){
    if(i == 1){
        return 1;
    }

    return (i * factorial(i - 1)) % limit;
}

int main(){
    int n, m;
    cin >> n >> m;
 
    ll ans = 0;

    if(n == m + 1 || m == n + 1 || n == m){
        if(n == m){
            ans += factorial(n);
            ans *= factorial(m);
            ans *= 2;
        }else if(n > m){
            ans += factorial(n);
            ans *= factorial(m);
        }else{
            ans += factorial(m);
            ans *= factorial(n);
        }
        ans %= limit;
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
}

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

int main() {
  string a,b;
  cin >> a >> b;
  string ans="No";
  int num=stoi(a+b);
  for(int i=1;i<=10000;i++){
    if(i*i==num){
      ans="Yes";
      break;
    }
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
s=input()
year=[]
month=[]
day=[]
g=0
for i in range(len(s)):
    if s[i]!='/':
        if g==0:
            year+=s[i]
        if g==1:
            month+=s[i]
        if g==2:
            break
    else:
        g+=1
figure=[0,1,2,3,4,5,6,7,8,9]
j=len(year)-1
Y=0
for i in year:
    Y+=figure[int(i)]*10**j
    j-=1
j=len(month)-1
M=0
for i in month:
    M+=figure[int(i)]*10**j
    j-=1
if Y<2019 or (Y>=2019 and M<5):
    print('Heisei')
elif Y>=2019 and M>=5 or Y>2019:
    print('TBD')




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

long long ara[57],dp[52][52][101];

long long solve(long long fr,long long sc,long long cap)
{

    if(sc<fr || cap==0)return 0;
    else if(dp[fr][sc][cap]!=-1)return dp[fr][sc][cap];
    else
    {

        long long p=-99999999999999;

        if(cap-1>=0)
        {
            p=max(p,ara[fr]+solve(fr+1,sc,cap-1));
            p=max(p,ara[sc]+solve(fr,sc-1,cap-1));
        }

        if(cap-2>=0)
        {

            p=max(p,solve(fr+1,sc,cap-2));
            p=max(p,solve(fr,sc-1,cap-2));
        }


        dp[fr][sc][cap]=p;  return dp[fr][sc][cap];



    }

}

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld %lld",&n,&k);

        for(i=1;i<=n;i++)
        {
            scanf("%lld",&a); ara[i]=a;

        }

        memset(dp,-1,sizeof dp);

        for(i=0;i<=k;i++)
        {
            ans=max(ans,solve(1,n,i));

        }

        printf("%lld\n",ans);





    return 0;
}





Measured memory_bytes: 5916
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

const int MAX_N = 110;
const int MAX_V = 100100;

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 n;
vector<double> p;

//i枚投げた時の表j枚の確率
double dp[3100][3100];

int main() {
	cin >> n;
	p.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	dp[0][0] = 1.0;

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

			//表がでた
			dp[i + 1][j + 1] += dp[i][j] * p[i];

			//裏がでた
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}

	double res = 0.0;
	//表が多いところだけ集める
	//nが奇数なのでこれでいい
	for (int j = (n+1)/2; j <=n; j++) {
		res += dp[n][j];
	}

	cout << fixed << setprecision(10) << res << endl;

	return 0;
}

Measured memory_bytes: 72320
#include <iostream>

using namespace std;

int main()
{
	long long  W, H, x, y;
	cin >> W >> H >> x >> y;

	auto x2 = W - x;
	auto y2 = H - y;

	double s = W * H / 2.0;
	int m = (x == x2 && y == y2);

	printf("%f %d\n", s, m);
}


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

int main() {
  	char a;
 	cin >> a;
	string ans;
  
  if(a == 'a' || a == 'b' || a == 'c' || a == 'd' || a == 'e' || a == 'f' || a == 'g' || a == 'h' || a == 'i' || a == 'j' || a == 'k' || a == 'l' || a == 'm' ||a == 'n' || a == 'o' || a == 'p' || a == 'q' || a == 'r' || a == 's' || a == 't' || a == 'u' || a == 'v' || a == 'w' || a == 'x' || a == 'y' || a == 'z' )
  //if(a = "a"|| a = "b" || a = "c" || a = "d" || a = "e" || a = "f" || a = "g" || a = "h" || a = "i" || a = "j" || a = "k" || a = "l" || a = "m" ||a n' || a = "o" || a = "p" || a = "q" || a = 'r' || a = 's' || a = 't' || a = 'u' || a = 'v || a = "w" || a = "x" || a = "y" || a = "z") 
  {ans = "a";}
  else
  {ans = "A";}
  
	cout << ans << endl;
}



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

using namespace std;

int N, L;
int pre[105];

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> L;
    for(int i = 1; i<=N; i++){
        cin >> pre[i];
        pre[i] += pre[i-1];
    }
    int idx = 0;
    for(int i= 1; i<=N; i++){
        if(pre[i] <= L){
            idx = i;
        }
    }
    idx++;
    cout << idx << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	int a[101][101];
	memset(a,0,sizeof(a));
	int r,c;
	cin >> r >> c;

	rep(i,r)
	{
		rep(j,c)
		{
			cin >> a[i][j];
		}
	}

	rep(i,r)
	{
		int sum = 0;
		rep(j,c) sum += a[i][j];
		a[i][c] = sum;
	}

	rep(i,c)
	{
		int sum = 0;
		rep(j,r) 
		{
			sum += a[j][i];
		}
		a[r][i] = sum;
	}

	int sum = 0;
	rep(i,r) sum += a[i][c];

	a[r][c] = sum;

	rep(i,r+1)
	{
		rep(j,c+1)
		{
			if(j == 0) cout << a[i][j];
			else cout << " " << a[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    rep2(i,1,n+1){
        int sum = 0;
        string str = to_string(i);
        
        rep(j,str.size()){
            sum += str[j] - '0';
        }
        if(a<=sum and b >=sum)ans+=i;
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 3720
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        if a[i] > a[j]:
            count += (k*(1+k) // 2) % mod
        if a[i] < a[j]:
            count += ((k-1)*k // 2) % mod
print(count % mod)

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

int main() {
	string s;
	cin >> s;
    int n;
	for (int i = 0, j = s.size() - 1; i < j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << "\n";
			return 0;
		}
	}

	 n = (s.size() - 1) / 2;

	for (int i = 0, j = n - 1; i < j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << "\n";
			return 0;
		}
	}
     
    n = (s.size() + 3) / 2; 
    
	for (int i = n - 1, j = s.size() - 1; i < j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << "\n";
			return 0;
		}
	}
    
    cout << "Yes" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long double W,H,X,Y;
  cin>>W>>H>>X>>Y;
  if(X==W/2&&Y==H/2){
    long double S=X*Y*2;
    cout<<fixed<<S<<" "<<1<<endl;
  }
  else{
    long double S=(W/2)*H;
    cout<<fixed<<S<<" "<<0<<endl;
  }
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10){
        cout << a * b << endl;
        return 0;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char b;
  
  scanf("%c",&b);
  
  if(b == 'A')
    printf("T");
  
  if(b == 'T')
    printf("A");
  
  if(b == 'C')
    printf("G");
  
  if(b == 'G')
    printf("C");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
        #include<climits>
        #include<iostream>
        typedef long long int ll;
        using namespace std;
         
        int main(){
		ll t,d;
          cin>>t>>d;
          d = d*d;
          ll a,c;
          int r=0;
          while(t--) {
            
            cin>>a>>c;
            if(a*a + c*c <= d)
              r++;
          }
          cout<<r<<"\n";
            
        }

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans;
int main(){
	string s;
	int n;
	cin>>n;
	cin>>s;
	for(int i=0; i<s.size(); i++){
		if(s[i] == 'A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
s = list(input())
count = 0
init = s[0]
for i in range(len(s)-1):
    if s[i+1] == s[i]:
        count += 1
        if s[i+1] == "0":
            s[i+1] = "1"
        else:
            s[i+1] = "0"
print(count)


Measured memory_bytes: 3956
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		int H, W, i, j;
		Scanner sc = new Scanner(System.in);
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) break;
			for (i = 0; i < H; i++) {
				for(j = 0; j < W; j++) {
					if(i == 0 || i == H - 1 || j == 0 || j == W - 1) System.out.print("#");
					else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 35176
#include <stdio.h>
 
#define N 101
#define INFTY 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2
 

 
int main(){
    int k,c,u,v,n,M[N][N], minv, d[N],color[N] ,m,l,p,i,j;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            M[i][j] = INFTY;
        }
    }
     
    for(i=0; i<n; i++){
        scanf("%d%d",&u,&k);
        for(j=0; j<k; j++){
            scanf("%d%d",&v,&c);
            M[u][v] = c;
        }
    }
     
;
     for(m=0; m<n; m++){
        d[m] = INFTY;
        color[m] = WHITE;
    }
    d[0] = 0;
    color[0] = GRAY;
    while(1){
        minv = INFTY;
        l=-1;
        for(m=0; m<n; m++) {
            if(minv > d[m] && color[m] != BLACK){
                l = m;
                minv = d[m];
            }
        }
        if(l==-1) break;
        color[l] = BLACK;
        for(p=0; p<n; p++){
            if(color[p] != BLACK && M[l][p] != INFTY){
                if(d[p] > d[l] + M[l][p]) {
                    d[p] = d[l] + M[l][p];
                    color[p] = GRAY;
                }
            }
        }
    }
    for(m=0; m<n; m++){
        printf("%d %d\n",m,d[m]);
    } 
     
    return 0;
}
 



Measured memory_bytes: 2088
s=int(input())
a = [s]
n=s
m=0
while n not in a[:m]:
 if n%2==0:
  n=n/2 
  m=m+1
  a.append(n)
 else:
  n=3*n+1
  m=m+1
  a.append(n)
print(m+1)

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

template < unsigned mod >
class Modint
{
public:
        using uint = unsigned;
        using u64 = uint64_t;
        using i64 = int64_t;

        Modint (const i64 dat = 0) : dat(dat >= 0 ? dat % mod : (mod - (-dat) % mod) % mod) {}

        constexpr Modint operator + (const Modint &v) const { return ( Modint(dat + v.dat) ); }
        constexpr Modint operator - () const { return ( Modint(-((i64)dat)) ); }
        constexpr Modint operator - (const Modint &v) const { return ( (*this) + -v ); }
        constexpr Modint operator * (const Modint &v) const { return ( Modint((u64)dat * v.dat) ); }
        
        constexpr Modint operator ~ () const
        {
                i64 a = dat, b = mod, x1 = 1, x2 = 0, t;
                
                while ( b > 0 ) {
                        t = a / b;
                        swap(a -= t * b, b);
                        swap(x2 -= t * x1, x1);
                }
                
                return ( Modint(x1) );
        }
        
        constexpr Modint operator / (const Modint &v) const { return ( (*this) * ~v ); }

        Modint &operator = (const uint &v) { return ( dat = Modint(v) ); }
        Modint &operator = (const u64 &v) { return ( dat = Modint(v) ); }
        Modint &operator = (const i64 &v) { return ( dat = Modint(v) ); }
        Modint &operator += (const Modint &v) { return ( (*this) = (*this) + v ); }
        Modint &operator -= (const Modint &v) { return ( (*this) = (*this) - v ); }
        Modint &operator *= (const Modint &v) { return ( (*this) = (*this) * v ); }
        Modint &operator /= (const Modint &v) { return ( (*this) = (*this) / v ); }

        constexpr Modint operator ^ (u64 n) const
        {
                Modint < mod > ret(1), mul(dat);
                while ( n > 0 ) {
                        if ( n & 1 ) ret *= mul;
                        mul *= mul;
                        n >>= 1;
                }
                return ( ret );
        }
        
        bool operator == (const Modint &v) { return ( dat == v.dat ); }
        bool operator != (const Modint &v) { return ( dat != v.dat ); }

        friend ostream& operator << (ostream &os, const Modint &p )
        {
                return ( os << p.dat );
        }
        
        friend istream& operator >> (istream &is, Modint &p )
        {
                i64 data;
                is >> data;
                p = Modint < mod >(data);
                return ( is );
        }

private:
        uint dat;
};

int main()
{
        constexpr int mod = 1000000007;
        string L;
        Modint < mod > ret(0), mul(1);

        cin >> L;
        for ( int i = 0; i < L.size() - 1; i++ ) {
                if ( L[i] == '1' ) {
                        ret += mul * (Modint < mod > (3)^(L.size() - i - 1));
                        mul *= 2;
                }
        }

        if ( L[L.size() - 1] == '0' ) {
                ret += mul;
        } else {
                ret += mul * 3;
        }

        cout << ret << endl;

        return ( 0 );
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int r;cin>>r;
    int g;cin>>g;
    cout<<r+(g-r)*2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if(m1!=m2){
		cout << 1;
	}
	else{
		cout << 0;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int r=0,g=0,b=0;
  rep(i,n){
    if(s[i]=='R')r++;
    if(s[i]=='G')g++;
    if(s[i]=='B')b++;
  }
  ll ans = r*g*b;
  rep(j,n)rep(i,j){
    if(s[i]!=s[j]){
      int k = 2*j-i;
      if(k>=n)continue;
      if(s[i]!=s[k]&&s[j]!=s[k])ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007LL

ll bin[1000010],inv[1000010];
int n;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

int main()
{
	n=rd();
	ll Inv=ksm(3,mod-2);
	bin[0]=1;
	for (int i=1;i<=n;i++) bin[i]=bin[i-1]*Inv%mod;
	inv[1]=1;
	for (int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	ll ans=0;
	for (int i=1;i<=n;i++) ans=pls(ans,bin[i-1]*inv[n-i+1]%mod);
	printf("%lld\n",ans*inv[n]%mod*Inv%mod);
	return 0;
}

Measured memory_bytes: 15872
/*
CF ID: Ankit717
PROG: Frog1
LANG: C++
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200005
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb push_back
#define pf push_front
#define nl cout << "\n";

const ll INF=1e18L+5;
 
struct Data{
	ll p;
	ll h;
};

void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pll &a,pll &b){
	// if(a.first==b.first){
	// 	return a.second<b.second;
	// }else{
		return a.first>b.first;
	//}
}

// vector<pll> adj[maxn];
// vector<ll> par;
// vector<bool> vis;

ll gcd(ll a,ll b){
    while(a!=0){
        ll temp=a;
        a = b % a;
        b = temp;
    }

    return b;
}

// bool prime[maxn],near[maxn];
// void sieve(){
// 	f(i,0,maxn+1){
// 		prime[i]=true;
// 	}
// 	prime[0]=falsrime[1]=false;
// 	for(ll i=2;i*i<=maxn;i++){
// 		if(prime[i]){
// 			for(j=i*i;j<=maxn;j+=i){
// 				prime[j]=false;
// 			}
// 		}
// 	}
// }

void solve(){
	ll n;
	cin >> n;
	ll h[n];
	f(i,0,n){
		cin >> h[i];
	}

	ll dp[n]={INF};
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);

	f(i,2,n){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}

	cout << dp[n-1];
}

int main(){
	ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    
	// ll t;
	// cin >> t;
	// f(i,0,t){
		solve();
	//}
}


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

/*
最初の得点がxの時、x*2^m>=kなる最小のmを求めれば良い
x*2^(m-1)<k     2^m<2*(k/x)
x*2^m>=k        2^m>=k/x

*/

void solve(){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    rep(i,n){
        int score = i+1;
        double denominator = 1;
        while(1<=score&&score<k){
            denominator *= 2;
            score *= 2;
        }
        ans += 1/(denominator*n);
    }
    cout << setprecision(12) << ans << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 main() {
    int n; cin >> n;
    vector<pll> v(n);
    rep(i, n) cin >> v[i].second >> v[i].first;
    sort(all(v));

    cout << v[0].first + v[0].second << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  srand((unsigned)time(NULL));
  ll n,d,x,y,cnt=0;
  cin >> n >> d;
  d *= d;
  rep(i,n){
    cin >> x >> y;
    if(square(x)+square(y)<=d){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3532
nk = input()
nk = nk.split()
n = int(nk[0])
k = int(nk[1])

s = input()

count = 0
now = None
clist = []

for ss in s:
    if now is None:
        if ss == '0':
            clist.append(0)

    if now is None or now == ss:
        count += 1
    else:
        clist.append(count)
        count = 1
    now = ss

clist.append(count)

max_len = k * 2 + 1
max_sum = 0
clist_len = len(clist)
now_sum = None

for i in range(0, clist_len):
    if i % 2 == 1:
        continue
    j = i + max_len

    if now_sum is None:
        now_sum = sum(clist[i:j])
        max_sum = now_sum
    else:
        now_sum -= sum(clist[(i-2):i])
        now_sum += sum(clist[(j-2):(j)])
        max_sum = max(max_sum, now_sum)

print(max_sum)


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

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

    int ans = 0, tmp = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') ++tmp;
        else tmp = 0;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  static int top = 0;
  static int max = 110;
  static int[] stack = new int[max];

  public static boolean isNum(String str) {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }
  public static void initialize() {
    top = 0;
  }
  public static boolean isEmpty() {
    return top == 0;
  }
  public static boolean isFull() {
    return top >= max - 1;
  }
  public static void push(int x) {
    if(isFull()) {
      throw new IllegalArgumentException("オーバーフロー");
    } else {
      top++;
      stack[top] = x;
    }
  }
  public static int pop() {
    if(isEmpty()) {
      throw new IllegalArgumentException("アンダーフロー");
    } else {
      top--;
      return stack[top + 1];
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = "";
    int a;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        push(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = pop() + pop();
        push(a);
      } else if(s.equals("-")) {
        a = - (pop() - pop());
        push(a);
      } else {
        a = pop() * pop();
        push(a);
      }
    }
    System.out.println(pop());
  }
}



Measured memory_bytes: 26448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println(fixString(br.readLine()));
	}
	public static String fixString(String str){
		String[] word = str.split(" ");
		StringBuffer bf = new StringBuffer();
		for(int i = 0; i < word.length; i++){
			bf.append(fixWord(word[i]));
			if(i != word.length - 1){
				bf.append(" ");
			}
		}
		return bf.toString();
	}
	private static String fixWord(String target){
		StringBuffer stringFixed = new StringBuffer();
		int indexHead;
		int indexTail;
		if((indexHead = target.indexOf("apple")) > -1){
			//appleをpeachに
			indexTail = indexHead + "apple".length();
			stringFixed.append(target.substring(0, indexHead));
			stringFixed.append("peach");
			stringFixed.append(target.substring(indexTail, target.length()));
		}
		else if((indexHead = target.indexOf("peach")) > -1){
			//peachをappleに置換する
			indexTail = indexHead + "peach".length();
			stringFixed.append(target.substring(0, indexHead));
			stringFixed.append("apple");
			stringFixed.append(target.substring(indexTail, target.length()));
		}
		else{
			stringFixed.append(target);
		}
		return stringFixed.toString();
	}
}

Measured memory_bytes: 9348
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;


//
int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);

	int n;
	int debt = 100000;
	cin >> n;
	for(int i = 0; i < n; i++ ){
		debt += 5*debt/100;
		if(debt % 1000 > 0) 
			debt = debt/1000*1000 + 1000;
	}
	cout << debt << endl;
//	while(1){}
	return 0;
}

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

using namespace std;

int main() {
	string s;
	bool f = true;
	int cc = 0, clower = 0;
	cin >> s;
	if (s[0] != 'A') f &= false;
	for(int i = 2;i <= s.length() - 2;++i){
		if(s[i] == 'C') {
			++cc;
		}
	}
	if(cc != 1) f &= false;
	for(int i = 0;i < s.length();++i){
		if('a' <= s[i] && s[i] <= 'z') ++clower;
	}
	if(s.length() - clower != 2) f &= false;
	cout << (f ? "AC" : "WA") << endl;
	return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.ans = n*(n-1)//2

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
    
        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
        sx = self.size(x)
        sy = self.size(y)
        self.ans += sx*(sx-1)//2 + sy*(sy-1)//2
        self.ans -= (sx+sy)*(sx+sy-1)//2

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

######
N,M = map(int,input().split())
uf = UnionFind(N)
ans = [uf.ans]
pp = [list(map(int,input().split())) for i in range(M)]
for i in range(M,1,-1):
  uf.union(pp[i-1][0]-1, pp[i-1][1]-1)
  ans.append(uf.ans)
print('\n'.join(map(str, reversed(ans))))

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

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

    if(s.size() <= k) cout << s << endl;
    else{
        rep(i,k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}


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

int main(){
    int n=0;
    cin>>n;
    vector<int>d(n);
    
    //入力
    
    for (int i = 0; i < n; i++)
    {
        cin>>d.at(i);
    }
    
    //計算
    int a=0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
           a+=d.at(i)*d.at(j);
        }
        
    }
    //出力
    cout<<a<<endl;
}

Measured memory_bytes: 3144
# AtCoder Regular Contest 069
# D - Menagerie
# https://atcoder.jp/contests/arc069/tasks/arc069_b
import sys
N = int(input())
S = [1 if s == 'o' else 0 for s in input()]

tostr = ('W', 'S')


def f(a, b):
    last = prev = a
    first = current = b
    ans = []
    for s in S:
        ans.append(tostr[current])
        prev, current = current, prev ^ current ^ s
    if current == first and prev == last:
        print(''.join(ans))
        sys.exit()

f(1, 1)
f(1, 0)
f(0, 1)
f(0, 0)

print('-1')


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

int main(){
  long long n,i;
  cin >> n;
  vector<long long> a(n);
  
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  if(n%2==0){
    long long s,m;
    s=0;
    for(i=0;i<=n/2-1;i++){
      s=s+a.at(i*2);
    }
    m=s;
    
    for(i=n/2-1;i>=0;i--){
      s=s-a.at(i*2)+a.at(i*2+1);
      m=max(m,s);
    }
    
    cout << m << endl;
    
  }else{
    vector<vector<long long>> s((n-1)/2,vector<long long>(3,0));
    s.at(0).at(0)=a.at(0);
    s.at(0).at(1)=a.at(1);
    s.at(0).at(2)=a.at(2);
    for(i=1;i<=(n-3)/2;i++){
      s.at(i).at(0)=s.at(i-1).at(0)+a.at(2*i);
      s.at(i).at(1)=max(s.at(i-1).at(0),s.at(i-1).at(1))+a.at(2*i+1);
      s.at(i).at(2)=max(max(s.at(i-1).at(0),s.at(i-1).at(1)),s.at(i-1).at(2))+a.at(2*i+2);
    }
    cout << max(s.at((n-3)/2).at(0),max(s.at((n-3)/2).at(1),s.at((n-3)/2).at(2))) << endl;
  }
}

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

int main()
{
    string str;

    getline(cin, str);

    for (int i = 0; i < (int)str.size(); i++) {
        if (islower(str[i])) {
            cout << (char)toupper(str[i]);
        } else if (isupper(str[i])) {
            cout << (char)tolower(str[i]);
        } else {
            cout << str[i];
        }
    }
    cout << endl;

    return 0;
}

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

int main() {
 	int K;
    
  	vector<int> b={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K  ;
  
	cout << b.at(K-1) << endl;
  }

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int A, B, c;
  cin >> A >> B;

  c = (B - 1) / (A - 1);
  if ((B - 1) % (A - 1) != 0)
  {
    c += 1;
  }
  cout << c << endl;
}


Measured memory_bytes: 3132
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;

  int left = 0;
  int right = S.size() - 1;
  int answer = 0;
  while (left <= right) {
    if (S[left] == S[right]) {
      left++;
      right--;
    } else {
      if (S[left] == 'x') {
        answer++;
        left++;
      } else if (S[right] == 'x') {
        answer++;
        right--;
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int x1, x2 ,x3 ,x4 ,x5;
    
    scanf("%d",&x1);
    scanf("%d",&x2);
    scanf("%d",&x3);
    scanf("%d",&x4);
    scanf("%d",&x5);
    
if (x1 != 1) {
    printf("1");
} else if (x2 != 2) {
  printf("2");
}else if (x3 != 3) {
  printf("3");
}else if (x4 != 4) {
  printf("4");
}else{
  printf("5");
}
  
  return 0;
}
    
    
    
    


Measured memory_bytes: 2088
from math import gcd, sqrt, ceil
from functools import reduce

def sieve(n):
    A = list(range(n+1))
    for i in range(2, n+1 ,2):
        A[i] = 2
    for j in range(3, ceil(sqrt(n+1))+1, 2)[::-1]:
        for i in range(j, n+1, j):
            A[i] = j
    return A

def factorize(n, A):
    factors = set()
    while n != 1:
        f = A[n]
        factors.add(f)
        n //= f
    return factors

_, *aa = map(int, open(0).read().split())

def main(aa):
    pair_co = True
    A = sieve(10**6)
    all_factors = [0] * (10**6+1)
    for a in aa:
        factors = factorize(a, A)
        for factor in factors:
            if all_factors[factor]:
                pair_co = False
                break
            else:
                all_factors[factor] = 1
        if not pair_co:
            break
    if pair_co:
        return 'pairwise coprime'
    elif reduce(gcd, aa) == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'

print(main(aa))

Measured memory_bytes: 223360
#include<stdio.h>
#include<math.h>
int main(){
  long long n,d,a[200001],b[200001],count=0;
  scanf("%lld %lld",&n,&d);
  for(int i=0;i<n;i++){
    scanf("%lld %lld",&a[i],&b[i]);
    if(a[i]*a[i]+b[i]*b[i]<=d*d){count++;}
  }
  printf("%d\n",count);
}

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

long long H, W, X, Y, S;

int main() {
	cin >> W >> H >> X >> Y;

	if (2 * X == W && 2 * Y == H) S = 1;
	printf("%.12Lf %d\n", 0.5L * (H * W), S);
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a >> b >> c;
    ll m = max({a,b,c});
    ll k;
    cin >> k;
    ll ans = a+b+c-m;
    ans += (m<<k);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;

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

    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        int tmp = C;
        for(int j = 0; j < M; j++){
            tmp += A[i][j] * B[j];
        }
        if(tmp > 0){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = 1000000000;
ll inf = 1000000000000;
int mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	int b[110];
	int i;
	for (i = 1; i < n; i++) {
		cin >> b[i];
	}
	int sum = 0;
	b[0] = Inf;
	b[n] = Inf;
	for (i = 0; i < n; i++) {
		sum += min(b[i], b[i + 1]);
	}
	cout << sum;
	return(0);
}

Measured memory_bytes: 256