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

int main(){
  int N;
  cin >> N;
  
  int out;
  for(int i=0;i<N;i++){
  	int input;
    cin >> input;
    int count=0;
    while(input%2==0){
      input=input/2;
      count++;
    }
    if ((i==0)||(count<out)){
      out=count;
    }
  }
  cout << out << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int e;

	void run(){
		for(;;){
			e=sc.nextInt();
			if(e==0){
				break;
			}
			solve();
		}
	}

	void solve(){
		long min=e;
		for(long z=0; z*z*z<=e; z++){
			for(long y=0; y*y<=e; y++){
				long x=e-y*y-z*z*z;
				if(x>=0){
					min=min(min, x+y+z);
				}
			}
		}
		println(min+"");
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}

}

Measured memory_bytes: 26212
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret);
  if(n%2)((ret *= a));
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}

vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}


////////////////////////////////////////////////////////////////////

int n,p,odd,even;
vector<vector<int>> dp;
int com(int n, int r){
  return dp[n][r];
}
signed main(){
  cin>>n>>p;
  rep(i,n){
    int a;cin>>a;
    (a % 2 == 1 ? odd : even)++;
  }
  dp = vector<vector<int>>(n+1, vector<int>(n+1,0));
  for(int i = 0; i <= n; i++) {
    dp[i][0] = 1;
    for(int j = 1; j <= i; j++) {
      dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % MOD;
    }
  }
  int ans = modpow(2,even,INF), a = 0, b = 0;
  rep(i,n+1){
    if(i % 2 == 0)a += com(odd, i);
  }
  rep(i,n+1){
    if(i % 2 == 1){
      b += com(odd, i);
    }
  }
  if(p == 1){
    ans *= b; 
  }else{
    ans *= a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> a(n);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			int d = i - j;
			d = min(d, abs(x - i) + 1 + abs(y - j));
			d = min(d, abs(y - i) + 1 + abs(x - j));
			a[d]++;
		}
	}
	for (int i = 1; i <= n - 1; i++) {
		cout << a[i] << "\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  double W,H,x,y,ans,check;
  check=0;
  cin>>W>>H>>x>>y;
 ans=W*H/2;
  if(W/2==x&&H/2==y){
  check++;
  }
 
  cout<<ans<<" "<<check<<endl;
}

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

int main(){

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	string s,t;

	cin>>s>>t;

	if(t.length() - s.length() == 1){
		int ch = 0;
		for(int i=0;i<s.length();i++){
			if(s[i] != t[i]){
				ch = 1;
				break;
			}
		}
		if(ch == 1)
		cout<<"No";
		else{
			cout<<"Yes";
		}
	}
	else
	cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    int res = n;
    
    for(int i=0 ; i<= n ; i++){
        int cc =0;
        int t = i;
        while(t>0){ cc += t%6; t/=6;}
        
        t=n-i;
        while(t>0){ cc+= t%9 ; t/=9;}
        
        if(res>cc) res = cc;
    }
    cout << res << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;
    int N=0;
    for (int i=A; A<=i && i<=B; i++){

        int e = i % 10;
        int d = (i/10) % 10;
        int c = (i/100) % 10;
        int b = (i/1000) % 10;
        int a = i/10000;
        if (e==a && d==b){
            N += 1;
        }
    }
    cout << N << endl;
}

Measured memory_bytes: 256
To_Acill = 96
 
N = int(input())
 
ans = []
 
jou26 = 1
while N > 0:
    tmp = N % (jou26*26)
    if tmp ==0:
        tmp =26*(jou26)
        ans.append(chr(To_Acill + 26))
    else:
        ans.append(chr(To_Acill + tmp//jou26))
    N = N-tmp
    jou26 = jou26*26
 
print("".join(reversed(ans)))

Measured memory_bytes: 61804
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] bingo = new int[3][3];
        for(int i = 0; i < 9; i++)
          bingo[i/3][i%3] = Integer.parseInt(sc.next());
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
          int num = Integer.parseInt(sc.next());
          for(int j = 0; j < 9; j++){
            if(bingo[j/3][j%3] == num){
              bingo[j/3][j%3] = -1;
            }
          }
        }
        culc(bingo);
    }

    public static void culc(int[][] bingo){
      boolean judge = false;
      for(int i = 0; i < 3; i++){
        if(bingo[i][0] == -1 && bingo[i][1] == -1 && bingo[i][2] == -1){
          judge = true;
          break;
        }
        if(bingo[0][i] == -1 && bingo[1][i] == -1 && bingo[2][i] == -1){
          judge = true;
          break;
        }
      }

      if(bingo[0][0] == -1 && bingo[1][1] == -1 && bingo[2][2] == -1)
        judge = true;
      if(bingo[2][0] == -1 && bingo[1][1] == -1 && bingo[0][2] == -1)
        judge = true;

      if(judge == false)
        System.out.println("No");
      else
        System.out.println("Yes");
    }
}

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

