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

using namespace std;
using ll = long long;

int main() {
	int n; scanf("%d", &n);
	vector<ll> arr(n);
	for (int i = 0; i < n; ++i) scanf("%lld", &arr[i]);
	vector<ll> sortValues(n);
	for (int i = 0; i < n; ++i) sortValues[i] = i;
	sort(begin(sortValues), end(sortValues), [&arr] (int i, int j) {
			return arr[i] < arr[j];
	});
	vector<vector<ll>> optWay(n, vector<ll>(n));
	for (int i = 0; i < n; ++i) optWay[i][i] = arr[sortValues[0]] * abs(i - sortValues[0]);
	for (int k = 2; k <= n; ++k) {
		for (int i = 0; i + k <= n; ++i) {
			int j = i + k - 1;
			if (sortValues[k-1] >= i) {
				optWay[i][j] = max(optWay[i][j], optWay[i+1][j] + arr[sortValues[k-1]] * (sortValues[k-1] - i));
			}
			if (sortValues[k-1] <= j) {
				optWay[i][j] = max(optWay[i][j], optWay[i][j-1] + arr[sortValues[k-1]] * (j - sortValues[k-1]));
			}
		}
	}
	printf("%lld\n", optWay[0][n-1]);
	return 0;
}


Measured memory_bytes: 34680
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n , k;
    cin  >> n >> k;
    string s;
    cin >> s;
    for(int i=0; i<n; i++){
        if(i==k-1){
            if(s[i]=='A') cout << 'a';
            if(s[i]=='B') cout << 'b';
            if(s[i]=='C') cout << 'c';
        }
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n;
int bottom[500005];
string s;
int main(){
    cin>>s;
    n=s.size()+1;
    for (int x=1;x<n;x++){
        if (s[x-1]=='<') bottom[x]=bottom[x-1]+1;
        else bottom[x]=0;
    }

    int curr=bottom[n-1];
    long long ans=curr;
    for (int x=n-2;x>=0;x--){
        if (s[x]=='<') curr=bottom[x];
        else curr=max(curr+1,bottom[x]);
        ans+=curr;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int mod2 = 1e9 + 9;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
void max_self(int& a, int b) {
	a = max(a, b);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<pair<ll, ll>>> hash(n, vector<pair<ll, ll>>(n));
	int b1 = 1568047842;
	int b2 = 1257471233;
	for (int i = 0;i < n;++i) {
		ll h1 = 0, h2 = 0;
		for (int j = i;j < n;++j) {
			h1 = (h1 * b1 + (s[j] - '0')) % mod;
			h2 = (h2 * b2 + (s[j] - '0')) % mod2;
			hash[i][j].first = h1;
			hash[i][j].second = h2;
		}
	}
	int answer = 0;
	for (int i = 0;i < n;++i) {
		for (int j = i + 1;j < n;++j) {
			int size = min(n - j, j - i);
			int l = 1, r = size;
			while (l <= r) {
				int mid = l + (r - l) / 2;
				bool ok = hash[i][mid + i - 1].first == hash[j][mid + j - 1].first;
				ok &= hash[i][mid + i - 1].second == hash[j][mid + j - 1].second;
				if (ok) {
					max_self(answer, mid);
					l = mid + 1;
				}
				else {
					r = mid - 1;
				}
			}
		}
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 391168
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const vector<int> dy = {-1,0,1,0};
const vector<int> dx = {0,1,0,-1};
 int n = 200005;
vector<vector<int>> G(n);
vector<int> counter(n);

void dfs(int v,int p = -1) {
    for (int e :G[v]) {
        if (e == p) continue;
        counter[e] += counter[v];
        dfs(e,v);
    }
}

int main() {
    int q; cin >> n >> q;
    rep(_,n - 1) {
        int a,b; cin >> a >> b;
        a --; b --;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(_,q) {
        int p,x; cin >> p >> x;
        p --;
        counter[p] += x;
    }
    dfs(0);
    rep(i,n) {
        cout << counter[i] << ' ';
    }
    cout << '\n';
}

Measured memory_bytes: 23424
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007
int main() {
	int n;
	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}

	int a, b;
	cin >> a >> b;
	cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

long A, B;

long eachdigit(int n){
    long unit = (long)pow(2, n); //  基本単位, 2^n
    long a = (A/(2*unit))*unit + ((A%(2*unit))/unit)*(A%unit); //  A-1 までに並ぶ 1 の数
    long b = ((B+1)/(2*unit))*unit + (((B+1)%(2*unit))/unit)*((B+1)%unit); // B までに並ぶ 1 の数
    return (b-a)%2;
}

int main(){
    cin >> A >> B;

    //  最高桁の決定
    int maxpow = 0;
    while((long)pow(2,maxpow) <= B) maxpow++;

    long ans = 0; //  答え用

    for(int i = 0; i < maxpow; i++) ans += eachdigit(i) * (long)pow(2, i);
    
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e6 + 10, oo = 1e9 + 10;
ll h[N], lptr, rptr = -1;
struct Line{
    ll k, b, index;
    ll f(ll x) {
        return k * x + b;
    }
    Line(){}
    Line(ll _k, ll _b) {
        k = _k; b = _b;
    }
    ll to(Line o) {
        ll l = 0, r = 5e12, point = 0;
        while(r >= l) {
            ll m = l + r >> 1; 
            if(o.f(m) <= f(m)) {
                point = m;
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        return point;
    }
} hull[N];
int main() {
    ll n, c, best;
    cin >> n >> c;
    for(int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    for(int i = 1; i <= n; ++i) {
        if(i == 1) {
            best = 0;
        } else {
            while(lptr < rptr) {
                Line me = hull[lptr];
                Line up = hull[lptr + 1];
                if(me.f(h[i]) < up.f(h[i])) break;
                ++lptr;
            } 
            best = hull[lptr].f(h[i]) + h[i] * h[i] + c;
        }
        Line cur(-2 * h[i], best + h[i] * h[i]); 
        cur.index = i;
        while(lptr < rptr) {
            Line me = hull[rptr - 1];
            Line up1 = hull[rptr];
            Line up2 = cur;
            if(me.to(up1) < up1.to(up2)) break;
            --rptr;
        }   
        hull[++rptr] = cur;
    }
    cout << best << endl;
}

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

int main() {
    string str;
    cin >> str;
    if((str.at(0) == str.at(1) || str.at(2) == str.at(3)) && str.at(1) == str.at(2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

    public static void main(String[] args) {
        FastReader fs = new FastReader();
        ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
        int n = fs.nextInt();
        int e = fs.nextInt();

        for (int i = 0; i < n + 1; i++) {
            graph.add(new ArrayList<>());
        }

        for (int i = 0; i < e; i++) {
            graph.get(fs.nextInt()).add(fs.nextInt());
        }

        boolean[] visited = new boolean[n + 1];
        int[] dp = new int[n + 1];
        Arrays.fill(dp, -1);
        for (int i = 1; i < n + 1; i++) {
            if (!visited[i]) {
                dfs(graph, i, visited, dp);
            }
        }

        int sol = 0;
        for (int i : dp) {
            // System.out.println(i);
            sol = Math.max(sol, i);
        }

        System.out.println(sol);


    }

    private static int dfs(ArrayList<ArrayList<Integer>> graph, int i, boolean[] visited, int[] dp) {

        visited[i] = true;

        if (dp[i] != -1) return dp[i];

        int sol = 0;

        for (int neighbor : graph.get(i)) {
            if (!visited[neighbor]) {
                sol = Math.max(sol, 1+dfs(graph, neighbor, visited, dp));
            } else {
                sol = Math.max(sol, 1+dp[neighbor]);
            }
        }

        dp[i] = sol;
        return dp[i];
    }

}

Measured memory_bytes: 76384
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    vector<ll> lpos;
    vector<ll> rpos;
    F0R(i, m)
    {
        ll a, b;
        cin >> a >> b;
        lpos.pb(a);
        rpos.pb(b);
    }
    sort(lpos.begin(), lpos.end());
    sort(rpos.begin(), rpos.end());
    ll ub = min(n, rpos[0]);
    ll res = ub - lpos[lpos.sz() - 1] + 1;
    cout << (res > 0 ? res : 0);
    return 0;
}

Measured memory_bytes: 2036
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var steps = []int{}
	n, x := nextInt(), nextInt()
	for i := 0; i < n; i++ {
		city := nextInt()
		steps = append(steps, absTwo(city, x))
	}
	fmt.Println(allGcd(steps))
}

func absTwo(a, b int) int {
	v := a - b
	return int(math.Abs(float64(v)))
}

func allGcd(slice []int) int {
	a := slice[0]
	for i := 0; i < len(slice)-1; i++ {
		b := slice[i+1]
		a = gcd(a, b)
	}
	return a
}

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


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

using namespace std;

const int N = 1234567;

int n, que[N];
char s[N], w[N];

int main() {
  scanf("%d %s %s", &n, s, w);
  if (strcmp(s, w) == 0) {
    puts("0");
    return 0;
  }
  int ans = 1;
  int qh = 0, qt = 0;
  int j = n - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (i == 0 || w[i] != w[i - 1]) {
      j = min(i, j);
      while (j >= 0 && s[j] != w[i]) {
        j--;
      }
      if (j < 0) {
        puts("-1");
        return 0;
      }
      while (qh < qt) {
        if (que[qh] - (qt - qh - 1) <= i) {
          break;
        }
        qh++;
      }
      if (i != j) {
        que[qt++] = j;
        ans = max(ans, qt - qh + 1);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);
        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


 
void solve()
{     
    int n;
    cin>>n;
    set<string> s;
    for(int i=0;i<n;i++)
    {
        string b;
        cin>>b;
        s.insert(b);
    }
    cout<<s.size()<<endl;
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 19324
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
void trozen()
{
  int d,t,s;
  cin>>d>>t>>s;
  double ans=(d+0.0)/(s+0.0);
  //cout<<ans<<endl;
  if(ans<=(double)t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 3576
def main():
  n, k = map(int, input().split())
  if (n - k) % (k - 1):
    print(1 + (n - k) // (k - 1) + 1)
  else:
    print(1 + (n - k) // (k - 1) )
if __name__=="__main__":
  main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<ios>
using namespace std;
int n,m;
double dp[101][100];
double g[100][100];
main()
{
	while(cin>>n>>m,n)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)cin>>g[i][j];
		}
		for(int i=0;i<n;i++)dp[0][i]=1;
		for(int i=1;i<m;i++)for(int j=0;j<n;j++)dp[i][j]=0;
		for(int i=0;i<m-1;i++)
		{
			for(int j=0;j<n;j++)
			{
				for(int k=0;k<n;k++)
				{
					dp[i+1][j]=max(dp[i+1][j],dp[i][k]*g[k][j]);
				}
			}
		}
		double ans=0;
		for(int i=0;i<n;i++)ans=max(ans,dp[m-1][i]);
		printf("%.02f\n",ans);
	}
}



Measured memory_bytes: 3260
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	int n;
	double students[1000] = {0},sum,m,div;

	while(true){
		scanf("%d",&n);
		if(n == 0) break;
		div = sum = 0;
		for(int i = 0; i < n; i++){
			scanf("%lf",&students[i]);
			sum += students[i];
		}
		m = sum/n;
		for(int i = 0; i < n;i++){
			div += (students[i] - m)*(students[i] - m);
			students[i] = 0;
		}
		printf("%.8lf\n",sqrt(div/n));
	}
}


Measured memory_bytes: 2636
var
n,i,j,cnt,t:Longint;
a,b:array[1..10000]of Byte;
begin
read(n);
t:=n+1-n mod 2;
writeln(n*(n-1)div 2-n div 2);
for i:=1 to n do begin
for j:=i+1 to t-i-1 do writeln(i,' ',j);
if(j=t-i-1)or(j=t-i)then j:=t-i+1;
for j:=j to n do writeln(i,' ',j);
end;
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int lcs(string s1, string s2) {
    int c[1005][1005];
    int m = s1.length();
    int n = s2.length();
    s1 = " " + s1;
    s2 = " " + s2;
    int max1 = 0;
    for (int i = 0; i <= m; i++) {
        c[i][0] = 0;
    }
    for (int i = 0; i <= n; i++) {
        c[0][i] = 0;
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (s1[i] == s2[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            max1 = max(max1, c[i][j]);
        }
    }
    return max1;
}

int main() {
    int q;
    cin >> q;
    string s1, s2;
    for (int k = 0; k < q; k++) {
        cin >> s1;
        cin >> s2;
        cout << lcs(s1, s2) << endl;
    }

    return 0;
}

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

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

   int a = N / 100;
   int b = (N / 10) % 10;
   int c = N % 10;

   cout << ((N == a + 10 * b + 100 * c) ? "Yes" : "No") << endl; 
}


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


signed main() {
  int N, M; cin >> N >> M;
  
  int i = (M+1)/2, j = N-M/2+1, k = 0;
  while(M > 0) {
    k++;
    if(k%2 == 1) {
      cout << i << " " << i+k << endl;
      i--;
    } else {
      cout << j << " " << j-k << endl;
      j++;
    }
    M--;
  }
  
  

}

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

//Author: Ashish

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> input(n);
	for(auto&itr:input) cin>>itr;
	vector<vector<int>> cache(n,vector<int>(n,-1));
	
	function<int(int,int)> dp = [&](int l,int r) {
		if(cache[l][r]!=-1) return cache[l][r];
		if(l==r) return cache[l][r]=0;
		int answer=1e18;
		int sum=0;
		for(int i=l;i<=r;i++) sum+=input[i];
		for(int i=l;i<r;i++) {
			answer=min(answer,dp(l,i)+dp(i+1,r)+sum);
		}
		return cache[l][r]=answer;
	};

	cout<<dp(0,n-1);
	
	return 0;
}

Measured memory_bytes: 4504
require 'pp'

n, d = gets.chomp!.split(" ").map(&:to_i)
x_n = []
n.times do |i|
    x = gets.chomp!.split(" ").map(&:to_i)
    x_n << x
end

#pp x_n
count = 0

memo = {}
0.upto(130) do |i|
    memo[i*i] = i
end

#pp memo


0.upto(n-2) do |i|
    (i + 1).upto(n-1) do |j|
        sum = 0
        x_n[i].zip(x_n[j]).each do |x, y|
            sum += (x - y) ** 2
        end
        
        if memo[sum]
            count += 1
        end
    end
end

puts count


Measured memory_bytes: 2172
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

lli x, y;

void read_input()
{
    cin >> x >> y;
}

void solve()
{
    cout << (abs(x - y) <= 1 ? "Brown\n" : "Alice\n");
}

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



Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	long long int a,b;
	
	do{
		scanf("%lld %lld",&a,&b);
		
		if(a==0 && b==0)
		break;
		if(a>b)
		{
			printf("%lld %lld\n",b,a);
		}
		else if(a<b)
		{
			printf("%lld %lld\n",a,b);
		}
		else
		{
			printf("%lld %lld\n",a,b);
		}
	}while(a!=0 || b!=0);
}


Measured memory_bytes: 1864
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
 
int main() {
	int n, h, ma = 0, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> h;
		if (ma <= h) ma = h;
		else if (ma > h && i != n - 1) {
			ans += ma - h;
			ma = h;
		}
	}
	ans += ma;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import decimal


def solve_gutyoku(N, K, A):
    A_combinations = []
    for i in range(len(A)):
        for j in range(i + 1, len(A)):
            A_combinations.append(A[i] * A[j])
    ans = sorted(A_combinations)[K-1]
    return ans


def solve(N, K, A):
    for i, a in enumerate(A):
        if a >= 0:
            break
    for j, a in enumerate(A):
        if a > 0:
            break
    A_hu = A[:i]
    A_0 = A[i:j]
    A_sei = A[j:]
    n_hu = len(A_hu)*len(A_sei)
    n_0 = len(A_0)*(len(A)-1) - len(A_0)*(len(A_0)-1)//2
    n_sei = (len(A_sei) - 1) * len(A_sei) // 2 + \
        (len(A_hu) - 1) * len(A_hu) // 2
    if K > n_hu and K <= n_hu + n_0:
        return 0
    elif K <= n_hu:
        left, right = int(-1 * 1e18), 0
        while right - left > 1:
            piv = (left + right) // 2
            cnt = 0
            i = 0
            for a in A_sei:
                while i < len(A_hu) and A_hu[i] * a <= piv:
                    i += 1
                cnt += i
            if cnt >= K:
                right = piv
            else:
                left = piv
        return right
    else:
        A_hu = [-1 * a for a in A_hu[::-1]]
        K -= n_hu + n_0
        left, right = 0, int(1e18) + 1
        while right - left > 1:
            piv = (left + right) // 2
            cnt = 0
            i = 0
            for a in A_sei[::-1]:
                while i < len(A_sei) and A_sei[i] * a <= piv:
                    i += 1
                cnt += i - (a * a <= piv)
            i = 0
            for a in A_hu[::-1]:
                while i < len(A_hu) and A_hu[i] * a <= piv:
                    i += 1
                cnt += i - (a * a <= piv)
            cnt = cnt // 2
            if cnt >= K:
                right = piv
            else:
                left = piv
        return right


def main():
    N, K = map(int, input().split())
    A = sorted(list(map(int, input().split())))
    ans = solve(N, K, A)
    print(ans)



main()


Measured memory_bytes: 151764
#include <cstdio>
#include <cstring>

int main()
{
  char s[101];
  scanf("%s", s);
  int len = strlen(s);
  int ans = 0;
  for (int i = 0; i < len / 2; ++i)
  {
    if (s[i] != s[len - 1 - i]) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
from operator import itemgetter
import sys
n = int(input())
a = [0] * n
#b = [0] * n
#print(a,b)
for i in range(n):
    a[i] = list(map(int,input().split()))

a.sort(key=itemgetter(1))
tmp = 0
for i in a:
    tmp += i[0]
    if tmp > i[1]:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 53728
import java.util.*;
import java.math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        if(N == 1L){
            System.out.println(0);
        }else{
            BigInteger n1 = BigInteger.valueOf(N);
            BigInteger n2 = BigInteger.valueOf(N - 1L);
            System.out.println((n1.multiply(n2).divide(BigInteger.valueOf(2L))).toString());
        }
    }
    
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int k;
 int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 cin >> k;
 cout << a[k-1];
 return 0;
}

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

string S;
int main(){
	cin >> S;
	for(long long i = 0; i < S.size(); i++){
		if(i%2 == 0){
			if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D'){
				cout << "No" << endl;
				return 0;
			}
		} else {
			if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 384
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int N, M;
bool adj[10][10]; // 0-origin
bool visited[10];
int vcount=0;
int ans=0;

void dfs(int from){
  visited[from] = true;
  ++vcount;

  if(vcount==N) ++ans;
  else REP(i,N) if(!visited[i] && adj[from][i]) dfs(i);

  visited[from] = false;
  --vcount;
  return;
}


int main(){
  cin>>N>>M;
  REP(i,N) REP(j,M) adj[i][j]=false;
  REP(i,M){
    int a,b; cin>>a>>b;
    adj[a-1][b-1]=adj[b-1][a-1]=true;
  }

  dfs(0);

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


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

#define ll long long
int n,T,E;
int a[100010];
long long ans;
long long f[100010],g[100010];
pair<int,long long> q[100010];

int main()
{int i,j,t,w;
 
 scanf("%d%d%d",&n,&E,&T);
 for(i=1;i<=n;i++) scanf("%d",&a[i]);
 f[0]=0;
 j=1;
 a[n+1]=E;
 t=1;
 w=0;
 for(i=1;i<=n;i++)
 {	while(j+1<=i && (a[i]-a[j+1])*2>=T) j++;
	if((a[i]-a[j])*2>=T) f[i]=max(f[i],(a[i+1]-a[i])*2+g[j-1]);
	while(t<=w && (a[i]-a[q[t].first])*2>=T) t++;
	while(t<=w && q[w].second<=f[i-1]-a[i]*2) w--;
	q[++w]=make_pair(i,f[i-1]-a[i]*2);
	if(t<=w) f[i]=max(f[i],q[t].second+2*a[i]+2*(a[i+1]-a[i])-T);
	g[i]=max(g[i-1],f[i]);
	//cout<<i<<" "<<f[i]<<endl;
 }
 ans=(ll)3*E-f[n]-2*a[1];
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    int x[2],a,b,c;
    cin >> x[0] >> x[1] >> a >> b >> c;
    vector<int> p(a);
    rep(i,a) cin >> p[i];
    vector<int> q(b);
    rep(i,b) cin >> q[i];
    vector<int> r(c);
    rep(i,c) cin >> r[i];
    priority_queue<pair<int,int> > pq;
    rep(i,a)pq.push(MP(p[i],0));
    rep(i,b)pq.push(MP(q[i],1));
    rep(i,c)pq.push(MP(r[i],2));
    ll sm = 0;
    int cnt[3]={};
    while(!pq.empty()){
        auto ss = pq.top();
        pq.pop();
        if(ss.second==2){
            cnt[2]++;
            sm += ss.first;
        }else{
            if(cnt[ss.second]==x[ss.second])continue;
            cnt[ss.second]++;
            sm += ss.first;
        }
        if(cnt[0]+cnt[1]+cnt[2] == x[0]+x[1]){
            break;
        }
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 7664
using System;

public class hello
{
    public static void Main()
    {
        var t = getT();
        var a = new int[5];
        var count = 0;
        for (int i = 0; i < 10; i++)
        {
            a[0] = i;
            for (int j = 0; j < 10; j++)
            {
                a[1] = j;
                for (int k = 0; k < 10; k++)
                {
                    a[2] = k;
                    for (int L = 0; L < 10; L++)
                    {
                        a[3] = L;
                        get5(t, a);
                        if (!check1(t, a) | !check2(t, a)) count++;
                    }
                }
            }
        }
        Console.WriteLine(count);
    }
    public static bool check2(int[,] t, int[] a)
    {
        var b = new int[5];
        b[0] = a[0]; b[1] = a[1]; b[2] = a[2]; b[3] = a[3]; b[4] = a[4];
        for (int i = 0; i < 4; i++)
            if (a[i] != a[i + 1])
            {
                b[i] = a[i + 1]; b[i + 1] = a[i];
                if (check(t, b)) return false;
                b[i] = a[i]; b[i + 1] = a[i + 1];
            }
        return true;
    }
    public static bool check1(int[,] t, int[] a)
    {
        var b = new int[5];
        b[0] = a[0]; b[1] = a[1]; b[2] = a[2]; b[3] = a[3]; b[4] = a[4];
        for (int i = 0; i < 5; i++)
            for (int j = 0; j < 10; j++)
                if (j != a[i])
                {
                    b[i] = j;
                    if (check(t, b)) return false;
                    b[i] = a[i];
                }
        return true;
    }
    public static bool check(int[,] t, int[] a) => t[t[t[t[t[0, a[0]], a[1]], a[2]], a[3]], a[4]] == 0;
    public static void get5(int[,] t, int[] a)
    {
        a[4] = t[t[t[t[0, a[0]], a[1]], a[2]], a[3]];
    }
    public static int[,] getT()
    {
        var a = new int[10, 10];
        for (int i = 0; i < 10; i++)
        {
            string[] s = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 10; j++)
                a[i, j] = int.Parse(s[j]);
        }
        return a;
    }
}



Measured memory_bytes: 17992
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) begin(x),end(x)
using LL=long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const int INF = numeric_limits<int>::max();
const int mod = 1000000007;
int main()
{
	LL N;
	cin >> N;
	LL res{ 1 };
	REP2( i, 1, N + 1 )
	{
		res *= i;
		res %= mod;
	}
	cout << res << endl;
	return 0;
}

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = input()

l, r = 0, len(S)-1
count = 0
while l < r:
    if S[l] != S[r]:
        count += 1
    l += 1
    r -= 1

print(count)


Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

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

	vector<int> W(N);
	for (int i = 0; i < N; i++)
	{
		cin >> W[i];
	}

	int ans = 110;

	int S1 = 0;
	int S2 = 0;
	
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (j <= i) {
				S1 += W[j];
			}
			else {
				S2 += W[j];
			}
		}
		ans = min(ans, abs(S1 - S2));
		S1 = 0;
		S2 = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  string s;
  int n,k;
  cin >> n >> k;
  cin >> s;
  s[k-1] = s[k-1] + 32;
  cout << s << endl;
  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int h, w;   cin >> h >> w;
    vector< vector<char> > vec(h, vector<char>(w));
    vector< vector<long long int> > dp(h, vector<long long int>(w));
    for(int i=0;h>i;i++){
        for(int j=0;w>j;j++){
            cin >> vec[i][j];
        }
    }
    dp[0][0]=1;
    for(int i=0;h>i;i++){
        for(int j=0;w>j;j++){
            if(vec[i][j]=='#'){
                continue;
            }
            if(j){
                dp[i][j]+=dp[i][j-1];
            }
            if(i){
                dp[i][j]+=dp[i-1][j];
            }
            dp[i][j]+=MOD;  dp[i][j]%=MOD;
        }
    }
    cout << dp[h-1][w-1];
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e3 + 5;

int g[MAXN][MAXN];

int col[MAXN];
int cnt[3];
int n;
int cnt_all[3];

vector<pii> pp;

int dp[MAXN], dp1[MAXN];

int dfs(int s, int cl){
	col[s] = cl;
	cnt[cl]++;
	REPN(i, 1, n){
		if (g[s][i]){
			if (!col[i]){
				if (dfs(i, 3 - cl)){
					return 1;
				}
			} else if (col[i] == cl){
				return 1;
			}
		}
	}
	return 0;
}

void solve(){
	int m, a, b;
	scanf("%d%d", &n, &m);
	REPN(i, 1, n){
		REPN(j, i + 1, n){
			g[i][j] = g[j][i] = 1;
		}
	}
	REP(i, 0, m){
		scanf("%d%d", &a, &b);
		g[a][b] = g[b][a] = 0;
	}
	REPN(i, 1, n){
		if (!col[i]){
			cnt[1] = cnt[2] = 0;
			if (dfs(i, 1)){
				printf("-1\n");
				return;
			}
			cnt_all[1] += min(cnt[1], cnt[2]);
			cnt_all[2] += max(cnt[1], cnt[2]);
			
			pp.pb(mp(cnt[1], cnt[2]));
			
			/*REPN(j, 1, n){
				printf("%d ", col[j]);
			}
			putchar('\n');*/
		}
	}
	//int ans = n * (n + 1) / 2 - m - cnt_all[1] * (cnt_all[1] + 1) / 2 - cnt_all[2] * (cnt_all[2] + 1) / 2;
	//int ans = cnt_all[1] * cnt_all[2] - (n * (n + 1) / 2 - m);
	
	dp[0] = 1;
	REP(i, 0, SZ(pp)){
		//printf("%d %d\n", pp[i]._1, pp[i]._2);
		REPN(j, 0, n){
			dp1[j] = 0;
		}
		for(int j = n; j >= 0; j--){
			if (dp[j]){
				dp1[j + pp[i]._1] = 1;
				dp1[j + pp[i]._2] = 1;
			}
		}
		REPN(j, 0, n){
			dp[j] = dp1[j];
		}
	}
	
	int ans = m;
	REPN(i, 0, n){
		//printf("%d ", dp[i]);
		if (dp[i]){
			ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
		}
	}
	
	//printf("%d %d\n", cnt_all[1], cnt_all[2]);
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 3072
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
	int N;
	cin >> N;
	vector<int>d(N);
	for (int i = 0; i < N; i++) {
		cin >> d.at(i);
	}
	sort(d.begin(), d.end());
	if (d.at(N / 2 - 1) == d.at(N / 2)) {
		cout << 0 << endl;
	}
	else {
		cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;
	}
}

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

long long ans;

int main(){
    int N;
    cin>>N;
    vector<long long> A,B;

    for(int i=0;i<N+1;i++){
        long long x;
        cin>>x;
        A.push_back(x);
    }

    for(int i=0;i<N;i++){
        long long x;
        cin>>x;
        B.push_back(x);
    }

    long long l=0, r=A.at(0);

    for(int i=0;i<N;i++){
        l=r;
        r=A.at(i+1);
        if(B.at(i)<=l) ans+=B.at(i);
        else if(B.at(i)<=l+r) {ans+=B.at(i); r-=(B.at(i)-l);}
        else {ans+=(l+r); r=0;}
    }

    cout<<ans<<endl;
    
}

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


template<typename VEC>
void make_z(const VEC& s, vector<ll>& z) { 
    const ll n = s.size(); 
    ll L = 0, R = 0; 
    for (int i = 1; i < n; ++i) {
        if (i > R) { 
            L = R = i; 
            while (R < n && s[R-L] == s[R]){
                R++;
            }
            z[i] = R-L; 
            R--; 
        }else{  // i <= R
            const ll k = i-L; 
            if (z[k] < R-i+1){
                z[i] = z[k]; 
            }else{
                L = i; 
                while (R<n && s[R-L] == s[R]){
                    R++;
                }
                z[i] = R-L; 
                R--; 
            }
        } 
    } 
} 

// void search(
//     const string& text,
//     const string& pattern,
//     set<ll>& out
// ){
//     string concat = pattern + "$" + text; 
//     ll l = concat.size(); 
  
//     vector<ll> z(l);
//     make_z(concat, z);
 
//     out.clear();
//     for (ll i = pattern.size() + 1; i < l; ++i){
//         if (z.at(i) == pattern.size()){
//             out.insert(i - pattern.size() - 1);
//         }
//     } 
// } 


void solve(long long N, std::vector<long long> a, std::vector<long long> b){
    vector<ll> a2(N), b2(N);
    REP(i, N){
        a2.at(i) = a.at(i) ^ a.at((i + 1) % N);
        b2.at(i) = b.at(i) ^ b.at((i + 1) % N);
    }

    // z-search
    vector<ll> concat;
    concat.reserve(3 * N + 1);
    copy(b2.begin(), b2.end(), back_inserter(concat));
    concat.push_back(-1);
    copy(a2.begin(), a2.end(), back_inserter(concat));
    copy(a2.begin(), a2.end(), back_inserter(concat));
    vector<ll> z(concat.size());
    make_z(concat, z);

    vector<ll> tmp;
    for(ll i = N + 1; i < concat.size(); ++i){
        if(z.at(i) == b2.size()){
            const ll j = i - b2.size() - 1;
            if(j < N){
                tmp.push_back(j);
            }
        }
    }

    for(ll k : tmp){
        cout << k << ' ' << (a.at(k) ^ b.at(0)) << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&b[i]);
    }
    solve(N, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 20720
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
# include <unordered_map>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 

int main()
{
	string s;
	bool f = false;
	while (cin >> s)
	{
		if (f)cout << endl;
		reverse(all(s));
		while (s.size() < 5)s += '0';
		reverse(all(s));
		f = true;
		for (int i = 0; i < s.size(); i++)
		{
			char c = '*';
			if (s[i] >= '5')
				c = ' ';
			cout << c;
		}cout << endl;
		for (int i = 0; i < s.size(); i++)
		{
			char c = ' ';
			if (s[i] >= '5')
				c = '*';
			cout << c;
		}cout << endl;
		for (int i = 0; i < s.size(); i++)
		{
			cout << '=';
		}cout << endl;

		for (int j = 0; j < 5; j++)
		{
			for (int i = 0; i < s.size(); i++)
			{
				char c = '*';
				if (s[i] == '0' + j || s[i] == '5' + j)
					c = ' ';
				cout << c;
			}cout << endl;
		}



	}

}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define I_O		ios::sync_with_stdio(false),cin.tie(0)
#define ll		long long
#define mod 	1000000007
#define rep(i,n)	for(int i=1;i<=n;i++)
#define pb 		push_back
int main()
{
	I_O;
	string s,t;
	cin>>s>>t;
	int x=0;
	for(int i=0;s[i]!='\0';i++)
	{
		if(s[i]!=t[i])
		{
			x=1;
			cout<<"No";
			break;
		}
	}
	if(!x)	cout<<"Yes";
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>


int sort(const void * a , const void * b)
{
  if (*(int *)a < *(int *)b)
    return -1;
  else if (*(int *)a == *(int *)b)
    return 0;
  
  return 1;
}


int main()
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  int arr[3] = {a, b, c};
  int arrSize = sizeof(arr) / sizeof(arr[0]);

  qsort(arr, arrSize, sizeof(arr[0]), sort);

  for (int i=0; i<arrSize; ++i)
    {
      if (i == arrSize-1)
        printf("%d\n", arr[i]);
      else
        printf("%d ", arr[i]);
    }
  
  return 0;
}



Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    set<string> st;
    int k; cin >> k;
    for(int i = 1; i <= k; i++){
        for(int j = i+1; j <= k; j++){
            string t = to_string(i); t += " ";
            if((j%2 == 0 && i%2 == 1) || (i%2 == 0 && j%2 == 1)){
                t += to_string(j); st.insert(t);
            }
        }
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s="CODEFESTIVAL2016";
  string t;
  cin>>t;
  int cnt=0;
  rep(i,s.size() ){
    if(s[i]!=t[i]) cnt++;
  }
  cout<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N,X,ans=1100,a=1100,sum=0,temp;
  cin>>N>>X;

  
  for(int i=0;i<N;i++){
    cin>>temp;
    X-=temp;
    ans=min(temp,ans);
  }

  
  cout<<X/ans+N<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
const ll mod = (ll)1e9 + 7;
	
int main(){
	speed;
	int n; cin >> n;
	int k = log2(n);
	cout << pow(2, k);	
	return 0;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int K,S; cin >> K >> S;
  int ret = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      int z = S-x-y;
      if (z >= 0 && z <= K) {
       ret++;
     }
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
$s = gets.chomp
$result = 0

def calc(idxs)
  sum = 0
  start = 0
  idxs.each do |idx|
    sum += $s[start..(idx-1)].to_i
    start = idx
  end
  return sum + $s[start..($s.size-1)].to_i
end

def explore(idx=0, idxs=[])
  if idx == $s.size-1 then
    $result += calc(idxs)
  else
    explore(idx+1, idxs)
    explore(idx+1, idxs + [idx+1])
  end
end

explore()
puts $result

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

#define ll long long
#define pb push_back
#define mod 1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define dbg(x) cout<<#x<<" = "<<x<<'\n';

void solve()
{
   int n;
   cin>>n;
   vector <int> a(n);
   int min_idx=0,max_idx=0;
   int min_val=INT_MAX,max_val=INT_MIN;
   for(int i=0;i<n;i++) 
   {
       cin>>a[i];
       if(a[i]<=min_val)
       {
           min_val=a[i];
           min_idx=i;
       }
       if(a[i]>=max_val)
       {
           max_val=a[i];
           max_idx=i;
       }
   }
    ll ans=0;
   for(int i=max_idx+1;i<n;i++)
   {
       ans+=(max_val-a[i]);
   }

    for(int i=0;i<max_idx;i++)
    {
        if(a[i+1]<a[i])
        {
            ans+=(a[i]-a[i+1]);
            a[i+1]=a[i];
        }
    }

   cout<<ans;


   
}

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


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

const int N = 1e4 + 4, D = 1e2 + 2, MOD = 1e9 + 7;

string k;
int d, n;
int dp[N][D][2];
// dp[i][j][0] : < k
// dp[i][j][1] : = k

int _sum(int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _sub(int a, int b) {
	int c = a - b;
	if (c < 0)
		c += MOD;

	return c;
}

int _mul(int a, int b) {
	return 1LL * a * b % MOD;
}


int main() {
	cin >> k >> d;
	n = k.size();
	k = '0' + k;

	dp[0][0][1] = 1;

	for (int i = 1; i <= n; i++)
		for (int j = 0; j < d; j++) {
			int h = k[i] - '0';

			for (int p = 0; p < h; p++)
				dp[i][j][0] = _sum(dp[i][j][0], dp[i - 1][(j - p + 10 * d) % d][1]);
			for (int p = 0; p < 10; p++)
				dp[i][j][0] = _sum(dp[i][j][0], dp[i - 1][(j - p + 10 * d) % d][0]);

			dp[i][j][1] = dp[i - 1][(j - h + 10 * d) % d][1];
		}

	cout << _sub(_sum(dp[n][0][0], dp[n][0][1]), 1) << "\n";
}

Measured memory_bytes: 8192