akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

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

int main() {
    int A, B;
    cin >> A >> B;
    cout << 6-A-B << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
using lli = long long int;

typedef struct pii{
  lli a, b;
}pii;

int main(){
  lli n, t, s;
  std::cin >> n >> t >> s;
  vector<pii> info(n);
  vector<vector<lli> > ans(n + 1, vector<lli>(t + 1, 0));
  for (int i = 0; i < n; i++) {
    lli a, b;
    std::cin >> a >> b;
    info[i] = (pii){a, b};
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= t; j++) {
      if(j < t) ans[i][j + 1] = max(ans[i][j + 1], ans[i][j]);
      ans[i + 1][j] = max(ans[i + 1][j], ans[i][j]);
      
      if(j < s and s < j + info[i].b)continue;
      if(j + info[i].b > t)continue;
      ans[i + 1][j + info[i].b] = max(ans[i + 1][j + info[i].b], ans[i][j] + info[i].a);
    }
  }
  std::cout << ans[n][t] << std::endl;
  return 0;
}




Measured memory_bytes: 73364
N,X = map(int,input().split())
L = list(map(int,input().split()))

x_ball = 0
out_flg = 0

for t in range(N):
    x_ball += L[t]
    if x_ball > X:
        out_flg = 1
        break

print(t+1 if out_flg == 1 else t+2)

Measured memory_bytes: 3060
#include<iostream>
#include<map>

using namespace std;

int main(){
  int N,M;
  map <int,int> count{};
  cin >> N >> M;
  for(int i = 0; i < N; i++){
    int k;
    cin >> k;
    for(int j = 0;j < k; j++){
      int a;
      cin >> a;
      count[a]++;
    }
  }
  
  int ans = 0;
  for(int i =1; i <= M; i++){
    if(count[i] == N) ans++;
  }
cout << ans;
}


Measured memory_bytes: 256
from math import factorial

n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

n1 = v.count(v[a - 1])
n2 = v[:a].count(v[:a][a - 1])

print(sum(v[:a]) / a)
if len(set(v[:a])) != 1:
	if n1 == n2:
		print(1)
	else:
		print(int(factorial(n1) / (factorial(n2) * factorial(n1 - n2))))
else:
	ans = 0
	if n1 == 1:
		print(1)
	else:
		for i in range(a, min(n1 + 1, b + 1)):
			ans += int(factorial(n1) / (factorial(i) * factorial(n1 - i)))
		print(int(ans))


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

