akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <atcoder/maxflow>

using namespace std;
using namespace atcoder;
typedef long long ll;
int N, M;

pair<int, int> id2p(int i)
{
   i -= 1;
   pair<int, int> ret;
   ret.first = i / M;
   ret.second = i % M;
   return ret;
}

int main()
{
   cin >> N >> M;
   mf_graph<int> graph(N * M + 2);
   vector<string> S(N);
   int dirX[] = {0, 0, 1, -1};
   int dirY[] = {1, -1, 0, 0};
   for (int i = 0; i < N; i++)
   {
      cin >> S[i];
   }
   for (int i = 0; i < N; i++)
   {
      for (int j = 0; j < M; j++)
      {
         int nodeID = i * M + j + 1;
         if (S[i][j] == '#')
            continue;
         if ((i + j) % 2 == 0)
         {
            graph.add_edge(0, nodeID, 1);
            for (int k = 0; k < 4; k++)
            {
               int ii = i + dirX[k];
               int jj = j + dirY[k];
               if (0 <= ii && ii < N && 0 <= jj && jj < M && S[ii][jj] == '.')
               {
                  int nodeID2 = ii * M + jj + 1;
                  graph.add_edge(nodeID, nodeID2, 1);
               }
            }
         }
         else
         {
            graph.add_edge(nodeID, N * M + 1, 1);
         }
      }
   }
   cout << graph.flow(0, N * M + 1) << endl;
   auto edges = graph.edges();
   for (auto edge : edges)
   {
      if (edge.flow == 1 && edge.from != 0 && edge.to != N * M + 1)
      {
         pair<int, int> p1 = id2p(edge.from);
         pair<int, int> p2 = id2p(edge.to);
         if (p1 > p2)
            swap(p1, p2);
         if (p1.first == p2.first)
         {
            S[p1.first][p1.second] = '>';
            S[p2.first][p2.second] = '<';
         }
         else
         {
            S[p1.first][p1.second] = 'v';
            S[p2.first][p2.second] = '^';
         }
      }
   }
   for (int i = 0; i < N; i++)
   {
      cout << S[i] << endl;
   }
   return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;
ll N; ll cnt = 0;

int main(){
  int N; cin >> N;
  vector<ll> A( N + 2); vector<ll> B(N + 1);
  
  for(int i = 1; i <= N + 1; i++){ cin >> A[i];}
                                  
  for(int j = 1; j <= N; j++){ cin >> B[j];}
                                  
  ll cnt = 0;
                                  
  if( A[1] >= B[1]){ cnt += B[1]; A[1] -= B[1]; B[1] = 0;}
  else{ cnt += A[1]; B[1] -= A[1]; A[1] = 0;}
  
  for(int i = 1; i <= N; i++){
    if( A[i + 1] >= B[i]){ cnt += B[i];  A[i+1] -= B[i]; B[i] = 0;}
    else{ cnt += A[i+1]; B[i] -= A[i+1]; A[i+1] = 0;}
    if( i != N){
    if( A[i+1] >= B[i+1]){ cnt += B[i+1];  A[i+1] -=B[i+1]; B[i+1] = 0;}
    else{ cnt += A[i+1]; B[i+1] -= A[i+1]; A[i+1] = 0;}}
  }
                                  
                                  cout << cnt << endl; return 0;}

Measured memory_bytes: 1792
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int n;

ll f(vector<ll> a, vector<ll> c) {
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	ll res = 0;
	for(int i = 0; i < n; ++i)
		res += a[i] * c[i];
	return res;
}

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

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

	vector<ll> c(n, 2);
	for (int i = 1; i < n; ++i)
		c[i] = (c[i - 1] * -1);
	c[0] /= 2;
	c[n - 1] /= 2;

	ll ans = 0;
	for (int round = 0; round < 2; ++round) {

		ll res = f(a, c);
		for (auto &&x : c)
			x *= -1;
		ans = max(ans, res);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3456
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    n, k = gets.chomp.split.map(&:to_i)

    last_c = 'Z'
    num = 0
    nums = []
    gets.chomp.each_char do |c|
      if last_c != c
        nums << num
        num = 1
      else
        num += 1
      end
      last_c = c
    end
    nums << num
    nums << 0
    # puts nums

    # 持ち点計算
    sum = 0
    nums.each do |i|
      if 1 < i
        sum += i - 1
      end
    end
    # puts sum

    # (n * 2) + 1 長さ の合計を尺取で
    # そのとき、2以上のを取り込んだら、rest を引いていく
    # 2以上のを排出したら rest に加算しておく
    rest = sum

    l = 0
    r = [k * 2, nums.length - 1].min
    cur = 0
    max_p = 0
    l.upto(r) do |i|
      if 1 < nums[i]
        rest -= nums[i] - 1
      end
      cur += nums[i]
    end
    if max_p < (cur - 1) + rest
      max_p = (cur - 1) + rest
    end

    t = nums.length - (k * 2 + 1)
    if t <= 0
      puts max_p
      return
    end

    t.times do
      if 1 < nums[l]
        rest += nums[l] - 1
      end
      cur -= nums[l]
      l += 1

      r += 1
      if 1 < nums[r]
        rest -= nums[r] - 1
      end
      cur += nums[r]

      if max_p < (cur - 1) + rest
        max_p = (cur - 1) + rest
      end
    end

    puts max_p
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 3508
n,k,q = map(int,input().split())

a = [0] * n
for i in range(q):
    ans = int(input())
    a[ans-1] += 1

for i in range(n):
#    print(a[i])
    if a[i] > q-k:
        print("Yes")
    else:
        print("No")


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

using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int temp = 0;
    bool last = 0;

    for(int i = 0; i < S.size(); i++) {
        if(S.at(i) == 'A' || S.at(i) == 'G' || S.at(i) == 'C' || S.at(i) == 'T') {
            temp++;
            ans = max(ans,temp);
            
            S.at(i) = '1';
        } else {
            temp = 0;
            S.at(i) = '0';
        }
    }
    cout << ans << endl;
    for(int i = 0; 0; i++) {
        if(S.at(i)) {
            
        }
    }

    return 0;
}

Measured memory_bytes: 3612
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 30;
const int N = (int)3e5 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

void solve() {
	LL x; cin >> x;
	LL val = 100, ans = 0;
	while (val < x) {
		val = val + val / 100;
		ans++;
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
   
using namespace std;
string s, t;
   
int main()
{  
  cin >> s >> t;
   
  int k;
  bool flag = false;
  for(int i = (int)s.size() - (int)t.size(); i >= 0; i--){
    for(int j = 0; j < t.size(); j++){
      if(s[i + j] == t[j] || s[i + j] == '?') flag = true;
      else{
        flag = false;
        break;
      }   
    } 
    if(flag){
      k = i;
      break;
    } 
  }
  if(flag)
    s.replace(k, t.size(), t); 
   
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '?') s[i] = 'a';
  }
   
  if(flag)
    cout << s << endl;
  else
    cout << "UNRESTORABLE" << endl;
   
  return 0;
}  


Measured memory_bytes: 256
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const a = input[1].split(" ").map(n => Number(n));
  const gcd = (a, b) => {
    if (b === 0) return a;
    return gcd(b, a%b);
  }
  const l = [];
  for (let i = 0; i < n; i++) {
    if (i === 0) {
      l.push(a[i]);
      continue;
    }
    l.push(gcd(l[l.length-1], a[i]));
  }
  
  const r = [];
  for (let i = n - 1; 0 <= i; i--) {
    if (i === n-1) {
      r.unshift(a[i]);
      continue;
    }
    r.unshift(gcd(r[0], a[i]));
  }
  
  let result = 0;
  for (let i = 0; i < n; i++) {
    const num = gcd(i === 0 ? 0 : l[i-1], i === n-1 ? 0 : r[i+1]);
    if (result < num) result = num;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int WHITE = 0, GRAY = 1, BLACK = 2, INF = 1 << 21;
int n, M[100][100];

int prim()
{
	int u, minv;
	int d[100], p[100], color[100];
	for (int i = 0; i < n; ++i)
	{
		d[i] = INF;
		p[i] = -1;
		color[i] = WHITE;
	}
	d[0] = 0;

	while (true){
		minv = INF;
		u = -1;
		for (int i = 0; i < n; ++i)
		{
			if (minv > d[i] && color[i] != BLACK){
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; ++v)
		{
			if (color[v] != BLACK && M[u][v] != -1){
				if (d[v] > M[u][v]){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		if(p[i] != -1)sum += M[i][p[i]];
	}
	return sum;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cin >> M[i][j];
		}
	}
	cout << prim() << endl;
	return 0;
}


Measured memory_bytes: 3120
import numpy as np
n, c = list(map(int, input().split()))
xv = list(list(map(int, input().split())) for i in range(n))
sushi1, max1, sushi2, max2 = [0], [0], [0], [0]
sum1, sum2 = 0, 0
for x, v in xv:
    sum1 += v
    sushi1.append(max(sum1 - x, sushi1[-1]))
    max1.append(max(sum1 - 2*x, max1[-1]))
for x, v in xv[::-1]:
    sum2 += v
    sushi2.append(max(sum2 - (c-x), sushi2[-1]))
    max2.append(max(sum2 - 2*(c-x), max2[-1]))
ans1 = max(np.array(sushi1) + np.array(max2[::-1]))
ans2 = max(np.array(sushi2) + np.array(max1[::-1]))
print(max(0, ans1, ans2))

Measured memory_bytes: 51244
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    REP(i,n) ans += (s.substr(i, 3) == "ABC");
    cout << ans << endl;
    return 0;
}


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

int main(){
  ll n; cin>>n;
  vector<string> s(n);
  rep(j,n){
    cin>>s.at(j);
    vector<char> memo(10);
    rep(i,10) memo.at(i)=s.at(j).at(i);
    sort(memo.begin(),memo.end());
    rep(i,10) s.at(j).at(i)=memo.at(i);
  }
  map<string,int> time;
  ll ans=0;
  rep(i,n) time[s.at(i)]++;
  for(auto p:time){
    ll k=p.second;
    ans+=k*(k-1)/2;
  }
   cout<<ans<<endl; 
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster
    ll n,nn;
    cin>>n;

    if(n%2==0)
    {

        ll c1=0;

        nn=n/2;

        while(nn!=0)
        {

            c1=c1+(nn/5);
            nn=nn/5;

        }

        cout<<c1<<endl;


    }
    else
        cout<<0<<endl;




    return 0;
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std; 
int main()
{
	long long n,b,j=0;
	cin>>n;
	long long i=n;
	char a[50]={0};
	do
	{
		b=i%26;
		i/=26;
		a[j]=b+96;
		if(a[j]==96)
		{
			a[j]=122;
			i--;
		}
		j++;
	}while(i!=0);
	for(int c=j-1;c>=0;c--)
	{
		cout<<a[c];
	}
	return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>

int main(void)
{
	int a, b, c;
	while (1)
	{
		scanf("%d %d %d", &a, &b, &c);
		if (a == -1 && b == -1 && c == -1)break;
		if (a == -1 || b == -1)
		{
			printf("F\n");
		}
		else if ((a + b) >= 80)
		{
			printf("A\n");
		}
		else if (((a + b) >= 65) && ((a + b) < 80))
		{
			printf("B\n");
		}
		else if (((a + b) >= 50) && ((a + b) < 65))
		{
			printf("C\n");
		}
		else if (((a + b) >= 30) &&((a+b)<50))
		{
			if (c >= 50)
			{
				printf("C\n");
			}
			else
			{
				printf("D\n");
			}
		}
		else if ((a + b) < 30)
		{
			printf("F\n");
		}


	}

	return 0;
}


Measured memory_bytes: 2044
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, k) = {
        let nums = get_line()
            .split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect::<Vec<i64>>();
        (nums[0], nums[1])
    };

    let mut new_value = n % k;
    let mut minimum = n % k;

    loop {
        new_value = (k - new_value).abs();
        if new_value > minimum {
            break;
        }
        minimum = new_value;
    }

    println!("{}", minimum);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
	int S = 0;
	int h, m, s = 0;
	scanf("%d", &S);
	s = S%60;
	m = S/60;
	h = m/60;
	m = m%60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int H, W; cin >> H >> W;
    vector<string> a(H);
    for (int i = 0; i < H; i++) cin >> a[i];

    vector<int> h, w;
    for (int i = 0; i < H; i++) {
        bool flag = true;
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '#') flag = false;
        }
        if (!flag) h.push_back(i);
    }

    for (int j = 0; j < W; j++) {
        bool flag = true;
        for (int i = 0; i < H; i++) {
            if (a[i][j] == '#') flag = false;
        }
        if (!flag) w.push_back(j);
    }

    for (int i : h) {
        for (int j : w) {
            cout << a[i][j];
        }
        cout << '\n';
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 3652
s = input()
for i in range(0, len(s), 2):
    if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
        print('No')
        exit()
for j in range(1, len(s), 2):
    if s[j] != 'L' and s[j] != 'U' and s[j] != 'D':
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if(a + b >= 10) cout << "error" << endl;
    else cout << (a+b) << endl;
    return 0;
}


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

int main(){
	long a,b,c,d,x = 0,y = 0;
	
	scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
	
	if(a * c <= a * d){
		x = a * d;
	}else if(a * c > a * d){
		x = a * c;
	}
	if(b * c <= b * d){
		y = b * d;
	}else if(b * c > b * d){
		y = b * c;
	}
	if(x <= y){
		printf("%ld\n",y);
	}else if(x > y){
		printf("%ld\n",x);
	}
	return 0;
}



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

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

    bool ex = false;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == "Y") ex = true;
    }

    if (!ex) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define MOD (long long)(1e9+7)
