akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 lll;

const int N=10000;
int n,vis[N],pr[N],cnt,ans;
map<lll,pair<int,int> >f;

void Init(){
	for(int i=2;i<N;++i){
		if(!vis[i])pr[++cnt]=i;
		for(int j=1;j<=cnt&&i*pr[j]<N;++j){
			vis[i*pr[j]]=1;
			if(i%pr[j]==0)break;
		}
	}
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;Init();
	for(int i=1;i<=n;++i){
		ll x;cin>>x;
		lll p=1,q=1;
		for(int j=1;j<=cnt&&(ll)pr[j]*pr[j]*pr[j]<=x;++j)if(x%pr[j]==0){
			int s=0;
			while(x%pr[j]==0)x/=pr[j],++s;
			s%=3;
			for(int k=0;k<s;++k)p*=pr[j];
			for(int k=0;k<(3-s)%3;++k)q*=pr[j];
		}
		ll t=sqrt(x)+0.5;
		if(x==t*t)p*=x,q*=t;
		else p*=x,q*=x*x;
		if(p<q)f[p].first++;
		else f[q].second++;
		if(p==q)f[p].first=f[p].second=1;
	}
	for(auto i:f)ans+=max(i.second.first,i.second.second);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 8064
n,m,q = map(int,input().split())

M = [[0]*(n+1) for _ in range(n+1)]
for i in range(m):
  l,r = map(int,input().split())
  M[r][l] += 1
  
D = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
  for j in range(1,n+1):
    D[i][j] = M[i][j] + D[i][j-1] + D[i-1][j] - D[i-1][j-1]
    
for i in range(q):
  p,q = map(int,input().split())
  ans = D[q][q] - D[q][p-1] - D[p-1][p] + D[p-1][p-1]
  print(ans)  

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

int main(){
  int N;
  cin>>N;
  char S[N];
  int flag[4];
  flag[0]=0;
  flag[1]=0;
  flag[2]=0;
  flag[3]=0;
  
  for (int i=0;i<N;i++){
    cin>>S[i];
    if(S[i]=='P'){
      flag[0]=1;
    }
    if(S[i]=='W'){
      flag[1]=1;
    }
    if(S[i]=='G'){
      flag[2]=1;
    }
    if(S[i]=='Y'){
      flag[3]=1;
    }
  }
  
  int count=0;
  for (int j=0;j<4;j++){
    if(flag[j]==1){
      count++;
    }
  }
  
  if(count==3){
    cout<<"Three"<<endl;
    return 0;
  }
  cout<<"Four"<<endl;
  return 0;
}


  

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

int main(){
    int n; cin >> n;
    map<int,int> mp;
    rep(i,n-1){
        int x; cin >> x;
        mp[x]++;
    }
    for(int i = 1;i <= n;++i) cout << mp[i] << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int f[20] ;
  ll ans = 1;
  rep(i,n) ans*=i+1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3088
sa = str(input())
sb = str(input())
sc = str(input())

a = b = c = 0
player = 'a'

while True:
    if player == 'a':
        if a == len(sa):
            print("A")
            break
        player = sa[a]
        a += 1
        
    elif player == 'b':
        if b == len(sb):
            print("B")
            break
        player = sb[b]
        b += 1

    elif player == 'c':
        if c == len(sc):
            print("C")
            break

        player = sc[c]
        c += 1


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

int N;
int A[210];

int main(){
  cin >> N;
  for (int i=0;i<N;++i) cin >> A[i];
  
  int res = 0;
  
  while(true){
    bool exists_odd = false;
    for (int i=0;i<N;++i){
      if (A[i]%2!=0) exists_odd = true;
    }
    if (exists_odd) break;
    
    for (int i=0;i<N;++i) A[i] = A[i]/2;
    ++res;
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

#define BUF_SIZE 1024

class Stack{
public:
	Stack(int stack_size):
		m_index(0){
		m_array = new int[stack_size];
	};
	~Stack(){
		delete[] m_array;
	};
	void push(int var){
		m_array[m_index++] = var;
	};
	int pop(){
		return m_array[--m_index];
	};

	bool isEmpty(){
		return m_index == 0;
	};

private:
	int* m_array;
	int m_index;
};

int main(){
	char buf[BUF_SIZE];

	for(int i = 0; i < BUF_SIZE; i++){
		buf[i] = 'e';
	}
	fgets(buf,BUF_SIZE,stdin);

	Stack stack(BUF_SIZE);

	bool numFLG = false;
	int S = 0,op1=0,op2=0;

	for(int i = 0;buf[i] != 'e'; i++){
		if(buf[i] >= '0' && buf[i] <= '9'){
			numFLG = true;
			S = 10*S + (buf[i] - '0');
		}else{
			if(numFLG){
				stack.push(S);
				S = 0;
				numFLG = false;
			}

			if(buf[i] == '+'){
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1+op2);
			}else if(buf[i] == '-'){
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1-op2);
			}else if(buf[i] == '*'){
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1*op2);
			}
		}
	}

	op1 = stack.pop();
	printf("%d\n",op1);
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    int ans = 0;
    rep(i,n){
        ll a; cin >> a;
        while (a % 2 == 0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<std::vector<int>> x;
void solve1(vector<int> a,std::vector<int> &v,int idx,int n){
  if(idx==v.size()){
    if(a.size()!=0) x.pb(a);
    return ;
  }
  a.pb(v[idx]);
  solve1(a,v,idx+1,n);
  a.pop_back();
  solve1(a,v,idx+1,n );
}
void solve(){
  int n,m,k;
  cin>>n>>m>>k;
  vector<int> v(n,0);
  rep(i,1,n) v[i]=i;
  vector<int> a;
  solve1(a,v,0,n);
  vector<vector<int>> ax(n,vector<int>(m,0));
  vector<ll> c(n);
  rep(i,0,n){cin>>c[i]; rep(j,0,m) cin>>ax[i][j];}

  ll ans=LLONG_MAX;
  rep(i,0,x.size()){
    int flag=0;
    ll tc_=0;
    map<int,int> m1;
    rep(j,0,m) m1[j]=0;
    rep(j,0,x[i].size()){
      rep(l,0,m){
        m1[l]+= ax[x[i][j]][l];
      }
      tc_+=c[x[i][j]];
    }
    for(auto j:m1){
      if(j.second< k){
        flag=1;
        break;
      }
    }
    if(!flag){
      ans=min(ans,tc_);
    }
  }
  if(ans!=LLONG_MAX)
  cout<<ans<<endl;
  else cout<<-1<<endl;
}
int main(){
    optimizeIO();
    // tc
    {
      solve();
    }
}


Measured memory_bytes: 3884
#include <stdio.h>
#include <string.h>

#define MAX 244140625

int Hash[MAX];
char s[13];

int getChar(char);
int getKey();
int find();
void insert();

int main(){
  int n;
  char com[7];

  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,s);

    if(com[0] == 'i'){
      insert();
    }else{
      if(find()){
	puts("yes");
      }else{
	puts("no");
      }
    }
  }

  return 0;
}

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}

int getKey(){
  int sum = 0, p = 1, i;

  for(i = 0 ; i < strlen(s) ; i++){
    sum += p*(getChar(s[i]));
    p *= 5;
  }
  return sum;
}

int find(){
  int key = getKey();

  if(Hash[key]){
    return 1;
  }

  return 0;
}

void insert(){
  Hash[getKey()] = 1;
}

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

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


Measured memory_bytes: 256
s = input()
if s[0]=='R':
  if s[1]=='R':
    if s[2]=='R':
      print(3)
    else:
      print(2)
  else:
    print(1)
elif s[0]=='S':
  if s[1]=='R':
    if s[2]=='R':
      print(2)
    else:
      print(1)
  else:
    if s[2]=='R':
      print(1)
    else:
      print(0)

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

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


int main() {
  int N;
  cin >> N;
  vector<vector<ll>> A(N,vector<ll> (N)),dl(N,vector<ll> (N,0));
  ll ans = 0;
  rep(i,N)rep(j,N) {
    cin >> A[i][j];
    if (i>j) ans+=A[i][j];
  }
  
  rep(k,N)rep(i,N)rep(j,N) {
    if (i==j||j==k||k==i) continue;
    if (A[i][k]+A[k][j]<A[i][j]) {
      cout << -1 << endl;
      return 0;
    }
    else {
      if (i<j && A[i][k]+A[k][j]==A[i][j] && dl[i][j]==0) {
        ans-=A[i][j];
        dl[i][j] = 1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1664
N,K = map(int,input().split())
h = list(map(int,("0 "+input()).split()))
ans=[float('inf')]*(N+1)
ans[1]=0
for i in range(1,N+1):
 for j in range(i+1,min(i+K+1,N+1)):
  ans[j]=min(ans[j],ans[i]+abs(h[j]-h[i]))
print(ans[N])


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

int main() {
  int group1[7] = {1, 3, 5, 7, 8, 10, 12};
  int group2[4] = {4, 6, 9, 11};
  int x, y;
  cin >> x >> y;
  int cnt = 0;
  bool flag = false;
  for (int i = 0; i < 7; i++) {
    if (group1[i] == x) cnt++;
    if (group1[i] == y) cnt++;
  }
  if (cnt == 2) flag = true;
  cnt = 0;
  for (int i = 0; i < 4; i++) {
    if (group2[i] == x) cnt++;
    if (group2[i] == y) cnt++;
  }
  if (cnt == 2) flag = true;
  // 解答
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int largest_rectangle_in_a_histogram(const vector<int> &h) {
	int n = h.size();
	using P = pair<int, int>;
	stack<P> st;
	st.emplace(-1, -1);
	int area = 0;
	for (int i = 0; i < n; i++) {
		if (st.top().first == h[i])
			continue;
		int pos = i;
		while (st.top().first >= h[i]) {
			chmax(area, st.top().first*(i - st.top().second));
			pos = st.top().second;
			st.pop();
		}
		st.emplace(h[i], pos);
	}
	while (st.size()) {
		chmax(area, st.top().first*(n - st.top().second));
		st.pop();
	}
	return area;
}

int largest_rectangle(vector<vector<int>> v) {
	int H = v.size(), W = v.front().size();
	rep(i, 0, H - 1)rep(j, 0, W) {
		if (v[i + 1][j] == 0)continue;
		v[i + 1][j] += v[i][j];
	}
	int area = 0;
	rep(i, 0, H)
		chmax(area, largest_rectangle_in_a_histogram(v[i]));
	return area;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int H, W; cin >> H >> W&&H;) {
		vector<vector<int>> v(H, vector<int>(W));
		rep(i, 0, H) rep(j, 0, W) {
			char c; cin >> c;
			v[i][j] = c == '.';
		}
		cout << largest_rectangle(v) << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

int main(void)
{
    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    if (x / d <= k)
    {
        k -= x / d;
        x -= (x / d) * d;

        if (k % 2 == 1)
            x -= d;
    }
    else
    {
        x -= k * d;
        k -= k;
    }

    cout << abs(x) << endl;

    return 0;
}


Measured memory_bytes: 3584
// include
#include <array>
#include <algorithm>
#include <set>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <unordered_map>


// pow(10, 15) 10の15乗

//  多倍長整数
#include <boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;


// ============================================
int main() {
  int N;
 std::cin >> N;
  int a = N % 1000;
  int s = 1000 - a;
  if (s == 1000) {
    s = 0;
  }
  
  
 std::cout << s << std::endl;


    return 0;
}


Measured memory_bytes: 3196
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
#define CRP(t, x) const t &x
#define OPL(t, x) bool operator<(CRP(t, x)) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 2e5 + 60;
ll a[N];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", a + i), a[i] += a[i - 1];
    ll ans = numeric_limits<decltype(ans)>::max();
    for (int i = 2; i < n - 1; i++)
    {
        int sp1 = lower_bound(a, a + n + 1, a[i] >> 1) - a;
        int sp2 = lower_bound(a, a + n + 1, (a[n] + a[i]) >> 1) - a;
        for (int j = -1; j <= 1; j++)
            for (int k = -1; k <= 1; k++)
            {
                int sp3 = max(min(sp1 + j, i - 1), 1);
                int sp4 = max(min(sp2 + k, n - 1), i + 1);
                auto res = {a[sp3], a[i] - a[sp3], a[sp4] - a[i], a[n] - a[sp4]};
                //printf("%d %d %d %lld\n", sp3, i, sp4, max(res) - min(res));
                ans = min(ans, max(res) - min(res));
            }
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b, c;
  cin >> a >> b >> c;
  int res;
  if(c < a+b)
    res = c + b;
  else{
    if( c <= b )
      res = c + b;
    else if( c <= a) // c > b
      res = c + b;
    else if ( c >= a + b + 1)// c > b && c > a
      res = a + b + 1 + b ;
    else // a or b < c <= a + b
      res = c + b;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }
template<class T> ostream& operator<<(ostream &s, set<T> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<*it;}return s<<" }"<<endl;}



int n, k;

set<string> se;

int main() {
    while (cin >> n >> k) {
        if (n == 0) break;
        
        vector<string> vec(n);
        for (int i = 0; i < n; ++i) cin >> vec[i];
        
        se.clear();
        
        for (int bit = (1<<k)-1, bx, by; bit < (1<<n); bx = bit&-bit, by = bit+bx, bit = ((bit&~by)/bx>>1)|by) {
            vector<string> tmp;
            for (int i = 0; i < n; ++i) if (bit & (1<<i)) tmp.PB(vec[i]);
            
            sort(ALL(tmp));
            do {
                string str = "";
                for (int i = 0; i < tmp.size(); ++i) str += tmp[i];
                se.insert(str);
            } while (next_permutation(ALL(tmp)));
        }
        
        //COUT(se);
        
        cout << se.size() << endl;
    }
    return 0;
}


Measured memory_bytes: 1464
s=input()
a=int(s[0])*10+int(s[1])
b=int(s[2])*10+int(s[3])
YYMM=0
MMYY=0
if a<13 and a>0:
  MMYY=1
if b<13 and b>0:
  YYMM=1
if MMYY==1 and YYMM==1:
  print('AMBIGUOUS')
elif MMYY==1 and YYMM==0:
  print('MMYY')
elif MMYY==0 and YYMM==1:
  print('YYMM')
else:
  print('NA')
  
  
  

Measured memory_bytes: 3060
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
import math


def main():
    a, b, x = map(int, input().split())
    v = a * b / 2
    if v * a >= x:
        h = x / v
        theta = math.degrees(math.atan2(h, b))
        ans = 90 - theta

    else:
        k = 2 * x / a / a - b
        theta = math.degrees(math.atan2(a, (b-k)))
        ans = 90 - theta
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    st=set()
    for i in range(K):
        d=int(sys.stdin.readline())
        A=list(map(int,sys.stdin.readline().split()))
        st=st|set(A)
    print(N-len(st))
    
main()

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  string s; cin >> s;
  int n = (int)(s.size());
  char now = s[0];
  int mi = 1;
  int cnt = 0;
  int ans = 0;
  for(int i=0;i<n;++i) {
    if(s[i] == now) {
      cnt++;
      if(cnt >= mi) {
        ans++;
        (mi == 1 ? mi = 2: mi = 1);
        cnt = 0;
      }
    } else {
      ans++;
      if(cnt == 0) {
        mi = 2;
        cnt = 0;
        now = s[i];
      } else {
        mi = 1;
        cnt = 0;
        now = s[i];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;

// 素数判定法を使った場合
// 　→　「合成数 x は p≤x√ を満たす素因子 pをもつ」
// テストケース3: 6.123 ms ばくそく！！
bool IsPrime(int s){
    if(s == 2) return true;

    if(s < 2 || s%2==0) return false;
    int sqr = sqrt(s);
    for(int i=3;i<=sqr;i+=2){
        if(s % i == 0) return false;
    }
    return true;
}

int main(void)
{

    int n;
    cin >> n;
    int *a = new int[n];

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

    int ans = 0;
    for(int i=0;i<n;i++){
        if(IsPrime(a[i])){
            ans++;
        }
    }
    cout << ans << endl;

    delete[] a;

    return 0;
}



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

int gcd(int a, int b){
  int tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  int r;
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main()
{
  int k;
  cin >> k;
  
  int s,t;
  s = 0;
  for(int i =1 ;i<=k;++i){
    for(int j =1 ;j<=k;++j){
      t = gcd(i,j);
      if(t == 1){
        s+=k;
      }else{
        for(int l =1 ;l<=k;++l){
          s += gcd(t,l);
        }
      }
    }
  }
  
  cout << s << endl;
}

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

int main()
{
  int i,j;
  int n;
  int minj;
  int stable=1;
  
  scanf("%d",&n);
  
  if(n < 1 || 36 < n)
    exit(0);
  
  char c1[n][3];
  char c2[n][3];
  char tmp[3];
  
  for(i=0; i<n; i++){
    scanf("%s",c1[i]);
    for(j=0; j<4; j++){
      c2[i][j] = c1[i][j];
    }
  }
  
  /*BubbleSort*/
  
  for(i = 0; i < n; i++){
    for(j = n-1; j > i; j--){
      if(c1[j][1] < c1[j-1][1]){
	strcpy(tmp, c1[j]);
	strcpy(c1[j],c1[j-1]);
	strcpy(c1[j-1],tmp);
      }
    }
  }
  
  for(i = 0; i<n-1; i++){
    printf("%c%c ",c1[i][0],c1[i][1]);
  }
  printf("%c%c\n",c1[i][0],c1[i][1]);
  printf("Stable\n");
  
  /*SelectionSort*/
  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(c2[j][1] < c2[minj][1]){
	minj = j;
      }
    }
    strcpy(tmp, c2[i]);
    strcpy(c2[i],c2[minj]);
    strcpy(c2[minj],tmp);
  }
  
  for(i = 0; i<n-1; i++){
    printf("%c%c ",c2[i][0],c2[i][1]);
  }
  printf("%c%c\n",c2[i][0],c2[i][1]);

  for(i=0; i<n; i++){
    if(strcmp(c1[i],c2[i]) != 0){
      stable = 0;
    }
  }

  if(stable == 1){
    printf("Stable\n");
  }
  else printf("Not stable\n");
  
  return 0;
}
	



Measured memory_bytes: 2840
N = raw_input()
ns = raw_input()
ns = ns.split(' ')

data = {}
for i in ns:
    i = int(i)
    if i in data:
        data[i] += 1
    else:
        data[i] = 1

Q = raw_input()
opr = []
for _ in range(int(Q)):
    tmp = raw_input()
    tmp = tmp.split(' ')
    opr.append([int(tmp[0]), int(tmp[1])])

ans = 0
for k, v in data.iteritems():
    ans += k * v
for op in opr:
    if op[0] not in data:
        print ans
        continue

    old1 = data[op[0]]
    del data[op[0]]

    old2 = 0
    if op[1] in data:
        old2 = data[op[1]]
    ans -= old1 * op[0] + old2 * op[1]

    data[op[1]] = old1 + old2
    ans += data[op[1]] * op[1]

    print ans


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

int main() {
	int i{ 0 };
	std::cin >> i;
	i = 0;
	std::string str;
	std::cin >> str;
	int max{ 0 };
	for (const auto &s : str) {
		switch (s) {
		case 'I': ++i;
			if (max < i) {
				max = i;
			}
			break;
		case 'D': --i; break;
		}
	}
	std::cout << max << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int k,n, ans, max=0, tmp=0;
    cin >> k >> n;
    int a[n+1];
    REP(i,n){
        cin >> a[i];
    }
    a[n] = a[0];

    REP(i,n){
        tmp = abs(a[i+1] - a[i]);
        if(tmp>=k/2){
            tmp = k-tmp;
        }
        if(tmp>max){
            max = tmp;
        }
    }
    
    ans = k-max;
    cout << ans;
   
}


Measured memory_bytes: 1024
N = int(input())
S = input()

x = [0] * (N+1)

for i in range(N):
    if S[i] == '#':
        x[i+1] = x[i] + 1
    else:
        x[i+1] = x[i]

ans = min(N - x[-1], x[-1])
for i in range(1, N):
    ans = min(ans, x[i] + N - i - (x[-1] - x[i]))

print(ans)



Measured memory_bytes: 11144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	mod = 998244353
	if a[0] != 0 {
		fmt.Println(0)
	} else {
		z := max(a) + 1
		d := make([]int, z)
		for _, v := range a {
			d[v]++
		}
		if d[0] > 1 {
			fmt.Println(0)
		} else {
			ans := 1
			for i := 1; i < z; i++ {
				ans *= repeatPow(d[i-1], d[i], mod)
				ans %= mod
			}
			fmt.Println(ans)
		}
	}
}
func repeatPow(x, y, d int) int {
	if y == 0 {
		return 1
	} else if y == 1 {
		return x
	} else {
		z := repeatPow(x, y/2, d)
		if y%2 == 0 {
			return z * z % d
		} else {
			return z * z % d * x % d
		}
	}
}


Measured memory_bytes: 3944
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  ll stb = 0, ena = 0, bth = 0;
  ll ans = 0;
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, (ll)s.size() - 1) {
      if (s.substr(j, 2) == "AB") ans++;
    }
    if (s[0] == 'B') {
      if (s.back() == 'A')
        bth++;
      else
        stb++;
    } else {
      if (s.back() == 'A') ena++;
    }
  }

  if(ena > 0 || stb > 0){
    ans += min(ena, stb);
    ll abr = max(ena, stb) - min(ena, stb);
    ans += min(abr, bth);
    bth -= min(abr, bth);
    if(bth > 0) ans += bth;
  } else {
    if(bth > 0) ans += bth - 1;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int sol = 0;
	if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0){
		cout << sol << "\n";
		exit(0);
	}
	int MA = 0;
	int MB = 0;
	int MC = 0;
	while(A != B && B != C){
		MA = B/2 + C/2;
		MB = A/2 + C/2;
		MC = B/2 + A/2;
		
		A = MA;
		B = MB;
		C = MC;
		++sol;
		
		if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0){
			cout << sol << "\n";
			exit(0);
		}
	}
	cout << -1 << "\n";
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    memo = defaultdict(int)
    for i in range(1,N+1):
        head,tail = str(i)[0], str(i)[-1]
        memo[head,tail] += 1
    ans = 0
    for i in range(1,N+1):
        head,tail = str(i)[0], str(i)[-1]
        ans += memo[tail,head]
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 6608
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  double a,c,d=0,e=0;
  cin>>a>>c;
  vector<int>b(a);
  rep(i,a){
    cin>>b.at(i);
    d+=b.at(i);
  }
  d=d/(4*c);
  rep(i,a){
    if(b.at(i)>=d)e++;
  }
  if(e>=c)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
	
	char str[80+1];
	int n=0,s=0,i;
	
	while(scanf("%s",str)+1){
		i=0;
		while(1){
			if(str[i]>='0'&&str[i]<='9'){
				n*=10;
				n+=str[i]-'0';
			}else{
				s+=n;
				n=0;
				if(str[i]=='\0')break;
			}
			++i;
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1156
url = "https://atcoder.jp//contests/abc160/tasks/abc160_c"

import itertools


def main():
    n, m , X = list(map(int, input().split()))
    books = []
    ans = -1
    for _ in range(n):
        books.append(list(map(int, input().split())))
    for i in range(n):
        for row in itertools.combinations(range(0, n), i+1):
            cost = 0
            rikai = [0] * m
            for idx in row:
                cost += books[idx][0]
                for idx2 in range(1, len(books[idx])):
                    rikai[idx2 - 1] += books[idx][idx2]
                if len(list(filter(lambda x: x >= X, rikai))) == len(rikai):
                    ans = min(ans, cost) if ans != -1 else cost
    print(ans)








if __name__ == '__main__':
    main()


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

struct Vector2{
    int y,x;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h,w,d; cin >> h >> w >> d;
    int a[h][w];
    Vector2 p[h*w]; rep(i,h) rep(j,w){
        cin >> a[i][j];
        --a[i][j];
        p[a[i][j]] = Vector2({i,j});
    }
    map<int, int> score;
    rep(i, h*w){
        if(i+d >= h*w) continue;
        score[i+d] += score[i] + abs(p[i+d].y-p[i].y) + abs(p[i+d].x - p[i].x);
    }
    int q,l,r; cin >> q;
    rep(i,q){
        cin >> l >> r;
        --l; --r;
        cout << score[r] - score[l] << "\n";
    }
}

Measured memory_bytes: 8856
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int f(int n, int k) {
  if (n == 0) return 0;
  return 1 + f(n / k, k);
}

int main() {
  int N, K;
  cin >> N >> K;
  cout << f(N, K) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int H1, H2;
  int M1, M2;
  int K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int A = H1*60+M1;
  int B = H2*60+M2-K;
  if(B-A<0){
    cout << "0" << endl;
    return 0;
  }
  cout << B-A << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  string s;
  cin>>s;
  int count=0;
  REP(i,s.size()){
    if(s[i]=='x'){
      count++;
    }
  }
  
  cout<<(count<=7 ? "YES" : "NO");
}


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

using namespace std;
int main()

{
    string num;
  	cin >> num;

  	if( (num[0]==num[1] && num[1]==num[2]) ||
      	(num[1]==num[2] && num[2]==num[3])){
      		cout << "Yes" << endl;
    }else{
     	cout << "No" << endl;
    }
  return 0;
}

Measured memory_bytes: 256
// パスカルの三角形
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	m = 1000000007
)

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

func main() {
	defer flush()

	N := readInt()
	K := readInt()

	n := max(K, N-K+1)
	c := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		c[i] = make([]int, n+1)
	}
	c[0][0] = 1
	for i := 0; i < n+1; i++ {
		c[i][0] = 1
		for j := 1; j < i+1; j++ {
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % m
		}
	}

	for i := 1; i <= K; i++ {
		println(c[K-1][i-1] * c[N-K+1][i] % m)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 23084
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

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

	int n; cin >> n;
	vector<double> x(n), y(n);
	double X = 0, Y = 0;
	rep(i, 0, n) {
		cin >> x[i] >> y[i];
		X += x[i];
		Y += y[i];
	}
	X /= (double)n;
	Y /= (double)n;

	auto dist = [](double x, double y) {
		return x * x + y * y;
	};

	double p = .1;
	double max_dist;
	rep(_, 0, 20000) {
		max_dist = 0.0;
		int max_idx = 0;
		rep(i, 0, n) {
			double d = dist(X - x[i], Y - y[i]);
			if (d > max_dist) {
				max_dist = d;
				max_idx = i;
			}
		}

		X += (x[max_idx] - X) * p;
		Y += (y[max_idx] - Y) * p;
		p *= 0.999;
	}
	cout << fixed << setprecision(10) << sqrt(max_dist) << endl;
	return 0;
}


Measured memory_bytes: 3800
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int result = Integer.MAX_VALUE;
        int[] w = new int[n];
        int[] e = new int[n];
        int countW = 0;
        int countE = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'W') {
                countW++;
            }
            w[i] = countW;
            if (s[n - 1 - i] == 'E') {
                countE++;
            }
            e[n - 1 - i] = countE;
        }
        for (int i = 0; i < n; i++) {
            result = Math.min(result, w[i] + e[i] - 1);
        }
        System.out.println(result);

    }
}

Measured memory_bytes: 32772
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX
const int N=1e5+5;
const int M=1e9+7;

ll tot[N];

ll modexp(ll a,ll b){
	if(b==0){
		return 1;
	}
	else if(b%2==0){
		return modexp((a*a)%M,b/2);
	}
	else{
		ll val=modexp((a*a)%M,b/2);
		return (a*val)%M;
	}
}

void solve(){
	ll n,k;
	sfl(n) sfl(k)

	ll cnt=0;

	ll ans=0;

	for(ll i=k;i>=2;i--){
		tot[i]=modexp(k/i,n);
		for(int j=i*2;j<=k;j+=i){
			tot[i]=(tot[i]-tot[j]+M)%M;
		}	
		cnt=(cnt+tot[i])%M;

		ans=(ans+(tot[i]*i)%M)%M;
	}

	cnt=(modexp(k,n)-cnt+M)%M;

	ans=(ans+cnt)%M;

	pfln(ans)


}

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

Measured memory_bytes: 4504
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll dp[405][405];
int main(){
    int n;
    cin>>n;
    memset(dp,0x1c,sizeof(dp));
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    auto sum=[&](int l,int r){
        ll s=0;
        for(int i=l;i<=r;i++){
            s+=a[i];
        }
        return s;
    };
    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if(i==j){
                dp[i][j]=0;
            }
            else{
                ll s=sum(i,j);
                for(int k=i;k<j;k++){
                    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
                }
            }
        }
    }
    cout<<dp[0][n-1]<<endl;


}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
    using namespace std;
    #define itn int
    #define int long long 
    int dp[1000005];

    int n=0;
    bool h[1000005];
    vector<itn> e[1000005];
      int a,b,c,d;
    int f(int g){
      if(h[g]) return dp[g];
      int nx=0;

      for(int j=0;j<e[g].size();j++){
        nx=max(nx,f(e[g][j])+1);
      }
      dp[g]=nx;
      h[g]=true;
      return nx;
    }
    signed main(){
      cin>>a>>b;
      for(int i=0;i<b;i++){
        cin>>c>>d;
        e[c].push_back(d);
      }
      for(int i=1;i<=a;i++){
        n=max(n,f(i));
      }
      cout<<n<<"\n";
      return 0;
    }

