akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);

int main()
{
  // input_from_file;
  //------------ SEE BELOW ARTICLE---------------
 // https://codeforces.com/blog/entry/64250?#comment-484569
  
  ll n,m,k,x;cin>>n>>k;
  vector<ll> vec(n+1,0);for(int i=1;i<=n;i++)  cin>>vec[i];
  vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
  for(int i=0;i<=n;i++)   {
    dp[i][0]=1;
}
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=k;j++){
      dp[i-1][j]+=dp[i-1][j-1];   //SIMILAR TO PREFIX SUM
      if(j>vec[i])
        dp[i][j]=(dp[i-1][j]+mod-dp[i-1][j-vec[i]-1])%mod;
      else  
        dp[i][j]=dp[i-1][j]%mod; 
    }
  }
  cout<<dp[n][k]%mod;
  return 0;
}


Measured memory_bytes: 80256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	var sum, max int
	for _, v := range ar {
		if max <= v {
			sum++
			max = v
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}


// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }

int main() 
{ 
    fastio;
    // fact[0]=1;
    // f(i,1,2000009)fact[i]=(fact[i-1]*i)%mod;
    int t;
    // cin>>t;
    t=1;
    // int temp=t;
    while(t--){
      int n;
      cin>>n;
      lli a[n+1];
      lli arr[n];
      memset(a,0,sizeof a);
      f(i,0,n){
        int x;cin>>x;
        arr[i]=x;
        a[x]++;
      }
      lli ans=0;
      f(i,1,n+1){
        ans+=(a[i]*(a[i]-1))/2;
      }
      f(i,0,n){
        cout<<ans-(a[arr[i]]-1)<<"\n";
      }
    }

    return 0; 	
}



Measured memory_bytes: 5760
<?php

$string = trim(fgets(STDIN));

$parts = explode(" ", $string);

$cats = array(
    0,
    2,
    0,
    1,
    0,
    1,
    0,
    0,
    1,
    0,
    1,
    0,
    1,
    0,
);

if ($cats[$parts[0]-1] == $cats[$parts[1]-1])
{
    echo "Yes\n";
}
else
{
    echo "No\n";

}

Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws Exception {
try {
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));

	while(true){
	String input = buf.readLine();	
	String[] strAry = input.split(" ");
    int a = Integer.parseInt(strAry[0]);
    String b = strAry[1];
    int c = Integer.parseInt(strAry[2]);
	
    int opt =0;
    
    if(b.equals("?")){
    	break;
    }else if(b.equals("+")){
    	opt =a + c;
    }else if(b.equals("-")){
    	opt = a - c;
    }else if(b.equals("*")){
    	opt = a * c;
    }else if(b.equals("/")){
    	opt = a / c;
    }
    	
	System.out.println(opt);
    
	}
} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    }

Measured memory_bytes: 24288
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int coor[101][101],tmp[101][101];
int main()
{
	for(int i=0;i<101;i++)
	{
		for(int j=0;j<101;j++)
		{
			coor[i][j]=0;
			tmp[i][j]=0;
		}
	}
	string s;
	int k=0,p=0;
	while(cin >> s)
	{
		int len=s.size(),in=0;
		for(int i=0;i<=len;i++)
		{
			if(s[i]==','||i==len)
			{
				coor[k][p]=in;
				in=0;
				p++;
			}
			if(s[i]!=',')
			{
				in*=10;in+=s[i]-'0';
			}
		}
		k++;p=0;
	}
	/*for(int i=0;i<k;i++)
	{
		for(int j=0;j<min(i+1,k-i);j++)
		{
			cout << coor[i][j] <<' ';
		}
		cout << endl;
	}*/
	tmp[0][0]=coor[0][0];
	for(int i=0;i<k/2;i++)
	{
		for(int j=0;j<i+1;j++)
		{
			tmp[i+1][j]=max(tmp[i+1][j],tmp[i][j]+coor[i+1][j]);
			tmp[i+1][j+1]=max(tmp[i+1][j+1],tmp[i][j]+coor[i+1][j+1]);
		}
	}
	int c=k/2;
	for(int i=0;i<k/2;i++)
	{
		for(int j=0;j<(k/2-i);j++)
		{
			tmp[i+c+1][j]=max(tmp[i+c][j],tmp[i+c][j+1])+coor[i+c+1][j];
		}
	}
	/*for(int i=0;i<k;i++)
	{
		for(int j=0;j<min(i+1,k-i);j++)
		{
			printf("%2d ",tmp[i][j]);
		}
		cout << endl;
	}*/
	cout << tmp[k-1][0] << endl;
	return 0;
}

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

