akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  using mint = modint<998244353>;
  int N, K, A;
  cin >> N >> K >> A;
  vector<mint> dp(K+N+2,0);
  dp[0] = 1;
  dp[1] = -1;
  mint a = 1;
  for(int i = 0; i < K; ++i){
    mint t = dp[i];
    dp[i+1] += dp[i];
    if(i > 0) a -= t*(100-A)/100;
    if(i > 0) t *= mint(A)/100;
    dp[i+1] += t/N;
    dp[min(K+N+1,i+N+1)] -= t/N;
  }
  cout << a << endl;
}



Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define bit(n) (1LL << (n))
using namespace std;
using ll = long long;

int bits(int n){
  int cnt = 0;
  while(n){
    n >>= 1;
    cnt++;
  }
  return cnt-1;
}

int main(){
  int n; cin >> n;
  vector<int> a(n, 0), ch(32, 0);
  int x=0; 
  REP(i, n){
    cin >> a[i];
    x ^= a[i];
    ch[bits(a[i]^(a[i]-1))]++;
  }

  bitset<64> b(x);
  int ans = 0;
  RFOR(i, 31, -1){
    if(b[i]){
      if(ch[i] == 0){
        cout << -1 << endl;
        return 0;
      }
      x ^= (bit(i+1)-1);
      ans++;
      b = bitset<64>(x);
    }
  }

  if(x == 0){
    cout << ans << endl;
  }
  else{
    cout << -1 << endl;
  }

  return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n;
string res;
int l,r;
int L,R;

int ask(int i) {
	cout<<i<<endl;
	string res;cin>>res;
	if(res=="Vacant") exit(0);
	else return res=="Male";
}

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

	cin>>n;
	l=1,r=n-1;
	bool L=ask(0);
	while(true) {
		int mid=(l+r)/2;
		bool M=ask(mid);
		if(((mid-l)%2==1&&L==M)||((mid-l)%2==0&&L!=M)) l=mid+1,L=M;
		else r=mid-1;
	}

	return 0;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  ll x[n], y[n];
  ll mxxpy = -2e9-9, mxxmy = -2e9-9;
  ll mnxpy = 2e9+9, mnxmy = 2e9+9;
  for (int i = 0; i < n; ++i){
    cin >> x[i] >> y[i];
    mxxpy = max(mxxpy, x[i]+y[i]);
    mnxpy = min(mnxpy, x[i]+y[i]);
    mxxmy = max(mxxmy, x[i]-y[i]);
    mnxmy = min(mnxmy, x[i]-y[i]);
  }
  cout << max( (mxxpy-mnxpy), (mxxmy-mnxmy) ) << endl;
  return 0;
}

Measured memory_bytes: 6748
import random
INF = 2**30
N, M, X = map(int, input().split())
C = [0] * N
A = []
for i in range(N):
    A.append([])

for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    for j in range(M):
        A[i].append(line[j+1])
ans = INF

for bit in range(2**17):
    sum = 0
    skill = [0] * M
    for i in range(N):
        if random.randint(0, 1):
            sum += C[i]
            for j in range(M):
                skill[j] += A[i][j]
    ok = True
    for j in range(M):
        if skill[j] < X:
            ok = False
    if ok:
        ans = min(ans, sum)
if ans == INF:
    ans = -1
print(ans)


Measured memory_bytes: 79816
def main():
    N, T = map(int, input().split())
    C = []
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            C.append(c)
    if len(C) == 0:
        print("TLE")
    else:
        print(min(C))


if __name__ == '__main__':
    main()


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

int main() {
  int k, mx = 0, s = 0;
  rep(i, 3) {
    int a;
    cin >> a;
    if (a > mx) mx = a;
    s += a;
  }
  cin >> k;
  s = s - mx + pow(2, k) * mx;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main() {
	int N;
	int n[100040];
	int time = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> n[i];
	}
	if (N == 1) {
		cout << "Yes";
	}
	else {
		for (int i = N - 1; i > 0; i--) {
			if (n[i - 1] - 1 > n[i]) {
				cout << "No";
				break;
			}
			else if (n[i - 1] - 1 == n[i]) {
				n[i - 1] = n[i - 1] - 1;
			}
			if (i == 1) {
				cout << "Yes";
			}
		}
	}
}

Measured memory_bytes: 640
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