typedef long long int ll;
typedef unsigned long long int ull;

ll modularExponentiation(ll x, ll y, ll  p){
  ll res = 1;
  x = x % p;
  while (y > 0){
      if (y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
  }
  return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll T=1;
  // cin>>T;
  for(int _case=0;_case<T;_case++){
    ll n, a;
    cin>>n;
    map<ll, ll> mp;
    for(int i=0;i<n-1;i++){
      cin>>a;
      mp[a]++;
    }
    for(int i=1;i<=n;i++) cout<<mp[i]<<endl;

  }
  return 0;
}


Measured memory_bytes: 16160
from fractions import gcd
a,b,c,d=map(int,input().split())
f=b//c - (a-1)//c
g=b//d - (a-1)//d
k=c*d//gcd(c,d)
h=f+g-(b//k-(a-1)//k)
print((b+1-a)-h)

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k;
    double s,t,d;
    scanf("%d%d",&n,&m);
    d=1.0/n;
    s=0;
    for(i=1;i<=n;i++)
    {
        j=i;
        t=d;
        while(j<m)
        {
            j=j*2;
            t=t/2;
        }
        s=s+t;
    }
    printf("%.12lf\n",s);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> graph(N);
  for (int i: range(1, N)) {
    int a, b;
    std::cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  std::vector<bool> wins(N);
  std::vector<int> order(N);
  std::iota(order.begin(), order.end(), 0);
  std::sort(order.begin(), order.end(), [&](int i, int j) {
    return A[i] < A[j];
  });
  std::vector<int> ans;
  for (int u: order) {
    for (int v: graph[u]) {
      if (A[v] < A[u] && !wins[v]) {
        wins[u] = true;
      } 
    }
    if (wins[u]) {
      ans.push_back(u);
    }
  }
  std::sort(ans.begin(), ans.end());
  for (int i: range(0, ans.size())) {
    std::cout << ans[i] + 1 << " \n"[i + 1 == ans.size()];
  }
  return 0;
}


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

#define ll long long

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

    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt = 0;
    for(int i=0;i<n-2;i++)
    {
    	if(s.substr(i,3) == "ABC")
    		cnt++;
    }
    cout<<cnt;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100000;
int n;
int a[MAX_N];
int rg[MAX_N];

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

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;

  forn (i,n) cin >> a[i];


  rg[n-1] = a[n-1];
  for (int i = n-2; i >= 0; i--) {
    rg[i] = gcd(rg[i+1],a[i]);
  }

  int g = a[0];
  int res = rg[1];
  for (int i = 1; i < n-1; i++) {
    chmax(res, gcd(g, rg[i+1]));
    g = gcd(g, a[i]);
  }
  chmax(res,g);

  cout << res << endl;


  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int m,n;
	int x,y,W,H;
	int X,Y;
	
	cin>>m;
	
	while(m>0){
		cin>>x>>y>>W>>H;
		cin>>n;
		int s=0;
		vector< vector<int> >c(n,vector<int>(2));
		for(int i=0;i<n;i++){
			cin>>X>>Y;
			if(x<=X&&X<=x+W&&y<=Y&&Y<=(y+H))
				s++;
			}
	
		cout<<s<<endl;
		m--;
	}
	
	
	
	
	
}

Measured memory_bytes: 1220
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

res = 0
prev_B = 0
for i in range(N):
  _A = max(0, A[i] - prev_B)
  if _A < B[i]:
    res += A[i]
    prev_B = B[i] - _A
  else:
    res += B[i] + prev_B
    prev_B = 0
res += min(A[N], prev_B)

print(res)


Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M



void solve() {
	int n,m,i,k,s=0,x,y;
	cin>>n;
	int a[n];
	map<int,int> mp;
	rep(i,0,n) {
		cin>>a[i];
		s+=a[i];
		mp[a[i]]++;
	}
	cin>>m;
	while(m--){
		cin>>x>>y;
		int f=mp[x];
		mp[y]+=f;
		mp[x]-=f;
		s+=f*(y-x);
		cout<<s<<"\n";
	}
	

	
}


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





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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

void solve(){
    string S, T;
    cin >> S >> T;

    int N = 26;
    vi x(N,0), y(N,0);
    for (int i = 0; i < (int)S.length(); i++) {
        x[alpha2int(S[i])]++;
        y[alpha2int(T[i])]++;
    }


    sort(all(x));
    sort(all(y));

    for (int i = 0; i < N; i++) {
        if (x[i] != y[i]) {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

//幅優先探索　BFS startからendまでの最短距離を出力（無効グラフ　辺の重み 1）
int bfs_mindistance(int startx, int starty, int endx, int endy, vector<vector<char>> field, int height, int width) {
  /*　4方向への移動を表すベクトル　*/
  const vector<int> dx = {1, 0, -1, 0};
  const vector<int> dy = {0, 1, 0, -1};

  //各セルの最短距離を記憶する配列（まだ訪れていないところには-1を入れておく）
  vector<vector<int>> dist(height, vector<int>(width, -1));
  dist.at(startx).at(starty) = 0; //スタートには0を入れておく

  //「一度見た頂点」のうち「まだ訪れていない頂点」を表すキュー（待ち行列　first in first out）
  queue<pair<int, int>> que;
  que.push(make_pair(startx,starty)); //スタートをpush

  /*　キューが空になるまで　*/
  while(!que.empty()) {
    pair<int, int> current_pos = que.front(); //キューの先頭をみる

    int x = current_pos.first;
    int y = current_pos.second;
    que.pop();

    //隣接頂点を探索
    rep(direction, 4) {
      int next_x = x + dx.at(direction);
      int next_y = y + dy.at(direction);
    
      //場外ならダメ
      if(next_x < 0 || next_x >= height || next_y < 0 || next_y >= width) continue;
      //壁でもダメ
      if(field.at(next_x).at(next_y) == '#') continue;
      //まだ見ていない頂点なら push
      if(dist.at(next_x).at(next_y) == -1) {
        que.push(make_pair(next_x, next_y));
        //distも更新
        dist.at(next_x).at(next_y) = dist.at(x).at(y) + 1;
      }
    }
  }
  
  //ゴールの最短距離をreturn
  return dist.at(endx - 1).at(endy - 1);
}

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char> (w));

  int count = 0;

  rep(i,h) {
    rep(j,w) {
      cin >> s.at(i).at(j);
      if(s.at(i).at(j) == '#') count++;
    }
  }
  
  int min_d = bfs_mindistance(0, 0, h, w, s, h, w);

  if(min_d == -1) {
    cout << -1 << endl;
    return 0;
  }

  int result = h * w - min_d - 1 - count;

  cout << result << endl;

  
}


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

int main()
{
    double n, x[200], ave = 0, ans = 0;
    cin >> n;
    rep(i, n)
    {
        cin >> x[i];
        ave += x[i];
    }
    ave = round(ave / n);

    rep(i, n) ans += pow(x[i] - ave, 2);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3812
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        char[] arr = sc.next().toCharArray();
        int cnt = 0;

        for (int i=0; i<arr.length; i++) {
            if (arr[i]=='7') cnt++;
        }

        if (cnt==0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }


    }
}


Measured memory_bytes: 35780
#include<bits/stdc++.h>
#include<vector>
#include<map>
#include<set>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define E cout<<endl
#define PII pair<int, int>
#define fin(i, n) for(int i = 0; i < n; i++)
#define pb(x) push_back(x);
#define pp() pop_back();
#define i_n v.begin(), v.end()
#define dec_v(v) std::vector<int> v;
#define in(x) insert(x)
#define file()  freopen("input.text", "rt", stdin), freopen("out.txt", "wt", stdout);
#define pr(ar) for (auto i : ar) cout<<i<<" "; E;
#define cn(v) for(auto &i : v) cin>>i;
#define x5 (int) 1e5+5
#define x6 (int) 1e6+6
#define x9 (int) 1e9+9
#define x18 (ll) 1e18+18
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vpii vector<PII>
#define inf  (ll) 1e18
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl; 
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl; 
#define pr_1 cout<<-1<<endl;

bool cmp(PII a, PII b) {return a.ff+a.ss > b.ff+b.ss;}
bool cmp1(PII a, PII b) {return a.ss+b.ff>a.ff+b.ss;}

void solve()
{
   int n;
   cin>>n;

   vpii v;
   int x, y;
   fin(i, n)
   {
       cin>>x>>y;
       v.push_back(PII(x, y));
   }

   sort(v.begin(), v.end(), cmp);
   int ans1 = abs(v[0].ff - v[n-1].ff) + abs(v[0].ss - v[n-1].ss);
   sort(v.begin(), v.end(), cmp1);
   int ans2 = abs(v[0].ff - v[n-1].ff) + abs(v[0].ss - v[n-1].ss);

   cout<<max(ans1, ans2)<<endl;


}

void solve_2() {int t; cin>>t; while(t--) solve();}

int main()
{   
    int t = 1;


    if(t == 1) solve();
    else solve_2();

    return 0;
}   

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 61;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    priority_queue<int> A;
    rep(_, n) {
        int a;
        cin >> a;
        A.push(a);
    }

    rep(_, m) {
        int maximum = A.top();
        A.pop();
        A.push(maximum / 2);
    }

    llong sum = 0;
    while (! A.empty()) {
        sum += A.top();
        A.pop();
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 1e5+5;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main()
{
    ll i,j,k,l,p,q,n;
    cin >> n;
    if(n==1)
    {
        cout << 0;
        return 0;
    }
    l = 1;p = 1;q = 1;
    for(i=0;i<n;i++)
    {
        l = (l*10)%MOD;
        p = (p*9)%MOD;
        q = (q*8)%MOD;
    }
    p = (p*2)%MOD;
    l = (l+q)%MOD;
    l = (l-p)%MOD;
    l = (l+MOD)%MOD;
    cout << l;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>p(n);
    rep(i,n)cin>>p[i];
    sort(p.begin(),p.end());
    ll ans = 0;
    rep(i,k){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int d[100];
    for(int i = 0; i < n; i++) cin >> d[i];
    
    int nums[100] = {0};
    for (int i = 0; i < n; i++) {
      nums[d[i]]++;
    }
    
    int ans = 0;
    for (int i = 0; i < 101; i++) {
      if (nums[i] > 0) {
        ans++;
      }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 方針: Kがめちゃくちゃ小さいから総当たり
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    string S;
    int K;
    cin >> S >> K;
    set<string> s;
    for(int k = 1; k <= K; k++) {
        for(int i = 0; i <= int(S.size()) - k; i++) {
            s.insert(S.substr(i, k));
        }
    }
    auto itor = s.begin();
    for(int i = 0; i < K - 1; i++) itor++;
    cout << *itor << endl;
    return 0;
}

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

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

using ll = long long;
using P = pair<int, int>;

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

int main(int, char**)
{
    ll a, b;
    string s;
    cin >> a >> s;

    b = (s[0]-'0') * 100 + (s[2]-'0') * 10 + (s[3]-'0'); 

    cout << a * b / 100 << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;

  if (M1 != M2)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}

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


int main(){
	int N;cin>>N;
	vector<int> A(N),B(N),OA(N);
	for(auto &x: A) cin>>x;
	for(auto &x: B) cin>>x;
	OA = A;
	vector<int> I(N);
	for(int i=0;i<N;i++) I[i] = i;
	sort(I.rbegin(), I.rend(), [&A,&B](int &lhs,int &rhs){return A[lhs] - B[lhs] < A[rhs] - B[rhs];});
	
	for(int i=0,j=0;i<N && j<N;i++) while(A[i] < B[i] && j < N){
		int idx = I[j];
		if(A[idx] < B[idx]) break;
		int diff = min(A[idx] - B[idx],B[i] - A[i]);
		A[idx] -= diff;
		A[i] += diff;
		if(A[idx] == B[idx]) j += 1;
	}
	
	for(int i=0;i<N;i++) if(A[i] < B[i]){
		cout<<-1<<endl;
		return 0;
	}
	 
	int cnt = 0;
	for(int i=0;i<N;i++) if(A[i] != OA[i]) cnt += 1;
	cout<<cnt<<endl;
}

Measured memory_bytes: 1792
N = int(input())
a = list(map(int,input().split()))
import fractions
from functools import reduce
def lcm_base(x,y):
	return (x * y) // fractions.gcd(x,y)
def lcm(*numbers):
	return reduce(lcm_base,numbers,1)
mod = lcm(*a) - 1
ans = 0
for i in range(N):
	ans += mod % a[i]
print(ans)

Measured memory_bytes: 5288
input_num = input()
input = input().split()

times = 0
i = 0
    
while True:
  if int(input[i]) % 2 == 0:
    input[i] = int(input[i]) / 2
    i += 1
    if i == int(input_num) - 1:
      i = 0
      times += 1
  else:
    break
print(times)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 2e5+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[maxn];
int main(){
	n=read();
	for(register int i=1;i<=n;i++)a[i]=read();
	int min_=n+1,ans=0;
	for(register int i=1;i<=n;i++){
		min_=min(min_,a[i]);
		if(min_==a[i])ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	long H, W, X, Y; cin >> H >> W >> X >> Y;
	if (H * W % 2 != 0 && (X + Y) % 2 != 0) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}

signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			if (4 * i*j - n * i - n * j <= 0)continue;
			if ((n*i*j) % (4 * i*j - n * i - n * j) == 0) {
				cout << i << " " << j << " " << n * i*j / (4 * i*j - n * i - n * j) << endl;
				endre;
			}
		}
	}
	endre;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 998244353;

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

int main(){
    int N;
    cin >> N;
    vector<ll> T(N);
    for(int i=0;i<N;i++) cin >> T[i];
    ll gcd_n = 1;
    ll lcm_n = 1;
    for(int i=0;i<N;i++){
        gcd_n = gcd(lcm_n,T[i]);
        lcm_n = T[i]/gcd_n*lcm_n;
    }
    cout << lcm_n << endl;
}


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

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
int n;
vector<pair<int, int>> G[100000];
vector<long long> d(100000, 100000000); // 始点sから頂点iまでの最短距離をd[i]に記録
/*
* main関数からこれらを削除すること
* 隣接リストGの頂点数と最短距離dの要素数はnの最大値を整数で入力すること
*/
 
void bfs(int s) {
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
    if(d[G[u][v].first] == 100000000){
        d[G[u][v].first] = d[u] + G[u][v].second;
        q.push(G[u][v].first);
      }
    }
  }
}

int main() {
// 重み付き無向(有向)グラフの隣接リスト
  int u, v, w;
  cin >> n;
  
  for(int i = 0; i < n - 1; i++){
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w)); // 有向グラフではこの行をコメントアウト
  }
  
  bfs(0);
  
  for(int i = 0; i < n; i++){
    if(d[i] % 2 == 0) cout << 0 << endl;
    else cout << 1 << endl;
  }
}

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

