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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll N;
  cin >> N;

  ll ans = 0;
  if (N < 10) {
    ans = N;
  } else if (N < 100) {
    ans = 9;
  } else if (N < 1000) {
    ans = 9 + (N - 99);
  } else if (N < 10000) {
    ans = 9 + 900;
  } else if (N < 100000) {
    ans = 9 + 900 + (N - 9999);
  } else {
    ans = 9 + 900 + 90000;
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
a, b = map(int,input().split())
c = 0

if a % 2 == 1:
  c = a
  a += 1

d = (b - a + 1) % 4

if d == 0:
  ans = 0
elif d == 1:
  ans = b ^ 0
elif d == 2:
  ans = 1
else:
  ans = b ^ 1
  
if c != 0:
  ans ^= c

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=2e5+10;
ll a[mn],nxt[mn],cur[mn],sp[mn][60];
bool in[mn];
ll inf=0x3f3f3f3f3f3f3f3f;
int main()
{
    ll n,k,i,j;
    scanf("%lld%lld",&n,&k);
    memset(cur,-1,sizeof(nxt));
    for(i=0;i<n;i++)scanf("%lld",a+i);
    for(i=n-1;i>=0;i--){
        nxt[i]=cur[a[i]];
        cur[a[i]]=i;
    }
    for(i=n-1;i>=0;i--){
        if(nxt[i]==-1)nxt[i]=cur[a[i]]+n;
    }
    for(i=0;i<n;i++){
        sp[i][0]=nxt[i]-i+1;
    }
    for(i=1;i<60;i++)for(j=0;j<n;j++)sp[j][i]=min(inf,sp[j][i-1]+sp[(j+sp[j][i-1])%n][i-1]);
    ll cum=0;
    for(i=59;i>=0;i--){
        if(cum+sp[cum%n][i]<=n*k)cum+=sp[cum%n][i];
    }
    vector<int>ans;
    for(i=cum;i<n*k;i++){
        if(!in[a[i%n]])ans.push_back(a[i%n]),in[a[i%n]]=1;
        else while(in[a[i%n]]){
            in[ans[ans.size()-1]]=0;
            ans.pop_back();
        }
    }
    for(int x:ans)printf("%d ",x);
}


Measured memory_bytes: 101108
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

const int max_v = 3001;

ll dp[max_v][max_v][4];

int main(){
    int R,C,K; cin >> R >> C >> K;

    vector<vector<ll>> rcv(R+1, vector<ll>(C+1,0));
    rep(i,K){
        ll tr, tc, tv; cin >> tr >> tc >> tv;
        tr--;
        tc--;
        rcv[tr][tc] = tv;
    }

    rep(i,max_v){
        rep(j,max_v){
            rep(k,4){
                dp[i][j][k] = -INF;
            }
        }
    }
    dp[0][0][0] = 0;
    dp[0][0][1] = rcv[0][0];
    
    rep(i,R){
        rep(j,C){
            rep(k,4){
                dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
                dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k]+rcv[i+1][j]);
                dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
                if (k+1 < 4){
                    dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k]+rcv[i][j+1]);
                }
            }
        }
    }
    ll ans = -1;
    rep(i,4){
        ans = max(ans, dp[R-1][C-1][i]);
    }

    cout << ans << endl;

}

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

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

using namespace std;

