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

using namespace std;

template <unsigned long long mod> class modint {
public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) {
				ret *= a;
			}
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint& u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

template <class T> T fastpow(T a, long long p) {
	T tmp = a;
	T ret = 1;
	while (p) {
		if (p & 1) ret *= tmp;
		p >>= 1;
		tmp = tmp * tmp;
	}
	return ret;
}

const int MOD = 998244353;
using mint = modint<MOD>;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> a(n, 0);
		for (int i = 0; i < n; i++) cin >> a[i];
		int s = accumulate(a.begin(), a.end(), 0);
		vector<vector<mint>> dp(n + 1, vector<mint>(s + 1));
		dp[0][0] = 1;
		mint ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= s; j++) {	// GB
				dp[i + 1][j] += dp[i][j] * 2;
			}
			for (int j = s; j >= a[i]; j--) {	 // R
				dp[i + 1][j] += dp[i][j - a[i]];
			}
		}
		for (int i = (s + 1) / 2; i <= s; i++) {
			ans += dp[n][i];
		}
		if (s % 2 == 0) {
			vector<vector<mint>> dp2(n + 1, vector<mint>(s + 1));
			dp2[0][0] = 1;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j <= s; j++) {	// G
					dp2[i + 1][j] += dp2[i][j];
				}
				for (int j = s; j >= a[i]; j--) {	 // R
					dp2[i + 1][j] += dp2[i][j - a[i]];
				}
			}
			ans -= dp2[n][s / 2];
		}
		ans *= 3;
		cout << (fastpow(mint{3}, n) - ans).v << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 423872
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >>S;
    
    int ans = 0;
    char memo = S[0];
    for(int i = 0; i < S.length();i++){
        
        if(memo != S[i]){
            ans++;
            memo = S[i];
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Read().ToInt();
            var r = ReadSplit();
            var min = 100100101;
            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                var p = r[i].ToInt();
                if (p < min)
                {
                    min = p;
                    ans++;
                }
            }
            Write(ans);
            Read();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void Write(object value)
        {
            Console.WriteLine(value);
        }
    }

    public static class Extensions
    {
        public static int ToInt(this object str)
        {
            return int.Parse(str.ToString());
        }

        public static decimal ToDecimal(this object str)
        {
            return decimal.Parse(str.ToString());
        }
    }
}


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