int main() {
    int n, k;
    std::string s;
    std::cin >> n >> k >> s;

    const char c = s[0];

    for(int i = 0; i < n && k; ++i) {
        if(s[i] != c) {
            for( ; i < n && s[i] != c; ++i) {
                s[i] = c;
            }
            --k;
        }
    }

    int answer = 0;

    for(int i = 1; i < n - 1; ++i) {
        if('L' == s[i] && 'L' == s[i - 1]) {
            ++answer;
        } else if('R' == s[i] && 'R' == s[i + 1]) {
            ++answer;
        }
    }

    if( n >= 2 && 'L' == s[n - 1] && 'L' == s[n - 2]) {
        ++answer;
    }

    if( n >= 2 && 'R' == s[0] && 'R' == s[1]) {
        ++answer;
    }

    std::cout << answer;

    return 0;
}


Measured memory_bytes: 512
def isPal(arr):
    resp = True
    for i in range(0, int(len(arr) / 2)):
        if arr[i] != arr[len(arr) - i - 1]:
            resp = False
            break
    return(resp)

str = input()
resp = 'No'
if isPal(str):
    if isPal(str[0:(len(str) // 2)]) and isPal(str[(len(str) // 2) + 1:len(str)]):
        resp = 'Yes'
print(resp)

Measured memory_bytes: 3064
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  string s;
  cin >> n >> s;

  int x = 0, y = 0;
  REP(i,n){
    if(range(s[i],'a','m'+1)) x++;
    else if(range(s[i],'n','z'+1)) x--;
    else if(range(s[i],'A','M'+1)) y++;
    else y--;
  }

  cout << abs(x)+abs(y) << endl;
  REP(_,abs(x)) cout << (x>0?'a':'n');
  REP(_,abs(y)) cout << (y>0?'A':'N');

  cout << endl;

  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=401;
int a[N],cache[N][N],pref[N];

int dp(int i,int j)
{
     if(i==j)
          return 0;
     if(j==i+1)
          return a[j]+a[i];
     int &ans=cache[i][j];
     if(ans!=-1)
          return ans;
     ans=1e15;     
     for(int k=i;k<j;k++)
          ans=min(ans,dp(i,k)+dp(k+1,j)+pref[j]-pref[i-1]);
     return ans;     
}

int32_t main()
{
     IOS;
     
     memset(cache,-1,sizeof cache);
     int n;
     cin>>n;
     for(int i=1;i<=n;i++)
     {
          cin>>a[i];
          pref[i]=pref[i-1];
          pref[i]+=a[i];
     }
     
     cout<<dp(1,n);
     
     return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    reverse(ALL(S));
    vvi dp(S.size() + 1, vi(2, INF));
    dp[0][0] = 0;
    dp[0][1] = 1;
    REP(i, S.size()) {
        int s = S[i] - '0';
        REP(n, 10) {
            if (n < s) {
                dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + (n + 10) - s + n);
                dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + (n + 10 - 1) - s + n);
            } else if (n > s) {
                dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + n - s + n);
                dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + n - 1 - s + n);
            } else if (n == s) {
                dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + n - s + n);
                dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + (n + 10 - 1) - s + n);
            }
        }
    }
    cout << min(dp[S.size()][0], dp[S.size()][1] + 1) << endl;
}

Measured memory_bytes: 58864
n = int(input())

a =  n**0.5//1
num = 0

while a-num>=2:
    if n%(a-num) == 0:
        break
    num += 1

def keta(b):
    c = 1
    while b/10**c >=1:
        c += 1
    return c
    
print(max(keta(a-num),keta(n/(a-num))))

Measured memory_bytes: 3060
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    string s;
    int i = 0;
    cin >> s;
    while(s[i] != '\0')
    {
        cout << "x";
        i++;
    }
    cout << endl;
    return 0;
}

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

//create arrays outside of main()

int a[5];

int main(){

    int a;
    int b;
    cin >> a >> b;

    if(b%a == 0){
        cout << a+b;
    } else {
        cout << b-a;
    }

    return 0;
}

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

#define ll long long int

int main()
{
    int a,ans;
    cin>>a;
    ans=ceil(a/1.08);

    if(a==floor(ans*1.08))
           cout<<ans<<endl;
    else
            cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 3632