double a,b,x;
signed main(){
    cin >> a >> b >> x;
    x /= a;
    double lo = 0.0;
    double hi = 90.0;
    while(abs(lo-hi) > 1e-9){
        double mid_d = (lo+hi) / 2;
        double mid =  mid_d / 45 * atan(1) ;
        double h = b * cos(mid);
        double det;
        if (h > a * sin(mid)){
            det = a * b - a * a * tan(mid) / 2;
        } else {
            det = b * b * cos(mid) / 2 / sin(mid);
        }
        // cerr << lo << " " << hi << " : " << det << endl;
        (det > x ? lo : hi) = mid_d;
    }
    printf("%.9f\n",lo);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n; cin>>n;
    
    int a;
    map<int,int> c;
    
    rep(i,n){
        cin>>a;
        c[a]++;
        c[a-1]++;
        c[a+1]++;
    }
    
    int ans=0;
    
    for(auto p: c){
        ans = max(ans, p.second);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 1000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    sort(all(a));
    bool b=0;
    rep(i,n-1){
        if(a[i]==a[i+1])b=1;
    }
    if(b)std::cout << NO << std::endl;
    else std::cout << YES << std::endl;
    
}

Measured memory_bytes: 1024
#include <iostream>

int P[100000];
void init(int n);
int root(int n);
void unite(int a, int b);
bool is_in_the_same_tree(int a, int b);

using namespace std;
int main(){
  int n, q, com, x, y;
  cin >> n >> q;
  init(n+1);
  for (int i = 0; i < q; ++i){
    cin >> com >> x >> y;
    if(com==0){unite(x, y);}
    else if(com==1){cout<<is_in_the_same_tree(x,y)<<endl;}
  }
}

void init(int n){
  for (int i = 0; i < n; ++i){P[i] = i;}
}

int root(int n){
  if(P[n]==n){return n;}
  return root(P[n]);
}

void unite(int a, int b){
  P[root(a)] = root(b);
}

bool is_in_the_same_tree(int a, int b){
  return root(a) == root(b);
}

Measured memory_bytes: 1200
// https://atcoder.jp/contests/abc052/tasks/arc067_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
const int MOD = 1e9 + 7;

// 素因数分解
vector<pair<ll, ll>> getFactor(ll x) {
    vector<pair<ll, ll>> result;
    for (ll i = 2; i * i <= x; i++) {
        ll num = 0;
        while (x % i == 0) {
            x /= i;
            num++;
        }
        if (num) {
            result.push_back({i, num});
        }
        if (x <= 1) {
            break;
        }
    }
    if (x > 1) {
        result.push_back({x, 1});
    }
    return result;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    unordered_map<ll, int> a;
    FOR(i, 1, n + 1) {
        auto t = getFactor(i);
        for (auto &x : t) {
            a[x.first] += x.second;
        }
    }
    ll sum = 1;
    for (auto &x : a) {
        sum *= (x.second + 1);
        sum %= MOD;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  char s[n];
  scanf("%s", s);
  int black[n];
  black[0] = 0;
  if (s[0] == '#') {
    black[0]++;
  }
  for (int i = 1; i < n; i++) {
    black[i] = black[i-1];
    if (s[i] == '#') {
      black[i]++;
    }
  }
  int min = n-black[n-1];
  int change;
  for (int i = 0; i < n; i++) {
    change = black[i] + n-i-1-(black[n-1]-black[i]);
    if (change < min) {
      min = change;
    }
  }
  printf("%d\n", min);

  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define fs first
#define sc second
#define P pair<int, int>
#define mk_p make_pair
int n, a[200010];
map<int, int> mp;
int main(){
	cin>>n;
	for(int i = 1;i <= n; i++){
		int x;
		scanf("%d", &x);
		if(mp[x]){
			puts("NO");
			return 0;
		}
		mp[x]++;
	}
	puts("YES");
	return 0;
}

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

void Cin(int X[],int N) {
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}
}

int main() {
	int N, B[99], Score = 0;
	cin >> N;
	for (int i = 0; i < N-1; i++) cin >> B[i];

	int A[99];

	for (int i = 0; i < 99; i++) {
		A[i] = -1;
	}

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

		if (i == N - 1) {
			A[i] = B[i - 1];
		}

		//�܂����������Ă��Ȃ�����
		if (A[i] == -1) {
			A[i] = B[i];

			if (B[i] <= B[i + 1]) {
				A[i + 1] = B[i];
			}
		}
		else {
			if (B[i] <= B[i + 1]) {
				A[i + 1] = B[i];
			}
		}
	}

	for (int i = 0; i < N; i++) Score += A[i];
	cout << Score << endl;

	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> t(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int p, x;
		cin >> p >> x;
		cout << sum - t[p - 1] + x << endl;
	}
}

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

class Node {
public:
  int pre;
  int now;
  int vel;
  double time;

  Node(int p, int n, int v, double t) {
    pre = p;
    now = n;
    vel = v;
    time = t;
  }

  bool operator<(const Node &n) const {
    if (time != n.time)
      return time < n.time;
    return vel < n.vel;
  }
  bool operator>(const Node &n) const {
    if (time != n.time)
      return time > n.time;
    return vel > n.vel;
  }
};

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;

    if (n == 0) {
      break;
    }

    int s, g;
    cin >> s >> g;

    vector<vector<int> > d(n + 1), c(n + 1);
    for (int i = 0; i <= n; i++) {
      d[i].resize(n + 1);
      c[i].resize(n + 1);
      fill(d[i].begin(), d[i].end(), -1);
      fill(c[i].begin(), c[i].end(), 0);
    }

    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      cin >> d[x][y] >> c[x][y];
      d[y][x] = d[x][y];
      c[y][x] = c[x][y];
    }

    bool f[31][31][31];
    for (int i = 0; i < 31; i++) {
      for (int j = 0; j < 31; j++) {
	for (int k = 0; k < 31; k++) {
	  f[i][j][k] = false;
	}
      }
    }
  
    bool goal = false;
    Node snd(0, s, 0, 0.0);
    priority_queue<Node, vector<Node>, greater<Node> > q;
    q.push(snd);
    while (!q.empty()) {
      Node nd = q.top();
      q.pop();
      if (nd.now == g && nd.vel == 1) {
	goal = true;
	cout << nd.time << endl;
	break;
      }

      if (f[nd.pre][nd.now][nd.vel]) {
	continue;
      }
    
      f[nd.pre][nd.now][nd.vel] = true;
      for (int i = 1; i <= n; i++) {
	if (i != nd.pre && d[nd.now][i] != -1) {
	  for (int j = -1; j <= 1; j++) {
	    int vel = nd.vel + j;
	    if (vel > 0 && vel <= c[nd.now][i]) {
	      Node next(nd.now, i, vel, nd.time + (double)d[nd.now][i] / vel);
	      q.push(next);
	    }
	  }
	}
      }
    }

    if (!goal) {
      cout << "unreachable" << endl;
    }
  }

  return 0;
}

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