int main()
{
	double num, t, w, flg;
	char ch;
	flg = 0;
	while (cin>>num>>ch>>w>>ch>>t)
	{
		if (w/(t*t)>=25)
		{
			cout << num << endl;
			flg = 1;
		}
	}
	if (flg=0)
	{
		cout << "該当なし" << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<int> dp;
	int tmp = 2, res = 1;
	while(res <= 1e7)
	{
		dp.push_back(res);
		res += tmp++;
	}
	while(N > 0)
	{
		int k = lower_bound(dp.begin(), dp.end(), N)-dp.begin()+1;
		if (k == 0) break;
		cout << k << endl;
		N -= k;
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){

  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(N);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }

  using P = pair<int, int>;
  vector<int> is_confirm(N, -1);
  int max_group = 0;
  for(int i=0; i<N; i++){
    if(is_confirm[i] != -1) continue;
    int num = 1;
    stack<P> st;
    st.push(P(i, -1));
    while(!st.empty()){
      int node = st.top().first;
      int parent = st.top().second;
      st.pop();
      

      for(int child : vec[node]){
        if(child == parent) continue;
        if(is_confirm[child] !=-1) continue;
        is_confirm[child] = 1;
        num++;
        // cout << " num: " << num << " node: " << node << " parent: " << parent << " child: " << child << endl;
        st.push(P(child, node));
      }
    }
    max_group = max(max_group, num);
  }

  cout << max_group << endl;
  return 0;

}


Measured memory_bytes: 15408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    ll a,b,t;
    cin>>a>>b>>t;
    cout<<t/a*b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,l,r;
    cin >> N;
    int sum = 0;
    for(int i = 0;i < N;i++){
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0usize; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    let mut count = 0;
    for i in 0..n {
        if av[i] == count + 1 {
            count += 1;
        } else {
            ans += 1;
        }
    }
    println!("{}", if count == 0 { -1 } else { ans });
}


Measured memory_bytes: 6396
import math
a, b, h, m=map(int, input().split())

long=math.pi*h/6 + (math.pi/6)*m/60
short=math.pi*m/30

dg=abs(long-short)

ans=(a**2 +b**2 -2*a*b*math.cos(dg))**0.5
print(ans)

Measured memory_bytes: 9512
// Problem : F - Strivore
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

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

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}
vi fact;
int inv(int n)
{ return Pow(fact[n],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}
int ncr(int n,int r){
	if(r>n) return 0;
return (((fact[n]*inv(r))%md)*inv(n-r))%md;
}

void solve()
{
factorial(3000000);
int k;cin>>k;
string s;cin>>s;
int n=size(s);
int ans=0;
for(int i=n;i<=n+k;i++)
{
	ans=(ans+ncr(n+k,i)*Pow(25,n+k-i)%md)%md;
}
cout<<ans;
}

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


Measured memory_bytes: 27536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
using namespace std;

#define N 50

static int d[ N ][ N ];
static int x, y;

struct P
{
  int tx; int ty;
  int kx; int ky;
  int t;
  P move ( int dtx, int dty, int dkx, int dky )
  {
    P res = { tx + dtx, ty + dty, kx + dkx, ky + dky, t + 1 };

    if ( res.tx < 0 || res.tx >= x || res.ty < 0 || res.ty >= y
      || d[ res.tx ][ res.ty ] ) { res.tx -= dtx; res.ty -= dty; }
    if ( res.kx < 0 || res.kx >= x || res.ky < 0 || res.ky >= y
      || d[ res.kx ][ res.ky ] ) { res.kx -= dkx; res.ky -= dky; }

    return ( res );
  }
};

static int t[ N ][ N ][ N ][ N ];

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    queue<P> lis;
    P p;

    scanf ( "%d%d", &x, &y );
    if ( x == 0 && y == 0 ) break ;
    scanf ( "%d%d%d%d", &p.tx, &p.ty, &p.kx, &p.ky );
    --p.tx; --p.ty; --p.kx; --p.ky;
    for ( j = 0; j < y; ++j )
    for ( i = 0; i < x; ++i )
      scanf ( "%d", &d[ i ][ j ] );

    p.t = 0;
    lis.push ( p );
    memset ( t, 0, sizeof ( t ) );
    while ( !lis.empty ( ) )
    {
      p = lis.front ( );
      lis.pop ( );

      if ( t[ p.tx ][ p.ty ][ p.kx ][ p.ky ] ) continue ;
      t[ p.tx ][ p.ty ][ p.kx ][ p.ky ] = 1;
      if ( p.tx == p.kx && p.ty == p.ky )
      {
        printf ( "%d\n", p.t );
        goto CONT;
      }

      if ( p.t + 1 < 100 )
      {
        lis.push ( p.move (  1,  0, -1,  0 ) );
        lis.push ( p.move ( -1,  0,  1,  0 ) );
        lis.push ( p.move (  0,  1,  0, -1 ) );
        lis.push ( p.move (  0, -1,  0,  1 ) );
      }
    }
    puts ( "NA" );
CONT: ;
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 26672
/* Suryansh Kumar */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define vect(x) vector<x>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;


ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }

ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;}

ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}


 
vector<vector<ll>> v;
ll n;
 
ll dp[1LL<<22][22];
 
ll solve(ll &mask, ll student )
{
    if(student<0)
    {
        ll temp = mask;
        temp = temp + 1;
     //   cout << temp << " ** ";
        if((temp&(temp-1)) == 0) return 1;
        else return 0;
    }
    if(dp[mask][student]!=-1) return dp[mask][student];
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
        if(v[student][i]==1 && (mask&(1LL<<i))==0)
        {
            mask = mask^(1LL<<i);
            ans = (ans + solve(mask , student-1)%MOD)%MOD;
            mask = mask^(1LL<<i);
        }
    }
    return  dp[mask][student] = ans%MOD;
}
 
