akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,ara[25];

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

    int ck=0,cnt=0;

    for(int i=0;i<n;i++){
        if(ck<=ara[i]){
            cnt++;
            ck=ara[i];
        }
    }

    cout <<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP((i),0,(n))
#define RREP(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rrep(i,n) RREP(i,n,0)
#define each(it,X) for(__typeof((X).begin())  it=(X).begin();it!=(X).end();it++)
#define all(v) ((v).begin(),(v).end())
#define fi first
#define se second
#define pb push_back
typedef pair<int,int>pr;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef set<int>si;
const int INF=1070000000ll;
const int mod=1000000007ll;

int N,M;
int d[30000];
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    while(cin>>N>>M,N){
        int sum=0;
        rep(i,N){
            int c;cin>>c;
            sum=(sum+c)%M;
            d[i]=sum;
        }
        set<int>S;
        S.insert(M);
        int ans=0;
        rep(i,N){
            int v=*(S.upper_bound(d[i]));
            ans=max(ans,(d[i]-v+M)%M);
            S.insert(d[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2640
N = int(input())
a = list(map(int,input().split()))
k = 4*sum(a[1::2])
l = 2*sum(a)
r = [0]*N
r[0] = (l-k)//2
for i in range(1,N):r[i]=2*a[i-1]-r[i-1]
print(*r)

Measured memory_bytes: 14028
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BMinorChange {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string s, t;
        in>>s>>t;
        int ans = 0;
        int n = LEN(s);
        REP(i, n){
            if(s[i]!=t[i]) ++ans;
        }
        out<<ans<<'\n';
    }
};


int main() {
	BMinorChange solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

const int N = 1e6 + 10, mod = 1e9 + 7;

int n;

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        int m;
        scanf("%d%d", &n, &m);
        int sum = 0;
        for(int i = 0; i < m; i++) {
            int x; scanf("%d", &x);
            sum += x;
        }
        printf("%d\n", max(-1, n - sum));
    }    
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const ll MOD = 1e9 + 7;
const int MX = 11000;

ll ans = 0;
ll fc[MX];
ll bfc[MX];
int n, a, b, c;

ll pw(ll a, ll b) {
	ll ans = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = (a * a) % MOD;
		--b;
		ans = (ans * a) % MOD;
	}
	return ans;
}

void init() {
	fc[0] = bfc[0] = 1;
	for (int i = 1; i < MX; ++i)
		fc[i] = (fc[i - 1] * i) % MOD, bfc[i] = pw(fc[i], MOD - 2);
}

int main() {
	cin >> n >> a >> b >> c;
	init();
	if (b % 2 != 0) {
		cout << 0 << "\n";
		return 0;
	}
	int y = b / 2;
	for (int x = 0; x <= a; ++x) {
		for (int w = 0; w * 3 <= c; ++w) {
			int z = a - x;
			if (z + 3 * w > c)
				continue;
			int lst = c - 3 * w - z;
			if (lst != 0 && y == 0)
				continue;
			ll now = fc[x + y + z + w];
			now = now * bfc[x] % MOD * bfc[y] % MOD * bfc[z] % MOD * bfc[w] % MOD;
			if (y != 0)
				now = now * fc[y + lst - 1] % MOD * bfc[lst] % MOD * bfc[y - 1] % MOD;
			ans = (now + ans) % MOD;
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int ans, ansMax, temp;

    ansMax = M / N;
  
    for(ans = ansMax; ans > 0; --ans){
        temp = M - ans * (N - 1);
        if((temp % ans) == 0){
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, max=0;
  cin >> a >> b >> c;
  if (a > b) {
    if (a > c) cout << 10*a+b+c << endl;
    else cout << 10*c+a+b << endl;
  } else {
    if (b > c) cout << 10*b+a+c << endl;
    else cout << 10*c+a+b << endl;
  }
  return 0;
}

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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e3 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
  ll n,p;
  cin >> n >> p ;
  string s;
  cin >> s;
  ll ans=0,dig;
  if(p==2 || p==5){
      for(ll i=0;i<n;i++){
        dig=s[i]-'0';
        if(dig%p==0)
          ans+=i+1;
      }
  }
  else{
    vl count(p+10,0);
    ll num=0,tens=1;
    count[0]=1;
    for(ll i=n-1;i>=0;--i){
      dig=s[i]-'0';
      num=(dig*tens + num)%p;
      tens=(tens*10ll)%p;
      // cout << num << " " << num%p << "\n";
      ans+=count[num%p]++;
    }
  }
  cout << ans;
} 
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;
}


Measured memory_bytes: 720
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n, m;
vector<int> a;

string solve(string s)
{
    int x = count(s.begin(), s.end(), '1');
    if(x != a[0])
        return "";

    for(int i=1; i<n; ++i){
        x -= s[i-1] - '0';
        if(x == a[i]){
            s.push_back('0');
        }else if(x + 1 == a[i]){
            s.push_back('1');
            ++ x;
        }else{
            return "";
        }
    }

    return s;
}

int main()
{
    for(;;){
        cin >> n >> m;
        if(n == 0)
            return 0;

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

        string ret = "Goofy";
        for(int i=0; i<(1<<m); ++i){
            bitset<12> bs(i);
            string s = solve(bs.to_string().substr(12-m));
            if(s != ""){
                ret = s;
                break;
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1236
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e9)

int main(){
	int n;
	cin >> n;
	int d[n+1], h[n+1];
	d[0]=0, d[1]=0;
	for(int i=1; i<=n; i++){
		cin >> h[i];
	}
	h[0]=h[1];

	for(int i=2; i<=n; i++){
		d[i]=min(d[i-1]+abs(h[i-1]-h[i]), d[i-2]+abs(h[i-2]-h[i]));
	}
	cout << d[n] << endl;
	return 0;
}

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

using namespace std; 
 
#define int long long
#define M 1000000007 
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
//	int t;
//	cin >> t;
//	while(t--){
		int n;
		cin >> n;
		int a[n+1];
		for(int i=1;i<=n;i++){
			cin >> a[i];
		}
		int b[n+1];
		for(int i=1;i<=n;i++){
			cin >> b[i];
		}
		int c[n];
		for(int i=1;i<n;i++){
			cin >> c[i];
		}
		int ans=0,lst=-1;
		for(int i=1;i<=n;i++){
			ans+=b[a[i]];
			if(lst==a[i]-1){
				ans+=c[a[i]-1];
			}
			lst=a[i];
		}
		cout << ans << endl;
//	}
}
 

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n, s;
	cin >> m >> n >> s;
 
	vector<string> a(m);
	FOR(i,0,m) cin >> a[i];
	
	ll res = oo;
	FOR(mask,0,1 << (m-1)) {
		vl bounds = {0};
		FOR(i,0,m-1) if (mask & (1 << i)) bounds.pb(i+1);
		bounds.pb(m);
		ll cur = __builtin_popcount(mask);
		
		ll k = sz(bounds)-1;
		vl cnt(k);
		FOR(j,0,n) {
			ll t = 0;
			vl add(k);
			FOR(i,0,m) {
				if (i == bounds[t+1]) t++;
				add[t] += a[i][j]-'0';
			}
			FOR(i,0,k) cnt[i] += add[i];
 
			bool ok = true;
			FOR(i,0,k) if (cnt[i] > s) ok = false;
 
			if (ok) continue;
 
			cur++;
			FOR(i,0,k) cnt[i] = add[i];
 
			ok = true;
			FOR(i,0,k) if (cnt[i] > s) ok = false;
 
			if (!ok) cur = oo;
		}
 
		res = min(res, cur);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int n,a,b;
  cin >> n >> a >> b;
 
  cout << min(n*a,b) << endl;
       
}

Measured memory_bytes: 256
S = [list( input()) for _ in range(3)]
C = ['A', 'B', 'C']
now = 0
nowc = 'A'
while True:
    if not S[now]:
        ans = C[now]
        break
    nowc = S[now].pop(0)
    if nowc == 'a':
        now = 0
    elif nowc == 'b':
        now = 1
    else:
        now = 2
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
#include <utility>
#include <string.h>

#define lli long long int
#define ll pair<lli, lli>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

bool visited[100010];
lli dist[100010];
vector<ll> adj[100010];

void dfs(lli pos) {
	ll x;
	lli nxt;
	visited[pos] = true;
	for (lli j = 0; j < (lli) adj[pos].size(); j++) {
		x = adj[pos][j];
		nxt = x.fi;
		if (!visited[nxt]) {
			dist[nxt] = dist[pos] + x.se;
			dfs(nxt);
		}
	}
}

int main() {
	lli n, u, v, w;
	scanf("%lld", &n);
	for (lli i = 1; i < n; i++) {
		scanf("%lld %lld %lld", &u, &v, &w);
		adj[u].pb(mp(v, w));
		adj[v].pb(mp(u, w));
	}
	dist[1] = 0;
	memset(visited, false, sizeof visited);
	dfs(1);
	for (lli i = 1; i <= n; i++)
		printf("%lld\n", dist[i] % 2);
	return 0;
}

Measured memory_bytes: 10240
// https://atcoder.jp/contests/abc122/tasks/abc122_c

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, Q, l, r, cnt, s[100000], v[100000];
char t, lt;
string S;

int main()
{
  t = lt = '0';

  cin >> N >> Q;

  cnt = 0;
  REP(i, N)
  {
    cin >> t;
    if (lt == 'A' && t == 'C')
      cnt++;
    s[i] = cnt;
    lt = t;
  }

  REP(i, Q)
  {
    cnt = 0;
    cin >> l >> r;
    v[i] = s[r - 1] - s[l - 1];
  }

  REP(i, Q)
  {
    cout << v[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 2432
#include <string>
#include <iostream>
#include <vector>
#include <climits>

using namespace std;
int main() {
	int n;
	string s;
	cin >> n >> s;
	//左は白で右は真っ黒
	//どこまで白にしておくのが効率が良いかという話
	vector<int> b(s.size()) , w(s.size());

	for(int i = 0; i < (int) s.size(); i++) {
		if(i > 0) w[i] = w[i - 1];
		w[i] += s[i] == '#' ? 1 : 0;
	}

	for(int i = s.size() - 1; i >= 0; i--) {
		if(i != (int) s.size() - 1) b[i] = b[i + 1];
		b[i] += s[i] == '.' ? 1 : 0;
	}

	int m = INT_MAX;
	for(int i = 0; i < (int) s.size(); i++) {
		int l, r;
		l = i > 0 ? w[i] : 0;
		r = i != (int) s.size() ? b[i+1] : 0;
		int nm = l + r;
		m = min(nm, m);
	}
	cout << m << endl;
}


Measured memory_bytes: 2180
#include <stdio.h>
    
    int main(void){
        int a,b,c,ans=0;
        int n,x,i;

        scanf("%d %d %d",&a,&b,&c);
        n=(b-a)+1;
        for(i=0;i<n;i++){
            x = a + i;
            if(c % x == 0){ans++;}
        }
        printf("%d\n",ans);
    }


Measured memory_bytes: 2100
def main():
    a,b,c=map(int,input().split())
    if a == b :
        if a!= c and b !=c:
            print('Yes')
        else:
            print('No')
    elif c == b :
        if a!= c and b !=a:
            print('Yes')
        else:
            print('No')
    elif c == a :
        if a!= b and b !=c:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

if __name__=='__main__':
    main()


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

class Cube{
public:
    int f[6];
    Cube(){}
    void roll_z(){ roll(1,2,4,3);}//
    void roll_y(){ roll(0,2,5,3);}// to W
    void roll_x(){ roll(0,1,5,4);}// to N
    void roll(int i, int j, int k, int l){
        int t= f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
    }
};

bool eq( Cube c1, Cube c2){
    for(int i=0; i<6; i++)
    if( c1.f[i] != c2.f[i]) return false;
    return true;
}

bool equal(Cube c1, Cube c2){
    for(int i=0; i<6; i++){
        for(int j=0; j<4; j++){
            if( eq(c1,c2)) return true;
            c1.roll_z();
        }
        if(i % 2 == 0) c1.roll_y();
        else c1.roll_x();
        }
        return false;
}

Cube C[100]; int n;

bool check(){
    for(int i=0; i< n-1; i++)
        for(int j=i+1; j<n; j++) if(equal(C[i],C[j]))  return false;
        return true;
}

int main(){
    cin >> n;
    for( int j=0; j<n; j++)
        for(int i=0; i<6; i++) cin >> C[j].f[i];
        
        if (check()) cout << "Yes" << endl;
        else cout << "No" << endl;
        
    return 0;
    
}


Measured memory_bytes: 3112
<?php
  $n = trim(fgets(STDIN));
  while($w = trim(fgets(STDIN))){
    $w_li[$w]++;
  }
  
  if(count($w_li)!=$n){
    echo "No\n";
    exit;
  }
  $words = array_keys($w_li);
  for($i=0; $i<$n-1; $i++){
    $last = strlen($words[$i])-1;
    if($words[$i][$last] != $words[$i+1][0]){
      echo "No\n";
      exit;
    }
  }

  echo "Yes\n";
  

Measured memory_bytes: 4604
#include <iostream>
#include <array>

using namespace std;

int main()
{
  array <array<char, 3>, 3> S;
  for(int j = 0; j < 3; j++){
   for(int i = 0; i < 3; i++){
    std::cin >> S[j][i];
   }
  std::cout << S[j][j];
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int a,b,c,i;
    while(cin>>a>>b){
    	for(i=1;i<=7;i++){
    		c=pow(10,i);
    		if((a+b)/c==0){
    			cout<<i<<endl;break;goto p1;
    		}
    	}
    }
    p1:return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m,k,a,b,c,d,li1[110][110],li2[110][110];

int main(){
	while(cin >> n >> m,n||m){
		REP(i,0,m) REP(j,0,m) if(i!=j) li1[i][j]=INF,li2[i][j]=INF;
		REP(i,0,n) cin >> a >> b >> c >> d,li1[a-1][b-1]=c,li1[b-1][a-1]=c,li2[a-1][b-1]=d,li2[b-1][a-1]=d;
		REP(k,0,m) REP(j,0,m) REP(i,0,m) li1[i][j]=min(li1[i][j], li1[i][k]+li1[k][j]),li2[i][j]=min(li2[i][j], li2[i][k]+li2[k][j]);
		cin >> k;
		REP(i,0,k){
			cin >> a >> b >> c;
			if(c) cout << li2[a-1][b-1] << endl;
			else cout << li1[a-1][b-1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


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

	string s;
	cin>>s;
	int ans;
	while(s.size()>0){
		s.erase(s.end()-1);
		if(s.size()%2==0){
			int n=s.size()/2;
			string fir=s.substr(0,n);
			string sec=s.substr(n,n);
			if(fir==sec){
				ans=s.size();
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int table[26];
    int value = 0;
    rep(i, 26) table[i] = 0;
    string str;
    cin >> str;
    rep(i, str.length()) {
        table[str[i] - 'a'] = 1;
        value += (str.length() - i) * (str[i] - 'a');
    }
    if (value >= 5850) {
        cout << -1 << endl;
        return 0;
    }
    if (str.length() >= 26) {
        for (int i = str.length() - 1; i >= 0; i--) {
            for (int j = str[i] - 'a'; j <= 'z' - 'a'; j++) {
                if (table[j] == 1)
                    continue;
                rep(k, i)
                    cout << str[k];
                cout << (char) ('a' + j) << endl;
                return 0;
            }
            table[str[i] - 'a'] = 0;
        }
    } else {
        for (int i = 0; i < 26; i++) {
            if (table[i] == 0) {
                cout << str << (char) ('a' + i) << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
A = np.array(rl())
A.sort()

def shake_cnt(x):
    # x以上の幸福度の時、何回握手するかを返す
    # Xは握手しない人の数
    X = np.searchsorted(A, x-A)
    return N * N - X.sum()

right = 10 ** 6 #M回未満
left = 0 # M回以上
while right > left + 1:
    mid = (right+left) // 2
    if shake_cnt(mid) >= M:
        left = mid
    else:
        right = mid

# right以上の幸福度の場合はまず握手して、ちょうどleftの幸福度で人数調整
Acum = np.zeros(N+1, dtype=np.int64)
Acum[1:] = A.cumsum()
Y = np.searchsorted(A, right-A)
happy = (Acum[-1] - Acum[Y]).sum() + (A * (N-Y)).sum()
happy += left * (M-shake_cnt(right))
print(happy)


Measured memory_bytes: 23432
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n, x, ans = 0;
	cin >> n >> x;
	vector<i64> a(n);
	REP(i, n)
	{
		cin >> a[i];
		if (a[i] > x)
		{
			ans += a[i] - x;
			a[i] = x;
		}
	}

	REP(i, n - 1)
	{
		if (a[i] + a[i + 1] > x)
		{
			i64 sub = a[i] + a[i + 1] - x;
			ans += sub;
			if (a[i + 1] > sub)
			{
				a[i + 1] -= sub;
				sub = 0;
			}
			else
			{
				sub -= a[i + 1];
				a[i + 1] = 0;
			}

			if (sub > 0)
			{
				a[i] -= sub;
			}
		}
	}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    long long int n;
    cin >> n;
    vector<long long int> a(n);
    rep(i, n) cin >> a[i];

    //fiを求める。
    long long int f1 = 0;
    rep(i, n)
    {
        if (i % 2 == 1)
        {
            f1 -= a[i];
        }
        else
            f1 += a[i];
    }

    vector<long long int> ans(n);
    ans[0] = f1;
    REP(i, 1, n - 1)
    {
        ans[i] = a[i - 1] * 2 - ans[i - 1];
    }
    ans[n - 1] = a[n - 1] * 2 - ans[0];
    rep(i, n)
    {
        cout << ans[i];
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }


int main() {
    int n;
    string s;
    cin >> n >> s;
    REP(i,s.length()){
        int x = s[i] - 'A';
        x = (x + n) % 26;
        s[i] = 'A' + x;
    }
    cout << s << endl;

    return 0;
}


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

int main(){
  int i, N;
  int C = 0;
  cin >> N;
  int t = N;
  vector<int> A(N);
  for(i = 0; i < N; i++){
  	cin >> A.at(i);
  }
  
  while(N == t){ 
    t = 0;
  	for(i = 0; i < N; i++){
	  if(A.at(i)/2==(A.at(i)+1)/2){
      	A.at(i) /= 2;
  		t++;
      }
	}
    if(N == t){
      C++;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
 
#define ll long long
 
#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));
 
int main(){
  int S;
	string N;
  cin >> S >> N;
  int W = 0,R = 0;
  froop1(1,S){
    if(N[i] == 'R')R++;
    else W++;
  }
  int count =0,a = 0,b = R;
  count = max(a,b);
     if(N[0] == 'W')a++;
  froop1(1,S){
    if(N[i] == 'R') b--;
    if(count > max(a,b)){
      count = max(a,b);
    }
   if(N[i] == 'W')a++;
  
  }
  cout << count << endl;
return 0;
}

Measured memory_bytes: 3724
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>

using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

struct Edge{
    int to;
    double cost;
    Edge(int a,int b):
        to(a),cost(b){}
    Edge(){}
};

struct Visit{
    int pos;
    double total;
    Visit(int a,double b):
        pos(a),total(b){}
    Visit(){}
    bool operator<(const Visit &v)const{
        return total>v.total;
    }
};
const double INF=1e9;
const double EPS=1e-8;
int N;
vector<vector<Edge> >G;
int b[1000],x[1000],y[1000];

void solve(int s,int g){
    double D[1000];
    fill_n(D,1000,INF);
    priority_queue<Visit>Q;
    Q.push(Visit(s,0));
    while(!Q.empty()){
        Visit v=Q.top();
        Q.pop();
        if(D[v.pos]!=INF)continue;
        D[v.pos]=v.total;
        rep(i,G[v.pos].size()){
            Edge e=G[v.pos][i];
            if(D[e.to]!=INF)continue;
            Q.push(Visit(e.to,v.total+e.cost));
        }
    }
    if(D[g]==INF){
        puts("NA");
        return;
    }
    vi ans;
    ans.pb(g);
    while(s!=g){
        rep(i,G[g].size()){
            Edge &e=G[g][i];
            if(fabs(D[e.to]+e.cost-D[g])<EPS){
                ans.pb(e.to);
                g=e.to;
                break;
            }
        }
    }
    reverse(all(ans));
    rep(i,ans.size()){
        if(i)printf(" ");
        printf("%d",b[ans[i]]);
    }
    puts("");
}

int main(){
    while(scanf("%d",&N),N){
        G=vector<vector<Edge> >(N);
        rep(i,N){
            scanf("%d%d%d",&b[i],&x[i],&y[i]);
            rep(j,i){
                double dist=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
                if(dist<=50.0){
                    G[i].pb(Edge(j,dist));
                    G[j].pb(Edge(i,dist));
                }
            }
        }

        int M;
        scanf("%d",&M);
        while(M--){
            int s,g;
            scanf("%d%d",&s,&g);
            rep(i,N){
                if(b[i]==s){
                    s=i;
                    break;
                }
            }
            rep(i,N){
                if(b[i]==g){
                    g=i;
                    break;
                }
            }


            solve(s,g);

        }
    }

    return 0;
}

Measured memory_bytes: 1252
#include<unordered_map>
#include<utility>
template<typename T>
class UnionFind {
 public:
  void unite(const T& a, const T& b) {
    auto x = find(a), y = find(b);
    if(rank_[x] < rank_[y]) std::swap(x, y);
    parent_[y] = x;
    if(rank_[x] == rank_[y]) rank_[x] += 1;
  }
  T find(const T& x) {
    if(!parent_.count(x)) {
      rank_[x] = 1;
      return parent_[x] = x;
    }
    return (parent_[x] == x) ? x : (parent_[x] = find(parent_[x]));
  }
 private:
  std::unordered_map<T, T> parent_;
  std::unordered_map<T, int> rank_;
};

#include<bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> P(N);
  for(auto& i: P) cin >> i, --i;
  UnionFind<int> G;
  for(auto i=0; i<M; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    G.unite(x, y);
  }

  vector<int> index(N);
  for(auto i=0; i<N; ++i) index[P[i]] = i;

  auto res = 0;
  for(auto p: P) if(G.find(p) == G.find(index[p])) ++res;
  cout << res << endl;
}


Measured memory_bytes: 9288
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int children_number = sc.nextInt();
		int ame_number = sc.nextInt();
		int array[] = new int[children_number];
		int answer = 0;

		//入力値の取得
		for (int i = 0; i < children_number; i++) {
			array[i] = sc.nextInt();
		}

		Arrays.sort(array);

		for (int ame : array) {
			ame_number -= ame;
			if (ame_number < 0) {
				break;
			}
			answer++;
		}

		if (ame_number > 0) {
			answer--;
		}

		System.out.println(answer);
	}
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

A,B = inputIL()

if A+B>9:
  print("error")
else:
  print(A+B)

Measured memory_bytes: 64108
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,cnt =0 ;
    cin >> n;
    for(int i = 1; i <= n;++i ){
        int p =log10(i);
        if(p%2 == 0){
            ++cnt;
        }
    }    
    cout <<cnt;    
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <stdio.h>
#define ll long long
#define MAXN 60
using namespace std;

ll a[MAXN], b[MAXN], c[MAXN][MAXN];

void gelou(void){
    c[1][0]=c[1][1]=1;
    for(int i = 2; i<MAXN; i++){
        c[i][0]=1;
        for(int j = 1; j<MAXN; j++)
            c[i][j]=(c[i-1][j]+c[i-1][j-1]);
    }
}

int main(void){
    gelou();
    ll n, x, y;
    cin >> n >> x >> y;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    ll pos=0, cc=a[n-1];
    for(int i=n-1; i>=0; i--){
        if(a[i]==cc){
            b[pos]++;
        }else{
            cc=a[i];
            pos++;
            b[pos]++;
        }
    }
    pos++;
    ll gg=0, num=0;
    if(b[0]>=x){
        for(int i=x; i<=min(b[0], y); i++){
            num+=c[b[0]][i];
        }
        printf("%.6lf\n", (double)a[n-1]);
        printf("%lld\n", num);
        return 0;
    }
    for(int i=0; i<pos; i++){
        if(gg+b[i]>=x){
            ll f=x-gg;
            num=c[b[i]][f];
            break;
        }else{
            gg+=b[i];
        }
    }
    double ave=0;
    for(int i=n-1,j=0; j<x; j++,i--){
        ave+=a[i];
    }
    ave/=x;
    printf("%.6lf\n", ave);
    printf("%lld\n", num);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
  public static void main(String[] args) throws Exception {
    String line = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    int nn = Integer.parseInt(line);
    long cards = 0L;
    long answer = 0L;
    long pair = 0;
    int val = 0;
    for (int i = 1; i <= nn; i++) {
      line = br.readLine();
      val = Integer.parseInt(line);
      if (val == 0) {
        if (cards != 0) {
          pair = cards / 2;
          answer = answer + pair;
          cards = 0;
        }
      } else {
        cards = cards + val;
      }
    }
    if (cards != 0) {
      pair = cards / 2;
      answer = answer + pair;
    }
    System.out.println(answer);
  }

}

Measured memory_bytes: 30548
#include <iostream>
using namespace std;
int main() {
    int a,b,i,j,c,d;
    d=0;
    c=0;
    cin>>a>>b;
    for (i=0;i<b-a;i++){
        c=c+1;
        d=d+c;
    }
    cout<<d-b;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        x = r*x-d;
        cout << x << endl;
    }
    
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <math.h>
#include <bits/stdc++.h>
 
 
 
 
int main(void) {
	int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
  int ans1=abs(x-a);
  int ans2=abs(x-b);
  if(ans1>=ans2)
      printf("B");
  
  else
     printf("A");
  
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl 
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e17;
const int N=1e5+5;
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}

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

int main() {
  int N, K, tmp, num;
  cin >> N >> K;
  
  num = 0;
  for(int i=0; i<N; i++) {
    cin >> tmp;
    if(tmp>=K) {
      num++;
    }
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	char X, Y;
	cin >> X >> Y;

	if (X == Y) cout << '=';
	if (X < Y) cout << '<';
	if (X > Y) cout << '>';
	cout << endl;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  cout.precision(17);

  double a,b,x;cin>>a>>b>>x;
  double l = 0, r = M_PI / 2.0;
  double full = a * a * b;
  double rad;
  for(int i=0;i<100;i++){
    rad = (r + l) / 2.0;
    double edge = b * tan(M_PI / 2.0 - rad);
    double test = 0;
    if(edge > a) {
      test = full - pow(a, 2) * a * tan(rad) / 2.0;
    }else {
      test = b * a * edge / 2.0;
    }
    if (test >= x) {
      l = rad;
    } else {
      r = rad - pow(10, -10);
    }
  }

  cout<<rad / M_PI * 180<<endl;

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	for (auto ch : s) {
		if (ch == ',') cout << " ";
		else cout << ch;
	}

	return 0;
}



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

using namespace std;

int N, K;
int A[100001];
vector<int> adj[100001];
vector<pair<int, int>> v;
int in[100001];
int out[100001];
int now;
int bit[100001];
int P[100001];

void add(int x, int v)
{
    for(; x<=N; x+=x&-x)
        bit[x]+=v;
}

int sum(int x)
{
    int ret=0;
    for(; x>0; x-=x&-x)
        ret+=bit[x];
    return ret;
}

void dfs(int u, int p, int d)
{
    v.push_back({d, u});
    in[u]=++now;
    P[u]=p;
    for(auto& v: adj[u]) if(v!=p)
        dfs(v, u, d+1);
    out[u]=now;
}

int solve()
{
    for(int i=2; i<=N; i++)
        adj[A[i]].push_back(i);
    dfs(1, 1, 0);
    int ret=0;
    sort(v.rbegin(), v.rend());
    for(int i=0; i<N && v[i].first>K; i++)
    {
        if(sum(in[v[i].second]))
            continue;
        int p=v[i].second;
        for(int j=0; j<K-1; j++)
            p=P[p];
        add(in[p], 1);
        add(out[p]+1, -1);
        ret++;
    }
    return ret;
}

int main()
{
    scanf("%d%d", &N, &K);
    for(int i=1; i<=N; i++)
        scanf("%d", A+i);
    int ans=0;
    if(A[1]!=1)
        ans++, A[1]=1;
    ans+=solve();
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 17908
//07
#include<iostream>
#include<algorithm>

using namespace std;

struct S{
  string s;
  double e;
  bool operator<(S a)const{
    if(e!=a.e){
      return e>a.e;
    }else{
      return s<a.s;
    }
  }
};

int main(){
  for(int n;cin>>n,n;){
    S a[50];
    for(int i=0;i<n;i++){
      int p,aa,b,c,d,e,f,s,m;
      cin>>a[i].s>>p>>aa>>b>>c>>d>>e>>f>>s>>m;
      a[i].e=(s*f*m-p)*1./(aa+b+c+(d+e)*m);
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
      cout<<a[i].s<<endl;
    }
    cout<<'#'<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 1e6 + 5;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int vis[mxN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	int f = 1;
	rep(i, n){
		int cur = a[i];
		for(int j = 2; (j * j) <= cur; j++){
			if(cur % j == 0){
				if(vis[j]){
					f = 0;
					break;
				}
				vis[j]++;
				while(cur % j == 0) cur /= j;
			}
		}
		if(cur > 1){
			if(vis[cur]){
				f = 0;
			}
			vis[cur]++;
		}
		if(!f) break;
	}
	if(f){
		cout << "pairwise coprime" << endl;
		return 0;
	}
	int g = a[0];
	repn(i, 1, n) g = gcd(g, a[i]);
	if(g == 1){
		cout << "setwise coprime" << endl;
		return 0;
	}
	cout << "not coprime" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 7576
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
using ll = long long;
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;



int main() {
  int n;
  cin >> n;
  // int bcp, bcm;
  ll ans = 0;
  std::vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(ALL(v));
  debug(v);

  for (int i=n-1; i>=0; i--) {
    for (int j=i-1; j>=0; j--) {
      int c = v[i];
      int b = v[j];
      int cb = c-b;
      auto it = upper_bound(v.begin(), v.end(), cb);
      if (*it > b) continue;  
      ans += (v.begin() + j) - it;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>i>>j;
        cout<<i*j<<endl;
    }
}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    int N, M;
    cin >> N >> M;
   
    if (M == 0) {
        if (N == 1) {
            print(0);
        } else {
            string out = "";
            for (int i = 0; i < N; i++) {
                if (i == 0) out += '1';
                else out += '0';
            }
            print(out);
        }
    } else {
        vector<pair<int, int>> D(M);
        vector<int> tmp(N, -1);
        REP(i, M) cin >> D[i].first >> D[i].second;

        sort(D.begin(), D.end());

        bool flag = true;
        REP(i, M) {
            int s = D[i].first;
            int c = D[i].second;
            if (tmp[s-1] == -1) {
                tmp[s-1] = c;
            } else if (tmp[s-1] != c) {
                flag = false;
                break;
            }
        }

        if (!flag) {
            print(-1);
        } else {
            if (tmp.size() == 1 && tmp[0] == 0) {
                print(0);
            } else {
                if (tmp[0] == 0) {
                    print(-1);
                } else {
                    string out = "";
                    for (int i = 0; i < N; i++) {
                        if (tmp[i] == -1) {
                            if (i == 0) out += '1';
                            else out += '0';
                        } else {
                            out += to_string(tmp[i]);
                        }
                    }
                    print(out);
                }
            }
        }

    }

}

signed main() {
    solve();
}


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

int main(int argc, char const *argv[])
{
	double x1, x2, y1, y2, distance;
	cin >> x1 >> y1 >> x2 >> y2;

	distance = hypot(x2 - x1, y2 - y1);

	printf("%lf\n", distance);
	return 0;
}

Measured memory_bytes: 1244