#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define mp make_pair
#define VI vector<int>
#define INF 1e9
#define ll long long
const int N=205;
const int M=200005;

int a[3][N];
int dp[3][N];

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=2;++i){
        for(int j=1;j<=n;++j){
            cin>>a[i][j];
        }
    }
    memset(dp,0,sizeof(dp));
    dp[1][1]=a[1][1];
    int ans=0;
    for(int i=1;i<=2;++i){
        for(int j=1;j<=n;++j){
            dp[i][j]=max(dp[i][j],dp[i-1][j]+a[i][j]);
            dp[i][j]=max(dp[i][j],dp[i][j-1]+a[i][j]);
            ans=max(ans,dp[i][j]);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	int n;
	cin>>n;
	vector<int>v(n+1);
	for(int i=1;i<=n;i++)
		cin>>v[i];
	int cnt = 0;
	vector<int>ans(n+1);
	for(int i=n;i>0;i--){
		int c = 0;
		for(int j=2*i;j<=n;j+=i)
		{
			if(ans[j])
				c++;
		}
		if(c%2==v[i])
			ans[i] = 0;
		else{
			ans[i] = 1;
			cnt++;
		}
	}
	cout<<cnt<<endl;
	for(int i=1;i<=n;i++)
	{
		// cout<<ans[i]<<" ";
		if(ans[i])
			cout<<i<<endl;
	}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int count = 0, mx = INT_MIN;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') count++;
        else {
            mx = max(mx, count);
            count = 0;
        }
    }
    mx = max(mx, count);
    cout << mx << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

ll res = 0;

int cnt = 0;

string s;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> s;
	for (auto c : s)
	{
		if (c == 'B')
			++cnt;
		else
			res += cnt;
	}
	cout << res << endl;
	return 0;	
}

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

