akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9) cout << a*b << endl;
    else cout << -1 << endl;
}

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

int m,n,ans,dp[2][N][N][N];
char mm[N][N];
bool now,cur;

inline void Max(int &u,int v){if(v>u) u=v;}
int main()
{
    int i,j,p,q,l,r,mid;
    cin>>m>>n;
    for(i=1;i<=m;i++) scanf("%s",mm[i]+1);
    now=1;
    for(q=1;q<=m;q++)
    {
	for(p=q;p>=1;p--)
	{
	    for(i=n;i>=1;i--)
	    {
		if(p==q)
		{
		    if(i==n) dp[now][p][q][i]=n+1;
		    if(mm[p][i]==mm[p][i+1]) dp[now][p][q][i]=dp[now][p][q][i+1];
		    else dp[now][p][q][i]=i+1;
		}
		else
		{
		    if(mm[q-1][i]==mm[q][i]) dp[now][p][q][i]=min(dp[now][p][q-1][i],dp[now][q][q][i]);
		    else dp[now][p][q][i]=i;
		}
	    }
	}
    }
    for(ans=0;;ans++)
    {
	if(dp[now][1][m][1]==n+1)
	{
	    cout<<ans;
	    return 0;
	}
	swap(now,cur);
	for(p=1;p<=m;p++)
	{
	    for(q=p;q<=m;q++)
	    {
		for(i=1;i<=n;i++)
		{
		    if(dp[cur][p][q][i]==n+1) dp[now][p][q][i]=n+1;
		    else dp[now][p][q][i]=dp[cur][p][q][dp[cur][p][q][i]];
		    for(l=p,r=q;l<r;)
		    {
			mid=((l+r)>>1);
			Max(dp[now][p][q][i],min(dp[cur][p][mid][i],dp[cur][mid+1][q][i]));
			if(dp[cur][p][mid][i]>dp[cur][mid+1][q][i]) l=mid+1;
			else r=mid;
		    }
		}
	    }
	}
    }
}


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

using namespace std;

#define MAX_N 7
#define MAX_S 3000
#define MOD 100000

int dp[MAX_N * MAX_N + 1][MAX_S + 1];

int main()
{
	int N, M, S;
	while (scanf("%d %d %d", &N, &M, &S), N || M || S) {
		memset(dp, 0, sizeof(dp));

		dp[0][0] = 1;

		for (int k = 1; k <= M; ++k) {
			for (int i = N * N; i >= 1; --i) {
				for (int j = k; j <= S; ++j) {
					dp[i][j] += dp[i - 1][j - k];
					dp[i][j] %= MOD;
				}
			}
		}

		printf("%d\n", dp[N * N][S]);
	}
}

Measured memory_bytes: 1620
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	vector<int>v(10010, 0);
	rep(i, 0, N)v[a[i]]++;
	vector<int>b(N); int x(0);
	rep(i, 0, 10010) {
		while (v[i]--)b[x++] = i;
	}
	rep(i, 0, N)cout << b[i] << (i == N - 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 18300
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
    
    long long n;
    cin >> n;

    vector<long long> v(n+1,1e9);
    vector<long long> cost(n);

    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        cost[i] = tmp;
    }
    v[n-1] = 0;
    for (int i = n-2; i >= 0; i--)
    {
        v[i] = min(v[i+2]+abs(cost[i+2]-cost[i])
        ,v[i+1]+abs(cost[i+1]-cost[i]));
    }

    cout << v[0] << endl;
    
}


Measured memory_bytes: 1792
// ABC139 A - Tenki
// 20190902

using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力受け取り
            string S, T;
            S = Console.ReadLine();
            T = Console.ReadLine();

            //計算
            int count = 0;

            for (int i = 0; i < 3; i++)
            {
                count += (S[i] == T[i]) ? 1 : 0;
            }

            //出力
            Console.WriteLine(count);

        }
    }
}


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