const double PI=acos(-1.0);

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

    
    if(s == "Sunny") cout << "Cloudy" << endl;
    if(s == "Cloudy") cout << "Rainy" << endl;
    if(s == "Rainy") cout << "Sunny" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long[] list = new long[n];
        long sum = 0;

        for (int i = 0; i < n; i++) {
            list[i] = sc.nextLong();
            sum += list[i];
        }
        
        long ans = Long.MAX_VALUE;
        long raccoon = sum;
        for (int i = 0; i < n - 1; i++) {
            raccoon -= list[i];
            ans = Math.min(ans, Math.abs(sum - raccoon * 2));
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 74396
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    map<int, int> freq;
    int n;
    cin>>n;
    int a[n];
    int xorres = 0;
    for(int i= 0;i<n;i++){
    	cin>>a[i];
    	freq[a[i]]++;
    	xorres ^= a[i];
    }
    if(freq.size() == 1){
    	if(xorres == 0){
    		cout<<"Yes"<<endl;
    	} else {
    		cout<<"No"<<endl;
    	}
    } else if(freq.size()== 2){
    	if(n % 3 != 0){
    		cout<<"No"<<endl;
    	} else {
    		if(freq[0] == n/3 and xorres == 0){
    			cout<<"Yes"<<endl;
    		} else {
    			cout<<"No"<<endl;
    		}
    	}
    } else {
    	set<int> s;
    	for(auto it: freq){
    		s.insert(it.sc);
    	}
    	if(s.size()==1 and xorres == 0){
    		cout<<"Yes"<<endl;
    	} else {
    		cout<<"No"<<endl;
    	}
    }
    return 0;
}





Measured memory_bytes: 5760
import Data.Array  --変数衝突
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
import Debug.Trace

type DP s = STUArray s Int Bool

dp_i :: DP s -> [Int] -> Int -> ST s ()
dp_i dparr as k = do
  nexts <- forM as $ \a -> if k-a >= 0 then readArray dparr (k-a) else return True
  writeArray dparr k $ any (==False) nexts

solve :: [Int] -> Int -> Int -> ST s Bool
solve as n k = do
  dparr <- newArray (0,k) False
  let mina = head as --asは既にソート済み
  forM_ [mina..k] $ dp_i dparr as
  readArray dparr k

main :: IO ()
main = do
  [n,k] <- map read.words <$> getLine
  as <- map read.words <$> getLine
  case runST $ solve as n k of
    True  -> putStrLn "First"
    False -> putStrLn "Second"


Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#define maxx 2000000000
using namespace std;
int a,tot,k;
int main(){
	scanf("%d",&a);
	while (k*(k+1)/2<=a)
		k++;
	if (k*(k+1)/2>a)
		k--;
	for (int i=1;i<=k;i++){
		if ((a-k*(k+1)/2)==i){
			printf(")(");
		}		
		printf(")");
	}
	for (int i=1;i<=k;i++)
		printf("(");
	printf("\n");
	return 0;
} 

Measured memory_bytes: 3220
# https://atcoder.jp/contests/agc022/tasks/agc022_a

import sys
s = input()
A = [chr(ord("a") + i) for i in range(26)]
if len(s) < 26:
  for a in A:
    if a not in s:
      print(s + a)
      sys.exit()
else:
  for p in range(26)[::-1]:
    for a in A[A.index(s[p])+1:]:
      if a not in s[:p]:
        print(s[:p] + a)
        sys.exit()
print(-1)


Measured memory_bytes: 61988
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

#define AMAX 100010
#define DMAX 100000