using namespace std;

using   ll=long long;
using   ld=long double;

#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define long long      int 
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323

int chk(ll mid,ll k)
{
    return (240-k-5*((mid*(mid+1))/2))>=0;
}

bool isPrime(int n) 
{ 
    // Corner case 
    if (n <= 1) 
        return false; 
  
    // Check from 2 to n-1 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 
 
void solve()
{
    ll a,b,c;
    
    cin>>a>>b>>c;
    
    ll tt=min(a,c);
    
    a-=tt;
    c-=tt;
    
    tt=min(b,c);
    
    b-=tt;
    c-=tt;
    
    cout<<a<<" "<<b;
}
 
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoder_Begginer_Contest_159
{
    class B
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if(!s.Equals(new string(s.Reverse().ToArray())))
            {
                Console.WriteLine("No");
                return;
            }

            int halfLen = (s.Length - 2) / 2;
            string s1 = s.Substring(0, halfLen + 1);
            //Console.WriteLine(s1);
            //Console.WriteLine(new string(s1.Reverse().ToArray()));
            if (!s1.Equals(new string(s1.Reverse().ToArray())))
            {
                Console.WriteLine("No");
                //Console.ReadKey();
                return;
            }

            string s2 = s.Substring(s.Length - halfLen - 1, halfLen + 1);
            //Console.WriteLine(s2);
            //Console.WriteLine(new string(s2.Reverse().ToArray()));
            if (!s2.Equals(new string(s2.Reverse().ToArray())))
            {
                Console.WriteLine("No");
                //Console.ReadKey();
                return;
            }

            Console.WriteLine("Yes");
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
int main(){
	int n, i = 0, x;
	scanf("%d", &n);
	while(i != n) {
		i++;
		x = i;
		if(x % 3 == 0){
			printf(" %d", i);
		}else if(x >= 13){
			while(x >= 3){
				if(x % 10 == 3){
					printf(" %d", i);
					break;
				}
				x = x / 10;		
			}
		}
	}
	printf("\n");
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    string sa, sb, sc; cin >> sa >> sb >> sc;

    int a = 0, b = 0, c = 0; char next = 'a';
    while (1) {
        if (next == 'a') {
            if (a == sa.size()) {
                cout << "A" << endl;
                break;
            }
            next = sa[a++];
        } else if (next == 'b') {
            if (b == sb.size()) {
                cout << "B" << endl;
                break;
            }
            next = sb[b++];
        } else {
            if (c == sc.size()) {
                cout << "C" << endl;
                break;
            }
            next = sc[c++];
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

main() {
  int n;
  while((cin >> n) && n) {
    int A = 0, B = 0;
    for(int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      if(a < b) {
	B += a + b;
      } else if(a > b) {
	A += a + b;
      } else {
	A += a;
	B += b;
      }
    }
    cout << A << " " << B << endl;
  }
}

Measured memory_bytes: 0
var
    A:integer;
    B:integer;
    
begin
    readln(A,B);
    
    begin
        if (A = B) then begin
        writeln('Draw')
        
        end else if (A = 1) then begin
        writeln('Alice')
        
        end else if (B = 1) then begin
        writeln('Bob')
        
        end else if (A > B) then begin
        writeln('Alice')
        
        end else if (A < B) then begin
        writeln('Bob')
        end
    end
end
.

Measured memory_bytes: 128
import sys
import itertools

x = int(input())

nums = [100, 101, 102, 103, 104, 105]
if x >= 2000:
	print(1)
else:
	for i in range(20):
		for balls in itertools.combinations_with_replacement(nums, i):
			if sum(balls) == x:
				print(1)
				sys.exit()	
	else:
		print(0)

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

using namespace std;

int logcount(int x){
	int res = 0;
	while(1){
		if(x%2 == 0){
			x/=2;
			res++;
		}else{
			break;
		}
	}
	return res;
}

int main(){
	int N, ans = 0; cin >> N;
	for(int i = 0; i < N; ++i){
		int x; cin >> x;
		ans += logcount(x);
	}
	cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	REPN(i, 0, n) {
		REPN(j, 0, n) {
			int k = n - i * r - j * g;
			if (k >= 0 && k % b == 0) {
			ans++;
				}
		}
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        List<String> s = new LinkedList<>();
        String[] s_tmp = sc.next().split("");
        for(int i=0;i<s_tmp.length;i++){
            s.add(s_tmp[i]);
        }
        Integer q = sc.nextInt();
        Integer rev = 0;
        for(int i=0;i<q;i++){
            Integer t = sc.nextInt();
            if(t==1){// 反転
                rev = (rev+1)%2;
            }
            else{// 追加
                Integer f = sc.nextInt();
                String c = sc.next();
                if(rev==1){//反転中
                    if(f==2){// 先頭にc
                        s.add(0, c);
                    }
                    else{// 末尾にc
                        s.add(c);
                    }
                }
                else{
                    if(f==1){// 先頭にc
                        s.add(0, c);
                    }
                    else{// 末尾にc
                        s.add(c);
                    }
                }
            }
        }

        if(rev==1){
            Collections.reverse(s);
        }
        for(String tmp : s){
            System.out.print(tmp);
        }

    }
}


Measured memory_bytes: 182540
#include <iostream>

using namespace std;


int main()
{
  int n;
  int a, b, c;
  cin >> n;

  a = n / 100;
  b = (n%100)/10 ;
  c = n % 10;
  if (a == 7 || b == 7 || c == 7) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	ll A, B, C;
	cin >> A >> B >> C;

	ll min = (ll)1e18 + 1;
	min = std::min(min, B*C*(A % 2));
	min = std::min(min, B*A*(C % 2));
	min = std::min(min, A*C*(B % 2));

	cout << min << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for (int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

const int MAXNUM = 300000;

bool isSatNum[MAXNUM + 1];

void SatNum()
{
    rep(i, MAXNUM + 1) isSatNum[i] = true;

    for (int i = 2; i < sqrt(MAXNUM) + 1; i++)
    {
        if (isSatNum[i] && (i % 7 == 1 || i % 7 == 6))
        {
            for (int j = i * 2; j < MAXNUM + 1; j += i)
            {
                isSatNum[j] = false;
            }
        }
    }
}

int main()
{
    SatNum();

    vector<int> SatNums;

    REP(i, 2, MAXNUM + 1) if (isSatNum[i] && (i % 7 == 1 || i % 7 == 6)) SatNums.push_back(i);

    int N;

    while (cin >> N, N != 1)
    {
        cout << N << ":";

        vector<int> ans;

        for (int i = 0; i < SatNums.size() && SatNums[i] <= N; i++)
        {
            if (N % SatNums[i] == 0)
                ans.push_back(SatNums[i]);
        }

        for (auto x : ans)
        {
            cout << " " << x;
        }

        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        int k = scanner.nextInt();

        final List<Long> list = IntStream.range(0, n)
            .mapToObj(i -> (long) scanner.nextInt())
            .sorted()
            .collect(Collectors.toList());

        if (k % 2 == 1 && list.get(n - 1) <= 0) {
            final long answer = (MOD - IntStream.range(0, k)
                .mapToLong(i -> list.get(n - i - 1))
                .reduce((a, b) -> Math.abs(a * b) % MOD)
                .orElseThrow()) % MOD;
            System.out.println(answer);
            return;
        }

        long production = 1;
        int left = 0;
        int right = n - 1;
        for (int i = 0; i < k; i++) {
            if (i == k - 1) {
                production *= list.get(right);
                production %= MOD;
                continue;
            }

            final long multi;
            if (list.get(left) * list.get(left + 1) > list.get(right) * list.get(right - 1)) {
                multi = list.get(left) * list.get(left + 1) % MOD;
                left += 2;
                i++;
            } else {
                multi = list.get(right);
                right--;
            }
            production *= multi;
            production %= MOD;
        }
        System.out.println((production + MOD) % MOD);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
    

Measured memory_bytes: 62012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

vector<vector<int>> dp(500000,vector<int>(55,INF));
int main(){
  int N;
  cin >> N ;
  vector<int> A(N),B(N);
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  dp[0][0] = 0;
  rep(bit, 1<<N){
    int s_size = 0;
    rep(i,N){
      int mask = 1 << i;
      if(bit&mask){
        s_size++;
      }
    }
    vector<pair<int,int>> invS;
    int now = s_size;
    rep(i,N){
      int mask = 1 << i;
      if(!(bit&mask)) {
        invS.emplace_back(i,now);
        now++;
      }
    }
    rep(last,51){
      for(auto v:invS){
        int i=v.first;
        int now = v.second;
        int i_val;
        if(abs(i-s_size) % 2 == 0){
          i_val = A[i];
        }else{
          i_val = B[i];
        }
        if(i_val >= last){
          chmin(dp[bit | (1<<i)][i_val],dp[bit][last]+abs(now-s_size));
        }
      }
    }
  }
  int ans = INF;
  rep(i,55){chmin(ans,dp[(1<<N)-1][i]);}
  if(ans == INF){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 129152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int MOD = (1e+9)+7;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
mat dp(21,vec(1 << 21,-1)),a(21,vec(21));

ll solve(ll ma, ll fe){
  if(ma == N) return 1;
  if(dp[ma][fe] != -1) return dp[ma][fe];
  ll ans=0;
  rep(i,N){
    if(a[ma][i]&&!((fe>>i)&1)){
      (ans += solve(ma+1,fe|(1<<i)))%=MOD;
    }
  }
  dp[ma][fe]=ans;
  return ans;
}

int main() {
  cin>>N;
  rep(i,N) rep(j,N) cin>>a[i][j];
  cout<<solve(0,0)<<endl;
}


Measured memory_bytes: 360832
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

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

    multiset<int> st;
    int ans = 0;
    rep(i, n){
        auto it = st.lower_bound(a[i]);
        if(it == st.begin()){
            st.insert(a[i]);
            ++ans;
        }else{
            --it;
            st.erase(it);
            st.insert(a[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

string S;
stack<char> stk;
signed main() {
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        if (!stk.empty() && stk.top() != S[i]) { stk.pop(); }
        else { stk.push(S[i]); }
    }
    cout << S.length() - stk.size() << endl;
}


Measured memory_bytes: 512
#include<cstdio>
using ll = long long;
using ull = unsigned long long;
const static int MOD = 1000000007;

ll RepeatSquaring(ll N, ull P){
	if(P == 0 || N == 1) return 1;
	if(N == -1) return P & 1 ? -1 : 1;
	if(!(P & 1)){
		ll t = RepeatSquaring(N, P >> 1);
		return t*t % MOD;
	}
	return N*RepeatSquaring(N, P - 1) % MOD;
}

ull Combination(ull n, ull r){
	ull ret = 1;
	if(n - r < r) r = n - r;
	ull denominator = 1;
	for (ull i = 0; i < r; ++i){
		ret = ret*((n - i) %MOD) %MOD;
		denominator = denominator*((i + 1) %MOD) %MOD;
	}
	return ret*RepeatSquaring(denominator, MOD-2) %MOD;
}
int main(){
	ull X, Y;
	scanf("%llu %llu", &X, &Y);
	ull sum = X + Y;
	if(sum % 3){
		printf("0\n");
		return 0;
	}
	ull moves = sum/3;
	if(X < moves || Y < moves){
		printf("0\n");
	}else{
		printf("%llu\n", Combination(moves, X - moves));
	}
	return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int k;
    cin >> k;

    vector<int> traversed(k);

    int amari = 7;

    for(int i = 1; i <= k + 1; i++){
        if(traversed[amari % k] == 1){
            cout << -1 << endl;
            break;
        }else if(amari % k == 0){
            cout << i << endl;
            break;
        }else{
            amari = amari % k;
            traversed[amari] = 1;
            amari = amari * 10 + 7;
        }
    }
    return 0;
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

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

    string S;
    cin >> S;
    list<char> li;
    for (int i=0; i<(int)S.size(); ++i) li.push_back(S[i]);
    int Q;
    cin >> Q;
    int T, F; char c;

    bool rev = false;
    for (int i=0; i<Q; ++i) {
        cin >> T;
        if (T == 1) {
            rev = !rev;
        } else {
            cin >> F >> c;
            if (F == 1) {
                // front
                if (rev) li.push_back(c);
                else li.push_front(c);
            } else {
                // back
                if (rev) li.push_front(c);
                else li.push_back(c);
            }
        }
    }
    if (rev) li.reverse();

    for (char c: li) {
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 10064
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define evn(x) (!((x)&1))
#define MOD (ll)(1e9+7)
#define INF INT32_MAX
#define INFL INT64_MAX
using namespace std;

int n;
bool vis[MAX];
vector<int> gp[MAX];
int dist[MAX];

void connect(int a, int b)	{
	gp[a].push_back(b);
}

void bfs(int a)	{
	if(vis[a])	return;
	vis[a]=1;
	queue<int> q;
	q.push(a);
	while(!q.empty())	{
		q.pop();
		for(auto p:gp[a])	{
			if(vis[p])	continue;
			q.push(p);
			vis[p]=1;
			dist[p]=1+dist[a];
			//if(a==1 && p==2)	{cout << 1 << endl; exit(0);}
		}
		a=q.front();
	}
}

void solve()	{
	cin >> n;
	memset(dist,0,sizeof(dist));
	int x;
	for(int i=0; i<n; i++)	{
		cin >> x;
		connect(i+1,x);
	}
	bfs(1);

	if(vis[2])	cout << dist[2] << endl;
	else cout << -1 << endl;
}

int main()	
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 34232
PI = Math::PI

a,b,x = gets.split.map(&:to_f)

s = x / a
if s > b * a / 2
  bu = 2 * s / a - b
  s -= a * bu
  b -= bu
else
  a = 2 * s / b
end
r = Math.atan(b/a)
ans = r * (180.0/PI)

puts ans

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

typedef vector<double> vec;
typedef vector<vec> mat; 

mat mul(mat &A,mat &B){
	mat C( A.size(),vec(B[0].size() ));
	for(int i=0;i<A.size();i++)
		for(int k=0;k<B.size();k++)
			for(int j=0;j<B[0].size();j++)
				C[i][j]=(C[i][j]+A[i][k]*B[k][j])/*%M*/;
	return C;
}

mat pow(mat A,ll n){
	mat B(A.size(),vec(A[0].size()));
	for(int i=0;i<A.size();i++)
		B[i][i]=1;
	while(n>0){
		if(n&1) B=mul(B,A);
		A=mul(A,A);
		n >>=1;
	}
	return B;
}

int main(void){
	int n;
	while(cin >> n,n){
		char s,t,b;
		cin >> s >> t >> b;
		s-='A';t-='A';b-='A';
		mat A(9,vec(9));
		mat x(9,vec(1));

		rep(i,9){
			rep(j,9) A[i][j]=0.0;
			int d[4]={-3,-1,1,3};
			int tmp=0;
			rep(j,4){
				int cx=i%3,cy=i/3;
				int nx=(i+d[j])%3,ny=(i+d[j])/3;
				if(0<=i+d[j]&&i+d[j]<9&&i+d[j]!=b&&(cx==nx||cy==ny))
					A[i][i+d[j]]=0.25;
				else
					tmp++;
			}
			A[i][i]=0.25*tmp;

			//rep(j,9) cout << A[i][j] << " ";
			//cout << endl;
		}
		rep(i,9) x[i][0]=(i==s?1.0:0.0);

		A=pow(A,n);
		x=mul(A,x);
		cout << x[t][0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1292
n=int(input())
A=sorted(list(map(int,input().split())))
B=[A[0]]
for i in range(1,n):
  B.append(B[-1]+A[i])
ans=0
j=-1
for i in range(n-1):
  if B[i]*2<A[i+1]:
    ans=ans+i-j
    j=i
print(n-ans)

Measured memory_bytes: 14320
void main() {
	auto N = ri;
	auto A = readAs!(int[]);
	ulong cnt;
	foreach(i; 0..N-1) {
		if(A[i] < A[i+1]) cnt++;
	}
	cnt.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 5328
import java.io.IOException
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (a, b, t) = sc.nextInts(3)
    println(t / a * b)
}

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

Measured memory_bytes: 31396
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main()
{
    int N, Q;
    cin >> N >> Q;
    dsu disjoint(N);
    for (int i = 0; i < Q; ++i) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) 
            disjoint.merge(u, v);
        if (t == 1)
            cout << (disjoint.same(u, v) ? 1 : 0) << endl;
    }
}




Measured memory_bytes: 4056
n = int(input())
d = {}
for i in range(n):
  s = input()
  if s not in d:d[s] = 1
  d[s] += 1
max_cnt = sorted(d.items(), key=lambda x:x[1])[-1][1]
s = [x for x, y in d.items() if y == max_cnt]
s.sort()
for name in s:
    print(name)

Measured memory_bytes: 43228