int main() {
    int n,m;
    int count[31] = {};
    cin >> n >> m;
    int k,food;
    rep(i,n){
        cin >> k;
        rep(j, k){
            cin >> food;
            count[food]++;
        }
    }
    int ans = 0;
    rep(i, m + 1){
        if(count[i] == n){
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main() {
  int A,B,T;
  cin >> A >> B >> T;
  
  cout << B * (T / A) << endl;
  return 0;
}

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

int main()
{
	int n,k;
    cin>> n >> k;
   	int arr[n];
    for(int i=0;i<n;i++)cin>> arr[i];
    vector<int>dp(n,INT_MAX);
    dp[0]=0;
   
    for(int i=1;i<n;i++){
    	for(int j=i-1;j>=max(i-k,0);j--){
            dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif




int main()
{
	CIN(int, X);
	CIN(int, t);
	cout << max(0, X-t) << endl;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int H;

void maxHeapify(vector<int> &A, int i){
    int left = i*2+1;
    int right = i*2+2;
    int largest = i;
    if(left < H && A[i] < A[left]) largest = left;
    if(right < H && A[largest] < A[right]) largest = right;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(vector<int> &A){
    for(int i = (H-1)/2; i>=0; i--){
        maxHeapify(A, i);
    }
}

int main()
{
    cin >> H;
    vector<int> A(H);
    rep(i,H) cin >> A[i];
    buildMaxHeap(A);
    rep(i,H) printf(" %d", A[i]);
    cout << endl;
}


Measured memory_bytes: 4644
#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() {
    vector<int> x(5);
    for (int i=0; i<5; ++i) cin >> x[i];

    for (int i=0; i<5; ++i) {
        if (x[i] == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n;
    cin >> n;
    vector<ll> d(n);
    REP(i, n){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    ll ans = 1;
    REP(i, n - 1){
        if(d[i] < d[i + 1]){
            ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

const int INF = -1;

int main()
{
    int a, b;

    while (cin >> a >> b, a || b) {
        int n;
        int dp[20][20] = {0};

        dp[1][1] = 1;
        cin >> n;
        while (n--) {
            int x, y;
            cin >> x >> y;
            dp[y][x] = INF;
        }

        for (int y = 1; y <= b; y++) 
            for (int x = 1; x <= a; x++) {
                if (dp[y][x] != INF) {
                    if (y != 1 && dp[y - 1][x] != INF)
                        dp[y][x] += dp[y - 1][x];
                    if (x != 1 && dp[y][x - 1] != INF)
                        dp[y][x] += dp[y][x - 1];
                }
        }

        cout << dp[b][a] << endl;
    }

    return 0;
}

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

namespace ConsoleApp5
{
    class Program
    {
        int n;
        int inf = 1050000000;
        int[] kek;
        int result;
        int summ;
       
        int m,k,f;
        bool[,] pairs;
        int[,] g;
        List<int> tank;
        string a, b;
        char tmp;
        List<string> used;
        Dictionary<char, List<int>> tank1;
        int ans;

        public void Run()
        {
                var Elems = Console.ReadLine().Split().Select(int.Parse).ToArray();
                n = Elems[0];
                m = Elems[1];
            Console.WriteLine(n + m / 2);
        }

        
       
        void GoS(int i)
        {
        }

        /* string Kek(int i)
        {
            if (i == 1) return dp[1].ToString() + "+"+n;
            return "(" + Kek(i - 1) + ")" + dp[i].ToString() +"+"+ (n - i + 1).ToString();
        }
*/
        static void Main(string[] args)
        {
                    new Program().Run();
        }
    }
}


Measured memory_bytes: 13268
def main():
    s = input()
    mod = 10 ** 9 + 7

    DP = [[0] * 13 for i in range(len(s) + 1)]
    DP[0][0] = 1
    for ci, c in enumerate(s):
        if c == '?':
            for r in range(13):
                for k in range(10):
                    DP[ci + 1][(r * 10 + k) % 13] += DP[ci][r]
                    DP[ci + 1][(r * 10 + k) % 13] %= mod

        else:
            for r in range(13):
                DP[ci + 1][(r * 10 + int(c)) % 13] += DP[ci][r]
                DP[ci + 1][(r * 10 + int(c)) % 13] %= mod

    print(DP[len(s)][5])


if __name__ == '__main__':
    main()


Measured memory_bytes: 61948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=1e6+7;
struct Edge{
	int to,w;
};
map<int,set<int> > col[200005];
vector<Edge> G[maxn];
map<PII,int> num;
int curn=0;
inline int getid(int u,int col)
{
	if(!num.count(make_pair(u,col)))
		num[make_pair(u,col)]=curn++;
	return num[make_pair(u,col)];
}
int n,m;
struct Heap{
	int u,dis;
	bool operator<(const Heap& a)const{
		return dis>a.dis;
	}
};
int d[maxn];
bool vis[maxn];
int dij()
{
	memset(d,0x3f,sizeof(d));
	d[1]=0;
	priority_queue<Heap> q;
	q.push({1,0});
	while(!q.empty())
	{
		auto u=q.top();
		q.pop();
		if(vis[u.u]) continue;
		vis[u.u]=1;
		for(auto e:G[u.u])
		{
			int v=e.to;
			if(d[v]>d[u.u]+e.w)
			{
				d[v]=d[u.u]+e.w;
				q.push({v,d[v]});
			}
		}
	}
	return d[n];
}
int main()
{
	scanf("%d%d",&n,&m);
	curn=n+1;
	for(int i=0,u,v,c;i<m;i++)
	{
		scanf("%d%d%d",&u,&v,&c);
		col[u][c].insert(v);
		col[v][c].insert(u);
	}
	for(int i=1;i<=n;i++)
	{
		for(auto u:col[i])
		{
			int cc=u.first;
			for(auto v:u.second)
			{
				G[getid(i,cc)].push_back({getid(v,cc),0});
				G[getid(v,cc)].push_back({getid(i,cc),0});
			}
			G[i].push_back(Edge{getid(i,cc),1});
			G[getid(i,cc)].push_back(Edge{i,0});
		}
	}
	int ans=dij();
	if(ans==0x3f3f3f3f) ans=-1;
	printf("%d\n",ans);
}


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

int main()
{
	int takahashi_a, takahashi_hp;
	int aoki_a, aoki_hp;
	int i = 0;

	cin >> takahashi_hp >> takahashi_a >> aoki_hp >> aoki_a;

	while ((takahashi_hp > 0) and (aoki_hp > 0))
	{
		if (i % 2 == 0) { 		
			aoki_hp = aoki_hp - takahashi_a; 
			//cout << "aoki" << aoki_hp << endl;
		}
		else {
			takahashi_hp = takahashi_hp - aoki_a;
			//cout << "takahashi" << takahashi_hp << endl;
		}
		i++;
	}

	if (aoki_hp <= 0) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	

}

Measured memory_bytes: 3624
import sys
import io
import math
import re

datalist = input().split()
datalist_a = list(datalist[0])

flag = 0
flag_max = 0
for data in datalist_a:
    if data == 'A' or data == 'T' or data == 'C' or data == 'G':
        flag += 1
    else:
        flag = 0
    if flag > flag_max:
        flag_max = flag
print(flag_max)

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

int main() {
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    int ans = 0;
    
    for (int i = 0; i < 1000; i++) {
        string p(3, '0');
        
        p[0] = '0' + (i / 100);
        p[1] = '0' + ((i % 100) / 10);
        p[2] = '0' + i % 10;
        
        int j = s.find_first_of(p[0]);
        
        if (j == string::npos || j + 1 == n) {
            continue;
        }
        
        j = s.find_first_of(p[1], j + 1);
        
        if (j == string::npos || j + 1 == n) {
            continue;   
        }
        
        j = s.find_first_of(p[2], j + 1);
        
        if (j != string::npos) {
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
wins = {"p":"s", "r":"p", "s":"r"}
points = {"p":S, "r":P, "s":R}
hands = []

ans = 0
for i in range(N):
    if i - K < 0:
        hands.append(wins[T[i]])
        ans += points[T[i]]
    else:
        if hands[i-K] == wins[T[i]]:
            #あいこにするしか無い時
            hands.append("-")
        else:
            #勝てる時
            hands.append(wins[T[i]])
            ans += points[T[i]]
print(ans)


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

using namespace std;

template<typename Edge> class Graph {
public:
  virtual int size() const {return 0;};
  virtual vector<Edge> edges(int v) const {(void)v; return vector<Edge>();}
  virtual void addEdge(const Edge& edge) {(void)edge;};
  virtual vector<Edge> getEdges(int from, int to) const {(void)from; (void)to; return vector<Edge>();};
};

template<typename Edge> class AdjacencyList : public Graph<Edge> {
protected:
  vector<vector<Edge>> graph;

public:
  AdjacencyList(int n = 0) : graph(n) {}

  int size() {
    return graph.size();
  }

  vector<Edge> edges(int v) {
    return graph[v];
  }
  
  void addEdge(const Edge& edge) {
    if (int(graph.size()) <= max(edge.from, edge.to)) graph.resize(max(edge.from, edge.to) + 1);
    graph[edge.from].emplace_back(edge);
  }

  vector<Edge> getEdges(int from, int to) {
    vector<Edge> res;
    for (const auto& edge : edges(from)) {
      if (edge.to == to) res.emplace_back(edge);
    }
    return res;
  }
};

template<template<typename Edge> class Graph, typename Edge> class ShortestPath {
private:
  typedef __typeof(Edge::cost) Cost;

  struct State {
    int pos;
    Cost cost;
    bool operator<(const State& state) const {return cost > state.cost;}
  };

  Graph<Edge> graph;

public:
  const Cost INF;

  vector<Cost> dist;

  ShortestPath(const Graph<Edge>& graph) : graph(graph), INF(numeric_limits<Cost>::max()) {}
  
  void run (int from) {
    priority_queue<State> que;
    que.push((State){from, 0});
    dist.resize(graph.size(), INF);
    while (!que.empty()) {
      State now = que.top();
      que.pop();
      if (dist[now.pos] <= now.cost) continue;
      dist[now.pos] = now.cost;
      for (const Edge& edge : graph.edges(now.pos)) {
        if (dist[edge.to] < now.cost + edge.cost) continue;
        que.push((State){edge.to, now.cost + edge.cost});
      }
    }
  }
};

struct Edge {
  int from, to, cost;
};

int main() {
  int v, e, r;
  cin >> v >> e >> r;
  AdjacencyList<Edge> graph(v);
  for (int i = 0; i < e; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    graph.addEdge((Edge){s, t, d});
  }
  ShortestPath<AdjacencyList, Edge> shortestPath = graph;
  shortestPath.run(r);
  for (int c : shortestPath.dist) {
    if (c != shortestPath.INF) cout << c << endl;
    else cout << "INF" << endl;
  }
}

Measured memory_bytes: 24032
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    vi a(n),b(n),c(m),d(m);
    rep(i,n) cin >> a.at(i) >> b.at(i);
    rep(i,m) cin >> c.at(i) >> d.at(i);
    int64_t dx,dy,minDistance = 10000000007, minCheckPoint = -1;
    vi res(n);
    for(int i=0; i<n; i++){
        minDistance = 10000000007;
        minCheckPoint = -1;
        for(int j=0; j<m; j++){
            dx = abs(a.at(i) - c.at(j));
            dy = abs(b.at(i) - d.at(j));
            minCheckPoint = minDistance<=dx+dy?minCheckPoint:j+1;
            minDistance = min(minDistance, dx+dy);
        }
        res.at(i) = minCheckPoint;
    }
    rep(i,n) cout << res.at(i) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
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 (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int win(char c) {
	if (c == 'r') return 2;
	if (c == 's') return 0;
	else return 1;
}

int dp[100010][4];
int a[3];

int main() {
	int n, k;
	cin >> n >> k >> a[0] >> a[1] >> a[2];
	string t;
	cin >> t;
	for (int i = 0; i < n; i++) {
		if (i < k) {
			int w = win(t[i]);
			dp[i][w] = a[w];
		}
		else {
			for (int j = 0; j < 3; j++) {
				for (int l = 0; l < 3; l++) {
					if (j != l) chmax(dp[i][j], dp[i - k][l]);
				}
				if (j == win(t[i])) dp[i][j] += a[win(t[i])];
			}
		}
	}
	/*for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cout << dp[i][j] << ' ';
		}
		cout << endl;
	}*/
	int ans = 0;
	for (int i = n - 1; i >= n - k; i--) {
		ans += max({ dp[i][0],dp[i][1],dp[i][2] });
	}
	cout << ans << endl;
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;
const double PI = acos(-1);
//----------------------------------------------------------------
signed main(){

	int a,b,x;
	cin >> a >> b >> x;
	
	if(a*a*b*1.0/2.0 >= x){
		printf("%.10lf\n",atan(a*b*b*1.0/2.0/x)*180/PI);
		// cout << atan(a*b*b*1.0/2.0/x)*180/PI << endl;
		return 0;
	}else{
		printf("%.10lf\n",atan(2*(a*a*b-x)*1.0/a/a/a)*180/PI);
		// cout << atan(2*(a*a*b-x)*1.0/a/a/a)*180/PI << endl;
		return 0;
	}


	return 0;
}

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

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc144.contest.atcoder.jp/tasks/abc144_b

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
   ll N, K; cin >> N >> K; int a[202020]; bool check[202020] = {};;
  rep(i, N){
      cin >> a[i]; a[i]--;
  }
  int now = 0; check[0] = true; int next; int cnt = 0, syuki, begin;
  int cn[202020]; cn[0] = 0;
  rep(i, N){
      next = a[now]; cnt++;
      if(check[next]){
          syuki = cnt-cn[next]; begin = next; break;
      }
      cn[next] = cnt;
      check[next]=true;
      now=next;
  }
  //rep(i, N){
      //cout << cn[i]; cout << " ";
  //}
  //cout << syuki << endl;
  //cout << begin+1 << endl;
  if(K>cn[begin]){
    rep(i, N){
        if(cn[i]==(K-cn[begin])%syuki+cn[begin]){
            cout << i+1 << endl; return 0;
        }
    }
  }
  rep(i, N){
      if(cn[i]==K){
          cout << i+1 << endl; return 0;
      }
  }
}

Measured memory_bytes: 5340
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct linklist *list;
struct linklist{
	int key;
	list next;
	list back;
};

list head;
list tail;

void init(void){
	head = (list)malloc(sizeof(*head));
	tail = head;
	tail->next = NULL;
}

void insert(int k){
	list x;
	x = (list)malloc(sizeof(*x));
	x->next = head;
	x->key = k;
	x->back = NULL;
	head->back = x;
	head = x;
//	printf("insert\n");
	return;
}

void delete(int k){
	list x;
	list ins;
	x = head;
//	printf("delete\n");
	if(head->key==k){
		head = head->next;
		head->back = NULL;
		free(x);
		return;
	}
	while(x->next!=tail){
		if((x->next)->key==k){
			ins = x->next;
			x->next = ins->next;
			ins->next->back = x;
			free(ins);
			return;
		}else{
			x = x->next;
		}
	}
	return;
}

void deleteFirst(void){
	list ins;
	ins = head;
	head = head->next;
	head->back = NULL;
	free(ins);
	return;
}

void deleteLast(void){
	list x;
	list ins;
	x = tail;
	tail = tail->back;
	tail->next = NULL;
	free(x);
	return;
}

int main(int argc, char argv[]){
	int n;
	char command[20] = "\0";
	int d;
	list x;

	init();

	scanf("%d",&n);

	int i,j;
	for(i=0;i<n;i++){
		scanf("%s %d",command,&d);
		if(!strcmp(command,"insert"))insert(d);
		else if(!strcmp(command,"delete"))delete(d);
		else if(!strcmp(command,"deleteFirst"))deleteFirst();
		else if(!strcmp(command,"deleteLast"))deleteLast();
		else printf("The command does not exist.\n");
//		printf("%s %d\n",command,d);

/*		j=0;
		x = head;
		if(x!=NULL)printf("%d",x->key);
		x = x->next;
		while(x != NULL&&j<22){
			printf(" ");
			printf("%d",x->key);
			x = x->next;
			j++;
		}
		printf("\n");
*/	}

	x = head;
	if(x!=tail)printf("%d",x->key);
	x = x->next;
	while(x != tail){
		printf(" ");
		printf("%d",x->key);
		x = x->next;
	}
	printf("\n");

	return 0;
}

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

using namespace std;
	
const int maxn = 1e2 + 20;
int ar[maxn];

int main()
{
	string s;
	cin >> s;
	int b=1,maxx=10000;
	char a;
	bool c=0,ans=0;
	for(int i=0;i<s.size();i++)
		if(s[i] != s[i+1] && i!=s.size()-1)
			ans=1;
	
	if(ans == 0)
	{
		cout << 0;
		return 0;
	}
	for(int k=0;k<26;k++)
	{
		string b=s;
		a='a'+k;
		for(int i=1;i<b.size();i++)
		{
			for(int j=0;j<b.size()-i;j++)
			{
				if(b[j+1] == a || b[j] == a)
				{
					b[j]=a;
				}
				else c=1;
			}
			if(c == 0)
			{
				maxx=min(i,maxx);
				break;
			}
			else c=0;
		}
	}
	cout << maxx;
}		

 



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n;
	cin>>n;
	vl vec(n);
	cin>>vec;
	vl dp(n);
	dp[0]=0;
	dp[1]=Abs(vec[1]-vec[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+Abs(vec[i]-vec[i-1]),dp[i-2]+Abs(vec[i]-vec[i-2]));
	}
	cout<<dp[n-1]<<endl;
	
	
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
 
}

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

    if temp != 1:
        arr.append([temp, 1])

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

    return arr


N = int(input())
MOD = 10 ** 9 + 7
x = dict()
for i in range(N, 1, -1):
    for f in factorization(i):
        if not f[0] in x:
            x[f[0]] = 1
        x[f[0]] += f[1]
ans = 1
for i in x.values():
    ans *= i
print(ans % MOD)


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

#define LL      long long
#define pb      push_back
#define inf     111111111111111
#define READ    freopen("in.txt", "r", stdin)
#define WRITE   freopen("out.txt", "w", stdout);

LL GCD(LL a, LL b)
{
    if(a == 0)
        return b;
    return GCD(b%a, a);
}

LL LCM(LL a, LL b)
{
    return (a*b)/ GCD(a, b);
}

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

    LL mulToA = (a-1)/c + (a-1)/d - (a-1)/ LCM(c, d);
    LL mulToB = b/c + b/d - b/LCM(c, d);

    //cout << mulToA << " " << mulToB << endl;

    LL mulFromAToB = mulToB - mulToA;

    //cout << mulFromAToB << endl;

    LL ans = b - a + 1 - mulFromAToB;

    cout << ans << endl;

    return 0;
}


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

int main(void){
   string s,t;
   cin>>s>>t;
   int c=0;
   int si=s.size();
   rep(i,s.size()){
       if(s[i]!=t[i])c++;
   }
   cout<<c<<endl;
}

Measured memory_bytes: 3848
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if(x==y) cout << "Draw" << endl;
  else if(y==1) cout << "Bob" << endl;
  else if(x==1) cout << "Alice" << endl;
  else if(x<y) cout << "Bob" << endl;
  else if(x>y) cout << "Alice" << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   if(s=="SUN")
        cout<<7<<endl;
   else if(s=="MON")
    cout<<6<<endl;
   else if(s=="TUE")
    cout<<5<<endl;
   else if(s=="WED")
    cout<<4<<endl;
    else if(s=="THU")
    cout<<3<<endl;
    else if(s=="FRI")
    cout<<2<<endl;
    else if(s=="SAT")
    cout<<1<<endl;
    return 0;
}


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

int main()
{
	int n,m;
	cin >> n >> m;
	int A[n][m],b[m];
	int c[n];
	
	for(int i = 0;i < n;i++)
		c[i] = 0;
		
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			cin >> A[i][j];
		}
	}
	
	for(int i = 0;i < m;i++)
		cin >> b[i];
		
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			c[i] += A[i][j] * b[j];
		}
	}
	
	for(int i = 0;i < n;i++)
		cout << c[i] << endl;

		return 0;
}

Measured memory_bytes: 3132
import java.util.Scanner;

import java.math.BigInteger;

class Main

{

	public static void main(String[] args)

	{

		Scanner cin=new Scanner(System.in);


		BigInteger a,b,c,d;

		BigInteger q,w,e,r,s;
		a=cin.nextBigInteger();
		b=cin.nextBigInteger();
		c=cin.nextBigInteger();
		d=cin.nextBigInteger();
		q=a.multiply(c);
		w=a.multiply(d);
		e=b.multiply(c);
		r=b.multiply(d);
        BigInteger ans;
        ans=q.max(w);
        ans=ans.max(e);
        ans=ans.max(r);
      s=BigInteger.valueOf(0);
       if(a.compareTo(s)<=0&&b.compareTo(s)>=0||c.compareTo(s)<=0&&d.compareTo(s)>=0) 
        {
        	if(ans.compareTo(s)<=0) ans=s;
       }
        System.out.println(ans);


	}



}


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

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

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

	int countW = 0, countB = 0;
	for (size_t i = 1; i < s.length(); ++i) {
		if (s[i] != s[i - 1]) {
			if (s[i] == 'B') {
				countB++;
			}
			else {
				countW++;
			}
		}
	}
	
	cout << countB + countW << endl;
	return 0;
}

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

const int MAX_X = 1e3 + 10;
const ll INF = 1e14;

int main(){
    ll X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y) , C(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    vector<ll> D;
    priority_queue<ll> PQ;
    rep(i, X) rep(j, Y) D.push_back(A[i] + B[j]);
    sort(D.begin(), D.end(), greater<ll>());
    D.resize(min(X * Y, K));
    ll W = D.size();
    rep(i, W) rep(j, Z) PQ.push(D[i] + C[j]);

    rep(i, K){
        ll ans = PQ.top(); PQ.pop();
        cout << ans << endl;
    }

}

Measured memory_bytes: 43368
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> L = new ArrayList<Integer>();
		for(int i = 0; i < N;i++) {
			int num = sc.nextInt();
			L.add(num);
			}
		int max = L.get(0);
//		リスト内の最大値をとる
		for (int i = 1; i <L.size(); i++) {
		    int v = L.get(i);
		    if (v > max) {
		        max = v;
		    }
		}

//		System.out.println(max);
//		System.out.println(sum);
		int sum = 0;
		for(int i = 0; i < L.size();i++) {
			sum = sum + L.get(i);
		}
		sum = sum - max;
		if(sum > max) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
//		System.out.println(sum);
//		System.out.println(max);
//		System.out.println(L);
//		String A = sc.next();
//1 8 10 5 8 12 34 100 11 3
//		double answer = T/X;
//
//		 String str = BigDecimal.valueOf(answer).toPlainString();
//
//
//		 System.out.println(answer);
	}
}


Measured memory_bytes: 21972
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b;

signed main(){
    io();

    in(a,b);
    out(a+b/2);

    return 0;
}


Measured memory_bytes: 888
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            double a = Double.parseDouble(in.next());
            double b = Double.parseDouble(in.next());
            double x = Double.parseDouble(in.next());
            double ans = 0;
            x /= a;

            if (x > (a * b) / 2) {
                ans = Math.atan2((a * b - x) * 2, a * a) * 180 / Math.PI;
            } else {
                ans = Math.atan2(b * b, x * 2) * 180 / Math.PI;
            }

            // 出力
            out.printf("%.10f\n", ans);

        }

    }
}



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

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

    ll n, q, t, l, r, a;
    cin >> n >> q;
    fenwick_tree<ll> fw(n);
    rep(i, n) {
        cin >> a;
        fw.add(i, a);
    }
    rep(i, q) {
        cin >> t >> l >> r;
        if (t==0) {
            fw.add(l, r);
        } else {
            cout << fw.sum(l, r) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let x = line[0];
    let y = line[1];
    let z = line[2];
    let k = line[3];

    let mut A: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut B: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut C: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    A.sort_by(|a,b| b.cmp(a));
    B.sort_by(|a,b| b.cmp(a));
    C.sort_by(|a,b| b.cmp(a));
    let mut used = HashSet::new();
    let mut heap = BinaryHeap::new();
    heap.push((A[0] + B[0] + C[0], (0, 0, 0)));

    let mut count = 0;
    while count < k {
        let (ans, tup) = heap.pop().unwrap();
        if used.contains(&tup) {
            continue;
        }
        used.insert(tup);
        println!("{}", ans);
        count += 1;
        if tup.2 + 1 < z {
            heap.push((A[tup.0] + B[tup.1] + C[tup.2 + 1], (tup.0, tup.1, tup.2 + 1)));
        }
        if tup.1 + 1 < y {
            heap.push((A[tup.0] + B[tup.1 + 1] + C[tup.2], (tup.0, tup.1 + 1, tup.2)));
        }
        if tup.0 + 1 < x {
            heap.push((A[tup.0 + 1] + B[tup.1] + C[tup.2], (tup.0 + 1, tup.1, tup.2)));
        }
    }    
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val (K, X) = readInputLine().split(" ").map{it.toInt()}
    
    for (i in X - (K - 1)..X + (K - 1)) {
        print(i)
        if (i != X + (K - 1)) {
            print(" ")
        }
    }
    
    println("")
}

fun readInputLine(): String {
    return readLine()!!
}


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

namespace abc64
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int max = 0;
            int min = 1000;
            for (int i = 0; i < N; i++)
            {
                int temp = int.Parse(str[i]);
                max = Math.Max(max, temp);
                min = Math.Min(min, temp);
            }
            Console.WriteLine(max - min);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

string solve( string s ) {
	if( s == "0" || s == "1" ) return s;
	rep(i, s.length()) {
		if(s[i] == '(') {
			int p = i+1;
			int shell = 0;
			while(p<s.length()) {
				if(s[p]==')') {
					shell--;
					if(shell==-1) break;
				}
				else if(s[p]=='(') {
					shell++;
				}
				p++;
			}
			string ss = solve(s.substr(i+1, p-i-1));
			s.replace(i, p-i+1, ss);
		}
	}

	rep(i, s.length()) {
		if(s[i] == '*') {
			string sa = solve(s.substr(0, i));
			string sb = solve(s.substr(i+1));
			s = (sa=="1" && sb=="1") ? "1" : "0";
		}
		else if(s[i] == '+') {
			string sa = solve(s.substr(0, i));
			string sb = solve(s.substr(i+1));
			s = (sa=="0" && sb=="0") ? "0" : "1";
		}
		else if(s[i] == '-' && i+1<s.length() && s[i+1]=='>') {
			string sa = solve(s.substr(0, i));
			string sb = solve(s.substr(i+2));
			s = (sa=="1" && sb=="0") ? "0" : "1";
		}
	}
	rep(i, s.length()) {
		if(s[i] == '-') {
			string ss = solve(s.substr(i+1));
			s = (ss=="0" ? "1" : "0");
		}
	}
	return s;
}

int main() {
	string in;
	while(cin >> in, in!="#") {
		string aa, ab;
		rep(i, in.length()) {
			if( in[i] == 'T' ) {
				in[i] = '1';
			}
			else if( in[i] == 'F' ) {
				in[i] = '0';
			}
		}
		rep(i, in.length()) {
			if( in[i] == '=' ) {
				aa = in.substr(0, i);
				ab = in.substr(i+1);
				break;
			}
		}
		bool ng = false;
		rep(i, (1<<11)) {
			string a=aa, b=ab;
			rep(j, a.length()) {
				if('a'<=a[j] && a[j]<='k') {
					a[j] = '0' + ((i & (1<<(a[j]-'a'))) ? 1 : 0);
				}
			}
			rep(j, b.length()) {
				if('a'<=b[j] && b[j]<='k') {
					b[j] = '0' + ((i & (1<<(b[j]-'a'))) ? 1 : 0);
				}
			}
			a = solve(a);
			b = solve(b);
			if( a != b ) {
				cout << "NO" << endl;
				ng = true;
				break;
			}
		}
		if( !ng ) {
			cout << "YES" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1980
N,M,K=map(int,input().split())

mod=998244353

fact=[1 for i in range(N+1)]
for i in range(1,N):
    fact[i+1]=(fact[i]*(i+1))%mod

def nCk(n,k):
    return fact[n]*pow(fact[n-k]*fact[k],mod-2,mod)

result=0
for k in range(K+1):
    result+=nCk(N-1,k)*M*pow(M-1,N-k-1,mod)
    result=int(result)%mod
print(result)

Measured memory_bytes: 81088
#include<bits/stdc++.h>
//#pragma GCC target ("avx")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

template<class T>
struct RollingHash{
	int Base=283;
	const int MOD1=1e9+7,MOD2=1e9+9;
	vector<int>hash1,hash2,power1,power2;
	RollingHash(T s){
		int sz=s.size();
		hash1.resize(sz+1,0);hash2.resize(sz+1,0);
		power1.resize(sz+1,1);power2.resize(sz+1,1);
		rep(i,sz){
			hash1[i+1]=(hash1[i]*Base+s[i])%MOD1;
			hash2[i+1]=(hash2[i]*Base+s[i])%MOD2;
			power1[i+1]=power1[i]*Base%MOD1;
			power2[i+1]=power2[i]*Base%MOD2;
		}
	}
	P get(int l,int r){
		return P((hash1[r]-hash1[l]*power1[r-l]+MOD1)%MOD1,(hash2[r]-hash2[l]*power2[r-l]+MOD2)%MOD2);
	}
	int lcp(int x,int y){
		int len=min(hash1.size()-1-y,hash1.size()-1-x);
		int ok=0,ng=len+1;
		while(ng-ok>1){
			int mid=(ok+ng)/2;
			if(get(x,x+mid)==get(y,y+mid))ok=mid;
			else ng=mid;
		}
		return ok;
	}
};

int N;
string S[200005];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N;
	rep(i,N){
		cin>>S[i];reverse(all(S[i]));
	}
	map<P,int>has;
	int ans=0;
	int cnt[26];
	rep(i,N){
		RollingHash<string>RH(S[i]);
		has[P(RH.hash1[len(S[i])],RH.hash2[len(S[i])])]++;
	}
	rep(i,N){
		RollingHash<string>RH(S[i]);
		memset(cnt,0,sizeof(cnt));
		for(char c:S[i])cnt[c-'a']++;
		rep(j,26)if(cnt[j]){
			P p=P((int)('a')+j,(int)('a'+j));
			if(has.find(p)!=has.end())ans+=has[p];
		}
		rep(j,len(S[i])){
			cnt[S[i][j]-'a']--;
			rep(k,26){
				if(cnt[k]){
					int m1=(RH.hash1[j+1]*RH.Base+(int)('a'+k))%RH.MOD1;
					int m2=(RH.hash2[j+1]*RH.Base+(int)('a'+k))%RH.MOD2;
					if(has.find(P(m1,m2))!=has.end())ans+=has[P(m1,m2)];
				}
			}
		}
	}
	cout<<ans-N<<endl;
}


Measured memory_bytes: 42008
m = gets.to_i

m.times do
  cars = gets.strip
  #p cars

 
  finals = {}
  ncars = cars.length

  for k in (1...ncars)
    cars0 = cars[0, k]
    cars1 = cars[k, ncars - k]
    # p [cars0, cars1]

    rcars0 = cars0.reverse
    rcars1 = cars1.reverse

    finals[ cars0 +  cars1] = 1
    finals[rcars0 +  cars1] = 1
    finals[ cars0 + rcars1] = 1
    finals[rcars0 + rcars1] = 1
    finals[ cars1 +  cars0] = 1
    finals[rcars1 +  cars0] = 1
    finals[ cars1 + rcars0] = 1
    finals[rcars1 + rcars0] = 1
  end

  puts finals.keys.length
end



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

using namespace std;

int main() {
    int n;
    cin >> n;
    n%=10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon";
    } else if (n == 8 || n == 6 || n == 1 || n == 0) {
        cout << "pon";
    } else {
        cout << "bon";
    }
    return 0;
}

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

const int maxn = 1e5 + 7 ;

vector < int > g[ maxn ] ;
vector < bool > visited( maxn , false ) ;
vector < int > s_num( maxn ) ;


void dfs ( int u , int set )
{
    visited[u] = true ;
    s_num[u] = set ;
    for (  int j = 0 ; j < g[u] .size() ; j++  )
    {
        int v = g[u][j];
         if ( ! visited[v] )
         {
             dfs ( v , set );
         }
    }
}


int main ( )
{
     int n , m , set = 0 ;
     cin >> n >> m ;
     vector < int > a ( n ) ;
    
     for ( int i = 0 ; i < n ; i++ )
     {
         cin >> a[i] ; 
     }
    
    for ( int i = 0 ; i < m ; i++ )
    {
        int x , y ;
        cin >> x >> y;
        g[x].push_back( y ) ;
        g[y].push_back( x ) ;
    }
    
    int ss = 1 ;
    for ( int i = 1 ; i <= n ; i++ )
    {
        if ( !visited [ i ] )
        {
            dfs ( i , ss ) ;
            ss++;
        }
    }
    int ans = 0 ;
    for ( int i = 0 ; i < n ; i++ )
    {
        if ( s_num [ i + 1 ] == s_num[ a[i] ] || a[i] == i+1 )
        {
            ans++ ;
        }
    }
    cout << ans << endl ;
    return 0 ;
}

Measured memory_bytes: 9600