void solve__()
{

       v.clear();
        cin >> n;
        for(ll i=0;i<n;i++)
        {
            vector<ll> temp(n);
            for(ll j=0;j<n;j++) cin >> temp[j];
            v.emplace_back(temp);
        }
        ll mask = 0;
        ll f = 1LL<<21;
        f++;
        for(ll i=0;i<f;i++)
        {
            for(ll j=0;j<n;j++)
            {
                dp[i][j] = -1;
            }
        }
        cout << solve(mask , n-1) << "\n";
 
} 

int main()
{
   
    fastio
    
    ll tc=1;
  //  read(tc);
    while(tc--)
    {
        solve__();
    }
    
    return 0;
}

Measured memory_bytes: 362752
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

int n, m, q;
vector<int> a(55), b(55), c(55), d(55);
int res = 0;

void dfs(int cnt, int now, vector<int> &v)
{
	if (cnt == n)
	{
		int tmp = 0;
		rep(i, q)
		{
			if (v[b[i]] - v[a[i]] == c[i])tmp += d[i];
		}
		chmax(res, tmp);
		return;
	}
	for (int i = now; i <= m; ++i)
	{
		v[cnt] = i;
		dfs(cnt + 1, i, v);
	}
}


int main()
{
	cin >> n >> m >> q;
	rep(i, q)
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		--a[i];
		--b[i];
	}
	vector<int> v(11);
	dfs(0, 1, v);
	cout << res << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] p = new int[n];
        int ans=0;
        for(int i=0;i<p.length;i++)
        {
            p[i] = scan.nextInt();
        }
        Arrays.sort(p);
        p[n-1]/=2;
        for(int i=0;i<p.length;i++)
        {
            ans+=p[i];
        }
        System.out.println(ans);
        }
}