using namespace std;
#define rep(x, n)          for (int x = 0; x < n; x++)
#define REP(x, a, b)       for (int x = a; x <= b; x++)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).begin(), container.end()
#define sz(container)      (int) (container).size()

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define debug(...) 0
#endif
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(void) {
    int n,m;
    scanf("%d%d",&n,&m);
    if(m&1){
        int end=2*m+1;
        REP(i,m+1,3*m/2+1)
            printf("%d %d\n",i,end-i+m+1);
        end=m;
        REP(i,1,m/2)
            printf("%d %d\n",i,end-i+1);
    }else{
        int end=2*m+1;
        REP(i,m+2,3*m/2+1)
            printf("%d %d\n",i,end-i+m+2);
        end=m+1;
        REP(i,1,m/2)
            printf("%d %d\n",i,end-i+1);
    }
    return 0;
}

Measured memory_bytes: 3856
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n > 1) ret -= ret / n;
    return ret;
}

int main() {
    int N, M; cin >> N >> M;
    vector<bool> ac_f(100100, false);
    int ac_num=0;
    int wa_num=0;
    map<int,int> mp;
    rep(i,M){
        int p; cin >> p;
        string S; cin >> S;
        if((S=="AC") && !ac_f[p]){
            ac_f[p]=true;
            ac_num++;
        }else if((S=="WA") && !ac_f[p]){
            mp[p]++;
        }
    }


    for(int i=1; i<=N; i++){
        if(ac_f[i]){
            wa_num+=mp[i];
        }
    }
    cout << ac_num << ' ' << wa_num << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

void solve()
{
	ll n,k;
	cin>>n>>k;
	
	ll a[n];
	
	ll ans=0;
	rep(i,0,n) cin>>a[i];
	sort(a,a+n);
	
	rep(i,0,n-k)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
}

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

Measured memory_bytes: 1792
import heapq
V,E,r = list(map(int,input().split()))
STD = [list(map(int,input().split())) for _ in range(E)]

G = {i:[] for i in range(V)}
for std in STD:
    G[std[0]].append([std[1],std[2]])

dist = [float('inf')] * V
que = [(0, r)]
dist[r] = 0
while que:
    c, v = heapq.heappop(que)
    if dist[v] < c:
        continue
    for t, cost in G[v]:
        if dist[v] + cost < dist[t]:
            dist[t] = dist[v] + cost
            heapq.heappush(que, (dist[t], t))
for cost in dist:
    if cost == float('inf'):
        print('INF')
    else:
        print(cost)


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

int main(int argc, char** args)
{
    char str[10];
    int cnt=0;
    memset(str,'\0',sizeof(str));
    
    fgets( str,sizeof(str), stdin);
    str[strlen(str)-1]='\0';
    for( int i=0; i<strlen(str); i++ )
    {
        if( str[i]=='1') cnt++;
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define fLoop for(lli i = 0; i < N; i++)
main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli T;
    cin >> T;
    cout << 1 - T << '\n';
}

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

long long n;
string s = "";
long long r;

int main()
{
	ios::sync_with_stdio(0);
	cin >> n;
	while(n--)
	{
		r = n % 26;
		n /= 26;
		s += char('a' + r);
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;
typedef vector<int> vi;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){
    int tmp,ans=753;
    string S;
    cin >> S;
    for(int i=0; i < S.length()-2; i++){
        tmp = ctoi(S[i]) * 100 + ctoi(S[i+1])*10 + ctoi(S[i+2]);
        if(abs(tmp-753) < ans ){
            ans = abs(tmp-753);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
inline int sum (int x) {return x*(x-1)%mod*((mod + 1)/2)%mod;}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, ans = 1, cur = 0;
	string s;
	cin >> n >> s;
	
	for (char ch: s)
	{
	    if (!cur)
	    {
	        if (ch == 'W') {cout << 0; return 0;}
	        else cur++;
	    }
	    
	    else if (cur % 2)
	    {
	        if (ch == 'W') cur++;
	        else ans = ans * cur % mod, cur--;
	    }
	    
	    else
	    {
	        if (ch == 'W') ans = ans * cur % mod, cur--;
	        else cur++;
	    }
	}
	
	if (cur) {cout << 0; return 0;}
	FOR (i, 1, n) ans = ans*i % mod;
	print(ans);
}



















Measured memory_bytes: 720
#include "iostream"
#include "string"
#include "vector"
#include "algorithm"
#include "functional"
#include "cmath"
#include "numeric"

int get_water_time(std::vector<int> h_area) {
    int flower_count = h_area.size();

    if (flower_count == 0) {
        return 0;
    } else if (flower_count == 1) {
        return h_area[0];
    }

    int time_to_water_all = *std::min_element(h_area.begin(), h_area.end());
    std::vector<int> h_after(flower_count);
    std::transform(h_area.begin(), h_area.end(), h_after.begin(),
            [=] (int x) {return x - time_to_water_all;});

    std::vector<std::vector<int>> h_areas;

    auto last_itr = h_after.begin();
    for (auto itr = h_after.begin(); itr < h_after.end(); itr++) {
        if (*itr == 0) {
            std::vector<int> tmp_h_area(last_itr, itr);
            h_areas.push_back(tmp_h_area);
            last_itr = itr + 1;
        }
    }
    std::vector<int> tmp_h_area(last_itr, h_after.end());
    h_areas.push_back(tmp_h_area);

    std::vector<int> times_to_water_remains(h_areas.size());
    std::transform(h_areas.begin(), h_areas.end(),
            times_to_water_remains.begin(),
            [] (std::vector<int> v) {return get_water_time(v);});

    int time_to_water_remains_sum = std::accumulate(
            times_to_water_remains.begin(), times_to_water_remains.end(), 0);

    return time_to_water_all + time_to_water_remains_sum;
}

int main() {
// get values from input
    int n;
    std::vector<int> h;

    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        int h_i;
        std::cin >> h_i;
        h.push_back(h_i);
    }
//    n = 4;
//    h = {1,2,2,1};
// main procedure
    int time = get_water_time(h);
// output
    std::cout << time << std::endl;

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int now=0;
    int cnt=0;
    rep(i,n){
        if(a[i]==now+1){
            now=a[i];
        }
    }
    if(now==0){
        cout << -1;
    }
    else{
        cout << n-now;
    }

    return 0;
}

Measured memory_bytes: 3968
#include <stdlib.h>
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <sstream>

using namespace std;

int a[21];

pair<int,pair<int,int> > solve(string a0,int L){
	pair<int,pair<int,int> > test;
	list<int> tmp;
	list<int> tmpmax;
	int nexta;
	int max,min;
	string current;

	current=a0;
	a[0]=atoi(a0.c_str());

	int k=1;
	while(true){
		int len=current.length();
		
	//	cout << "1:" << current << endl;
		for(int i=1;i<=L-len;i++){
			current="0"+current;
		}
	
		for(int i=0;i<current.length();i++){
			tmp.push_back((int)((current.at(i))-'0'));
			tmpmax.push_back((int)((current.at(i))-'0')*-1);
		}
		
//		cout << "2:" << current << endl;
		tmp.sort();
		tmpmax.sort();
		list<int>::iterator it = tmp.begin();
		int cnt=L-1;
		min=0;
		while(it!=tmp.end()){
			min+=pow(10,cnt)*(*it);
			++it;
			cnt--;
		}
	
		it = tmpmax.begin();
		cnt=L-1;
		max=0;
		while(it!=tmpmax.end()){
			max+=pow(10,cnt)*((*it))*-1;
			++it;
			cnt--;
		}
	//	cout << min << ":" << max << endl;
	
		a[k]=max-min;
	
		for(int i=0;i<k;i++){
			if(a[i]==a[k]){
	//			return abs(k-i);
	//			cout << "aaa" << endl;

				test.first=i;
				test.second.first=a[k];
				test.second.second=abs(k-i);
				return test;
			}
		}

		stringstream sst;
		sst << a[k];
		current=sst.str();

	//	cout << a[k] << endl;
	//	getchar();
		k++;

		tmp.clear();
		tmpmax.clear();
	}
	


	return test;
}

int main(void){

	string a0;
	int L;
	pair <int, pair<int,int> > res;

	while(true){
		cin >> a0;
		cin >> L;
		if(L==0) return 0;

		res=solve(a0,L);
		cout << res.first << " " << res.second.first << " " << res.second.second << endl;
//		cout <<  << endl;
	}

	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
int main(){
  int n;
  std::cin>>n;
  char c[n];
  std::cin>>c;
  if(n%2){std::cout << "No";}
  else{
    bool f=true;
    for(int i=0;i<n/2;++i){
      if(c[i]!=c[n/2+i]){f=false;break;}
    }
    (f?std::cout<<"Yes":std::cout<<"No");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

class Dice {
    public:
        int f[6];
        void xAxis() {
            roll(0, 1, 5, 4);
        }
        void yAxis() {
            roll(0, 2, 5, 3);
        }
        void zAxis() {
            roll(1, 3, 4, 2);
        }

        void roll(int a, int b, int c, int d) {
            int tmp = f[a]; f[a] = f[b]; f[b] = f[c]; f[c] = f[d]; f[d] = tmp;
        }

        bool isSameElements(Dice d) {
            for (int i=0; i<6; i++) {
                bool match = false;
                for (int j=0; j<6; j++) {
                    if (f[i] == d.f[j]) {
                        match = true;
                    }
                }
                if (!match) return false;
            }
            return true;
        }

        bool equal(Dice d2) {
            for (int i=0; i<6; i++) {
                if (f[i] != d2.f[i]) return false;
            }
            return true;
        }

        bool turnTF(int top, int front) {
            if (top != f[0]) {
                for (int i=0; i<4; i++) {
                    xAxis();
                    if (top == f[0]) break;
                }
                if (top != f[0]) {
                    xAxis();
                    for (int i=0; i<4; i++) {
                        yAxis();
                        if (top == f[0]) break;
                    }
                }
            }
            if (front != f[1]) {
                for (int i=0; i<3; i++) {
                    zAxis();
                    if (front == f[1]) break;
                }
            }
            return (front == f[1] && top == f[0]);
        }
};


int main () {
    int n;
    cin >> n;
    Dice ddd[n];
    for (int i=0; i<n; i++) {
        Dice dd;
        for (int j=0; j< 6; j++) cin >> dd.f[j];
        ddd[i] = dd;
    }
    for (int i=0; i < n-1; i++) {
        Dice d1 = ddd[i];
        for (int j=i+1; j<n; j++) {
            Dice d2 = ddd[j];
            if (d1.isSameElements(d2) && d2.turnTF(d1.f[0], d1.f[1])) {
                if (d1.equal(d2)) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    if (k > ((n - 1) * (n - 2) / 2)) {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<ll, ll>> ans;
    reps(i, 1, n) ans.push_back(make_pair(0, i));
    ll remain = ((n - 1) * (n - 2) / 2) - k;
    reps(i, 1, n - 1) {
        if (remain == 0) break;
        reps(j, i + 1, n) {
            if (remain == 0) break;
            ans.push_back(make_pair(i, j));
            remain--;
        }
    }
    printf("%lld\n", sz(ans));
    rep(i, sz(ans)) printf("%lld %lld\n", ans[i].first + 1, ans[i].second + 1);
    return 0;
}


Measured memory_bytes: 512
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5,L=(1<<26)+5;
char s[N];int a[N],f[N],pos[L],n;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	fp(i,1,n)a[i]=a[i-1]^(1<<(s[i]-'a'));
	memset(pos,-1,sizeof(pos));
	pos[0]=0;
	fp(i,1,n){
		f[i]=233333;
		fp(j,0,25)if(pos[a[i]^(1<<j)]!=-1)cmin(f[i],f[pos[a[i]^(1<<j)]]+1);
		if(pos[a[i]]!=-1)cmin(f[i],f[pos[a[i]]]+1);
		if(pos[a[i]]==-1||f[i]<f[pos[a[i]]])pos[a[i]]=i;
//		pos[a[i]]!=-1?cmin(f[i],f[pos[a[i]]]+1):pos[a[i]]=i;
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 264192
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		Dice[] dices = new Dice[n];

		for (int i = 0; i < n; i++) {
			dices[i] = new Dice();
			for (int j = 0; j < 6; j++) {
				dices[i].faces.add(sc.nextInt());
			}
		}

		boolean hasSameDice = false;
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int k = 1; k <= 6; k++) {
					dices[j].roll(dices[i].getFace(k));
					for (int l = 0; l < 4; l++) {
						if (dices[i].getFace(2) == dices[j].getFace(2))break;
						dices[j].spin();
					}
					if (dices[i].getFace(1) == dices[j].getFace(1) &&
							dices[i].getFace(2) == dices[j].getFace(2) &&
							dices[i].getFace(3) == dices[j].getFace(3) &&
							dices[i].getFace(4) == dices[j].getFace(4) &&
							dices[i].getFace(5) == dices[j].getFace(5) &&
							dices[i].getFace(6) == dices[j].getFace(6)) {
						hasSameDice = true;
						break;
					}
				}
			}
			if (hasSameDice)break;
		}

		System.out.println(hasSameDice ? "No" : "Yes");

	}
}

class Dice {
	List<Integer> faces;

	public Dice() {
		this.faces = new ArrayList<Integer>();
		faces.add(0);
	}

	public void roll(int direction) {
		faces.set(0, faces.get(1));
		switch (faces.indexOf(direction)) {
		case 5:
			faces.set(1, faces.get(5));
			faces.set(5, faces.get(6));
			faces.set(6, faces.get(2));
			faces.set(2, faces.get(0));
			break;
		case 3:
			faces.set(1, faces.get(3));
			faces.set(3, faces.get(6));
			faces.set(6, faces.get(4));
			faces.set(4, faces.get(0));
			break;
		case 2:
			faces.set(1, faces.get(2));
			faces.set(2, faces.get(6));
			faces.set(6, faces.get(5));
			faces.set(5, faces.get(0));
			break;
		case 4:
			faces.set(1, faces.get(4));
			faces.set(4, faces.get(6));
			faces.set(6, faces.get(3));
			faces.set(3, faces.get(0));
			break;
		case 6:
			faces.set(1, faces.get(6));
			faces.set(6, faces.get(0));
			faces.set(0, faces.get(2));
			faces.set(2, faces.get(5));
			faces.set(5, faces.get(0));
			break;
		default:
			break;
		}
	}

	public void spin() {
		faces.set(0, faces.get(2));
		faces.set(2, faces.get(3));
		faces.set(3, faces.get(5));
		faces.set(5, faces.get(4));
		faces.set(4, faces.get(0));
	}

	public int getFace(int face) {
		return faces.get(face);
	}

}



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

int main() {
  string a, b, c;
  int x = 0;
  cin >> a;
  cin >> b;
  cin >> c;
  for (int i = 0, j = 0, k = 0;;) {
    if (x == 0) {
      x = a[i] == 'a' ? 0 : a[i] == 'b' ? 1 : a[i] == 'c' ? 2 : 3;
      i++;
    } else if (x == 1) {
      x = b[j] == 'a' ? 0 : b[j] == 'b' ? 1 : b[j] == 'c' ? 2 : 4;
      j++;
    } else if (x == 2) {
      x = c[k] == 'a' ? 0 : c[k] == 'b' ? 1 : c[k] == 'c' ? 2 : 5;
      k++;
    }
    if (x > 2) {
      cout << (x == 3 ? 'A' : x == 4 ? 'B' : x == 5 ? 'C' : ' ');
      return 0;
    }
  }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

from collections import Counter
c=Counter(a)

cnt_all=0
cnt_up=0
for key in c:
    if c[key]>=2:
        cnt_up+=c[key]-1
    cnt_all+=1
print(cnt_all if cnt_up%2==0 else cnt_all-1)



Measured memory_bytes: 21912
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int len, plu[15];
string s1;
long long F(string s) {
    long long sum=0,num=0;
    for (int i=0;i<s.size();i++) {
        if(s[i]=='+') {sum+=num, num=0;}
        else
            num=num*10+s[i]-'0';
    }
    return sum+num;
}
int main()
{
	
    cin>>s1;
    len=s1.size()-1;
    long long ans=0;
	while(true) {
        string s;
        for(int i=0;i<len;i++) {
            plu[i+1]+=plu[i]/2;
            plu[i]%=2;
        }
        if(plu[len])
            break;
        
		for (int i=0;i<len;i++) {
            s+=s1[i];
            if(plu[i])
                s+="+";
        }
        s+=s1[len];
        ans+=F(s);
        
		plu[0]++;
    }
    printf("%lld",ans);
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N+1, 0);

    for(ll i=1; i<=N; i++){
        cin >> A[i];
    }

    vector<ll> S(N+1, 0);

    for(ll i=1; i<=N; i++){
        S[i] = S[i-1] + A[i]; 
    }

    vector<ll> B(N+1, 0);

    for(ll i=1; i<=N; i++){
        B[i] = ((S[i]-i)%K + K) % K;
    }

    // for(ll i=1; i<=N; i++){
    //     cout << B[i] << endl;
    // }

    map<ll, ll> M;
    ll ans = 0;

    for(ll i=1; i<=min(N,K); i++){
        ll temp = B[i];

        // if(temp == 0){
        //     ans++;
        //     continue;
        // }
        // もしもmapに入っていないなら
        if(M.count(temp) == 0){
            M[temp]++;
        }
        else{
            ans += M[temp];
            M[temp]++;
        }
        if(i < K){
            if(temp == 0) ans++;
        }   
    }

    for(ll i=2; i+K-1<=N; i++){
        // 一つ前の要素を消す
        M[B[i-1]]--;

        ll temp = B[i+K-1];

        // if(temp == 0){
        //     // ans++;
        //     continue;
        // }
        // もしもmapに入っていないなら
        if(M.count(temp) == 0){
            M[temp]++;
        }
        else{
            ans += M[temp];
            M[temp]++;
        }
        
    }

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

Measured memory_bytes: 20280
nabcd=list(map(int,input().split()))
n=nabcd[0]
a=nabcd[1]
b=nabcd[2]
c=nabcd[3]
d=nabcd[4]

if n%a!=0:
    x_set=int(n/a)+1
else:
    x_set=int(n/a)

if n%c!=0:
    y_set=int(n/c)+1
else:
    y_set=int(n/c)
x_goukei=x_set*b
y_goukei=y_set*d

if x_goukei<y_goukei:
    print(x_goukei)
else:
    print(y_goukei)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,k;
  cin>>n>>k;
  ll dp[n];
  ll h[n];
  for(ll i=0;i<n;i++)
    cin>>h[i];
  //memset(dp,1e9,sizeof(dp));
  for(ll i=0;i<n;i++)
  dp[i]=1000000007;
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  //int cnt=k;
  for(ll i=2;i<n;i++)
  {
    for(ll j=1;j<=k;j++)
    {
		if(j<=i)
		dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		
	}
  }
  //for(ll i=0;i<n;i++)
  //cout<<dp[i]<<" ";
  cout<<dp[n-1];
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename Iter, typename T> int gt(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L; }
template <typename Iter, typename T> int ge(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L; }
template <typename Iter, typename T> int lt(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L - 1; }
template <typename Iter, typename T> int le(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L - 1; }
template <typename Bst, typename T> typename Bst::const_iterator gt(const Bst& bst, T v) { return bst.upper_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator ge(const Bst& bst, T v) { return bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator lt(const Bst& bst, T v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator le(const Bst& bst, T v) { return bst.upper_bound(v) == bst.begin() ? bst.end() : --bst.upper_bound(v); }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(1 << n);
    cin >> a;
    multiset<int> s(a.begin(), a.end());
    bool can = true;
    vector<int> made = {*s.rbegin()};
    s.erase(--s.end());
    for(int i = 0; i < n and can; i++) {
        for(int j = 0; j < 1 << i and can; j++) {
            auto pre = lt(s, made[j]);
            if(pre != s.end()) {
                made.push_back(*pre);
                s.erase(pre);
            } else {
                can = false;
            }
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 14840
#include <iostream>
#include <vector>
#include <string>
#include <limits>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  i32 N;
  cin >> N;
  
  i32 mi = 1 << 30;
  i32 ans = 0;
  for(i32 i = 0; i < N; ++i) {
    i32 p;
    cin >> p;
    if(mi >= p) ans++;
    mi = min(mi, p);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, D: int, X: "List[List[int]]"):
    x_array = np.array(X)

    count = 0
    for i, x in enumerate(x_array):
        if not i == N:

            for x_target in x_array[i + 1 :]:

                distance = np.sqrt(np.power(x - x_target, 2).sum())
                if distance == int(distance):
                    count += 1
                else:
                    pass

        else:
            pss

    print(count)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    X = [
        [int(next(tokens)) for _ in range(D)] for _ in range(N)
    ]  # type: "List[List[int]]"
    solve(N, D, X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12392
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <climits>
#include <string>
#include <vector>

using namespace std;

int main () {
    long long n = 0, k = 0;
    cin >> n >> k;
    vector<long long> candle(n);
    for (int i=0; i<n; i++) {
        cin >> candle.at(i);
    }
    int zero = lower_bound(candle.begin(), candle.end(), 0) - candle.begin();
    long long mini = (n - zero >= k) ? candle.at(zero-1+k) : LLONG_MAX;
    for (int i=0; i<zero; i++) {
        if (zero - i > k) continue;
        if (zero - i == k) mini = min(abs(candle.at(i)), mini);
        if (k + i - 1 > n-1) break;
        mini = min(abs(candle.at(i)) + candle.at(k + i - 1) + min(abs(candle.at(i)), abs(candle.at(k+i-1))), mini);
    }
    cout << mini << endl;
    return 0;
}


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

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

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        while(a % 2 == 0){
            ans++;
            a /= 2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll n;
int main() {
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		n += s[i] - '0';
	}
	if (n % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 200010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

ll q[32];
int main(){
    //srand(time(NULL)+clock());
    int ca=0,T,k,i,j,m=0,n,K;
    double start=clock();
    q[0]=1;
    rep(i,1,32)q[i]=q[i-1]*2LL;
    scanf("%d",&n);
    map<int,int>g;
    rep(i,0,n){
        scanf("%d",&k);
        g[k]++;
    }
    int ans=0;
    while(!g.empty()){
        auto it=g.end();it--;
        pii o=*it;
        if(o.y==0){
            g.erase(it);continue;
        }
        per(i,0,32){
            if(q[i]<=o.x)break;
            if(q[i]-o.x<=o.x){
                K=q[i]-o.x;
                if(K==o.x){
                    ans+=o.y/2;
                    break;
                }
                else if(g.count(K)){
                    int r=min(o.y,g[K]);
                    ans+=r;
                    g[K]-=r;
                }
            }
        }
        g.erase(it);
    }
    printf("%d\n",ans);
    cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>

using namespace std;

int pack(const vector<int>& w, int p) {
    int ret = 1;
    int buff = p;
    for (int sw : w) {
        if (buff >= sw) {
            buff -= sw;
        } else {
            ++ret;
            buff = p - sw;
        }
    }

    return ret;
}

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

    vector<int> w(N);
    int ma = 0;
    for (int i = 0; i < N; ++i) {
        cin >> w[i];
        ma = max(ma, w[i]);
    }

    int ok = 1 << 30, ng = ma - 1;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if (pack(w, mid) <= K) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
    return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007

void ayn(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll gcd(ll a, ll b)
{
    if (a == 0) return b;
    return gcd(b % a, a);
}
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }
ll mulmod(ll a, ll b, ll mod)
{
    ll res = 0;
    a = a % mod;
    while (b > 0)
    {
        if (b % 2 == 1) res = (res + a) % mod;
        a = (a * 2) % mod;
        b /= 2;
    }
    return res % mod;
}
int binCoeff(int n, int k)
{
    int C[n + 1][k + 1]; int i, j;
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }
    return C[n][k];
}

const int maxn = 100005;
int dfs(ll v, ll ans2, vector<bool>& visited, vector<vector<ll>>& vc){
    visited[v]=true;
    ans2++;
    for(auto z:vc[v])
    {
        if(!visited[z])
        {
           ans2+=dfs(z,0,visited,vc);
        }
    }
    return ans2;
}

ll conv(string n)
{
    string num = n;
    ll dec_value = 0;
    int base = 1;

    int len = num.length();
    for (int i=0; i<len; i++) {
        if (num[i] == '1') dec_value += base;
        base = base * 2;
    }
    return dec_value;
}

int main(){
    fastio;
    ll t; t=1;
    while(t--){
        ll x; cin>>x;
        ll ai=1; ll b=0;
        while(ai>0){
            if(x-pow(b,5)<0) break;
            ai = pow(x-pow(b,5),0.2);
            ll y = pow(ai,5)+pow(b,5);
            if(x==y) {cout<<ai<<" "<<-b; return 0;}
            b++;
        }
        ai=1;
        b=1;
        while(ai<INT_MAX){
            ai = pow(x+pow(b,5),0.2);
            ll y = pow(ai,5)-pow(b,5);
            if(x==y) {cout<<ai<<" "<<b; return 0;}
            b++;
        }
    }
    return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;
struct ki {
    int num;
    ki *parent;
    int depth = -1;
    string type = "internal node";
    int kokazu;
    vector<ki *> v;
};

int decide(ki *x) {
    x->depth = x->parent->depth + 1;
    if (x->depth == 0) {
        x->type = "root";
    } else if (x->kokazu == 0) {
        x->type = "leaf";
    }
    for (int i = 0; i < x->kokazu; ++i) {
        decide(x->v[i]);
    }

    return 0;
}

int main(void) {
    int n, node, ji, temp;
    cin >> n;
    ki *l;
    ki toptop;
    toptop.num = -1;
    l = new ki[n];

    //すべての親をtoptopに
    for (int i = 0; i < n; ++i) {
        l[i].parent = &toptop;
        l[i].num = i;
    }


    for (int i = 0; i < n; ++i) {
        cin >> node >> ji;
        l[node].kokazu = ji;
        for (int j = 0; j < ji; ++j) {
            cin >> temp;
            l[node].v.push_back(&(l[temp]));
            l[temp].parent = &l[node];
        }
    }
    ki *top;
    for (int i = 0; i < n; ++i) {
        if (l[i].parent == &toptop) {
            top = &l[i];
        }
    }
    top->parent = &toptop;
    decide(top);
    for(int i = 0; i < n; ++i){
        printf("node %d: parent = %d, depth = %d, ",i,l[i].parent->num,l[i].depth);
        if(l[i].type != "leaf" and l[i].kokazu != 0) {
            cout << l[i].type << ", [";
            for (int j = 0; j < l[i].kokazu - 1; ++j) {
                cout << l[i].v[j]->num << ", ";
            }
            cout << l[i].v[l[i].kokazu - 1]->num << "]" << endl;
        } else {
            cout << l[i].type << ", []" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 15556
S = list(input())
N = len(S)
for i in range(N // 2):
  if S[i] != S[N - i - 1]:
    print("No")
    exit()
S_earlier = S[0 : (N - 3) // 2 + 1]
S_later = S[(N + 1) // 2 : N]

for j in range(len(S_earlier) // 2):
  if S_earlier[j] != S_earlier[len(S_earlier) - j - 1]:
    print("No")
    exit()
for k in range(len(S_later) // 2):
  if S_later[k] != S_later[len(S_later) - k - 1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 38512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] count = new int[100000 + 1];
        int N = sc.nextInt();

        for (int i = 0; i < N; i++) {
            count[sc.nextInt()]++;
        }

        int[] table = new int [100000 + 2];
        for (int i = 0; i <= 100000; i++) {
            table[i + 1] = table[i] + count[i];
        }

        int ans = 0;
        for (int i = 3; i < table.length; i++) {
            ans = Math.max(ans, table[i] - table[i - 3]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 50240
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 12784
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...)
#endif
using namespace std;

const int maxN = 1 << 20;

int parent[maxN], dist[maxN], mx;
vector <int> G[maxN];

void dfs(int v, int fat)
{
	parent[v] = fat;
	dist[v] = dist[fat] + 1;
	for (int u : G[v]) if (u != fat)
		dfs(u, v);
}

void dfs2(int v, int fat, int d)
{
	mx = max(mx, d);
	for (int u : G[v])
		if (u != fat)
			dfs2(u, v, d+1);
}

int main()
{
	int n, x, y;
	scanf ("%d%d%d", &n, &x, &y);
	
	FOR(i, 1, n)
	{
		int a, b;
		scanf ("%d%d", &a, &b);
		G[a].pb(b);
		G[b].pb(a);
	}
	dist[0] = -1;
	dfs(y, 0);
	
	int target = dist[x]/2 + 1, res = dist[x]%2 ^ 1;
	while (dist[x] != target)
		x = parent[x], res++;
		
	dfs2(x, parent[x], 0);
	res += mx;
	printf("%d", res);
	
	printf("\n");

	return 0;
}


Measured memory_bytes: 34432
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> aa(n,vector<int>(2));
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++){
      cin>>aa[i][j];
    }
  }
  sort(aa.begin(),aa.end());
  long long ans=0;
  int cut=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<aa[i][1];j++){
      cut++;
      ans+=aa[i][0];
      if(cut==m) break;
    }
    if(cut==m) break;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];

void bfs(int s)
{
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; i++)
        d[i] = INFTY;
    d[s] = 0;
    int u;
    while (!q.empty())
    {
        u = q.front();
        q.pop();
        for (int v = 0; v < n; v++)
        {
            if (M[u][v] == 0)
                continue;
            if (d[v] != INFTY)
                continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++)
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
}

int main()
{
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            M[i][j] = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++)
        {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}


Measured memory_bytes: 3128