int main(){
  int N;
  cin>>N;
  string T[N];
  rep(i,N) cin>>T[i];
  int S[200][200]={};
  rep(i,N) rep(j,N) S[i][j]=T[i][j]-'0';
  int M=0;
  rep(a,N){
  VI Y(N);
  int st=a;
  Y[st]=1;
  int ans=1;
  VVI Z(202,VI(0));
  Z[1].push_back(st);
  rep(k,201){
    rep(j,Z[k+1].size()){
      st=Z[k+1][j];
      rep(i,N){
        if(S[st][i]){
          if(Y[i]==0){
            Y[i]=k+2;
            Z[k+2].push_back(i);
          }else if(Y[i]==k||Y[i]==k+2){
          }else{
            ans=0;
            break;
          }
        }
      }
    }
    if(ans==0) break;
  }
  sort(all(Y));
  if(ans) M=max(M,Y[N-1]);
  }
  if(M) cout<<M<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC target("sse4.2")
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vd = vector<double>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for (int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

const double PI = acos(-1);
const ll MOD = 998244353;

void cxxio() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}

ll gcd(ll a, ll b) {
    return b==0? a:gcd(b, a%b);
}

ll modpow(ll x, ll n, ll mod) {
    ll ans=1;
    for (; n; n/=2) {
        if (n%2) ans=ans*x%mod;
        x=x*x%mod;
    }
    return ans;
}

ll fact(int n) {
    static vi cache{1};
    for (ll i=cache.size(); i<=n; i++)
        cache.pb(cache.back()*i%MOD);
    return cache[n];
}

ll invfact(int n) {
    static vi cache{1};
    for (ll i=cache.size(); i<=n; i++)
        cache.pb(modpow(fact(i), MOD-2, MOD));
    return cache[n];
}

ll binomod(ll n, ll k) {
    if (k<0 || k>n) return 0;
    return fact(n)*invfact(k)%MOD*invfact(n-k)%MOD;
}

vvi matmul(const vvi& a, const vvi& b, ll mod=MOD) {
    int N = a.size();
    vvi ans(N, vi(N));
    forn(i, N) forn(j, N) forn(k, N)
        ans[i][k] = (ans[i][k]+1ll*a[i][j]*b[j][k])%mod;
    return ans;
}

vvi matpow(vvi x, ll n, ll mod=MOD) {
    int N = x.size();
    vvi ans(N, vi(N));
    forn(i, N) ans[i][i] = 1;
    for (; n; n/=2) {
        if (n%2) ans = matmul(ans, x);
        x = matmul(x, x);
    }
    return ans;
}
// END TEMPLATE

int main() {
    cxxio();
    ll n, m;
    cin>>n>>m;
    string a, b;
    cin>>a>>b;
    ll d=__gcd(n, m);
    forn(i, d)
        if (a[n/d*i]!=b[m/d*i])
            return cout<<"-1\n", 0;
    cout<<(n*m/d)<<'\n';
}


Measured memory_bytes: 640
require 'set'
io = STDIN
N=io.gets.to_i
def add(ar)
  ar.each do |b|
    [3,5,7].each do |a|
      num = 10*b+a
      return ar if num > N
      ar << num
    end

  end
  add(ar)
end
p add([3,5,7]).select{|a|a.to_s.split(//).uniq.size==3}.size


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

int main(){
  int A, B;
  
  cin >> A >> B;
  
  for(int i = 0;i < 10000;i++){
    int a = i * 8 / 100;
    int b = i * 10 / 100;
    if(A == a && B == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#include <stdio.h>
#include <vector> 
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>

#include<iostream>
using namespace std;

std::vector< std::vector<int> > graph;
std::vector<int> c;


void rr(int root, int count) {
	if (count == 0){
		return;
	}
	for(const auto &a : graph[root]) {
		c[a] += count;

		rr(a, count);
	}
}

void eee(int root, int count) {
	c[root] += count;
	for (const auto &a : graph[root]) {
		eee(a, c[root]);
	}
}

int main()
{
	int N, K, Q;
	//std::string s, t;
	cin >> N >> K >> Q;
	std::vector<int> a;
	a.resize(Q);

	std::vector<int> c;
	c.resize(N);
	for (int i = 0; i < Q; ++i) {
		cin >> a[i];

		c[a[i] - 1]++;
	}

	for (int i = 0; i < N; ++i) {
		if (K - Q + c[i] > 0) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}


	return 0;
}



Measured memory_bytes: 1408
package main

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

func solve() {
	n, m := getInt(), getInt()
	graph := make([][]int, n)
	degs := make([]int, n)
	dp := make([]int, n+1)
	que := make([]int, 0)

	for i := range graph {
		graph[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		x, y := getInt()-1, getInt()-1
		graph[x] = append(graph[x], y)
		degs[y]++
	}
	for v, deg := range degs {
		if deg == 0 {
			que = append(que, v)
		}
	}

	for len(que) > 0 {
		now := que[0]
		que = que[1:]
		for _, next := range graph[now] {
			degs[next]--
			if degs[next] == 0 {
				que = append(que, next)
				dp[next] = max(dp[next], dp[now]+1)
			}
		}
	}

	ans := max(dp...)
	fmt.Fprintln(wr, ans)
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


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

using namespace std;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int solve(int, const vector<int>& xs)
{
    int ans = xs.front();

    for (auto x : xs)
        ans = gcd(ans, x);

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
typedef double db;

int main() {
  int n = read();
  db x = n / 3.0;
  printf("%.10lf", x * x * x);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  cout<< pow(n,3) <<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>

using namespace std;
bool s[51][51];
int ans[52][52];
int H, W;

int min(int a, int b, int c, int d) {
  return min(min(min(a, b), c), d);
}

int main() {
  cin >> H >> W;
  int count = 0; // number of white
  for (int i=1; i<=H; i++) {
    for (int j=1; j<=W; j++) {
      char tmp;
      cin >> tmp;
      s[i][j] = (tmp == '.');
      if (s[i][j]) {
        count++;
      }
    }
  }

  for (int i=0; i<=H+1; i++) {
    for (int j=0; j<=W+1; j++) {
      ans[i][j] = INT_MAX-1;
    }
  }

  ans[1][1] = 1;
  bool changed = true;
  while (changed) {
    changed = false;
    for (int i=1; i<=H; i++) {
      for (int j=1; j<=W; j++) {
        if (!s[i][j]) {
          continue;
        }
        int tmp = min(ans[i-1][j]+1, ans[i][j-1]+1, ans[i+1][j]+1, ans[i][j+1]+1);
        // cout << "tmp[" << i << "][" << j << "]: " << tmp << endl;
        if (tmp < ans[i][j]) {
          changed = true;
          // cout << "ans[" << i << "][" << j << "]: " << tmp << endl;
          ans[i][j] = tmp;
        }
      }
    }
  }
  if (ans[H][W] == INT_MAX-1) {
    cout << -1 << endl;
    return 0;
  }
  // cout << "count: " << count << endl;
  // cout << "ans[H][W]: " << ans[H][W] << endl;
  cout << count - ans[H][W] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int main()
{
	ll N,A,B;
	cin>>N>>A>>B;
	ll t=N/(A+B);
	ll rem=N%(A+B);
	cout<<(t*A+min(A,rem));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a; cin >> a;
  cout << a+a*a+a*a*a << endl;
  ret;
}


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

int main(){
    int n,m,dif;
    int r[2000000];
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> r[i];
    }

    m = r[0];
    dif = r[1] - r[0]; 
    for(int i = 1; i < n; i++){
        dif = max(dif,r[i] - m);
        m = min(m, r[i]);
    }
    cout << dif << endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

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

int N, A, B, C;
vint v;

int dfs(int n, int a, int b, int c) {
    if (n==N) return min(a, min(b, c))>0? abs(a-A)+abs(b-B)+abs(c-C)-30 : 1e9;
    int ret0 = dfs(n+1, a, b, c);
    int ret1 = dfs(n+1, a+v[n], b, c) + 10;
    int ret2 = dfs(n+1, a, b+v[n], c) + 10;
    int ret3 = dfs(n+1, a, b, c+v[n]) + 10;
    return min(ret0, min(ret1, min(ret2, ret3)));
}


int main() {
    cin >> N >> A >> B >> C;
    rep(_, N) {int l; cin >> l; v.pb(l);}
    cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int fun(string S1, string S2) { 
    int n = S1.size(), m = S2.size(); 
    int ans = INT_MAX; 
    for (int i = 0; i < m - n + 1; i++) { 
        int tmp = 0; 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                tmp++; 
            } 
        } 
        ans = min(tmp, ans); 
    } 
    return ans; 
} 
int main(){ 
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    string S1,S2;
    cin >> S2 >> S1;
    cout << fun(S1, S2) << '\n'; 
    return 0; 
} 



Measured memory_bytes: 3632
//
//  main.c
//  Practice
//
//  Created by hoshino on 2015/10/19.
//  Copyright ?? 2015??´ hoshino. All rights reserved.
//

#include <stdio.h>

int main(void) {
    int W,H,x,y,r;

    scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
    if(x-r<0 || x+r>W){
        printf("No\n");
    }else if(y-r<0 || y+r>H){
        printf("No\n");
    }else
     {
         printf("Yes\n");
    }
    
    //insert code here...
    
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,ans=0;

signed main(){
    cin>>n;
    
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    
    for(int i=2;i*i<=n;i++){
		if(n%i==0){
			int pos=0;
			while(n%i==0)  
                n=n/i,pos++;
			
			int now=sqrt(pos*2);
			
			if(now*(now+1)>pos*2)  
                now--;
			
			ans+=now;
		}
	}
    
    if(n>1)
        ans++;
        
    cout<<ans<<endl;
	
	return 0;
}


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

int main() {
    int n, h, w;
    cin >> n >> h >> w;

    int ans = 0;
    int a, b;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;

        if (a >= h && b >= w) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<pii>A(N);
  for(int i=0;i<N;i++)cin>>A[i].first,A[i].second=i;
  sort(rng(A));
  vector<int>ans(N);
  for(int i=0;i<N;i++){
    if(i==N-1)ans[A[i].second]=A[N-2].first;
    else ans[A[i].second]=A[N-1].first;
  }
  for(int i=0;i<N;i++)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i, n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
typedef vector<int> vi;
const int MOD = 1000003;
int n, m;
vector<vi> g;

vi solve(int l, int r, int gi){
	vi res(2, 1);
	for(int i=l;i<r;i++){
		if(gi < (int)g[i].size()){
			vi ret = solve(i, g[i][gi], gi+1);
			res[0] = (ll)res[0]*ret[0]%MOD;
			res[1] = (ll)res[1]*ret[1]%MOD;
			i = g[i][gi]-1;
		}
		swap(res[0], res[1]);
		gi = 0;
	}
	swap(res[0], res[1]);
	if(r-l > 1) res[1] = (res[1] + res[0]) % MOD;
	return res;
}

int main(){
	while(scanf("%d%d", &n, &m), n){
		g = vector<vi>(n);
		REP(i, m){
			int u, v;
			scanf("%d%d", &u, &v);u--; v--;
			if(v < u) swap(u, v);
			if(((u^v)&1)) g[u].push_back(v);
		}
		REP(i, n) sort(g[i].rbegin(), g[i].rend());
		printf("%d\n", n%2 ? 0 : (int)(solve(0, n-1, 0)[1]));
	}
	return 0;
}

Measured memory_bytes: 6440
#include<iostream>

int main(void){
  int X;
  std::cin >> X;
  int nummax = X/100;
  int mod = X%100;
  int modd = ((mod%5) > 0)?1:0;
  if((int)(mod/5)+1*modd > nummax ){
    std::cout << "0";
  }else{
    std::cout << "1";
  }
  
  return 0;
}


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

int main(){
  int x,a[100],i=0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a[i-2]+=a[i-1];
      i--;
    } else if ( s[0] == '-' ){
      a[i-2]-=a[i-1];
      i--;
    } else if ( s[0] == '*' ){      
      a[i-2]*=a[i-1];
      i--;
    }
    else {
      x = atoi(s);
      a[i]=x;
      i++;
    }
  }
  printf("%d\n",a[0]);
  return 0;
}

Measured memory_bytes: 548
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H, W):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


H, W = read_ints()
A = read_map(H, W)

from collections import deque


# 探索の準備
mvx = (1, 0, -1, 0)
mvy = (0, 1, 0, -1)
visited = [[False for _ in range(W)] for _ in range(H)]

# 開始地点
start = []
for i, a in enumerate(A):
    for j, aa in enumerate(a):
        if aa == '#':
            start.append((i, j))
            visited[i][j] = True

n_white = W * H

que = deque([(si, sj, 0) for si, sj in start])
# 幅優先探索
while que:
    y, x, cost = que.popleft()
    # 白マスの数の管理
    n_white -= 1
    if n_white == 0:
        print(cost)
        exit()

    for dy, dx in zip(mvy, mvx):
        y_new, x_new = y + dy, x + dx
        # 探索に含めない条件
        if not (-1 < y_new < H) or not (-1 < x_new < W):
            continue
        if visited[y_new][x_new]:
            continue

        # 探索に追加してあげる
        que.append((y_new, x_new, cost + 1))
        visited[y_new][x_new] = True


Measured memory_bytes: 197136
#include <stdio.h>
#include <string.h>
#define ll long long
int main(void)
{
	char s[11];
	int len,i,j;
	ll t,sum,res=0;
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<(1<<(len-1));i++){
		t=sum=0;
		for(j=0;j<len;j++){
			t=t*10+(s[j]-'0');
			 if(i>>j&1||j==len-1) sum+=t,t=0;
		}
		res+=sum;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 128
from bisect import bisect_left as bl
from bisect import bisect_right as br
n=int(input())
s=sorted(list(map(int,input().split())))
q=0
d=[[""]*(1001)for i in range(1001)]
for i in range(n):
    for j in range(i+1,n):
        x,y=max(s[i],s[j]),min(s[i],s[j])
        if d[x][y]=="":
            c=br(s,x+y-1)-bl(s,x-y+1)-1
            if x-y<y:
                c-=1
            c=max(c,0)
            d[x][y]=c
        q+=d[x][y]
print(q//3)

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 300005;
int n, f[N], sm[N];

bool ok(int mid, int i) {
    int x = lower_bound(f+1, f+n+1, mid) - f;
    int k = n-x+1 + sm[x]/mid;
    return k >= i;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    sort(f+1, f+n+1);

    for(int i = 1; i <= n; ++i) {
        sm[i+1] = sm[i] + f[i];
    }
    
    for(int i = 1; i <= n; ++i) {
        int l = 0, r = n/i + 1;
        while(r-l > 1) {
            int mid = l + (r-l)/2;
            if(ok(mid, i)) {
                l = mid;
            } else {
                r = mid;
            }
        }
        cout << l << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

std::pair<bool, int64_t> change(int64_t x) {
    int64_t ret = 0;
    int64_t dig = 1;
    bool flag[4] = {}; 
    while(x > 0) {
        int64_t tmp = x % 4;
        if (tmp == 0) {
            flag[0] = true;
        } else if (tmp == 1) {
            ret += dig * 3;
            flag[1] = true;
        } else if (tmp == 2) {
            ret += dig * 5;
            flag[2] = true;
        } else {
            ret += dig * 7;
            flag[3] = true;
        }
        x = x / 4;
        dig = dig * 10;
    }
    return std::pair<bool, int64_t>({ !flag[0] && flag[1] && flag[2] && flag[3], ret});
}

int64_t N;

int main(int argc, char **argv) {
    std::cin >> N;
    
    int i = 0;
    int64_t ret = 0;
    while(true) {
        auto p = change(i);
        //std::cout << i << " " << p.second << std::endl;
        if (p.first && p.second <= N) {
            ret++;
        }
        if (N <= p.second) {
            break;
        }
        
        i++;
    }

    std::cout << ret << std::endl;
    
    return 0;

}



Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    ss=readline().rstrip()
    #yn(1)
    rn=[0]*n
    gn=[0]*n
    bn=[0]*n

    for i in range(n):
        if i>0:
            rn[i]=rn[i-1]
            gn[i]=gn[i-1]
            bn[i]=bn[i-1]

        if ss[i]=="R":
            rn[i]+=1
        elif  ss[i]=="G":
            gn[i]+=1
        else:
            bn[i]+=1
    rsum=rn[n-1]
    gsum=gn[n-1]
    bsum=bn[n-1]

    ans=rsum*gsum*bsum
    w=0
    for d in range(1,4000):
        for i in range(n):
            a=i
            b=i+d
            c=b+d
            if a>=n or b>=n or c>=n:
                if i==0:
                    print(ans-w)
                    return
                break
            if ss[a]!=ss[b] and ss[a]!=ss[c] and ss[b]!=ss[c]:
                w+=1

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16384
/**

author:	©LoneWolfDON
Git: MahinHossainMunna

**/
/*

*/

#include <stdio.h>

int main()
{
    char s[4];

    gets(s);

    if(s[0] == '7' || s[1] == '7' || s[2] == '7')
       printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1524
#include <iostream>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;

// Grid
ll H, W;

// print(x, y, z);
// printVec(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main(int argc, char* argv[])
{
  ll A, B;
  std::cin >> A >> B;
  A--;
  B--;

  H = 100;
  W = 100;

  // Init
  std::vector< std::string > grid(H, std::string(W, '#'));
  for (ll y = 51; y < H; y++) {
    for (ll x = 0; x < W; x++) {
      grid[y][x] = '.';
    }
  }

  // Put White
  for (ll y = 0; y < 50; y+=2) {
    for (ll x = 0; x < W; x+=2) {
      if (A > 0) {
	grid[y][x] = '.';
	A--;
      }
    }
  }

  // Put Black
  for (ll y = 52; y < H; y+=2) {
    for (ll x = 0; x < W; x+=2) {
      if (B > 0) {
	grid[y][x] = '#';
	B--;
      }
    }
  }

  print(H, W);
  for (ll y = 0; y < H; y++) {
    print(grid[y]);
  }

  return 0;
}


Measured memory_bytes: 256
# あるマスの接する面・点の数が偶数の時、そのマスは裏になる
N,M = list(map(int, input().split()))

# 四隅でも外周でも無い内側のマス
if N == 1 or M == 1:
    print(abs(N * M - 2))
else:
    print(N * M - (4 + (N - 2) * 2 + (M - 2) * 2))

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int d, i, j, c[28], s[370][28], b[28] = {}, ans;

    scanf("%d", &d);
    for (i = 0; i < 26; i++) {
        scanf("%d", &c[i]);
    }
    for (i = 0; i < d; i++) for (j = 0; j < 26; j++) {
        scanf("%d", &s[i][j]);
    }

    for (i = 0; i < 26; i++) {
        b[i] = 1;
    }

    int t[370];

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

    ans = 0;
    for (i = 0; i < d; i++) {
        ans += s[i][t[i] - 1];
        b[t[i] - 1] = 0;
        for (j = 0; j < 26; j++) {
            ans -= c[j] * b[j];
            b[j]++;
        }
        printf("%d\n", ans);
    }
    
    return 0;
}

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

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	bool isValid = true;
	int tSize = T.length();
	for(int i = 0; i < tSize; ++i) {
		if(i == tSize - 1) {
			continue;
		}
		if(S[i] != T[i]) {
			isValid = false;
		}
	}
	if(isValid) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3548
N = int(input())
S = input()
word = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = ''
for i in S:
    k = word.index(i)
    if k+N > 25:
        ans+=word[k+N-26]
    else:
        ans+=word[k+N]
print(ans)

Measured memory_bytes: 3060
use std::cmp::max;
use std::io::stdin;
fn main() {
    let q: i32 = read();
    let xy = (0..q).map(|_| (read::<String>(), read::<String>()));
    for (x, y) in xy {
        println!("{}", lcs(x.as_str(), y.as_str()));
    }
}

fn lcs(x: &str, y: &str) -> i32 {
    let x: Vec<char> = x.chars().collect();
    let y: Vec<char> = " ".chars().chain(y.chars()).collect();
    let mut dp: Vec<Vec<i32>> = vec![vec![0; y.len() + 1]; x.len() + 1];
    for i in 0..x.len() {
        for j in 0..y.len() {
            dp[i + 1][j + 1] = if x[i] == y[j] {
                max(dp[i][j] + 1, max(dp[i][j + 1], dp[i + 1][j]))
            } else {
                max(dp[i + 1][j], dp[i][j + 1])
            }
        }
    }
    dp[x.len()][y.len()]
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum = 0;
  cin >> N;
  vector<int> B(N-1);
  for(int i=0; i<N-1; i++)
    cin >> B.at(i);
  
  vector<int> A(N);
  A.at(0) = B.at(0);
  A.at(N-1) = B.at(N-2);
  sum += A.at(0) + A.at(N-1);
  for(int i=1; i<N-1; i++){
    A.at(i) = min(B.at(i), B.at(i-1));
    sum += A.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i<n;i++)
#define nforn(i,n) for(ll i=n-1;i>=0;i--)
#define forne(i,n) for(ll i=1;i<=n;i++)
#define forse(i,s,e) for(ll i=s;i<e;i++)
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define d1(x) cerr <<"> "<<#x<<" = "<<x<<'\n'
#define d2(x, y) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<'\n'
#define d3(x, y, z) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<' '<<#z<<" = "<<z<<'\n'
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
	// cin>>t;
	while(t--){
		int h,w;
		cin>>h>>w;
		int c = max(h,w);
		int n;
		cin>>n;
		cout<<((n+c-1)/(c))<<"\n";
	}
}

Measured memory_bytes: 256
#ifdef LOCAL_EXEC
#include "include.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define trace(...)
#endif

using LL = long long;

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

	int n; cin >> n;
	vector<int> x(n), y(n);
	vector<int> perm(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		perm[i] = i;
	}

	double ans = 0;
	do {
		for (int i = 0; i + 1 < n; i++) {
			int a = perm[i], b = perm[i + 1];
			ans += hypot(x[a] - x[b], y[a] - y[b]);
		}
	} while (next_permutation(perm.begin(), perm.end()));

	for (int i = 1; i <= n; i++) {
		ans /= i;
	}

	cout << setprecision(10) << fixed << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try(Scanner scan = new Scanner(System.in)){
			int N = Integer.parseInt(scan.next());//標準入力の数
			List<Integer> list = new ArrayList<Integer>();//標準入力格納リスト
			for(int i=0; i<N; i++) {//入力内容をリストに格納
				list.add(Integer.parseInt(scan.next()));
			}
			int turn = 1; // 1:Alice , -1:Bob
			List<Integer> aliceCard = new ArrayList<Integer>();//Alice's Card
			List<Integer> bobCard = new ArrayList<Integer>();// Bob's Card
			
			while(list.size() > 0) {
				int currentMax = getMax(list);
				if(turn == 1) {
					aliceCard.add(currentMax);
				}else{
					bobCard.add(currentMax);
				}
              	turn = turn * -1;
				deleteMax(list, currentMax);
			}
			int aliceSum = getSum(aliceCard);
			int bobSum = getSum(bobCard);
			System.out.println(aliceSum - bobSum);
			
			
		}
	}
	public static int getMax(List<Integer> list) {
		int max = 0;
		for(int num: list) {
			if(num > max) {
				max = num;
			}
		}
		return max;
	}
	 public static void deleteMax(List<Integer> list, int max) {
		 Iterator<Integer> ite = list.iterator();
		 while(ite.hasNext()) {
			 int elm = ite.next();
			 if(elm == max) {
				 ite.remove();
               	 break;
			 }
		 }
	 }
	 public static int getSum(List<Integer> list) {
		 int sum = 0;
		 for(int elm: list) {
			 sum = sum + elm;
		 }
		 return sum;
	 }

}


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


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

int main() {
    int N;
    int64_t W;
    cin >> N >> W;
    
    vector<int64_t> value(N + 1, 0);
    vector<int> weight(N + 1, 0);
    for (int i = 1; i < N + 1; i++) {
        cin >> weight[i] >> value[i];
    }
    vector<vector<int64_t>> dp(N + 1, vector<int64_t>(W + 1, 0));
    for (int i = 1; i < N + 1; i++) {
        for (int64_t j = 1; j < W + 1; j++) {
            // 品物iをナップサックに入れることができる
            if (weight[i] <= j) {
                // 入れて、余った重量分をDPテーブルから参照
                int64_t temp1 = value[i] + dp[i - 1][j - weight[i]];
                // 入れない場合
                int64_t temp2 = dp[i -1][j];
                // 比較して価値の高い方をDPテーブルに記録
                dp[i][j] = max(temp1, temp2);
            }
            // 品物iを入れられない 
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[N][W] << endl;
}

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

int main(){
    int n;
    cin >> n;
    int data[4][3][10] = {0};
    for (int i = 0; i < n; i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        data[a-1][b-1][c-1] += d;
    }
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                cout << " " << data[i][j][k];
            }
            cout << endl;
        }
        if(i == 3)break;
        cout << "####################" << endl;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
        double a,b,h,m;
        cin>>a>>b>>h>>m;

        double angle_h = h*30 + m*.5;
        double angle_m = (m*360)/60;

        double angle = abs(angle_h - angle_m);
        angle = (pi * angle)/180.0;

        double c = a*a + b*b - 2*a*b*cos(angle);

        printf("%.10f\n", sqrt(c));
        //printf("Case %d: ",++te);
    }
    return 0;
}






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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int X[1000000];
int main() {
  int N, A, B;
  scanf("%d%d%d", &N, &A, &B);
  REP(i,N) scanf("%d", &X[i]);

  LL result;
  REP(i,N-1) {
    result += min((LL)B, (X[i+1]-X[i])*(LL)A);
  }
  printf("%lld\n", result);
}


Measured memory_bytes: 640