akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld             long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
// const int N = 1e5 + 5; 
// int n;
// int a[N];



int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){


int n; ld m;
cin >> n>>m;
int mm = round(m*100);
cout <<(n*mm)/100<<endl;






}
return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> h(n);
  
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }
  
  int ans = 1;
  int m = h.at(0);
  
  for(int i = 0; i < n-1; i++){
    if(i==0){
      if(m<=h.at(1)){
        ans++;
        m = h.at(1);
      }
    }
    else{
      if(m<=h.at(i+1)){
        ans++;
        m = h.at(i+1);
      }
    }
  }
    
    cout << ans << endl;
}

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

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	int count = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		count = ((s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') ? count + 1 : 0);
		ans = max(ans, count);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000000000000007LL
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
map<ll,ll>m;
ll n,a,b,c,d;
ll fu(ll n1)
{
	if(n1==0)return 0;
	if(n1==1)return d;
	if(m.count(n1))return m[n1];
	ll ans=M;
	if(M/d>=n1)
	ans=d*n1;
	ans=min(ans,a+(n1%2)*d+fu(n1/2));
	ans=min(ans,b+d*(n1%3)+fu(n1/3));
	ans=min(ans,c+d*(n1%5)+fu(n1/5));
	if(n1%2)ans=min(ans,(2-n1%2)*d+fu(n1/2+1)+a);
    ans=min(ans,(3-n1%3)*d+fu(n1/3+1)+b);
    ans=min(ans,(5-n1%5)*d+fu(n1/5+1)+c);
    return m[n1]=ans;
}
int main()
{
	IOS;
	int t;
	cin>>t;
	while(t--)
	{
		cin>>n>>a>>b>>c>>d;
		m.clear();
		ll p=fu(n);
		cout<<p<<endl;
	}
}



Measured memory_bytes: 4628
/**
 *  Hi, I'm Arpan.
 *  Hardwork beats talent if talents doesn't work hard, friend me if you want to. ✌.|•͡˘‿•͡˘|.✌
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back

ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

void solve()
{
    int n;
    cin >> n;
    vl arr(n);
    inv(arr);
    ll ans = arr[0];
    for(int i=1;i<n;i++){
		ans^=arr[i];
    }
    for(int i=0;i<n;i++){
			ll d = ans^arr[i];
		cout << d << " ";
    }
}

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



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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}

ll mod(ll a, ll b) {return (a % b + b) % b;}

ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}

using namespace std;

int main() 
{	
	fast;
	ll a,b,c,d; cin>>a>>b>>c>>d;
	ll ans = 0;
	if(d > 0)
	{
		ans += a;
		d -= a;
	}
	if(d < 0)
	{
		ans += d;
		d = 0;
	}
	if(d > 0)
	{
		d -= b;
	}
	if(d < 0)
	{
		d = 0;
	}
	if(d > 0)
	{
		d -= c;
		ans += -c;
	}
	if(d < 0)
	{
		ans -= d;
		d = 0;
	}
	cout << ans << endl;
 	return 0;
}

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

#define fast ios_base:: sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long

int32_t main(){
	fast;
	int n,x;	cin >> n >> x;
	int a[n+5];
	
	a[0] = 0;
	for(int i=1 ; i<=n ; i++){
		cin >> a[i];
		a[i] += a[i-1];
	}
	
	int ans = 0;
	for(int i=0; i<=n ; i++){
		if(a[i] <= x)	ans++;
	}
	cout << ans;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 100010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;

ll N, M;


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll A, B, N;
    sll(A);
    sll(B);
    sll(N);
    
    ll x;
    if(N < B){
        x = N;
    }else{
        x = B-1;
    }
    ll ans = (A*x)/ B - A * (x / B);

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


    // cout<<fixed<<setprecision(10)<<num<<endl;
    // cout << num << endl;

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#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)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

char ba[3][3];

bool judge(char c) {
  REP(i,3) {
    int ct1 = 0, ct2 = 0;
    REP(j,3) {
      if (ba[i][j] == c) ct1++;
      if (ba[j][i] == c) ct2++;
    }
    if (ct1 == 3 || ct2 == 3) return true;
  }
  int ct1 = 0, ct2 = 0;
  REP(i,3) {
    if (ba[i][i] == c) ct1++;
    if (ba[2-i][i] == c) ct2++;
  }
  if (ct1 == 3 || ct2 == 3) return true;
  return false;
}

int main() {
  char a;
  while(cin >> a, a!='0') {
    ba[0][0] = a;
    REP(i,3) {
      REP(j,3) {
        if (i||j)
          cin >> ba[j][i];
      }
    }
    if (judge('b')) cout << 'b' << endl;
    else if (judge('w')) cout << "w" << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
  int N,n,a[200000],max1=0,k,max2=0,i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    if(max1<a[i]){
      max1=a[i];
      k=i;
    }
  }
  for(i=0;i<n;i++){
    if(i == k){
      continue;
    }
    if(max2<a[i]){
      max2=a[i];
    }
  }
   for(i=0;i<n;i++){
      if(i == k){
        printf("%d\n",max2);
      }else{
        printf("%d\n",max1);
      }
    }
    
  return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int C(int M, int N){
    for(; N; N >>= 1, M >>= 1) if((N & 1) > (M & 1)) return 0;
    return 1;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, ans = 0, k = 1;
    cin >> N;
    string s;
    cin >> s;
    for(int i = 1; i < N; i += 1) s[i - 1] = abs(s[i] - s[i - 1]);
    s.pop_back();
    k += not count(s.begin(), s.end(), 1);
    for(int i = 0; i < N - 1; i += 1) ans += C(N - 2, i) * s[i] / k;
    cout << ans % 2 * k;
    return 0;
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
int N, W;
int v[1001], w[1001];
int a[101][10001];
int c;
int main()
{
	cin >> N >> W;
	for(int i=1; i<=N; i++)
	{
		cin >> v[i] >> w[i];
	}
	for(int i=0; i<=N; i++)
	{
		a[i][0]=0;
	}
	for(int i=0; i<=W; i++)
	{
		a[0][i]=0;
	}
	for(int i=1; i<=N; i++)
	{
		for(int j=1; j<=W; j++)
		{
			if(w[i]<=j)
			{
				a[i][j]=max(a[i-1][j], a[i][j-w[i]]+v[i]);
			}
			else
			{
				a[i][j]=a[i-1][j];
			}
		}
	}
	cout << a[N][W] << endl;
	return 0;
}

Measured memory_bytes: 7004
fun main(args: Array<String>) {
    val n=readLine()!!.toInt()
    val m = if(n%2==0)n*(n-2)/2 else (n-1)*(n-1)/2
    val n2 = n-n%2
    val n3 = n-n%2+1
    println(m)
    for (i in 0 until n2){
        for(j in i+1 until n2){
            if(i+j+2!=n3){
                print(i+1)
                print(" ")
                println(j+1)
            }
        }
    }
    if(n%2==1)
        for(i in 0 until n2){
            print(i+1)
            print(" ")
            println(n)
        }
}

Measured memory_bytes: 33796
#Edgeの組を拾う時に，辞書が良いかも？
import sys
input = sys.stdin.readline

N = int(input())
E=[[] for _ in range(N)]

index ={}

for i in range(N-1):
    a,b = map(int,input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
    index[(a-1,b-1)]=i
    index[(b-1,a-1)]=i

K=0
#ここに答えを入れていく，
ans=[None]*(N-1)

#dfs,root=-1
#Q=[(node,pare)]
Q=[(0,-1)]
while(Q):
    node,p=Q.pop()
    col=1
    #根の時
    if p==-1:
        for to in E[node]:
            #ansの適切な位置に色情報を入れる
            ans[index[(node,to)]]=col
            col +=1
            K=max(col,K)
            Q.append((to,node))
    #根ではない時
    else:
        for to in E[node]:
            if to==p:
                continue
            #親の色と同じなら1を足す．
            col+=(col==ans[index[(node,p)]]) 
            ans[index[(node,to)]]=col
            col+=1
            K=max(col,K)
            Q.append((to,node))

print(K-1)
print(*ans,sep="\n")

Measured memory_bytes: 91936
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;

void solve(long X) {
  long sum(0);
  long i(0);
  while (sum < X) {
    sum += i++;
  }
  cout << i - 1 << endl;
}

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

  long X;
  cin >> X;

  solve(X);

  return 0;
}


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

using namespace std;

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

	while(!S.empty()){
		switch(S[0]){
		case 'e':
			if(S.find("erase") != 0){
				goto NG;
			}

			if(S[5] == 'r'){
				S.erase(0, 6);
			} else {
				S.erase(0, 5);
			}

			break;
		case 'd':
			if(S.find("dream") != 0){
				goto NG;
			}

			if(S.find("dreamer") == 0){
				if(S.find("dreamerase") == 0){
					S.erase(0, 5);
				} else {
					S.erase(0, 7);
				}
			} else {
				S.erase(0, 5);
			}
			break;
		default:
			goto NG;
		}
	}

	cout << "YES" << endl;
	return 0;
NG:
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    if ((b-a)%2 == 0){
        PRINT((b-a)/2);
    }
    else{
        PRINT(min((b-1+a-1)/2+1,(n-a+n-b)/2+1));
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; i++)
#define SZ(a) (int)a.size()
struct UF {
	vector<int> dt;
	UF(int n) { dt.assign(n, -1); }
	bool merge(int x, int y) {
		x = rt(x); y = rt(y);
		if (x != y) {
			if (dt[y] < dt[x])
				swap(x, y);
			dt[x] += dt[y];
			dt[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) { return rt(x) == rt(y); }
	int rt(int x) { return dt[x] < 0 ? x : dt[x] = rt(dt[x]); }
};

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	UF uf(N);
	FOR(i, 0, Q) {
		int com, x, y;
		cin >> com >> x >> y;
		if (!com) {
			uf.merge(x, y);
		}
		else {
			cout << uf.same(x, y) << endl;
		}
	}
}


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

using namespace std;

int const N = 241;
int n, a[N], ans;

int main(){
	ans = 1e9 + 7;
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
	}
	
	for(int i=-100;i<=100;++i){
		int pans = 0;
		for(int j=0;j<n;++j){
			pans += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans, pans);
	}
	printf("%d\n",ans);



	return 0;
}

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

#define NDEBUG
#include <cassert>

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

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

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

void solve(int H,int W,int h,int w) {
    int u = 501;
    int neg = (h*w-1)*u+1;
    vvi a(H, vi(W, u));
    for (int i=h-1; i<H; i+=h) {
        for (int j=w-1; j<W; j+=w) {
            a[i][j] = -neg;
        }
    }
    int sum = 0;
    rep(i,H) rep(j,W) sum += a[i][j];
    if (sum > 0) {
        cout << "Yes" << endl;
        rep(i,H) {
            rep(j,W) {
                if (j > 0) cout << " ";
                cout << a[i][j];
            }
            cout << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

int main() {
    int H,W,h,w; scanf("%d%d%d%d", &H,&W,&h,&w);
    solve(H,W,h,w);
    return 0;
}


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

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

int main(){
  string s;
  cin >> s;
  s[5] = s[13] = ' ';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  if (s.size() % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i + 2 <= s.size(); i += 2) {
    if (s[i] != 'h' || s[i + 1] != 'i') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

#define pi 3.14159265

double s(double a, double b, double ct){
   return ( a * b ) * sin( ct * pi / 180.0) / 2;
}
double l(double a, double b, double ct){
    double
    c = sqrt( a * a + b * b - 2 * a * b * cos(ct * pi / 180.0));
    return a + b + c;
}
double H(double a, double b, double ct){
    return s(a,b,ct) * 2 / a;
}

int main(){
    double a, b, ct;
    scanf("%lf%lf%lf", &a, &b, &ct);
    printf("%f\n%f\n%f\n", s(a,b,ct), l(a,b,ct), H(a,b,ct));
    return 0;
}

Measured memory_bytes: 676
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	double r; int n;
	while (cin >> r >> n, r) {
		double high[40] = {};
		int x, y; double h;
		rep(i, n) {
			cin >> x >> y >> h;
			Rep1(j, x + 20, y + 19) {
				high[j] = max(high[j], h);
			}
		}
		double out=100;
		rep(i, 40) {
			if (i < 20) {
				double d = 19 - i;
				if (r*r - d * d > 0) {
					out = min(out, high[i] - sqrt(r*r - d * d));
				}
			}
			else {
				double d = i - 20;
				if (r*r - d * d > 0) {
					out = min(out, high[i] - sqrt(r*r - d * d));
				}
			}
		}
		cout << fixed << setprecision(4) << r+out << endl;
	}
	return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int n;

void solve(string s, char Max){
    if(s.size() == n) cout << s << endl;
    else{
        for(char c = 'a'; c <= Max; c ++) solve(s+c,(c == Max ? char(Max+1):Max));
    }

}

int main() {
    cin >> n;
    solve("a",'b');
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;

vector<bool> Prime(500000, true);

void init() {
	Prime[0] = Prime[1] = false;
	for (int i = 2; i < 500000; i++) {
		if (Prime[i]) {
			for (int j = 2; i * j < 500000; j++) {
				Prime[i * j] = false;
			}
		}
	}
}

int main() {
	init();
	int N;
	while (cin >> N) {
		if (N == 0) return 0;
		int ANS = 0;
		for (int i = N + 1; i <= N * 2; i++) {
			if (Prime[i]) ANS++;
		}
		cout << ANS << endl;
	}
}


Measured memory_bytes: 3156
# -*- coding: utf-8 -*-

import sys
import os
import math
import itertools


def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

for s in sys.stdin:
    n = int(s)

    for i in range(n-1, 0, -1):
        if is_prime(i):
            answer0 = i
            break

    for i in range(n+1, 100000, 1):
        if is_prime(i):
            answer1 = i
            break

    print(answer0, answer1)

Measured memory_bytes: 7640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> count(N, 0);
    for (int i = 1; i < N; i++) {
        if (S[i] == 'E') count[0]++;
    }
    int min_count = count[0];
    for (int i = 1; i < N; i++) {
        count[i] = count[i-1] + (S[i-1] == 'W') - (S[i] == 'E');
        min_count = min(min_count, count[i]);
    }

    cout << min_count << endl;
}

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

struct BIT{
    int n;
    vector<int> v;

    BIT(int _n) : n(_n){
        v.resize(n+1, 0);
    }

    void add(int i, int x){
        while(i <= n){
            v[i] += x;
            i += i&-i;
        }
    }

    int sum(int i){
        int ret = 0;
        while(i > 0){
            ret += v[i];
            i -= i&-i;
        }
        return ret;
    }
};

typedef pair<int,int> pii;
typedef long long ll;
const int mod = 998244353;

int main(){
    int n;
    cin >> n;
    vector<pii> vp;
    vector<int> y;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        vp.push_back({a,b});
        y.push_back(b);
    }
    sort(y.begin(), y.end());
    BIT bit(n);
    for(int i = 1; i <= n; i++) bit.add(i, 1);
    sort(vp.begin(), vp.end());
    vector<ll> fact(n+1, 1);
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*2%mod;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        int left = i;
        int right = n-1-left;
        int down = lower_bound(y.begin(),y.end(),vp[i].second)-y.begin();
        int up = n-1-down;
        bit.add(down+1, -1);
        (ans += fact[n-1]) %= mod;   // select vp[i]
        int scatt[2][2];
        scatt[1][1] = bit.sum(down+1);
        scatt[0][1] = bit.sum(n)-bit.sum(down+1);
        scatt[1][0] = down-scatt[1][1];
        scatt[0][0] = up-scatt[0][1];
        ll add = 0;
        bool all = true;
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < 2; k++){
                all &= scatt[j][k]>0;
                bool valid = true;
                ll tmpadd = 1;
                for(int l = 0; l < 2; l++){
                    for(int m = 0; m < 2; m++){
                        if(l==j&&k==m)  continue;
                        valid &= scatt[l][m]>0;
                        tmpadd *= fact[scatt[l][m]]-1;
                        tmpadd %= mod;
                    }
                }
                if(valid)   (add += tmpadd) %= mod;
            }
        }
        if(scatt[0][0] > 0 && scatt[1][1])  (add += (fact[scatt[0][0]]-1)*(fact[scatt[1][1]]-1)%mod) %= mod;
        if(scatt[1][0] > 0 && scatt[0][1])  (add += (fact[scatt[1][0]]-1)*(fact[scatt[0][1]]-1)%mod) %= mod;
        if(all){
            ll tmp = 1;
            for(int j = 0; j < 2; j++){
                for(int k = 0; k < 2; k++){
                    (tmp *= fact[scatt[j][k]]-1) %= mod;
                }
            }
            (add += tmp) %= mod;
        }
        (ans += add) %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5232
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MAXN = 5000 + 10;
const int MAXK = 5000 + 10;

int N, K;
int A[MAXK];
bool DP1[MAXN][MAXK], DP2[MAXN][MAXK];

const int MAXTREE = MAXK;
const int TREEBASE = 1;
int Tree[MAXTREE];
void Modify(int p, int val)
{
	p += TREEBASE;
	for (; p < MAXTREE; p += p & (-p))
		Tree[p] += val;
}
int GetSum(int p)
{
	p += TREEBASE;
	int Ret = 0;
	for (; p > 0; p -= p & (-p))
		Ret += Tree[p];
	return Ret;
}

void Work()
{
	scanf("%d%d", &N, &K);
	long long Sum = 0;
	for (int i = 1; i <= N; i ++)
		scanf("%d", &A[i]);
	
	DP1[0][0] = 1;
	for (int i = 0; i < N; i ++)
		for (int j = 0; j <= K; j ++)
			if (DP1[i][j])
				DP1[i + 1][j] = DP1[i + 1][min(j + A[i + 1], K)] = 1;
	DP2[N + 1][0] = 1;
	for (int i = N + 1; i > 1; i --)
		for (int j = 0; j <= K; j ++)
			if (DP2[i][j])
				DP2[i - 1][j] = DP2[i - 1][min(j + A[i - 1], K)] = 1;
	int Ans = 0;
	for (int i = 1; i <= N; i ++)
	{
		if (A[i] >= K)
			continue;
		int L = K - A[i];
		int R = K - 1;

		for (int j = 0; j <= K; j ++)
			if (DP1[i - 1][j])
				Modify(j, 1);
		
		int unnecessary = 1;
		for (int j = 0; j < K; j ++)
			if (DP2[i + 1][j])
			{
				// [L - j, R - j]
				int l = max(L - j, 0);
				int r = R - j;
				if (GetSum(r) - GetSum(l - 1) != 0)
					unnecessary = 0;
			}
		Ans += unnecessary;

		for (int j = 0; j <= K; j ++)
			if (DP1[i - 1][j])
				Modify(j, -1);
	}
	printf("%d\n", Ans);
}

int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 49152
N , A = map(int, input().split())
x = [0] + list((map(int, input().split())))

ans = 0

dp = [[[0 for _ in range(N*A + 1)] for _ in range(N+1)] for _ in range(N+1)] # dp[i][num][j] : iこ目までみてnum個選んでjをつくる方法
dp[0][0][0] = 1
for i in range(1, N+1):
    for num in range(i+1):
        for j in range(N * A+1):
            dp[i][num][j] += dp[i-1][num][j]
            if j >= x[i]:
                dp[i][num][j] += dp[i-1][num-1][j-x[i]]

for num in range(1, N+1):
    ans += dp[N][num][num * A]

print(ans)

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

    rep(a, x + 1)
    {
        if ((2 * a + 4 * (x - a)) == y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, k, i, br=0;
    scanf("%d%d", &n, &k);
    int a[n+1];
    for(i=0; i<n; i++){
		scanf("%d", &a[i]);
    }

    for(i=0; i<n; i++){
		if(a[i]>=k) br++;
    }

    printf("%d", br);

    return 0;
}


Measured memory_bytes: 512
use std::cmp;

const INF: u64 = 1 << 50;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let h: usize = sc.read();
    let w: usize = sc.read();
    let board: Vec<_> = (0..h).map(|_| sc.chars()).collect();

    let board: Vec<Vec<char>> = (0..w)
        .map(|j| (0..h).map(|i| board[h - 1 - i][j]).collect())
        .collect();

    let mut ans = 0;
    for i in 1..w {
        ans += calc(&board[i - 1], &board[i]);
    }
    println!("{}", ans);
}

fn calc(a: &Vec<char>, b: &Vec<char>) -> u64 {
    let n = a.len();

    let mut cost = vec![vec![0; n + 1]; n + 1];
    for x in 0..(n + 1) {
        let mut c = 0;
        for i in 0..(n - x) {
            if a[i + x] == b[i] {
                c += 1;
            }
        }
        cost[x][0] = c;
    }

    for x in 0..(n + 1) {
        let mut c = 0;
        for i in 0..(n - x) {
            if a[i] == b[i + x] {
                c += 1;
            }
        }
        cost[0][x] = c;
    }

    for x in 0..n {
        for i in 0..(n - x) {
            cost[i + x + 1][i + 1] = cost[i + x][i] - if a[x + i] == b[i] { 1 } else { 0 };
            cost[i + 1][i + x + 1] = cost[i][i + x] - if a[i] == b[i + x] { 1 } else { 0 };
        }
    }

    let mut dp = vec![vec![INF; n + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..(n + 1) {
        for j in 0..(n + 1) {
            if i + 1 <= n {
                dp[i + 1][j] = cmp::min(dp[i + 1][j], dp[i][j] + cost[i][j]);
            }
            if j + 1 <= n {
                dp[i][j + 1] = cmp::min(dp[i][j + 1], dp[i][j] + cost[i][j]);
            }
        }
    }
    dp[n][n]
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;
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 dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int d[200005];

ll modpow(ll a, ll n, ll mod) {
    if (mod <= 0) return 0;
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int solve(int n) {
    if (n == 0) return 0;
    return solve(n % __builtin_popcount(n)) + 1;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int p = 0;
    rep(i,n)if(s[i]=='1')p++;

    int a1 = 0; 
    int a2 = 0;

    for(int i=0;i<n;i++){
        if(s[i] == '1'){
            if(p==1){
                a1 = 0;
            }else{
                a1 = (a1 + modpow(2,n-1-i,p-1)) % (p-1);
            }
            a2 = (a2 + modpow(2,n-1-i,p+1)) % (p+1);
        }
    }

    for(int i=0;i<n;i++){
        ll now;
        if(s[i] == '1'){
            if(p==1){
                cout << 0 << endl;
                continue;
            }
            now = a1 - modpow(2,n-1-i,p-1) + (p-1)*1e4;
            now %= p-1;
            cout << 1 + solve(now) << endl;
        }else{
            now = a2;
            now += modpow(2,n-1-i,p+1);
            now %= p+1;
            cout << 1 + solve(now) << endl;
        }
    }
}

Measured memory_bytes: 3788
n = gets.to_i
a = gets.split.map(&:to_i)

b = a.dup

ans0 = 0

if b[0] <= 0
  ans0 += -b[0] + 1
  b[0] = 1
end

(n-1).times do |i| 
  b[i+1] += b[i]
  seki = b[i+1] * b[i]
  
  if seki < 0
    next
  else
    sgn = b[i] > 0 ? 1 : -1
    ans0 += (b[i+1]).abs + 1
    b[i+1] = -sgn
  end
end

# p b

b = a.dup
ans1 = 0

if b[0] >= 0
  ans1 += b[0] + 1
  b[0] = -1
end

(n-1).times do |i| 
  b[i+1] += b[i]
  seki = b[i+1] * b[i]
  
  if seki < 0
    next
  else
    sgn = b[i] > 0 ? 1 : -1
    ans1 += (b[i+1]).abs + 1
    b[i+1] = -sgn
  end
end

# p b
# p [ans0, ans1]
puts ans0 < ans1 ? ans0 : ans1
  
  
  

Measured memory_bytes: 10124
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;


class P
{
    static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToList();
        int[] count = Enumerable.Repeat(1, nm[0]).ToArray();
        bool[] isPossible = new bool[nm[0]];
        isPossible[0] = true;
        for (int i = 0; i < nm[1]; i++)
        {
            var xy = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToList();
            count[xy[0]]--;
            count[xy[1]]++;
            isPossible[xy[1]] |= isPossible[xy[0]];
            if (count[xy[0]] == 0) isPossible[xy[0]] = false;
        }
        Console.WriteLine(isPossible.Count(x => x));
    }
}



Measured memory_bytes: 17512
#include <stdio.h>

int main(){
    int s = 100000;
    float w;
    int week;

    scanf( "%d", &week );
    while ( week ) {
        w = ( float )s + ( float )s * 0.05;
        s = ( int )w;
        if ( ( s % 1000 ) > 0 ) {
            s /= 1000;
            s ++;
            s *= 1000;
        }
        week --;
    }
    printf( "%d\n", s );

    return 0;
}

Measured memory_bytes: 592
#!/usr/bin/env python3
import sys
from math import ceil

def solve(N: int, A: int, B: int, h: "List[int]"):
    INF = 10000000000
    
    def f(K: int):
        c = 0
        for i in range(N):
            c += ceil(max(0, h[i] - B*K)/(A-B))

        if c <= K:
            return True
        else:
            return False


    def b(ok: int, ng: int):
        
        while ok-ng > 1:
            mid = (ok+ng)//2
            # print(ok, ng, mid)  
            if f(mid):
                ok = mid
            else:
                ng = mid

        return ok

    print(b(INF, 0))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7116
#include <iostream>
#include <string>
using namespace std;
void island(int map[14][14],int x,int y){
	map[x][y]=0;
	if(map[x+1][y]==1){
		island(map,x+1,y);
	}
	if(map[x][y-1]==1){
		island(map,x,y-1);
	}
	if(map[x][y+1]==1){
		island(map,x,y+1);
	}
}

int main(){
	int map[14][14]={0};
	string str;
	while(cin>>str){
		for(int k=0;k<12;k++){
			map[1][k+1]=str[k]-48;
		}
		for(int i=1;i<12;i++){
			cin>>str;
			for(int j=0;j<12;j++){
				map[i+1][j+1]=str[j]-48;
			}
		}
		int count=0;
		for(int i=1;i<13;i++){
			for(int j=1;j<13;j++){
				if(map[i][j]==1){
					island(map,i,j);
					count++;
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

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

int main() {
	int n,m;cin>>n>>m;
	vector<int> x(m),y(m),z(m);
	vector<vector<int>> next(n+1,vector<int>(0));
	vector<int> used(n+1,0);
	int ans=n-m;
	for(int i=0;i<m;i++){
		cin>>x[i]>>y[i]>>z[i];
		next[x[i]].push_back(y[i]);
		next[y[i]].push_back(x[i]);
//		if(used[x[i]]*used[y[i]]){
//			ans++;
//		}
//		used[x[i]]++;
//		used[y[i]]++;
	}
	int i=1;
	ans=0;
	while(i<=n){
		if(used[i]){
			i++;
			continue;
		}
		ans++;
		vector<int> list;
		list.push_back(i);
		used[i]=1;
		while(list.size()){
			int num=list.back();
			list.pop_back();
			for(auto& x:next[num]){
				if(used[x]==0){
					used[x]=1;
					list.push_back(x);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8440
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    long D = sc.nextLong();
    D *= D;
    
    long X = 0;
    long Y = 0;
    int ans = 0;
    for(int i = 0; i < N; ++i) {
      X = sc.nextLong();
      Y = sc.nextLong();
      if(X * X + Y * Y <= D) {
        ++ans;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 59620
# ABC C-Tsundoku
n,m,k = map(int,input().split())
an = list(map(int,input().split()))
bn = list(map(int,input().split()))

suma = [0]
sumb = [0]
a = 0
b = 0
for i in an:
    a += i
    suma.append(a)
for i in bn:
    b += i
    sumb.append(b)

res = [0]
l = m
for j in range(n+1):
    if k-suma[j] < 0:
        break
    while k-suma[j]-sumb[l] < 0 and l > 0:
        l -= 1
    res.append(j+l)
print(max(res))

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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 4) {
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> ss(m);
  for (auto& s : ss) {
    int k;
    cin >> k;
    s.resize(k);
    for (auto& v : s) {
      cin >> v;
      v--;
    }
  }
  vector<int> ps(m);
  for (auto& v : ps)
    cin >> v;
  int pats = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int pop = 0;
      for (auto s : ss[j])
        if ((i >> s) & 1)
          pop++;
      if (pop % 2 != ps[j])
        ok = false;
    }
    if (ok) pats++;
  }
  cout << pats << endl;
}


Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
s=[input() for _ in range(h)]
vi=[ [-1 for _ in range(w)] for _ in range(h)]
st=deque()
st.append([0,0,1])
vi[0][0]=1
while st:
  h1,w1,i=st.popleft()
  d=[[0,1],[-1,0],[1,0],[0,-1]]
  for m in d:
    if h1+m[0]==h-1 and w1+m[1]==w-1:
      vi[h-1][w-1]=i+1
      st.clear()
    if 0<=h1+m[0]<h and 0<=w1+m[1]<w:
      if vi[h1+m[0]][w1+m[1]]==-1 and s[h1+m[0]][w1+m[1]]==".":
        st.append([h1+m[0],w1+m[1],i+1])
        vi[h1+m[0]][w1+m[1]]=i+1

print("".join(s).count(".")-vi[h-1][w-1] if vi[h-1][w-1]!=-1 else -1)


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

using namespace std;
using Int = long long;

int x[10 * 10] = {0};

signed main(){
    int n, d;
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            int tmp_x;
            cin >> tmp_x;
            x[i * 10 + j] = tmp_x;
        }
    }

    int count = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            double sum = 0;
            for(int k = 0; k < d; k++){
                sum += pow(x[i * 10 + k] - x[j * 10 + k], 2);
            }
            sum = sqrt(sum);
            if(ceil(sum) == floor(sum)) count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

ll lcm(ll a,ll b)
{
    return a * b / __gcd(a, b);
}

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

int main(){
    string S;
    cin >> S;
    int ans = 0;
    int size = S.size();
    for (int i = size; i > 0; i--)
    {
        S.erase(S.size()-1);
        int N = S.size();
        if(N%2 == 0)
        {
            if (S.substr(0, N / 2) == S.substr(N / 2))
            {
                ans = i-1;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
s = input()
x,answer = [" ","+"],0
for i in itertools.product(x,repeat=len(s)-1):
	s2 = ""
	for j in range(len(s)-1):
		s2 += s[j]+i[j]
	s2 += s[-1]
	s2 = s2.replace(" ","")
	answer += eval(s2)
print(answer)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) ||
		(b == c && b != a) ||
		(a == c && b != c)) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
def solve(a,b):
  if a <= 0 and b >= 0:
    return "Zero"
  elif a < b < 0 and (b-a+1) % 2 == 1:
    return "Negative"
  else:
    return "Positive"
    

a,b = map(int,input().split())
print(solve(a,b))

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

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3]){
        cout << "No" << endl;
    }else if(s[0]==s[2] && s[1]==s[3]){
        cout << "Yes" << endl;
    }else if(s[0]==s[3] && s[1]==s[2]){
        cout << "Yes" << endl;
    }else if(s[0]==s[1] && s[2]==s[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e18
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 2e5 + 7;
ll n,k;
string a;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k>>a;
    a[k - 1] = char('a' + (a[k - 1] - 'A'));
    cout<<a;       
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        string[] input = new string[2];
        for (int a = 0; a < 2; a++)
        { 
            input[a] = Console.ReadLine();
        }
        string f = "YES";
        //int input =int.Parse(input[0]+""+input[3+1]+""+input[3*2+2]);
        for(int a = 0; a < 3; a++)
        {
            if (input[0][a] != input[1][2 - a]) f = "NO";
        }
        Console.WriteLine(f);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

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

#define ll long long
#define LL long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define sch(n) scanf(" %c", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define Unique(a)  sort(all(a)),a.erase(unique(all(a)),a.end())

#define inf (1LL<<50)
#define eps 1e-9

ll Set(ll n, ll pos)
{
    return n|(1LL<<pos);
}

bool Check(ll n, ll pos)
{
    return (bool) (n&(1LL<<pos));
}


int main ()
{
    //  freopen("inl.txt", "r", stdin);
    // freopen("outu.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, ts, i, j, k, x, y, z, q, m, n;

    while(sl(x) != EOF)
    {
        sl(y);

        if (x%3 == 0 || y%3 == 0 || (x+y)%3 == 0)
        {
            printf("Possible\n");
        }
        else printf("Impossible\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define eb emplace_back
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first

bool isEven(string &s, int n)
{
    if(n&1) return false;
    for(int i=0;i<n/2;i++)
    {
        if( s[i]!=s[n/2+i] )
            return false;
    }
    return true;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.length()-1;
    while( !isEven(s,n) )
        n--;
    cout << n;
}

Measured memory_bytes: 3612
T = list(input())

try:
    for i in range(len(T)):
        if T[i] == '?':
            if T[i-1] == 'P' or T[i-1] == 'D':
                T[i] = 'D'
            elif T[i-1] == 'D' and T[i+1] == '?':
                T[i] = 'P'
            else:
                T[i] = 'D'
except IndexError:
    T[-1] = 'D'


for t in T:
    print(t,end='')


Measured memory_bytes: 10516
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key = lambda AB:AB[1])
sum = 0
flag = 0
for i in range(len(AB)):
    sum += AB[i][0]
    if sum > AB[i][1]:
        flag = 1

if flag == 0:
    print('Yes')
else:
    print('No')

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

int main() {
  int a, b, c;
  char s,t;
  cin >> a >> s >> b >> t >> c;
  if(b <= 4){
    cout << "Heisei";
  }
  else if (b > 4){
    cout << "TBD";
  }
 
  return 0;
}

Measured memory_bytes: 256