int main(){
  int t;
  int weight[10];
  int point[4][13];
  int s[5],n[5];
  int kind[4][13];
  string card;
  bool flag;
  bool f = false;

  while(cin >> t){
    if(f)cout << endl;
    f = true;

    for(int i=0;i<4;i++){
      for(int j=0;j<13;j++)cin >> point[i][j];
    }
    weight[0] = 0;
    for(int i=1;i<10;i++)cin >> weight[i];
    
    while(t--){
      for(int i=0;i<4;i++){
	for(int j=0;j<13;j++)kind[i][j] = false;
      }
      int ans = 0;
      for(int i=0;i<5;i++){
	cin >> card;
	if(card[0] == 'A')n[i] = 1;
	else if(card[0] == 'T')n[i] = 10;
	else if(card[0] == 'J')n[i] = 11;
	else if(card[0] == 'Q')n[i] = 12;
	else if(card[0] == 'K')n[i] = 13;
	else n[i] = card[0] - '0';

	if(card[1] == 'S')s[i] = 0;
	else if(card[1] == 'C')s[i] = 1;
	else if(card[1] == 'H')s[i] = 2;
	else if(card[1] == 'D')s[i] = 3;

	kind[s[i]][n[i]-1] = true;
	ans += point[s[i]][n[i]-1];
      }

      flag = false;
      int flash = -1;
      int c = 9;

      if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3] && s[3] == s[4])flash = s[0];

      //loyal straight flash
      if(flash>=0){
	if(kind[flash][0] && kind[flash][9] && kind[flash][10] && kind[flash][11] && kind[flash][12])flag = true;
      }
      if(!flag){
	c--;
	//straight flash
	if(flash>=0){
	  for(int j=0;j<9;j++){
	    if(kind[flash][j] && kind[flash][j+1] && kind[flash][j+2] && kind[flash][j+3] && kind[flash][j+4])flag = true;
	  }
	}
	if(!flag){
	  c--;
	  //four card
	  sort(n,n+5);
	  if(n[0] == n[1] && n[1] == n[2] && n[2] == n[3])flag = true;
	  if(n[1] == n[2] && n[2] == n[3] && n[3] == n[4])flag = true;
	  if(!flag){
	    c--;
	    //full house
	    if(n[0] == n[1] && n[1] == n[2] && n[3] == n[4])flag = true;
	    if(n[0] == n[1] && n[2] == n[3] && n[3] == n[4])flag = true;
	    if(!flag){
	      c--;
	      //flash
	      if(flash>=0)flag = true;
	      if(!flag){
		c--;
		//straight
		if(n[0] == n[1]-1 && n[1] == n[2]-1 && n[2] == n[3]-1 && n[3] == n[4]-1)flag = true;
		if(n[0] == 1 && n[1] == 10 && n[2] == 11 && n[3] == 12 && n[4] == 13)flag = true;
		if(!flag){
		  c--;
		  //three card
		  if(n[0] == n[1] && n[1] == n[2])flag = true;
		  if(n[1] == n[2] && n[2] == n[3])flag = true;
		  if(n[2] == n[3] && n[3] == n[4])flag = true;
		  if(!flag){
		    c--;
		    //two pair
		    if(n[0] == n[1] && n[2] == n[3])flag = true;
		    if(n[0] == n[1] && n[3] == n[4])flag = true;
		    if(n[1] == n[2] && n[3] == n[4])flag = true;
		    if(!flag){
		      c--;
		      if(n[0] == n[1])flag = true;
		      if(n[1] == n[2])flag = true;
		      if(n[2] == n[3])flag = true;
		      if(n[3] == n[4])flag = true;
		      if(!flag)c--;
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
      cout << ans * weight[c] << endl;
    }

  }
}

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

bool b[200][200];
int n;
int ask(int i, int j) {
	string s = string(n, '0');
	s[i] = '1'; s[j] = '1';
	cout << "? " << s << endl;
	int res; cin >> res;
	return res;
}
int main() {
	cin >> n;
	int cnt = 0;
	rep(i, n)for (int j = i + 1; j < n; j += 2) {
		if (cnt == n - 1)break;
		string s(n, '0'); s[i] = '1'; s[j] = '1';
		if (j + 1 < n)s[j + 1] = '1';
		cout << "? " << s << endl;
		int res; cin >> res;
		if (res == 0)continue;
		else {
			if (j + 1 == n) {
				b[i][j] = 1; cnt++; continue;
			}
			if (ask(i, j)) {
				b[i][j] = 1; cnt++;
			}
			if (ask(i, j + 1)) {
				b[i][j + 1] = 1; cnt++;
			}
		}
	}
	cout << "!";
	rep(i, n)for (int j = i + 1; j < n; j++) {
		if (b[i][j]) {
			cout << " ";
			cout << "(" << i << "," << j << ")";
		}
	}
	cout << endl;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,m,i,j,c=0;
	cin>>n>>m;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		ll a;
		cin>>a;v.push_back(a);c=c+a;
		}	
		sort(v.rbegin(),v.rend());
		ll x=(c/(4*m));
	//	ll x=ceil(c/(4*m));
	if(c-x*4*m>0) x++;
		if(v[m-1]>=x)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
}


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

int main(){
    int a,b;
    cin >> a >>b;
    string aa = to_string(a);
    string bb = to_string(b);
    string ai, bi;
    for (int i = 0; i < b ; i++){
        ai += aa;
    }
    for (int i = 0; i < a ; i++){
        bi += bb;
    }

    if(ai < bi){
        cout << ai << endl;
    }else if (ai == bi ){
        cout << bi << endl;
    }else {
        cout << bi << endl;
    }
}

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

int main(int argc, char *argv[]) {
    int K;
    std::cin >> K;
    int x=7%K;

    std::set<int> st;
    int i=1;
    while(st.count(x)==0) {

        if(x==0) {
            std::cout << i;
            return 0;
        }

        st.insert(x);
        x = (x*10+7)%K;
        i++;
    }
    std::cout << -1;
    return 0;
}

Measured memory_bytes: 50440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define VI  vector<ll>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
const ll mod=1e9+7;
double pi = 2 * acos(0.0);
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
bool cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return (a.first)<(b.first);
}
ll power(ll a,ll b)
{
        ll p=1;
        for(ll i=1;i<=b;i++)
        p*=a;

        return p;
}
ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
 }
void bfs(map<ll,vector<ll> > &g,ll src,vector<ll> &c)
{
    queue<ll> q;
    map<ll,ll> p;
    q.push(src);
    p[src]=src;
    c[src]=1;
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        ll i=1;
        for(auto v:g[u])
        {
            if(c[v]==-1)
            {
                q.push(v);
                p[v]=u;
                if(i==c[u]||i==c[p[u]])
                    i++;
                if(i==c[u]||i==c[p[u]])
                    i++;
                c[v]=i;
                i++;
            }
        }
    }
}
int main()
{
    FASTIO;
    ll n,i,k,j;
    cin>>n>>k;
    ll a[n],dp[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    //for(i=0;i<n;i++) cout<<dp[i]<<" ";
    //cout<<endl;
    cout<<dp[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1792
use std::io;
use std::cmp::max;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let iter = buf.split_whitespace();
    let mut v: Vec<T> = Vec::new();
    for i in iter {
        v.push(i.parse().ok().unwrap());
    }
    v
}

fn main() {
    let v:Vec<u64> = procon_read();
    let n = v[0]; let m = v[1]; let k = v[2];
    
    let a:Vec<u64> = procon_read();
    let mut S_a:Vec<u64> = Vec::new();
    S_a.push(0);
    for i in 0..n as usize {
        S_a.push(S_a[i]+a[i]);
    }
    
    let b:Vec<u64> = procon_read();
    let mut S_b:Vec<u64> = Vec::new();
    S_b.push(0);
    for i in 0..m as usize {
        S_b.push(S_b[i]+b[i]);
    }
    
    let mut cnt:usize = 0;
    let mut j:usize = m as usize;
    for i in 0..(n+1) as usize {
        if S_a[i] > k {
            break;
        }
        while S_b[j] > k - S_a[i] {
            j -= 1;
        }
        cnt = max(cnt, i+j);
    }     
    println!("{}", cnt);
}

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

using namespace std;

struct random_class {
	struct xorshift {
		using result_type = unsigned int;
		result_type x=123456789u,y=362436069u,z=521288629u,w;
		static constexpr result_type min() {return 0u;}
		static constexpr result_type max() {return UINT_MAX;}
		xorshift(result_type a) : w(a) {}
		result_type operator()() {
			result_type t;
			t = x ^ (x << 11);
			x = y; y = z; z = w;
			return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
		}
	};
	random_device rd;
	xorshift xor128;
	random_class() : rd(), xor128(rd()) {}
	random_class(unsigned int seed) : rd(), xor128(seed) {}
	double make_random(double min_v, double max_v) { return uniform_real_distribution<double>(min_v, max_v)(xor128);}
};

random_class R;

template<class T>
struct Treap {
	struct node {
		T val;
		double pri;
		node *lch, *rch;
		int cnt;
		node(T v) : val(v), lch(nullptr), rch(nullptr), cnt(1) {
			pri = R.make_random(DBL_MIN, DBL_MAX);
		}
	};
	node* top;
	Treap(node* t = nullptr) : top(t) {}
	node* update(node* n) {
		n->cnt = count(n->lch) + count(n->rch) + 1;
		return n;
	}
	inline int count(node* n) {
		return !n ? 0 : n->cnt;
	}
	node* merge(node* l, node* r) {
		if (!l || !r) return !l ? r : l;
		if (l->pri > r->pri) {
			l->rch = merge(l->rch, r);
			return update(l);
		} else {
			r->lch = merge(l, r->lch);
			return update(r);
		}
	}
	pair<node*, node*> split(node* t, int k) {
		if (!t) return make_pair(nullptr, nullptr);
		if (k <= count(t->lch)) {
			pair<node*, node*> s = split(t->lch, k);
			t->lch = s.second;
			return make_pair(s.first, update(t));
		} else {
			pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
			t->rch = s.first;
			return make_pair(update(t), s.second);
		}
	}
	void insert(const T&& val) {
		int pos = 0;
		node* n = top;
		while (n) {
			if (val < n->val) n = n->lch;
			else pos += count(n->lch) + 1, n = n->rch;
		}
		auto t = split(top, pos);
		n = merge(t.first, new node(val));
		top = update(merge(n, t.second));
	}
	const T& at(int idx) {
		node* n = top;
		int sz;
		while ((sz = count(n->lch)) != idx) {
			if (sz + 1 <= idx) idx -= sz + 1, n = n->rch;
			else n = n->lch;
		}
		return n->val;
	}
	inline const int size() {
		return count(top);
	}
};

int main() {
	Treap<int> T;
	int N;
	cin >> N;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		int t; cin >> t;
		T.insert(t-i);
		v.push_back(t-i);
	}
	int b = T.at(N / 2);
	long long res = 0;
	for (auto x : v) {
		res += abs(x - b);
	}
	cout << res << endl;
}

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

int main()
{
	int k;
	cin >> k;
	queue < string > q;
	for (int i=1; i<=9; i++){
		string x;
		x.push_back(i+'0');
		q.push(x);
	}
	while (k > 1){
		string x = q.front();
		q.pop();
		char last = x.back() - '0';
		for (int i=max(0, last-1); i<=min(last+1, 9); i++){
			x.push_back(i+'0');
			q.push(x);
			x.pop_back();
		}
		k--;
	}
	cout << q.front() << endl;
}

Measured memory_bytes: 13568
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = long.Parse(spl[0]);
        var b = long.Parse(spl[1]);
        var x = long.Parse(spl[2]);

        double rad = Math.PI/2;

        var min = 0.0;
        var max = Math.PI;
        
        for(int i=0; i<10000; i++) {        
            rad = (min + max) / 2;

            double s = calc(a, b, rad);
            
            if (s < x) max = rad;
            else min = rad;
        }
        return rad * 180 / Math.PI;
    }

    static double calc(double a, double b, double rad) {
        double w = b * Math.Tan(Math.PI / 2 - rad);

        if (w <= a) {
            return b * b * Math.Tan(Math.PI / 2 - rad) / 2 * a;
        } else {
            return (a * a * b) - (a * a * Math.Tan(rad) / 2 * a);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b=0;
  int out=0,point=0;
  string c;
  cin>>a;
  while(true){
    if(a==0) break;
    cin>>c;
    if(c=="HIT"){
      b++;
      if(b==4){
	point++;
	b--;
      }
    }
    if(c=="OUT"){
      out++;
      if(out==3){
	a--;
	out=0;
	cout<<point<<"\n";
	point=0;
	b=0;
      }
    }
    if(c=="HOMERUN"){
      point=point+b+1;
      b=0;
    }
  }
}



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

using ll = long long;

const ll INF = 1001001001;

vector<vector<int>> to(100000);
vector<int> dp(100000, -1);

int dfs(int s) {
	if (dp[s] != -1) return dp[s];
	int res = 0;
	for (int t : to[s]) {
		res = max(res, (dp[t] != -1 ? dp[t] + 1 : dfs(t) + 1));
	}
	dp[s] = res;
	return res;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> in(N, 0);
	for (int i = 0; i < M; ++i) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		to[x].push_back(y);
		in[y]++;
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (in[i] == 0) {
			ans = max(ans, dfs(i));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 11136
#include<stdio.h>
int main(void)
{
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  int temp;
  int count=0;
  for(int i=0;i<n-1;i++)
  {
    for(int j=0;j<n-1;j++)
    {
      if(a[j]>a[j+1])
      {
        temp=a[j];
        a[j]=a[j+1];
        a[j+1]=temp;
        count++;
      }
    }
  }
  for(int i=0;i<n-1;i++)
  {
    printf("%d ",a[i]);
  }
  printf("%d",a[n-1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int a, b;
  cin >> a >> b;
  cout << max(a+b, max(2*a-1, 2*b-1)) << endl;
}

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

class RMQsub1{//隣接差が±1だけのRMQ
	std::vector<int> pattern;//ブロックがどのパターンか
	std::vector<std::vector<int> > minpos;//バイナリパターンに対する最小位置
	std::vector<int> dat;//葉でないノード
	std::vector<int> depth;
	int blocksize;
	int n;
	int query(int a,int b,int k,int l,int r)const{
		if(r<=a||b<=l)return -1;
		if(n-1<=k){//leaf
			if(pattern[k-(n-1)]==-1)return -1;
			int s=l<a?a-l:0;
			int t=r<=b?blocksize:b-l;
			return (k-(n-1))*blocksize+minpos[pattern[k-(n-1)]][s*blocksize+t-1];
		}else{
			if(a<=l&&r<=b)return dat[k];
			int vl=query(a,b,k*2+1,l,(l+r)/2);
			int vr=query(a,b,k*2+2,(l+r)/2,r);
			return vl!=-1&&(vr==-1||depth[vl]<depth[vr])?vl:vr;
		}
	}
public:
	RMQsub1(){}
	void build(std::vector<int> &a){
		depth=a;
		int n=a.size();
		int k=1;
		while((1<<k)<a.size())k++;
		blocksize=k-1;//log(n)/2
		if(blocksize==0)blocksize=1;
		int m=(n+blocksize-1)/blocksize;//num node
		while(m&m-1)m+=m&-m;
		this->n=m;
		dat.resize(m-1,-1);
		pattern.resize(n,-1);
		minpos.resize(1<<blocksize-1);
		for(int i=0;i<(n+blocksize-1)/blocksize;i++){
			int s=i*blocksize;
			int p=0;
			for(int j=1;j<blocksize&&s+j<n;j++){
				if(a[s+j-1]>a[s+j])p|=1<<j-1;
			}
			pattern[i]=p;
			int b=(i+1)*blocksize<=n?blocksize:n-i*blocksize;
			if(minpos[p].empty()){
				minpos[p].resize(blocksize*blocksize);
				for(int j=0;j<blocksize;j++){
					int d=0,pos=j,mind=0;
					minpos[p][j*blocksize+j]=pos;
					for(int k=j+1;k<blocksize;k++){	
						if(p>>k-1&1)d--;
						else d++;
						if(d<mind){
							mind=d;
							pos=k;
						}
						minpos[p][j*blocksize+k]=pos;
					}
				}
			}
			if(m==1)break;
			int par=(m-1+i-1)/2;
			if(dat[par]==-1 || a[i*blocksize+minpos[p][0+b-1]]<a[dat[par]])
				dat[par]=i*blocksize+minpos[p][0+b-1];
		}

		dat.resize(m-1);
		for(int i=(m-2)/2-1;i>=0;i--){
			int vl,vr;
			vl=dat[2*i+1];
			vr=dat[2*i+2];
			dat[i]=vr==-1||a[vl]<a[vr]?vl:vr;
		}
	}
	int query(int a,int b)const{//[a,b)の最小値
		return query(a,b,0,0,n*blocksize);
	}
};

class LCA{
	vector<int> eulertour;
	vector<int> vertex;
	//SparseTableRMQ rmq;
	//RMQ rmq;
	RMQsub1 rmq;
	void dfs(const vector<int> edge[],int n,vector<int> &depth,int d,int u){
		eulertour[u]=vertex.size();	
		vertex.push_back(u);
		depth.push_back(d);
		for(int i=0;i<edge[u].size();i++){
			dfs(edge,n,depth,d+1,edge[u][i]);
			vertex.push_back(u);
			depth.push_back(d);
		}
	}
public:
	LCA(const vector<int> edge[],int n,int root):eulertour(n){
		vector<int> depth;
		dfs(edge,n,depth,1,root);
		vertex.push_back(root);
		depth.push_back(0);
		rmq.build(depth);
	}
	int query(int u,int v)const{
		if(u==v)return u;
		if(eulertour[u]>eulertour[v])swap(u,v);
		return vertex[rmq.query(eulertour[u], eulertour[v])];
	}
};



vector<int> edge[100000];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int k,v;
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>v;
			edge[i].push_back(v);
		}
	}
	LCA lca(edge,n,0);
	int q,u,v;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>u>>v;
		cout<<lca.query(u,v)<<endl;
	}
	return 0;
}

Measured memory_bytes: 20504
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  double n,k;
  cin >> n >> k;

  double sum = 0;
  for(int i = 1; i <= n; i++) {
    int cnt = 0;
    int t = i;
    while(t < k) {
      t *= 2;
      cnt++;
    }
    sum += pow((double)1/2, cnt);
  }
  sum /= n;

  cout << fixed << setprecision(20) << sum << endl;
}


Measured memory_bytes: 4204
// Package main provides
//
// File:  e.go
// Author: ymiyamoto
//
// Created on Thu Jan 10 21:23:06 2019
//
package main

import (
	"fmt"
	"sort"
)

type item struct {
	w, v int
}

func min(slice ...int) int {
	sort.Ints(slice)
	return slice[0]
}

func main() {
	var N, W int
	fmt.Scan(&N, &W)
	items := make([]item, N)

	for i := range items {
		fmt.Scan(&items[i].w, &items[i].v)
	}

	dp := make([][]int, N+1)
	for i := range dp {
		dp[i] = make([]int, 1e5+1)
		for j := range dp[i] {
			dp[i][j] = 1 << 60
		}
	}
	dp[0][0] = 0

	for i := range items {
		w, v := items[i].w, items[i].v
		for j := range dp[i+1] {
			if j-v >= 0 {
				dp[i+1][j] = min(dp[i][j], dp[i][j-v]+w)
			} else {
				dp[i+1][j] = dp[i][j]
			}
		}
	}
	ans := 0

	for i := range dp[N] {
		if dp[N][i] <= W {
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 163172
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::string::*;
#[allow(unused_imports)]
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// fn gcd (x : i32, y : i32) -> i32 {
//     let mut a = x;
//     let mut b = y;
//     while(a > 0){
        

//     }
// }


fn main() {

input! {
    x: i32,
    y: i32,
}
let ans = if x%y==0 {-1} else {x};
println!("{}",ans);


}




Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  int n1 = a1.size();
  int n2 = a2.size();
  if (n1 != n2) {
    return n1 - n2;
  }
  for (int i=0; i<n1; i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if(a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

vector<vector<int>> all_comb(int n, int k) {
  vector<vector<int>> combs(nCr(n, k), vector<int>(k));
  for(int i=0; i<k; i++) {
    combs[0][i] = i;
    combs[1][i] = i;
  }
  
  for(long i=1; i<nCr(n, k); i++) {
    int p = 1;
    while(combs[i][k - p] == n - p) {
      p++;
      if(p > k) {
        break;
      }
    }
    combs[i][k - p]++;
    int q = combs[i][k - p];
    for(int j=1; j<p; j++) {
      combs[i][k - p + j] = q + j;
    }

    if(i < nCr(n, k) - 1) {
      for(int j=0; j<k; j++) {
        combs[i + 1][j] = combs[i][j];
      }
    }
  }

  return combs;
}

template <typename TYPE> void co(TYPE a) {
  cout << a << endl;
}

template <typename TYPE> void co_2(TYPE a, TYPE b) {
  cout << a << ' ' << b << endl;
}

template <typename TYPE> void co_l(vector<TYPE> as) {
  int n = as.size();
  for(int i=0; i<n; i++) {
    cout << as[i] << endl;
  }
}

template <typename TYPE> void co_s(vector<TYPE> as) {
  int n = as.size();
  for(int i=0; i<n; i++) {
    if(i > 0) {
      cout << ' ';
    }
    cout << as[i];
  }
  cout << endl;
}

int main() {
  std::cout << std::setprecision(9);
  long h;
  cin >> h;

  long n2 = 1;
  long ans = 0;
  while(n2 <= h) {
    ans += n2;
    n2 *= 2;
  }
  co(ans);
}

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

int main(){
    int n,i,l,max_l,sum_l=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>l;
        if(max_l<l) max_l=l;
        sum_l+=l;
    }
    max_l*2<sum_l ? cout<<"Yes" : cout<<"No";

    return 0;
}


Measured memory_bytes: 256
/*
int a[] = new int[n];
String line = br.readLine(); // to read multiple integers line
String[] strs = line.trim().split("\\s+");
for (int i = 0; i < n; i++) {
    a[i] = Integer.parseInt(strs[i]);
}*/

/*
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int arr[] = Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
*/



import java.util.*;
import java.io.*;
public class Main {
    public static void main (String[]args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        long a[] = Arrays.stream(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();


        if(a[0] == 1 || a[1] == 1) {
            System.out.println(1);
        }
        else{
            System.out.println((a[0]*a[1] + 1)/2);
        }
    }
}

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

int main(void){
  int N, X, T, a, b, c;
  cin >> N >> X >> T;
  
  a = N / X;
  b = N % X;
  
  if (b>0){
    a++;
  }
  
  c = a * T;
  
  cout << c << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

// Integers: Some functions are not defined for ll.
// return n! mod p
int fact(int n, int p = INT_MAX){
    static vector<int> memo(1, 1);
    if ((int) memo.size() <= n) {
        int l = memo.size();
        memo.resize(n+1);
        for(int i = l; i <= n; i++) memo[i] = (ll) memo[i-1] * i % p;
    }
    return memo[n];
}

//solve ax+by=gcd(a, b)
//return gcd(a, b)
int gcd(int a, int b, int* px = NULL, int* py = NULL){
    if(py == NULL){
        if(b == 0) return a;
        return gcd(b, a % b);
    }
    int d = a;
    if( b != 0){
        d = gcd(b, a % b, py, px);
        *py -= (a / b) * *px;
    }else{
        *px = 1; *py = 0;
    }
    return d;
}

// return a^(-1) mod m
int modInverse(int a, int m = MOD){
    int x, y;
    gcd(a, m, &x, &y);
    return (m + x % m) % m;
}

// return a mod p (when n!=a*p^e), o(log_p n)
int modFact(int n, int& e, int p = MOD){
    e = 0;
    if(n == 0) return 1;

    int res = modFact(n / p, e, p);
    e += n / p;

    if((n / p % 2 != 0)) return (ll) res * (p - fact(n % p, p)) % p;
    return (ll) res * fact(n % p, p) % p;
}

// return nPk mod p
int perm(int n, int k, int p = MOD){
    if(n < 0 or k < 0 or n < k) return 0;
    int e1, e2;
    int a1 = modFact(n, e1, p), a2 = modFact(n - k, e2, p);
    return (ll) a1 * modInverse(a2, p) % p;
}

// return nCk mod p, o(log_p n)
int comb(int n, int k, int p = MOD){
    if(n < 0 or k < 0 or n < k) return 0;
    int e1, e2, e3;
    int a1 = modFact(n, e1, p), a2 = modFact(k, e2, p), a3 = modFact(n - k, e3, p);
    if(e1 > e2 + e3) return 0;
    return (ll) a1 * modInverse((ll)a2 * a3 % p, p) % p;
}

// return nHk mod p
int hcomb(int n, int k, int p = MOD){
    if(n < 0 or k < 0) return 0;
    if(n == 0 and k == 0) return 1;
    return comb(n + k - 1, k, p);
}

int main(void){
    int N, M;
    cin >> N >> M;
    int res = 0;
    if(abs(N - M) == 1) res = (ll) fact(N, MOD) * fact(M, MOD) % MOD;
    else if(N == M) res = (ll) 2 * fact(N, MOD) * fact(M, MOD) % MOD;

    cout << res << '\n';
    return 0;
}

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

using namespace std;

long long mx[107][100007];
vector<int> w, v;
int n, m;

long long cal(int i, int remW) {
  if (mx[i][remW] != -1) return mx[i][remW];
  if (remW <= 0 || i == n) return 0;
  if (remW < w[i]) {
    return mx[i][remW] = cal(i + 1, remW);
  }
  return mx[i][remW] = max(cal(i + 1, remW), v[i] + cal(i + 1, remW - w[i]));
}

int main() {
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 100001; j++) {
      mx[i][j] = -1;
    }
  }
  scanf("%d %d", &n, &m);
  w = vector<int>(n, 0);
  v = vector<int>(n, 0);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &w[i], &v[i]);
  }
  cal(0, m);
  long long mxV = 0;
  for (int i = 0; i <= m; i++) {
    if (mxV < mx[0][i]) {
      mxV = mx[0][i];
    }
  }
  printf("%lld\n", mxV);
  
  return 0;
}

Measured memory_bytes: 80128
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
int dp[3030][3030];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    
    //dp[i][j]:sをi番目まで,tをj番目まで見た時のLCS
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
            else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }
    string res="";
    while(n&&m){
        if(dp[n][m]==dp[n-1][m])n--;
        else if(dp[n][m]==dp[n][m-1])m--;
        else{
            res+=s[n-1];
            n--;
            m--;
        }
    }
    reverse(All(res));
    cout<<res<<endl;
}

Measured memory_bytes: 71936
#include <iostream>
using namespace std;
int main() {
	string s;
	cin >> s;

	int counter[26];
	for(int i=0;i<26;i++){
		counter[i] = 0;
	}

	for(int j=0;j<s.size();j++){
		counter[s[j]-'a']++;
	}

	string ans = "yes";
	for(int i=0;i<26;i++){
		if(counter[i]>1){
			ans = "no";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll h, w;
    cin >> h >> w;

    vvl board1(h, vl(w));
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '#') {
                board1[i][j] = 1;
            }
        }
    }

    vvl board2(h);
    rep(j, w) {
        bool ok = false;
        rep(i, h) {
            if(board1[i][j]) {
                ok = true;
            }
        }
        if(ok) {
            rep(i, h) {
                board2[i].pb(board1[i][j]);
            }
        }
    }    

    rep(i, h) {
        bool ok = false;
        rep(j, board2[i].size()) {
            if(board2[i][j]) {
                ok = true;
            }
        }
        if(ok) {
            rep(j, board2[i].size()) {
                if(board2[i][j]) {
                    cout << '#';
                }
                else {
                    cout << '.';
                }
            }
            cout << "\n";
        }
    }
    
    re0;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

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

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	s, t := readString(), readString()
	a, b := readInt(), readInt()
	u := readString()
	switch {
	case strings.Index(s, u) >= 0:
		a--
	case strings.Index(t, u) >= 0:
		b--
	}
	fmt.Println(a, b)
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    vector<ll>time(5);
    cin >> n;
    REP(i,5)cin >> time[i];
    ll bottle_neck = 0;

    REP(i,5){
        bottle_neck = max(bottle_neck,(n-1)/time[i]);
    }

    cout << bottle_neck + 5 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	# b1 = a2 ^ a3 ^ a4
	# b1 ^ a2 = a3 ^ a4
	# b2 = a1 ^ a3 ^ a4
	# b2 ^ a1 = a3 ^ a4
	# b1 ^ a2 = b2 ^ a1
	# a1 = a3 ^ a4 ^ b2
	# b2 ^ a4 = b4 ^ a2
	# b2 = b4 ^ a2 ^ a4
	# a1 = b1 ^ b4 ^ a4
	# b1 = a1 ^ a2 ^ a3 ^ a4 ^ a1
	#    = b2 ^ a2 ^ a1
	#    = b2 ^ b3 ^ a4
	# a1 = b2 ^ b3 ^ b4
	sumxor = a[0]
	for i in range(1, n):
		sumxor ^= a[i]
	ans = []
	for i in range(n):
		ans.append(sumxor ^ a[i])
	print(*ans)

	


main()

Measured memory_bytes: 32264
#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>;

int INF = 1001001001;

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;
}

int main() {
    int h, n;
    cin >> h >> n;
    vector<vector<int>> dp(n+1, vector<int>(h+1));
    rep(i,n+1)rep(j,h+1) {
        dp[i][j] = INF;
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for (int j = 0; j <= h; j++) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+a, h)], dp[i+1][j] + b);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}