int main()
{
   string str;
   cin>>str;
   bool flag = true;
   for(int i=0;i<str.length()-1;i++)
      if(str[i] == str[i+1])
      {
         flag = false;
         break;
      }
   if(flag)
      cout<<"Good";
   else
      cout<<"Bad";

   return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
#include <sstream>

using namespace std;

int main()
{
	int i, j, k, l;

	string str;
	cin >> str;

	int y, m, d;

	y = m = d = 0;

	y += 1000 * (int)(str[0] - '0');
	y += 100 * (int)(str[1] - '0');
	y += 10 * (int)(str[2] - '0');
	y += (int)(str[3] - '0');

	m += 10 * (int)(str[5] - '0');
	m += (int)(str[6] - '0');

	d += 10 * (int)(str[8] - '0');
	d += (int)(str[9] - '0');

	if (y >= 2020)
	{
		printf("TBD");
		return 0;
	}
	else
		if (y <= 2018)
		{
			printf("Heisei");
			return 0;
		}

	if (m >= 5)
	{
		printf("TBD");
		return 0;
	}
	else
		if (m <= 3)
		{
			printf("Heisei");
			return 0;
		}

	if (d >= 31)
	{
		printf("TBD");
		return 0;

	}

	printf("Heisei");
	return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

int main()
{

    //freopen("input.txt", "r", stdin); // for getting input from input.txt
    //freopen("output.txt", "w", stdout);// for writing output to output.txt

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

    int a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    if(k>=a+b+c)
        cout<<a-c;
    else if(k>=a+b)
        cout<<a-(k-a-b);
    else if(k>=a)
        cout<<a;
    else cout<<k;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split().Select(int.Parse).OrderBy(i => i).ToArray();

            var ans = 0;
            if (d.Length % 2 == 0)
            {
                var half = d.Length / 2;
                ans = d[half] - d[half - 1];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 22112
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

li dp[2000][2000];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    li n;
    cin >> n;
    vector<li> xs(3 * n);
    for (int i = 0; i < 3 * n; ++i) {
        cin >> xs[i];
        xs[i]--;
    }

    const li inf = 1LL << 50;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dp[i][j] = -inf;
        }
    }
//    vector<vector<li>> dp(n, vector<li>(n, -inf));
    vector<li> dp_maxx(n, -inf);
    vector<li> dp_maxy(n, -inf);
    li dp_max = -inf;

    auto update = [&](const li x, const li y, const li v) {
        dp[x][y] = max(dp[x][y], v);
        dp_maxx[y] = max(dp_maxx[y], v);
        dp_maxy[x] = max(dp_maxy[x], v);
        dp_max = max(dp_max, v);
    };

    update(xs[0], xs[1], 0);

    li offset = 0;
    for (int itr = 0; itr < n - 1; ++itr) {
        const li p = xs[2 + itr * 3];
        const li q = xs[2 + itr * 3 + 1];
        const li r = xs[2 + itr * 3 + 2];

        // add, use 3
        if (p == q && q == r) {
            offset++;
            continue;
        }

        vector<tuple<li, li, li>> updates;

        // add, use 2
        if (p == q || q == r || p == r) {
            li pair, rem;
            if (p == q) {
                pair = p;
                rem = r;
            } else if (q == r) {
                pair = q;
                rem = p;
            } else {
                pair = r;
                rem = q;
            }
            for (int k = 0; k < n; ++k) {
                updates.emplace_back(k, rem, dp[k][pair] + 1);
                updates.emplace_back(k, rem, dp[pair][k] + 1);
            }
        }

        // add, use 1
        updates.emplace_back(q, r, dp[p][p] + 1);
        updates.emplace_back(p, r, dp[q][q] + 1);
        updates.emplace_back(p, q, dp[r][r] + 1);

        // no-add, use 3
        // reusing the dp table to avoid O(n^2) updates.

        // no-add, use 2
        for (int k = 0; k < n; ++k) {
            updates.emplace_back(k, p, dp_maxx[k]);
            updates.emplace_back(k, p, dp_maxy[k]);
            updates.emplace_back(k, q, dp_maxx[k]);
            updates.emplace_back(k, q, dp_maxy[k]);
            updates.emplace_back(k, r, dp_maxx[k]);
            updates.emplace_back(k, r, dp_maxy[k]);
        }

        // no-add, use 1
        updates.emplace_back(p, q, dp_max);
        updates.emplace_back(p, r, dp_max);
        updates.emplace_back(q, r, dp_max);

        for (auto &upd: updates) {
            update(get<0>(upd), get<1>(upd), get<2>(upd));
        }
    }

    li ans = dp_max;
    for (int x = 0; x < n; ++x) {
        for (int y = 0; y < n; ++y) {
            if (x == y && y == xs[3 * n - 1]) {
                ans = max(ans, dp[x][y] + 1);
            }
        }
    }

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

Measured memory_bytes: 35328
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100000;

int main()
{
	ll n;
	ll res;
	cin >> n;
	if(n%11 >= 1 && n%11 <= 6){
		res = ((n-1)/11)*2+1;
	}else{
		res = ((n-1)/11)*2+2;
	}
	cout << res;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main(){
  int n = 10;
  int in;
  int ans = 0;

  for(int i=0;i<n;i++){
    scanf("%d",&in);
    ans += in;
  }

  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 1188
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(N, XY):
    g = defaultdict(dict)
    V = [(i, x, y) for i, (x, y) in enumerate(XY)]
    V.sort(key=lambda x: x[1])
    for i in range(1, N):
        v = V[i][0]
        u = V[i-1][0]
        d = min(abs(XY[v][0] - XY[u][0]), abs(XY[v][1] - XY[u][1]))
        g[v][u] = d
        g[u][v] = d

    V.sort(key=lambda x: x[2])
    for i in range(1, N):
        v = V[i][0]
        u = V[i-1][0]
        d = min(abs(XY[v][0] - XY[u][0]), abs(XY[v][1] - XY[u][1]))
        g[v][u] = d
        g[u][v] = d

    return Prim(g)


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]

    print(slv(N, XY))


if __name__ == '__main__':
    main()


Measured memory_bytes: 138404
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define mod 1000000007
int a[2000005],b[2000005];
int main()
{
    /*string s;
    cin >> s;
    int n = s.size();
    if(s[n-1]=='s')
        s+="es";
    else
        s+="s";
    cout <<s << endl;*/
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i] >> b[i];

    int f=0;
    for(int i=1;i<=n-2;i++)
    {
        if((a[i]==b[i])&&(a[i+1]==b[i+1])&&(a[i+2]==b[i+2]))
        {
            f=1;
            break;
        }
    }
    if(f) cout << "Yes\n";
    else
        cout << "No\n";
}


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

int main(){

int n,k;
	int num;
	int min=2000000000;
	cin>>n>>k;
	vector<int> data(n);
	
	for(int i=0;i<n;i++){
	cin>>data[i];
	}

	sort(data.begin(),data.end());
	
	for(int j=0;j<n-k+1;j++){
		if(min>data[(k-1)+j]-data[j]){
		min=data[(k-1)+j]-data[j];
		}
	}
	cout<<min<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include <vector>
#include<algorithm>

using namespace std;

int main(){
    vector<int> a;
    int b = 0;
    for(int i = 0; i < 3; i++){
        cin >> b;
        a.push_back(b);
    }

    sort(a.begin(), a.end(), greater<int>());

    int c = 0;
    c = a[0] * 10 + a[1] + a[2];

    cout << c << endl;

}

Measured memory_bytes: 256
def main():
    x, k, d = map(int, input().split())
    l = 0
    r = k
    ans = abs(x + k * d)
    while l <= r:
        mid = int((l + r)/2)
        nw = x - mid*d + (k - mid)*d
        ans = min(abs(nw), ans)
        if nw < 0:
            r = mid - 1
        else:
            l = mid + 1
    print(ans)

main()
    

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

bool checkDistanceInteger(int, int[], int[]);

int main(void){
    // Your code here!
    int N, D;
    cin >> N >> D;
    
    int** X = new int*[N];
    for(int i=0; i<N; i++){
        X[i] = new int[D];
        for(int j=0; j<D; j++){
            cin >> X[i][j];
        }
    }
    
    int ans_num = 0;
    
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(checkDistanceInteger(D, X[i], X[j])) ans_num++;
        }
    }
    
    cout << ans_num << endl;
}

bool checkDistanceInteger(int D, int A[], int B[]){
    int temp = 0;
    
    for(int i=0; i<D; i++){
        temp += (A[i] - B[i]) * (A[i] - B[i]);
    }
    
    double d = sqrt(temp);
    
    if(ceil(d) != floor(d)) return false;
    
    return true;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  vector<int>a(n);
  string ans="APPROVED";
  for(int i=0;i<n;i++){
    cin>>a[i];
   if(a[i]%2==0){
     if(a[i]%3!=0&&a[i]%5!=0){
       ans="DENIED";
        break;
     }
   }
  }
  cout<<ans<<endl;
    
  
  
  
  
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

void add(ll &a, ll b)
{
    a += b;
    if(a >= IMOD) { 
        a -= IMOD;
    }
}

int main(void)
{
    string s;
    cin >> s;
    int n = s.size();

    ll dp[n+5][4];

    irep(i, n+5) { 
        irep(j, 4) {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;
    irep(i, n) {
        irep(j, 4) {
            if(s[i] == '?') {
                add(dp[i+1][j], 3*dp[i][j]%IMOD);
            } else {
                add(dp[i+1][j], dp[i][j]);
            }
        }

        if(s[i] == 'A' || s[i] == '?') {
            add(dp[i+1][1], dp[i][0]);
        }

        if(s[i] == 'B' || s[i] == '?') {
            add(dp[i+1][2], dp[i][1]);
        }

        if(s[i] == 'C' || s[i] == '?') {
            add(dp[i+1][3], dp[i][2]);
        }
    }

    ll ans = 0;
    #if 0
    irep(j, 4) { irep(i, s.size()+1) {
        printf("%d,", dp[i][j]);
    } printf("\n"); }
    #endif
    cout << dp[s.size()][3] << endl;
    return 0;
}   
/** atcoder **/



Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
	string s;
	cin >> s;
	int count = 0;
	for(int i=0;i<s.length();i++){
		if(s.at(i)=='+'){
			count++;
		}else{
			count--;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define    fios ios_base::sync_with_stdio(false); cin.tie(0);
#define    sf(x) scanf("%d",&x)
#define    sfl(x) scanf("%lld",&x)
#define    pf(x) printf("%d\n",x)
#define    pfl(x) printf("%lld\n",x)
#define    ll long long
#define    nl "\n"
#define    PB(x) push_back(x)
#define    For(i,n) for(int i=0; i<n; i++)
#define    PI acos(-1)
using namespace std;


int main()
{

    double b;
    ll a;
    cin>>a>>b;

    long double ans=(a*b);

    cout<<(ll)(ans+0.001)<<nl;;


    return 0;
}


Measured memory_bytes: 3656
A, B, C = map(int, input().split())
five = 0
seven = 0
for i in [A,B,C]:
    if i == 5:
        five += 1
    if i == 7:
        seven += 1

if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=250000;
const ll inf=10000000000000;
int n,m,a,b;
ll ans;
int x[maxn];
ll sum[maxn];
int id[maxn];
int num[maxn];
ll f[maxn];
struct tree
{
	int l,r;
	ll fp;
}tree1[maxn*4],tree2[maxn*4];
bool cmp(int ai,int bi)
{
	return x[ai]<x[bi];
}
void build1(int p,int l,int r)
{
	tree1[p].l=l;
	tree1[p].r=r;
	tree1[p].fp=inf;
	if(l==r)
	{
		return;
	}
	int mid=(l+r)/2;
	build1(2*p,l,mid);
	build1(2*p+1,mid+1,r);
//	tree1[p].fp=min(tree1[2*p].fp,tree1[2*p+1].fp);
}
void build2(int p,int l,int r)
{
	tree2[p].l=l;
	tree2[p].r=r;
	tree2[p].fp=inf;
	if(l==r)
	{
		//tree2[p].fp=inf;
		return;
	}
	int mid=(l+r)/2;
	build2(2*p,l,mid);
	build2(2*p+1,mid+1,r);
	//tree2[p].fp=min(tree2[2*p].fp,tree2[2*p+1].fp);
}
void change1(int p,int l,int r,int point,ll fp0)
{
	if(l==r)
	{
		tree1[p].fp=fp0;return;
	}
	int mid=(l+r)/2;
	if(point<=mid)change1(2*p,l,mid,point,fp0);
	else change1(2*p+1,mid+1,r,point,fp0);
	tree1[p].fp=min(tree1[2*p].fp,tree1[2*p+1].fp);
}
void change2(int p,int l,int r,int point,ll fp0)
{
	if(l==r)
	{
		tree2[p].fp=fp0;return;
	}
	int mid=(l+r)/2;
	if(point<=mid)change2(2*p,l,mid,point,fp0);
	else change2(2*p+1,mid+1,r,point,fp0);
	tree2[p].fp=min(tree2[2*p].fp,tree2[2*p+1].fp);
}
ll query1(int p,int l,int r,int aL,int aR)
{
	if(aL==l&&aR==r)
	{
		return tree1[p].fp;
	}	
	int mid=(l+r)/2;
	if(aL>mid)return query1(2*p+1,mid+1,r,aL,aR);
	else if(aR<=mid)return query1(2*p,l,mid,aL,aR);
	else return min(query1(2*p,l,mid,aL,mid),query1(2*p+1,mid+1,r,mid+1,aR));
}
ll query2(int p,int l,int r,int aL,int aR)
{
	if(aL==l&&aR==r)
	{
		return tree2[p].fp;
	}	
	int mid=(l+r)/2;
	if(aL>mid)return query2(2*p+1,mid+1,r,aL,aR);
	else if(aR<=mid)return query2(2*p,l,mid,aL,aR);
	else return min(query2(2*p,l,mid,aL,mid),query2(2*p+1,mid+1,r,mid+1,aR));
}
ll work()
{
	build1(1,1,m+1);
	build2(1,1,1+m);
	change1(1,1,m+1,num[0],f[1]-sum[1]-(ll)x[0]);
	change2(1,1,1+m,num[0],f[1]-sum[1]+(ll)x[0]);
	for(int i=2;i<=m;i++)
	{
		f[i]=query1(1,1,1+m,1,num[i])+(ll)x[i]+sum[i-1];
		f[i]=min(f[i],query2(1,1,1+m,num[i],m+1)-(ll)x[i]+sum[i-1]);
		change1(1,1,m+1,num[i-1],f[i]-(ll)x[i-1]-sum[i]);
		change2(1,1,m+1,num[i-1],f[i]+(ll)x[i-1]-sum[i]);
	}
	for(int i=1;i<=m;i++)
	ans=min(ans,f[i]+sum[m]-sum[i]);
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x[i]);
		if(i>1) sum[i]=abs(x[i]-x[i-1]);
	}
	for(int i=1;i<=m;i++)
	sum[i]+=sum[i-1];
	
	ans=inf;
	x[0]=b;
	f[1]=abs(a-x[1]);
	for(int i=0;i<=m;i++)id[i]=i;//9 2 1 9									//5 9 
	sort(id,id+1+m,cmp);
	for(int i=0;i<=m;i++)
	{
		num[id[i]]=i+1;
	}
	work();
	
	x[0]=a;
	f[1]=abs(b-x[1]);
	for(int i=0;i<=m;i++)id[i]=i;
	sort(id,id+1+m,cmp);
	for(int i=0;i<=m;i++)
	{
		num[id[i]]=i+1;
	}
	work();
	
	printf("%lld\n",ans); 
} 

Measured memory_bytes: 27520
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll n;cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[n-i-1];
    }
    string s;cin>>s;
    set<ll,greater<ll>>basis;
    reverse(s.begin(),s.end());
    for(int i=0;i<n;i++){
        for(auto j:basis){
            arr[i]=min(arr[i],arr[i]^j);
        }
        if(arr[i]==0){
            continue;
        }
        if( s[i]=='0' )
            basis.insert(arr[i]);
        if( s[i]=='1' ){
            cout<<1<<"\n";
            return;
        }
    }
    cout<<0<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <string>
int main()
{
  int w, n;
  std::cin >> w;
  std::cin >> n;
  int num[w + 1];
  for (int i = 1; i <= w; i++) {
    num[i] = i;
  }
  while (n--) {
    std::string line;
    std::cin >> line;
    int index = line.find(",");
    if (index != -1) line.replace(index, 1, " ");
    std::istringstream iss(line);
    int a, b, temp;
    iss >> a >> b;
    temp = num[a];
    num[a] = num[b];
    num[b] = temp;
  }
  for (int i = 1; i <= w; i++) {
    std::cout << num[i] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1220
N=int(input())
K=int(input())
import sys
sys.setrecursionlimit(10**6)
def solve(N, K):
    if K==1:
        l=len(str(N))
        ans=0
        for i in range(l):
            if i!=l-1:
                ans+=9
            else:
                ans+=int(str(N)[0])
        #print(ans)
        return ans
    else:
        nextK=K-1
        l=len(str(N))
        ini=int(str(N)[0])
        res=ini*(10**(l-1))-1
        #print(res)
        if l>=K:
            ans=solve(res, K)
            nextN=int(str(N)[1:])
            ans+=solve(nextN, nextK)
            return ans
        else:
            return 0
ans=solve(N,K)
print(ans)

Measured memory_bytes: 119772
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;



int main(int argc, const char * argv[]) {

  int r;
  cin >> r;
  cout << 3 * pow(r, 2) << endl;

  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    long long r;
    cin >> r;
    long long A=3*r*r;
    cout << A;
    }

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

int main() {
    int a, b;
    cin >> a >> b;

    if(a > b) {
        cout << "a > b" << endl;
    } else if(a == b) {
        cout << "a == b" << endl;
    } else {
        cout << "a < b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(){
  int w, h, x, y, r;
  int N, S, E, W; 
  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
  N = y + r;
  S = y - r;
  E = x + r;
  W = x - r;
  if(N <= h && S >= 0 && E <= w && W >= 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2104
//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 2e5 + 50, oo = 3e18 + 500;
//const int mod = 998244353;
const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-12, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
set<int> g[N];
vi rg[N];
vi visit(N, 0);

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("abbreviation.in", "r", stdin);
	freopen("abbreviation.out", "w", stdout);*/

	cin >> n;

	string ans;
	
	while (n > 0)
	{
		int mod = n % 26;
		ans += (char)((mod + 25) % 26 + 'a');
		n /= 26;

		if (!mod)
			n--;
	}

	reverse(all(ans));
	cout << ans << endl;
}



Measured memory_bytes: 13436
function prime(max){
   var arr=[];
   for(var i=0;i<=max;i++)arr[i]=i;
   arr[0]=false;
   arr[1]=false;
   var sqrt=Math.floor(Math.sqrt(max));
   for(var i=2;i<=sqrt;i++){
      if(arr[i]==false)continue;
         for(var j=i+i;j<=max;j+=i){
            arr[j]=false;
         }
   }
   var result=[];
   for(var i=0;i<=max;i++){
      if(arr[i]!==false)result.push(arr[i]);
   }
   return result;
}
var p=prime(50000);
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var cnt=0;
   var k=p.length-1;
   for(var i=0;i<p.length;i++){
      while(p[i]+p[k]>n)k--;
      if(k<i)break;
      if(p[i]+p[k]==n)cnt++;
   }
   console.log(cnt);
}

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

int h,w;
vector<string>f(405);
int ans[405][405]={0};
long long res[200000][2]={0};
int cnt=1;

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

void dfs(int x, int y){
	for(int i = 0; i < 4; i++){
		int nx = x+ dx[i];
		int ny = y + dy[i];
		if(ans[nx][ny]==0&&0<=nx&&nx<h&&0<=ny&&ny<w&&f[nx][ny]!=f[x][y]){
			ans[nx][ny]=cnt;
			if(f[nx][ny]=='#') res[cnt][0]++;
			else res[cnt][1]++;
			dfs(nx,ny);
		}
	}
	return;
}


int main(){
	cin >> h >> w;
	for(int i = 0; i < h; i++) cin >> f[i];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(ans[i][j] == 0){
				ans[i][j]=cnt;
				if(f[i][j]=='#') res[cnt][0]++;
				else res[cnt][1]++;
				dfs(i,j);
				cnt++;
			}
		}
	}
	long long sum = 0;
	for(int i = 0; i < 200000;i++) sum += res[i][0]*res[i][1];
	cout << sum << endl;
	return 0;
}





Measured memory_bytes: 18560
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef pair<pair<int,int>,int> NODE;
#define cost first.first
#define ticket first.second
#define city second
#define make_bus_st(a,b,c) make_pair(make_pair(a,b),c)

int busMap[200][200] ;
int memo[200][20];

int main()
{
	int C, N, M, S, D;
	int a, b, f;
	
	while(cin >> C >> N >> M >> S >> D, C, N, M, S, D) {
		for(int i = 0; i < 200; i++) {
			for(int j = 0; j < 200; j++) {
				busMap[i][j] = 0;
				if(j < 20) { memo[i][j] = (1<<21); }
			}
		}
		
		vector<int> nextCity[200];
		
		for(int i = 0; i < M; i++) {
			cin >> a >> b >> f;
			busMap[a][b] = busMap[b][a] = f;
			nextCity[a].push_back(b);
			nextCity[b].push_back(a);
		}
		
		priority_queue<NODE> bus;
		bus.push(make_bus_st(0,C,S));
		
		while(!bus.empty()) {
			NODE tmp = bus.top();
			bus.pop();
			
			for(int i = 0; i < nextCity[tmp.city].size(); i++) {
				int next = nextCity[tmp.city][i];
				
				if((busMap[tmp.city][next] + tmp.cost) < memo[next][tmp.ticket]) {
					memo[next][tmp.ticket] = busMap[tmp.city][next] + tmp.cost;
					bus.push(make_bus_st(memo[next][tmp.ticket], tmp.ticket, next));
				}
				if(tmp.ticket && (((busMap[tmp.city][next] / 2) + tmp.cost) < memo[next][tmp.ticket-1])) {
					memo[next][tmp.ticket-1] = (busMap[tmp.city][next] / 2) + tmp.cost;
					bus.push(make_bus_st(memo[next][tmp.ticket-1], tmp.ticket-1, next));
				}
			}
		}
		
		int ans = (1<<21);
		for(int i = 0; i <= C; i++) {
			ans = min(ans, memo[D][i]);
		}
		cout << ans << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    int n, k;
    cin>>n>>k;
    map<int, int>u;
    for(int i = 0; i < k; i++){
        int d;
        cin>>d;
        for(int j = 0; j < d; j++){
            int a;
            cin>>a;
            u[a]++;
        }
    }   
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(!u[i])cnt++;
    }
    cout<<cnt;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

vector<int> adj[200000];
int update[200000],ans[200000];

void dfs(int cur,int par,int lst){
    ans[cur]=update[cur]+lst;
    for(int child:adj[cur]){
        if(child==par)continue;
        dfs(child,cur,ans[cur]);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,q;cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;
        a--,b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p,x;cin>>p>>x;
        p--;
        update[p]+=x;
    }
    dfs(0,-1,0);
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
}


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

int main() {
    string n;
    cin >> n;
    for (int i = 0; i < 3; i++) {
        if (n[i] == '1') {
            n[i] = '9';
        } else {
            n[i] = '1';
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 508
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let n: usize = buf.trim().parse().ok().unwrap();

    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let a =  buf.split_whitespace().map(|x| x.parse().ok().unwrap()).collect::<Vec<u64>>();

    let mut acc = Vec::with_capacity(n + 1);
    acc.push(0);
    for i in 0..n {
    	let last = acc[i];
        acc.push(last + a[i])
    }

    let mut left = 0usize;
    let mut right = n;

    while right - left > 1 {
        let mid = (left + right) / 2;
        if pred(mid, &acc, acc[n]/2) {
            left = mid;
        } else {
            right = mid;
        }
    }

    let reach_harf = right - 1;
    let ans = std::cmp::min(
        (acc[reach_harf] as i64 - (acc[n] - acc[reach_harf]) as i64).abs(),
        (acc[reach_harf+1] as i64 - (acc[n] - acc[reach_harf+1]) as i64).abs()
    );

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

fn pred(mid: usize, acc: &[u64], harf: u64) -> bool {
    harf >= acc[mid]
}


Measured memory_bytes: 12408
function Main (input) {
  input = input.split("\n");
  var ts = input[0].split(" ");
  const H = parseInt(ts[0], 10);
  const N = parseInt(ts[1], 10);
  const A = input[1].split(" ").map(inp => parseInt(inp, 10));
  var ans_1 = 0;
  for (var i_1 of A) {
    ans_1 += i_1;
  }
  ans_1 >= H ? console.log("Yes") : console.log("No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28468
#include <stdio.h>
#include <string.h>

int main(){
    char str[11];
    int i,j = 0;
    int tmp = 0,max = 0;
    scanf("%s",str);
    for(i=0;i<11;i++){
        if(str[i]=='\0') break;
        if(str[i] == 'A' || str[i] == 'T' ||str[i] == 'G' ||str[i] == 'C' ){
            tmp++;
            if(tmp > max) max = tmp;
        }else{
            tmp = 0;
        }
    }
    printf("%d",max);
}

Measured memory_bytes: 128
S = input()
T = list(input())
l = len(S) - len(T) + 1
ans = len(T)
t = len(T)
for i in range(l):
  s = list(S[i:i+t])
  ans = min(ans, len([0 for i in range(t) if T[i] != s[i]]))
print(ans)

Measured memory_bytes: 9060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 2

ll K;
double d_K;
typedef vector<ll> V;
typedef vector<V> MATRIX;
ll mini_ans[7] = {0,1,2,3,4,5,6};

MATRIX calc(MATRIX left,MATRIX right){

	MATRIX ret(SIZE,V(SIZE));

	for(int i = 0; i < SIZE; i++){
		for(int k = 0; k < SIZE; k++)ret[i][k] = 0;
	}

	for(int row = 0; row < SIZE; row++){
		for(int col = 0; col < SIZE; col++){
			for(int a = 0; a < SIZE; a++){
				ret[row][col] += left[row][a]*right[a][col]%MOD;
			}
		}
	}

	return ret;

}

MATRIX pow(MATRIX MULT,ll count){

	MATRIX ret(SIZE,V(SIZE));

	for(int row = 0; row < SIZE; row++){
		for(int col = 0; col < SIZE; col++){
			if(row == col)ret[row][col] = 1;
			else{
				ret[row][col] = 0;
			}
		}
	}

	while(count > 0){
		if(count%2 == 1)ret = calc(ret,MULT);
		MULT = calc(MULT,MULT);
		count /= 2;
	}

	return ret;
}

ll calc_Fibo(ll index){

	MATRIX A(SIZE,V(SIZE));
	A[0][0] = 1;
	A[0][1] = 1;
	A[1][0] = 1;
	A[1][1] = 0;

	A = pow(A,index+1);

	return A[1][0];
}

bool check(ll mid){

	double d_mid = mid;
	double mult;

	if(mid%2 == 0){

		mult = (d_mid*d_mid+2*d_mid)/4;

	}else{

		mult = (d_mid*d_mid+2*d_mid+1)/4;
	}

	if(fabs(mult-d_K) < EPS){
		return true;
	}else{
		return mult > d_K;
	}
}

int main(){

	scanf("%lld",&K);
	if(K <= 6){
		printf("%lld\n",mini_ans[K]);
		return 0;
	}

	d_K = K;

	ll left = 1,right = BIG_NUM,mid = (left+right)/2;
	ll line_num;

	while(left <= right){
		if(check(mid)){
			line_num = mid;
			right = mid-1;
		}else{
			left = mid+1;
		}
		mid = (left+right)/2;
	}

	ll calc_sum;
	if((line_num-1)%2 == 0){

		calc_sum = ((line_num-1)*(line_num-1)+2*(line_num-1))/4;

	}else{

		calc_sum = ((line_num-1)*(line_num-1)+2*(line_num-1)+1)/4;
	}

	ll rank = K-calc_sum;
	ll up_max,index_1,index_2;

	if(line_num%2 == 0){

		if(line_num%4 == 0){

			up_max = line_num/4;

			if(rank > up_max){
				index_1 = (line_num/2)-(2*(rank-(up_max+1)));
			}else{
				index_1 = 2*rank-1;
			}

		}else{

			up_max = (line_num+2)/4;

			if(rank > up_max){
				index_1 = (line_num/2)-(2*(rank-up_max)-1);
			}else{
				index_1 = 2*rank-1;
			}
		}

	}else{

		if(((line_num-1)/2)%2 == 0){

			up_max = (line_num+3)/4;

			if(rank > up_max){
				index_1 = ((line_num+1)/2)-(2*(rank-up_max)-1);
			}else{
				index_1 = 2*rank-1;
			}

		}else{

			up_max = (line_num+1)/4;

			if(rank > up_max){
				index_1 = ((line_num+1)/2)-(2*(rank-(up_max+1)));
			}else{
				index_1 = 2*rank-1;
			}
		}
	}

	index_2 = line_num+1-index_1;

	printf("%lld\n",(calc_Fibo(index_1)*calc_Fibo(index_2))%MOD);

	return 0;
}



Measured memory_bytes: 3312
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int b[] = new int[n - 1];
    int a[] = new int[n];
    
    for(int i = 0; i < n - 1; i++){
      b[i] = sc.nextInt();
    }
    
    for(int i = n - 1; i >= 0; i--){
      if(i == n - 1){
        a[n - 1] = b[n - 2];
      }else if(i == 0){
        a[i] = b[0];
      }else{
        if(b[i] <= b [i - 1]){
          a[i] = b[i];
        }else{
          a[i] = b[i - 1];
        }
      }
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
      sum += a[i];
    }
    
    System.out.println(sum);
    
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  int ans;
  ans = a[0] + a[1] + a[2]*10;
  cout << ans << "\n";
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC132
{
    class D2
    {
        static long[,] c;
        static long mod = 1000000007;
        static void Main(string[] args)
        {
            //input
            var nk = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var n = nk[0]; var k = nk[1];
            init(4005);
            //for i: 0 - k
            //n-k_C_i * n-1_C_i
            for (long i = 1; i <= k; i++)
            {
                if (n - k + 1 < i) Console.WriteLine(0);
                else Console.WriteLine((CalcCombination(n - k + 1, i) * CalcCombination(k - 1, i - 1)) % mod);
            }
        }

        public static long[,] init(long x)
        {
            c = new long[x + 5, x + 5];
            c[0, 0] = 1;
            for (long i = 1; i <= x; i++)
            {
                for (long j = 0; j <= i; j++)
                {
                    if (j == 0) c[i, j] = c[i - 1, j];
                    else c[i, j] = (c[i - 1, j] + c[i - 1, j - 1]) % mod;
                }
            }
            return c;
        }

        public static long CalcCombination(long n, long k)
        {
            return c[n, k];
        }

    }
}


Measured memory_bytes: 138324
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, P = list(map(int, sys.stdin.readline().split()))


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


factors = get_factors(P)
ans = 1
for f in set(factors):
    ans *= f ** (factors.count(f) // N)
print(ans)


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

int main(){
int a,e,ans;
cin>>a;
  ans=0;
 for(int i=1;i<=a;i++){
 e=0;
 if(i%2==1){
   for(int j=1;j<=i;j++){
   if(i%j==0){
     e++;
   }
   }
 }

   if(e==8){
     ans++;
   }
 }
cout<<ans<<endl;


}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define W V<long long>
#define L long long
#define R(n) for(L i=0;i<n;i++)
W S(V<W>&p,L E){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}V<W>c(4,W(3));c[3]=W(3,1);R(2){for(W x:T[i]){L Q=(2*x[0]+x[1])%3;c[i][Q]^=1;}}R(2){if(c[!i]==c[2]||c[!i]==c[3]){W ans=S(T[i],E-1);ans[0]*=2;ans[1]*=2;ans[1]+=i;return ans;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){L M=2e17;L n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

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

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

    int T[8] = {};
    T[0] = N;
    long long ans = 1;
    int A[] = {0b110, 0b101, 0b011, 0b100, 0b010, 0b001, 0b000};
    for (char s: S)
    {
        int t = 0;
        switch (s)
        {
            case 'R': t = 0b100; break;
            case 'G': t = 0b010; break;
            case 'B': t = 0b001; break;
        }
        int a;
        for (int i=0; i<7; i++)
            if ((A[i]&t)==0 && T[A[i]]>0)
            {
                a = A[i];
                break;
            }
        ans = ans*T[a]%998244353;
        T[a]--;
        T[a|t]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1336
/*input
100000 1
1 100000 100






*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ii pair<int, int>
#define mp make_pair
#define N 1000005
#define rep(i, n) for(int i=0; i < n; i++)
#define Rep(i, k, n) for(int i=k; i < n; i++)
#define pb push_back
#define vi vector<int>
#define vii vector< vector<int> >
#define vl vector<ll>
#define F first
#define S second
#define all(v) v.begin(),v.end()
// const  ll mod =1000000000+7; 
const ll mod = 998244353;
ll gd(ll a, ll b)
{
	if ( b==0)
		return a;
	return gd(b, a%b);
}
ll absl(ll a )
{
	return  a>= 0 ?a:-a;
}
ll maxl(ll a, ll b)
{
	return a >= b? a:b;
}
ll p(ll a, ll n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return a* p(a*a, n/2);
	else
		return p(a*a, n/2);
}
ll lm( ll a, ll b)
{
	return( a*b/ gd(a,b));
}
vi edges[N];
int vis[N];
void dfs(int child, int par)
{
	for ( int d : edges[child])
	{
		if ( !vis[d])
		{
			vis[d]=1;
			if ( d != par)
				dfs(d, child);
		}
	}
}
int main()
{
	int n, m;
	cin >> n >> m;
	while ( m--)
	{
		int u, v, w;
		cin >> u >> v >> w;
		edges[u].pb(v);
		edges[v].pb(u);
	}
	int cost=0;
	for ( int i=1; i <=n; i++)
	{
		if ( !vis[i])
		{
			vis[i]=1;
			cost++;
			dfs(i, -1);
		}
	}
	cout << cost;
}

Measured memory_bytes: 33792
function main(input) {
  input=input.trim();
  const n = parseInt(input.split(" ")[0], 10);
  var arrD = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
  arrD.sort(function(a,b){
    if( a < b ) return -1;
    if( a > b ) return 1;
    return 0;
  });
  console.log(arrD[(n/2)]-arrD[(n/2)-1]);
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29128
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int n, q;
int a[100001];

void add( int i, int x )
{
	while( i <= n )
	{
		a[i] += x;
		i += i & (-i);
	}

	return;
}

int sum( int i )
{
	int sum = 0;
	while( i > 0 )
	{
		sum += a[i];
		i -= i & (-i);
	}

	return sum;
}

int main()
{
	scanf( "%d%d", &n, &q );
	rep( i, q )
	{
		char com[2];
		int x, y;
		scanf( "%s%d%d", com, &x, &y );
	
		if( *com == '0' )
			add( x, y );
		else
			printf( "%d\n", sum( y ) - sum( x-1 ) );
	}

	return 0;
}

Measured memory_bytes: 1420