Measured memory_bytes: 32000
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
left = 0
for i in range(m):
    if x > a[i]:
        left += 1
    else:
        break
right = m - left
cost_min = left if left < right else right
print('{}'.format(cost_min))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#ifdef LOCAL
#include<ctime>
#include<random>
#include"file.h"
#endif

#define y1 zyy_orz
#define hash sto_zyy

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL>pLL;
typedef pair<int, int>pii;
const double eps = 1e-5;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,0,-1,1,0,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };



const int maxn = 1e6 + 5;
const int MOD = 998244353;
int n;
int A[maxn];
LL C[maxn];
LL f[maxn];

LL inv[maxn];

int prime[maxn], miu[maxn];
bool is_prime[maxn];
int pn = 0;


int main() {
#ifdef LOCAL
	fileopen();
#endif
	std::ios::sync_with_stdio(false);
	//scanf("%d", &n);
	cin>>n;
	int mx = -1;
	for (int i = 1; i <= n; i++) {
		cin >> A[i];
		mx = max(mx, A[i]), C[A[i]]++;
	}
	memset(is_prime, true, sizeof(is_prime));
	miu[1] = 1;
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= mx; i++) {
		if (is_prime[i]) {
			prime[++pn] = i;
			miu[i] = -1;
		}
		for (int j = 1; j <= pn && i*prime[j] <= mx; j++) {
			is_prime[i*prime[j]] = false;

			if (i%prime[j] == 0) {
				miu[i*prime[j]] = 0;
				break;
			}
			else {
				miu[i*prime[j]] = -miu[i];
			}
		}
	}

	inv[1] = 1;
	for (int i = 2; i <= maxn - 3; i++) {
		inv[i] = (MOD - MOD / i * inv[MOD%i] % MOD) % MOD;
	}
	for (int i = 1; i <= mx; i++) {
		for (int j = i; j <= mx; j += i) {
			f[i] = (f[i] + C[j] * j) % MOD;
		}
	}

	LL ans = 0;
	for (int d = 1; d <= mx; d++) {
		for (int q = 1; q <= mx / d; q++)if (miu[q]) {
			LL t = (f[q*d] * f[q*d]) % MOD;
			ans = (ans + miu[q] * inv[d] % MOD*t%MOD) % MOD;
		}
	}
	for (int i = 1; i <= n; i++) {
		ans = (ans - A[i]) % MOD;
	}
	ans = ans * inv[2] % MOD;
	ans = (ans + MOD) % MOD;
	//printf("%lld\n", ans);
	cout << ans << endl;