Measured memory_bytes: 42340
#include<iostream>
using namespace std;
int main() {
	int n;
	cin>>n;
	int t=n%10;
	if(t== 2||t== 4||t==5||t== 7||t==  9) {
		cout<<"hon"<<endl;
	} else if(t==0||t==1||t== 6||t== 8) {
		cout<<"pon"<<endl;
	} else if(t==3) {
		cout<<"bon"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << ((a <= c && c <= b)?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
X=int(input())

x=X%100
C=X//100

c=0
while(True):
    if(x>=5):
        x-=5
    else:
        x=0
    c+=1
    if(x==0):
        if(C>=c):
            print(1)
            exit()
        else:
            print(0)
            exit()


Measured memory_bytes: 2940
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
ans = 0
for i in range(N):
    ans += B[i]
    if i >= 1:
        if A[i] - A[i - 1] == 1:
            ans += C[A[i-1]-1]
print(ans)


Measured memory_bytes: 3064
inList = []
for i in range(5):
    inList.append(int(input()))
saigo = []
minCnt = 130
for i in inList:
    minx = int(i % 10)
    if minx != 0:
        minCnt = min(minCnt, minx)
    saigo.append(minx)
if minCnt == 130:
    minCnt = 0
minIdx = saigo.index(minCnt)
appx = inList.pop(minIdx)
inList.append(appx)
ans = 0
for i in range(len(inList)):
    ans += int(inList[i])
    if i != len(inList) - 1:
        amari = ans % 10
        if amari != 0:
            ans += + (10 - amari)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))



long long gcd(long long a, long long b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

double calculateDegree(double side, double B) {
	double radian = atan2(side, B);
	double degree = radian * (180.0 / 3.141592653589793238463);
	return degree;
}

int main() {
	double A = 0.0, B=0.0, X=0.0;
	cin >> A >> B >> X;
	double masterVolume = A * A * B;
	double volume = 0.0;
	double x2 = 0.0;
	double y2 = 0.0;
	if (X / masterVolume >= 0.5) {
		volume = masterVolume - X;
		x2 = A;
		y2 = volume / A / A * 2;
	}
	else {
		volume = X;
		x2 = volume / B / A * 2;
		y2 = B;
	}
	double degree = calculateDegree(y2, x2);
	cout << fixed << setprecision(10) << degree;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    forn(i, n) {
        int num = ('a' + 26 - s[i]) % 26;
        if (num <= k) {
            k -= num;
            s[i] = 'a';
        }
    }
    k %= 26;
    forn(i, k){
        if (s[n - 1] == 'z') s[n - 1] = 'a'; else s[n - 1]++;
    }
    cout << s << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3752
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
const int maxn(1e5+5);
ll n,l,q;
ll s[maxn],f[maxn][35];

void swap(ll &a,ll &b){int t=a;a=b;b=t;}
void init(){
	n=read();
	for (int i(1);i<=n;++i) s[i]=read();
	l=read(),q=read();
	for (int i(1);i<=n;++i) f[i][0]=upper_bound(s+1,s+n+1,s[i]+l)-s-1;
	for (int i(1);i<=30;++i)
		for (int j(1);j<=n;++j)
			f[j][i]=f[f[j][i-1]][i-1];
}

signed main(){
	init();
	while (q--){
		int a=read(),b=read(),tot=0;
		if (a>b) swap(a,b);
		int v=a;
		for (int i=30;~i;--i){
			if (f[v][i]<b){
				tot+=1<<i;
				v=f[v][i];
			}
		}
		printf("%d\n",tot+1);
	}
	return 0; 
}


Measured memory_bytes: 28928
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int sx, sy, tx, ty;
		int dx, dy;
		
		StringBuilder ans = new StringBuilder();
		
		sx = sc.nextInt();
		sy = sc.nextInt();
		tx = sc.nextInt();
		ty = sc.nextInt();
		
		sc.close();
		
		
		dx = tx - sx;
		dy = ty - sy;
		
		for(int j = 0; j < 2; ++j) {
			for(int i = 0; i < dy; ++i)ans.append('U');
			for(int i = 0; i < dx; ++i)ans.append('R');
			if(j == 1) {
				ans.append('D');
				ans.append('R');
			}
			for(int i = 0; i < dy; ++i)ans.append('D');
			for(int i = 0; i < dx; ++i)ans.append('L');
			if(j == 0) {
				ans.append('L');
				++dx;
				++dy;
			}
			else {
				ans.append('U');
			}
		}
		
		String ans2 = new String(ans);
		
		System.out.println(ans2);
	}

}


Measured memory_bytes: 22868
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 100000;
int N,A[maxn+1],B[maxn]; ll ans;
int main() {
    scanf("%d",&N); for (int i = 0;i < N+1;i++) scanf("%d",&A[i]);
    for (int i = 0;i < N;i++) scanf("%d",&B[i]);
    for (int i = 0,tmp;i < N;i++) {
        tmp = min(A[i],B[i]); ans+=tmp; B[i]-=tmp; A[i]-=tmp;
        if (B[i]) tmp = min(A[i+1],B[i]),ans+=tmp,A[i+1]-=tmp,B[i]-=tmp;
    }
    printf("%lld\n",ans);
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll A, B, M;
    cin >> A >> B >> M;
    std::vector<ll> a(A);
    std::vector<ll> b(B);
    rep(i, A) {
        cin >> a[i];
    }
    rep(i, B) {
        cin >> b[i];
    }
    ll ans = (*min_element(ALL(a)))+(*min_element(ALL(b)) );
    ll x[M], y[M], c[M];
    rep(i, M) {
        cin >> x[i] >> y[i] >> c[i];
    }

    std::vector<ll> v;
    rep(i, M) {
        v.push_back(a[x[i]-1]+b[y[i]-1]-c[i]);
    }
    Sort(v);
    cout << min(ans, v.at(0) ) << endl;
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	long long ans = 0;
	for(int i=1;i <= N;++i){
		if(i % 3 == 0) continue;
		if(i % 5 == 0) continue;
		ans += i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>

using namespace std;

#define NMAX 123456

int main(){

	bool zaru[NMAX*2+1];
	int n,c;

	for(int i=0;i<NMAX*2+1;i++){
		zaru[i]=true;
	}
	zaru[0]=false;
	zaru[1]=false;

	for(int i=0;i<NMAX*2+1;i++){
		if(zaru[i]){
			for(int j=i*2;j<NMAX*2+1;j+=i){
				zaru[j]=false;
			}
		}
	}

	while(1){

		cin>>n;
		if(n==0) break;

		c=0;
		for(int i=n+1;i<=2*n;i++){
			if(zaru[i]) c++;
		}
		cout<<c<<endl;
	}
}

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

int main(){
  int n,m,t;
  cin>>n>>m>>t;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];

  int cnt=a[0]-m;
  for(int i=1;i<n;i++){
    int diff=a[i]-a[i-1];
    int study=diff-2*m;
    if(study>0) cnt+=study;
  }
  int study=t-a[n-1]-m;
  if(study>0) cnt+=study;

  cout<<cnt<<endl;
}
  


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int k = sc.nextInt();

			int headNum = 1;			
			int digit = 1;

			while (true) {

				findRun(headNum, digit, new StringBuilder(), k);

				if ( count < k ) {
					if ( headNum == 9 ) {
						headNum = 1;
						digit++;
					}
					else {
						headNum++;
					}
				}
				else {
					break;
				}
			}
		}
	}
	
	private static int count = 0;
	
	private static void findRun(int headNum, int digit, StringBuilder sb, int k) {
		sb.append(headNum);
		
		if ( digit == 1 ) {
			count++;
			if ( count == k ) {
				System.out.println(sb.toString());
			}
			return;
		}

		if ( headNum > 0 ) {
			findRun(headNum-1,digit-1, new StringBuilder(sb), k);
		}
		
		findRun(headNum, digit-1, new StringBuilder(sb), k);

		if ( headNum < 9 ) {
			findRun(headNum+1, digit-1, new StringBuilder(sb), k);
		}

	}

}

Measured memory_bytes: 42148
#include <stdio.h>

int main()
{
	int cur = 1;

	int A, B;

	scanf("%d %d", &A, &B);

	for (int i = 0; i <= 100; ++i)
	{
		if (cur >= B)
		{
			printf("%d\n", i);
			break;
		}
		cur = cur - 1 + A;
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		int d_sum = 0;
		string s = to_string(i);
		for (int c = 0; c < s.size(); c++) d_sum += int(s[c] - '0');
		if (A <= d_sum && d_sum <= B) sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;
using namespace std;

int a[maxn];

int solve() {
    int n,all=0,b,flag=1;
    cin>>n;
    for (int i=0;i<n;++i)
        cin>>b,a[b]++,all=__gcd(all,b);
    for (int i=2;i<maxn;++i) {
        int sum=0;
        for (int j=i;j<maxn;j+=i) sum+=a[j];
        if (sum>1) flag=0;
    }
    return cout<<(flag?"pairwise coprime":all==1?"setwise coprime":"not coprime"),0;
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
//    cin>>_;
    while (_--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 7576