Measured memory_bytes: 22740
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N,M;
    for(;;){
        scanf("%d%d",&N,&M);
        if(N==0&&M==0) break;
        int d,p,len=0;
        vector<pair<int,int>> ds(N);
        for(auto &pa : ds){
            scanf("%d%d",&d,&p);
            pa=make_pair(p,d);
            len+=d;
        }
        sort(begin(ds),end(ds));
        int ans=0,rem=max(len-M,0);
        for(auto &p : ds){
            int nd=min(p.second,rem);
            ans+=p.first*nd;
            rem-=nd;
            if(rem==0) break;
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 1092
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define rep(i,N) for(lint i=0; i<N; i++)
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

vector<lint> depth(lint N,lint root,vector<lint> l1,vector<lint> l2) {
  vector<lint> res(N,-1);
  res[root] = 0;
  vector<queue<lint>> can(N);
  rep(i,N-1) {
    can[l1[i]].push(l2[i]);
    can[l2[i]].push(l1[i]);
  }
  
  queue<lint> que;
  que.push(root);
  lint pla;
  
  while (!que.empty()) {
    pla = que.front();
    while (!can[pla].empty()) {
      if (res[can[pla].front()] == -1) {
        res[can[pla].front()] = res[pla] + 1;
        que.push(can[pla].front());
      }
      can[pla].pop();
    }
    que.pop();
  }
  
  return res;
}

int main() {
  lint N,u,v;
  cin >> N >> u >> v;
  u--;
  v--;
  
  vector<lint> u_depth,v_depth;
  
  vector<lint> A(N-1),B(N-1);
  
  rep(i,N-1) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  
  u_depth = depth(N,u,A,B);
  v_depth = depth(N,v,A,B);
  
  lint ans = 0;
  
  rep (i,N) {
    if (u_depth[i] < v_depth[i]) {
      ans = max(ans,(v_depth[i] - 1));
    }
  }
  rep (i,N) {
    cerr << u_depth[i] << " " << v_depth[i] << endl;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 72264
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;

int main(int argc, char *argv[]) {
	
	vector<pair<int, int>> v;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		v.push_back(make_pair(t, i));
	}
	sort(v.begin(), v.end());
	for (auto p : v)
		cout << p.second + 1 << " ";
	
}














Measured memory_bytes: 1780
<?php

$line = fgets(STDIN);
list($a, $b) = explode(" ", trim($line));
$a = intval($a);
$b = intval($b);
if ($a > $b) {
	$str = '>';
} elseif ($a < $b) {
	$str = '<';
} else {
	$str = '==';
}
echo 'a '. $str . ' b' . "\n";

Measured memory_bytes: 15320
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;
#define endl '\n'
#define F first
#define S second
const double PI = 3.141592653589793238460;

  void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{
  ll n;cin>>n;
  map<string,int>mp;
  mp["AC"]=0;mp["TLE"]=0;mp["WA"]=0;mp["RE"]=0;

  for(int i=0;i<n;i++)
  {
    string s;cin>>s;
    mp[s]++;
  }
  
    cout<<"AC"<<" x"<<" "<<mp["AC"]<<endl;
    cout<<"WA"<<" x"<<" "<<mp["WA"]<<endl;
    cout<<"TLE"<<" x"<<" "<<mp["TLE"]<<endl;
    cout<<"RE"<<" x"<<" "<<mp["RE"]<<endl;
  


}

int main()
{
   
 c_p_c();

 int t=1;
 while(t--)
 {
  solve();
  
 }

  return 0;
}

Measured memory_bytes: 3660
N = int(input())
A1, A2, A3 = 9, 900, 90000

if len(str(N))%2 == 0:
  if N < 100 :
    print(A1)
  elif 100< N < 10000:
    print(A1 + A2)
  else:
    print(A1 + A2 + A3)
else:
  if N < 10:
    print(N)
  elif 10< N < 1000:
    print(N - 99 + A1)
  else:
    print(N - 9999 + A1 + A2)
    


Measured memory_bytes: 3060
def find(x):
    '''
    xの根を求める
    '''
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def union(x, y):
    '''
    xとyの属する集合の併合
    '''
    x = find(x)
    y = find(y)
    
    if x == y:
        return

    if par[x] > par[y]:
        x, y = y, x

    par[x] += par[y]
    par[y] = x


def size(x):
    '''
    xが属する集合の個数
    '''
    return -par[find(x)]


def same(x, y):
    '''
    xとyが同じ集合に属するかの判定
    '''
    return find(x) == find(y)


n, m = map(int, input().split())
p = list(map(int, input().split()))

par = [-1] * n

pos = [-1] * n
for i in range(n):
    pos[p[i]-1] = i

for _ in range(m):
    x, y = map(int, input().split())
    union(x-1, y-1)

res = 0
for i in range(n):
    if same(i, pos[i]):
        res += 1

print(res)

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

int main(){
    vector<int> a(4); rep(i,4) cin >> a[i];

    for(int i = 0;; i++){
        if(i % 2 == 0){
            a[2] -= a[1];
        }else{
            a[0] -= a[3];
        }
        if(a[0] < 1){
            put("No");
            return 0;
        }else if(a[2] < 1){
            put("Yes");
            return 0;
        }
    }
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX

int main(){
    int n;string S;cin>>n>>S;
    rep(i,S.length()){
        int x=(S[i]+n-'A')%26;
        S[i]='A'+x;
    }
    cout<<S<<endl;
}

Measured memory_bytes: 256
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "b.cpp"

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

  if (s.size() <= k) {
    cout << s << el;
  } else {
    rep(i, k) {
      cout << s[i];
    }
    cout << "..." << el;
  }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

char ans[(int)1e5 + 5];
int N, A, B, C;

void dfs(int n, int a, int b, int c, vec<string> &s) {
    if (n == N) {
        cout << "Yes" << endl;
        rep(i, N) cout << ans[i] << endl;
        exit(0);
    }

    if (s[n] == "AB") {
        if (b != 0) ans[n] = 'A', dfs(n + 1, a + 1, b - 1, c, s);
        if (a != 0) ans[n] = 'B', dfs(n + 1, a - 1, b + 1, c, s);
    }
    if (s[n] == "BC") {
        if (c != 0) ans[n] = 'B', dfs(n + 1, a, b + 1, c - 1, s);
        if (b != 0) ans[n] = 'C', dfs(n + 1, a, b - 1, c + 1, s);
    }
    if (s[n] == "AC") {
        if (a != 0) ans[n] = 'C', dfs(n + 1, a - 1, b, c + 1, s);
        if (c != 0) ans[n] = 'A', dfs(n + 1, a + 1, b, c - 1, s);
    }
}

int main() {
    cin >> N >> A >> B >> C;
    vec<string> s(N);
    rep(i,N) cin >> s[i];
    dfs(0, A, B, C, s);
    cout << "No" << endl;
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define f first
#define s second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 300500;



int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;

	ll A, B, C;
	map <pair <ll, pll> , bool> m;
	int ans = 0;
	cin >> A >> B >> C;

	while(true){
		if(A % 2 || B % 2 || C % 2)
			break;
		if(m.count(mp(A, mp(B, C)))){
			cout << -1;
			return 0;
		}
		m[mp(A, mp(B, C))] = 1;
		ans++;
		ll a = B / 2 + C / 2, b = A / 2 + C / 2, c = A / 2 + B / 2;
		A = a, B = b, C = c;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <limits>
#include <random>
#include <utility>
#include <vector>

namespace procon {
  class UnionFind {
  private:
    struct nodeinfo {
      int par;
      int rank;
      nodeinfo(int par) : par(par), rank(0) {}
    };
    std::vector<nodeinfo> node;

  public:
    UnionFind(int n) : node() {
      node.reserve(n);
      for (int i = 0; i < n; ++i) {
	node.push_back(nodeinfo(i));
      }
    }
    int root(int x) {
      if (node[x].par == x) {
	return x;
      }
      return node[x].par = root(node[x].par);
    }
    void unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) {
	return;
      }
      if (node[x].rank < node[y].rank) {
	node[x].par = y;
      } else {
	node[y].par = x;
	if (node[x].rank == node[y].rank) {
	  ++node[x].rank;
	}
      }
    }
    bool is_same_set(int x, int y) { return root(x) == root(y); }
  };
}
  
int main(void) {
  int size, n_query;
  std::cin.read((char *)&size, sizeof(int));
  std::cin.read((char *)&n_query, sizeof(int));

  std::vector<uint64_t> query(n_query);
  std::cin.read((char *)query.data(), sizeof(uint64_t) * n_query);

  const int mask = (1 << 30) - 1;

  uint64_t res = 123456789;
  procon::UnionFind uf(size);
  for (uint64_t q : query) {
    const int com = q >> 60;
    const int x = (q >> 30) & mask;
    const int y = (q >> 0) & mask;
    assert(0 <= x && x < size);
    assert(0 <= y && y < size);
    if (com) {
      res = res * 17 + (uf.is_same_set(x, y) ? 1 : 0);
    } else {
      uf.unite(x, y);
    }
  }
  std::cout << res << std::endl;
  return 0;
}



Measured memory_bytes: 269856
from math import factorial

n, k = map(int, input().split())
red = n - k
m = 10**9+7

def com_cal(p, q):
    return factorial(p) // (factorial(p - q) * factorial(q))

for i in range(1, k+1):
    if red+1 < i:
        print(0)
        continue
    com = com_cal(red + 1, i)
    div_num = com_cal(k - 1, i - 1)
    print((com * div_num)%m)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
vector<ll> v;
int MOD = 1e9 + 7;
int main() {
    int n, m;
    cin >> n >> m;
    v.resize(n+1, 0);
    v[0] = 1;
    rep(i, m) {
        int a;
        cin >> a;
        v[a] = -1;
    }
    ll ans = 0;
    if (v[1] != -1) {
        v[1] = v[0];
    }
    for (int i = 2; i <= n; i++) {
        if (v[i] != -1) {
            if (v[i - 1] != -1) {
                v[i] += v[i-1];
                v[i] %= MOD;
            }
            if (v[i -2] != -1) {
                v[i] += v[i -2];
                v[i] %= MOD;
            }
        }
    }
    cout << v[n] << endl;
    return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string a,b,c; cin>>a>>b>>c;
    string s="";
    s+=toupper(a[0]);
    s+=toupper(b[0]);
    s+=toupper(c[0]);
    cout<<s<<endl;
}

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


int main(){
	int N;
  	cin >> N;
  	
  	vector<long long> l(N);
  	for(int i = 0;i < N;i++){
      	cin >> l[i];
    }
  
  	int ct = 0;
  
  	for(int i = 0; i < N;i++){
      	for(int j = i+1;j < N;j++){
        	for(int k = j+1;k < N;k++){
              	if((l[i]-l[j])*(l[j]-l[k])*(l[k]-l[i])){
					if(abs(l[i]-l[j]) < l[k] && l[k] < l[i]+l[j]){
                      	ct++;
                    }
                }
            }
        }
    }
  
  	cout << ct << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
static const double g = 9.8;

double v, t, h;

int main(){
	while(cin >> v){
		t = v / g;
		h = 0.5 * g * t * t;
		//cout << t << " " << h << endl;
		int N = 0;
		while(1){
			if(5 * (N - 1) - 5 <= h && 5 * N - 5 > h) break;
			N++;
		}
		cout << N << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<limits>
#include<algorithm>

using std::begin;
using std::end;

int main() {
  int n;
  std::cin >> n;
  std::vector<int> v;

  for(int i{0}; i < n; ++i) {
    int t;
    std::cin >> t;
    v.push_back(t);
  }

  int min{v[0]};
  int diff{std::numeric_limits<int>::min()};
  for(int i{1}; i < n; ++i) {
    diff = std::max(diff, v[i] - min);
    min = std::min(min, v[i]);
  }

  std::cout << diff << std::endl;

  return 0;
}



Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct Graph {
    struct VertexQ {
        bool operator<(const VertexQ& o) const {
            return c > o.c; // 逆
        }
        int i;
        int64_t c;
    };
    struct Vertex { int n; int64_t c; };
    struct Edge { int i, n, c; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int c) {
        e[m] = { j, v[i].n, c };
        v[i].n = m;
        m++;
    }
    void dijkstra(int i, int j) {
        for (int i = 0; i < n; i++) v[i].c = (int64_t)1 << 60;
        priority_queue<VertexQ> q;
        q.push({ i, v[i].c = 0 });
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            if (p.i == j) break;
            if (p.c > v[p.i].c) continue;
            for (int j = v[p.i].n; j >= 0; j = e[j].n) {
                Edge& o = e[j];
                int64_t c = p.c + o.c;
                if (c < v[o.i].c) q.push({ o.i, v[o.i].c = c });
            }
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

int main() {
    int k;
    cin >> k;

    Graph g(k, (k - 1) * 2);
    for (int i = 1; i < k; i++) {
        g.add_edge(i, i * 10 % k, 0);
        g.add_edge(i, (i + 1) % k, 1);
    }

    g.dijkstra(1, 0);

    cout << g.v[0].c + 1 << endl;

    return 0;
}

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

int n;
int p[100];
int cnt[101];

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) { cin >> p[i]; cnt[p[i]]++; }
	for (i = 99; i >= 0; i--) cnt[i] += cnt[i + 1];
	for (i = 100; i >= 0; i--) if (cnt[i] >= i) break;
	cout << i << endl;
	return 0;
}


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

#define int long long

using namespace std;

int a[100001];
vector <int> g[100001];
int d[100001];
int c[100001];
int ans[100001];
int was[100001];
int u[100001];
int timer;

void dfs (int v, int k, int col) {
	queue <pair <int, int> > q;
	q.push (make_pair (k, v));
//	cout << "NEW\n";
	while (!q.empty ()) {
		pair <int, int> qwe = q.front ();
		int len = qwe.first;
		int v = qwe.second;
		q.pop ();
//		cout << v << ' ' << len << endl;
		was[v] = max (len, was[v]);
		if (!ans[v]) ans[v] = col;
		for (auto to : g[v]) {
			if (was[to] < len - 1) {
				q.push (make_pair (len - 1, to));
			}	
		}
	}
}

 main () {
	int n;
	int m;
	cin >> n >> m;
	for (int i = 1;i <= m;i ++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back (y);
		g[y].push_back (x);
	}
	for (int i = 1;i <= n;i ++) was[i] = -1;
	int q;
	cin >> q;
	for (int i = 1;i <= q;i ++) {
		cin >> a[i] >> d[i] >> c[i];
	}
	for (int i = q;i >= 1;i --) {
		timer ++;
		dfs (a[i], d[i], c[i]);
	}
	for (int i = 1;i <= n;i ++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 12080
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] in = line.split(" ");
		BigDecimal a = new BigDecimal(new Integer(in[0]));
		BigDecimal b = new BigDecimal(new Integer(in[1]));
		System.out.println(a.divideToIntegralValue(b).toPlainString() + " " + a.remainder(b).toPlainString() + " " + a.divide(b,10,RoundingMode.HALF_UP).toPlainString() );
	}
}

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

int main() {
	int n;
	cin >> n;
	set<int> a;
	rep(i, n){
		int tmp;
		cin >> tmp;
		a.insert(tmp);
	} 
	string ans = "NO";
	if(a.size() == n) ans = "YES";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9600
class UnionFind:
    """
    sizeによる実装
    """

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        """
        x: child
        ret-> node
        xのグループの代表を見つける
        """
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        """
        union (x ,y)
        x,y: node
        ret->None
        """
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.size[px] < self.size[py]:
            self.parent[px] = py
            self.size[py] += self.size[px]
        else:
            self.parent[py] = px
            self.size[px] += self.size[py]

    def same(self, x, y):
        """
        return true if x and y are in same group
        """
        return self.find(x) == self.find(y)

    def connectedNum(self, x):
        """
        return size of the group x belong to
        """
        return self.size[self.find(x)]

    def is_connected(self):
        """
        return true is all node is in one group
        """
        return self.connectedNum(0) == len(self.parent)

    def conpomentNum(self):
        """
        return num of component
        """
        par_set=set()
        for p in self.parent:
            par_set.add(self.find(p))
        return len(par_set())


N,M = map(int,input().split())
Un = UnionFind(N)

for _ in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    Un.union(a,b)

max_size=max(Un.connectedNum(i) for i in range(N))
print(max_size)


Measured memory_bytes: 94024
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n,d,c=0;
  cin>>n>>d;
  for(int i=0;i<n;i++){
  	double p,q;
  	cin>>p>>q;
  	double x=sqrt((pow(abs(p),2))+pow(abs(q),2));
  	if(x<=d)c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3792
#include<stdio.h>
int main(void)
{
    int A[100][100],B[100][100];
    int n,m,l,i,j,k;
    long long int C[100][100]={{},{}};
 
    scanf("%d%d%d",&n,&m,&l);
    for(i=0;i<n;i++)
      {
        for(j=0;j<m;j++)
      {
        scanf("%d",&A[i][j]);
      }
      }
    for(i=0;i<m;i++)
      {
        for(j=0;j<l;j++)
      {
        scanf("%d",&B[i][j]);
      }
      }
    for(i=0;i<n;i++)
      {
        for(j=0;j<l;j++)
      {
    for(k=0;k<m;k++)
      { C[i][j]+=A[i][k]*B[k][j];}
      }
      }
 
    for(i=0;i<n;i++)
      {
        for(j=0;j<l;j++)
      {
        printf("%lld",C[i][j]);
        if(j!=l-1){printf(" ");}
      }
        printf("\n");
      }
       
    return 0;
}


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

int main()
{
	int n;
	cin>>n;
	ll a[n];
	ll cost[n][n],pre[n];

	pre[0] = 0;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i];
		cost[i][i] = 0;
		pre[i] = i==0? a[i] : a[i]+pre[i-1];
	}

	//for(int i=0;i<n;i++) cout<<pre[i]<<" ";
	for(int l=2;l<=n;l++)
	{
		for(int i=0;i<n;i++)
		{
			if(i+l<=n)
			{
				int j = (i+l-1);
				if(j==i+1)
				{
					cost[i][j] = a[i]+a[j];
				}
				else
				{
					cost[i][j] = LONG_MAX;
					for(int k=i+1;k<=j;k++)
					{
						ll ans = cost[i][k-1] + cost[k][j] + (i==0? pre[j] : (pre[j] - pre[i-1]));
						cost[i][j] = min(ans,cost[i][j]);
					}
				}
			}
		}
	}
	cout<<cost[0][n-1]<<endl;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string S;
	cin>>S;
	vector<int>R((int)S.length(),0);
	vector<int>DP((int)S.length(),-1);
	for(int i=0;i<S.length();i++)
	{
		if(S[i]=='R')
		{
			int j;
			if(i!=0&&S[i-1]=='R')
			{
				int np=DP[i-1];
				if(S[np]=='L')
				{
					R[np-1]++;
					DP[i]=np-1;
				}
				else
				{
					R[np+1]++;
					DP[i]=np+1;

				}
			}
			else
			{
				for(j=0;S[i+j]!='L';j++);
				if(j%2)
				{
					R[i+j-1]++;
					DP[i]=i+j-1;
				}
				else
				{
					R[i+j]++;
					DP[i]=i+j;
				}
			}
		}

		if(S[i]=='L')
		{
			int j;
			if(S[i-1]=='L')
			{
				int np=DP[i-1];
				if(S[np]=='L')
				{
					R[np-1]++;
					DP[i]=np-1;
				}
				else
				{
					R[np+1]++;
					DP[i]=np+1;
				}
			}
			else
			{
				for(j=0;S[i-j]!='R';j++);
				if(j%2)
				{
					R[i-j+1]++;
					DP[i]=i-j+1;
				}
				else
				{
					R[i-j]++;
					DP[i]=i-j+1;
				}
			}
		}
	}
	for(int i=0;i<S.length();i++)
	{
		cout<<R[i];
		if(i!=S.length()-1)
			cout<<" ";
		else
			cout<<""<<endl;
	}
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define po pop_back
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd

int main()
{
    fast;
    ll n;cin>>n;
   ll i,j;
   ll ans=1e18;
   for(i=1;i<=sqrt(n);i++)
   { if(n%i==0)
     ans=min(ans,i+n/i);
   }
   cout<<ans-2<<endl;
}

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

ls = {}
for i in range(n):
    a = int(input())
    ls[i] = []
    for j in range(a):
        ls[i].append(list(map(int,input().split())))

c = 0
check = [0]*n
ans = 0
while c < (2 ** n):
    count = 0
    wari = c
    while wari > 0:
        #print(count,wari)
        check[count] = ((wari % 2 != 0) + 0)
        wari //= 2
        count += 1
    c += 1
    wari = 0
    #karikotae = 0
    mujyun = 0

    for v in check:
        if v == 0:
            wari += 1
            continue
        for a,b in ls[wari]:
            a -= 1
            if b != check[a]:
                mujyun = 1
                break
        if mujyun != 0:
            break
        wari += 1
    if mujyun != 0:continue
    else:ans = max(ans,sum(check))
print(ans)

Measured memory_bytes: 45548
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	int n = s.size();
	zip(i, 0, n)
	{
		if (s[i] == 'a')
			a++;
		else if (s[i] == 'b')
			b++;
		else
			c++;
	}
	if (a > b)
		swap(a, b);
	if (b > c)
		swap(b, c);
	if (a > c)
		swap(a, c);
	if (a > b)
		swap(a, b);
	if (a == b && b == c)
	{
		cout << "YES" << en;
	}
	else if (a == b && b == c - 1)
	{
		cout << "YES" << en;
	}
	else if (a == b - 1 && b == c)
	{
		cout << "YES" << en;
	}
	else
	{
		cout << "NO" << en;
	}


	return 0;
}



Measured memory_bytes: 512
N, M = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
X.sort(key=lambda x: x[0])
i = 0
num = 0
ans = 0
while i <= N - 1:
    num += X[i][1]
    ans += X[i][0] * X[i][1]
    if num > M:
        ans -= X[i][0] * (num - M)
        break
    i += 1
print(ans)

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

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) (container).begin(), (container).end()

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const int MOD = 1000000007;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  double sum = 0;
  REP(i, 0, N)
  {
    cin >> A[i];
    sum += 1.0 / A[i];
  }

  cout << 1.0 / sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 1;
    for(int i = 0; i < N; i++) {
        if(INF/A[i] < ans) {
            cout << -1 << endl;
            return 0;
        }
        else {
            ans *= A[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n,d;
	cin>>n>>d;
	d*=d;
	int sum = 0;
	while(n--){
		long long x,y;
		cin>>x>>y;
		if(x*x+y*y<=d) sum++;
	}
	cout<<sum;
}

Measured memory_bytes: 3684
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int H[200005];

int main(){
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> H[i];

    sort(H, H+N);
    ll ans = 0;
    if(N > K){
        for(int i = 0; i < N-K; i++){
            ans += H[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024