#ifdef LOCAL
	fileclose();
#endif
	return 0;
}



Measured memory_bytes: 33024
#include<stdio.h>

int n;

void partition(int *,int ,int);

int main(){

  int i,a[100000];


  scanf("%d",&n);

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

  partition(a,0,n-1);

  return 0;
}



void partition(int a[],int p,int r){

  int x,y,i,b;

  x = a[r];
  y = p-1;

  for(i = 0; i < r; i++){
    if(a[i] <= x){
      y += 1;
      b = a[y];
      a[y] = a[i];
      a[i] = b;
    }
  }


  for(i = 0; i < y+1; i++){
    printf("%d ",a[i]);
  }

  b = a[y+1];
  a[y+1] = a[r];
  a[r] = b;

  printf("[%d] ",a[y+1]);

  for(i = y+2 ; i < n; i++){
    if(i == n-1){
      printf("%d\n",a[i]);
      break;
    }
	     
    printf("%d ",a[i]);
  }
    
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    deque<int> dq;
    for(int i = 0; i < n; i++) {
        if(i%2 == 0) {
            dq.push_back(a[i]);
        }
        else {
            dq.push_front(a[i]);
        }
    }
    
    if(n%2 != 0) {
        for(int i = 0; i < n; i++) {
            cout << dq.back() << " ";
            dq.pop_back();
        }
    }
    else {
        for(int i = 0; i < n; i++) {
            cout << dq.front() << " ";
            dq.pop_front();
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3840
#include<iostream>

using namespace std;

int main()
{
	int x, y, i;
	int group1[] = { 1,3,5,7,8,10,12 }, group2[] = { 4,6,9,11 }, set_group[] = { 1,0,1,2,1,2,1,1,2,1,2,1 };

	cin >> x >> y;

	if (x == 2 || y==2) {
		cout << "No";
		return 0;
	}

	switch ( set_group[x-1])
	{
	case 1:
		for (i = 0; i < 7; i++) {
			if (y == group1[i]) {
				cout << "Yes";
				return 0;
			}
		}
		break;

	case 2:
		for (i = 0; i < 4; i++) {
			if (y == group2[i]) {
				cout << "Yes";
				return 0;
			}
		}
		break;

	default:
		break;
	}
	cout << "No";

	return 0;
}

Measured memory_bytes: 256
x = input()
ans = 0
if x[0] == "A":
    if "C" in x[2:len(x)-1]:
        x=x.replace("A","",1)
        x=x.replace("C","",1)
        if x.islower():
            ans = 1

if ans == 0:
    print("WA")
else:
    print("AC")

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int long long
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a, b, c;
   cin >> a >> b >> c;

   if (a == b && a == c)
      cout << "Yes" << '\n';
   else
      cout << "No" << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <functional>

using namespace std;

int main() {
    string str1,str2;

    cin >> str1 >> str2;

    if(str1 > str2){
        cout << ">" << endl;
    }

    else if(str1 < str2){
        cout << "<" << endl;
    }

    else {
        cout << "=" << endl;
    }

 
  return 0;
}


Measured memory_bytes: 256