akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100010
typedef long long LL;

int n, m, c[15][15], tmp[15], tmp2[15];
int f[15][33000], g[33000], sum;
int i, j, k, u, v, d, t;

int main()
{
    scanf("%d%d", &n, &m);
    memset(f, -0x3f, min(sizeof(f), sizeof(f[0])*(n+1)));
    for(i = 1; i <= m; ++i)
    {
        scanf("%d%d%d", &u, &v, &d);
        --u; --v;
        sum += d;
        c[u][v] = c[v][u] = d;
    }
    t = 1 << n;
    f[0][1] = 0;
    for(i = 1; i < t; ++i)
    {
    	int cnt = 0;
    	for(u = 0, k = i; k > 0; ++u, k >>= 1)
    		if (k & 1) tmp[cnt++] = u;
    	for (j = 0; j < cnt; ++j)
    	{
    		u = tmp[j];
    		for (k = j + 1; k < cnt; ++k)
    			g[i] += c[u][tmp[k]];
		}
	}
    for(i = 1; i < t; ++i)
    {
    	int cnt = 0, cnt2 = 0;
    	for(u = 0, k = i; u < n; ++u, k >>= 1)
    		if (k & 1 && f[u][i] >= 0) tmp[cnt++] = u;
			else if (!(k & 1)) tmp2[cnt2++] = u;
		
        for (int p = 0; p < cnt; ++p)
        {
        	u = tmp[p];
        	k = (t - 1) ^ i;
	        for(j = k; j; j = (j - 1) & k) // Ã¶¾Ù²¹¼¯µÄËùÓÐ×Ó¼¯ 
	            f[u][i | j] = max(f[u][i | j], f[u][i] + g[j | (1 << u)]);
		}
	    for (int p = 0; p < cnt; ++p)
        {
        	u = tmp[p];
	        for(int q = 0; q < cnt2; ++q)
	        {
	            v = tmp2[q];
	            if (c[u][v])
	            	f[v][i | (1 << v)] = max(f[v][i | (1 << v)], f[u][i] + c[u][v]);
			}
	    }
    }
    printf("%d\n", sum - f[n - 1][t - 1]);
    return 0;
}

Measured memory_bytes: 2304
import sys
#import bisect
input = sys.stdin.buffer.readline
#lb = bisect.bisect_left

def main():
	H,N=map(int,input().split())
	#vA=list(map(int, input().split()))
	INF = 1001001001
	#H=int(input())
	mAB=[tuple(map(int,input().split())) for _ in [0,]*N]
	
	vN = [INF,]*(H+2)
	vN[0] = 0
	#mD = []
	#apD = mD.append
	#apD(vI)
	
	for h in range(H+2):
		#vN = mD[-1][:]
		for a,b in mAB:
			j = min(h+a,H+1)
			vN[j] = min(vN[h]+b, vN[j])
		#apD(vN)
		
	#res = min(mD[-1][-1],mD[-1][-2])
	res = min(vN[-2:])
	print(res)

main()


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

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

  if(A == B && B == C || A != B && B != C && A != C) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
t, ans = sum(B), 0
j = M
for i in range(N+1):
   while j>0 and t>K:
       j -= 1
       t -= B[j]
   if t>K: break
   ans = max(ans, i+j)
   if i==N: break
   t += A[i]

print(ans)

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

vector<int> v(100005);
int n,k,m;
string s,t;

int main() {
  cin >> n;
  rep(i,n) cin >> v[i];
  int cnt=0;
  rep(i,n)if(v[v[i]-1]==i+1) cnt++;
  cout << cnt/2 << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cmath>
#include<set>
#include<stack>

using namespace std;
typedef unsigned long long ll;

map<string, int>ma;
vector<pair<int, string> >vec;

struct sortVec{
    bool operator()(string m1, string m2){
        return ma[m1]<ma[m2];
    }
}sv;

int main(){
    int n,p;
    while(cin>>n,n){
        ma.clear();
        vec.clear();
        string s;
        for(int i=0;i<n;i++){
            int day,time;
            cin>>s>>day>>time;
            if(time>=2400){
                day=(day+1);
                time-=2400;
            }
            time=(time/100)*60+time%100+day*24*60;
            ma[s]=time;
            vec.push_back(make_pair(time,s));
        }
        sort(vec.begin(),vec.end());
        cin>>p;
        vector<string>fav;
        for(int i=0;i<p;i++){
            cin>>s;
            fav.push_back(s);
        }
        sort(fav.begin(),fav.end(),sv);
        vector<string>res;
        res.push_back(fav[0]);
        bool nex=false;
        for(int i=1;i<fav.size();i++){
            if(ma[fav[i]]<ma[fav[i-1]]+30){
                cout<<-1<<endl;
                nex=true;
                break;
            }
            res.push_back(fav[i]);
            sort(res.begin(),res.end(),sv);
        }
        if(nex){
            continue;
        }
        for(int i=0;i<vec.size();i++){
            int start=vec[i].first;
            int resi=0;
            while(resi<res.size()&&ma[res[resi]]+30<=start){
                resi++;
            }
            if(resi==res.size()||start+30<=ma[res[resi]]){
                if(resi>0&&ma[res[resi-1]]+30>start){
                    continue;
                }
                res.push_back(vec[i].second);
                sort(res.begin(),res.end(),sv);
            }
        }
        cout<<res.size()<<endl;
    }
    return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 500+10;
const int N = 1e5+10;
const int E = 1e6+10;  
int x[6];

int main(){
	F(i,1,5){
		cin>>x[i];
	}
	F(i,1,5){
		if(!x[i]) {
			cout<<i<<endl;
			return 0; 
		}
	}
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


struct Range{
	int s,e;
	Range(){}
	Range(int s,int e):s(s),e(e){}
	bool operator<(const Range &r)const{return e<r.e;}
};
vector<Range> merge_range(vector<Range> r){
	vector<Range> res;
	sort(r.begin(),r.end());
	for(int i=0;i<(int)r.size();i++){
		int mi=r[i].s;
		while(!res.empty()&&r[i].s<=res.back().e){
			mi=res.back().s;
			res.pop_back();
		}
		res.push_back(Range(min(mi,r[i].s),r[i].e));
	}
	return res;
}


int main(){
	int n,m;
	Range r[500];
	cin>>n>>m;
	rep(i,m)cin>>r[i].s>>r[i].e;
	int ans=n+1;
	vector<Range> vr(merge_range(vector<Range>(r,r+m)));
	rep(i,vr.size()){
		ans+=(vr[i].e-vr[i].s)*2;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void){
    int A,B;
    int Acnt=0,Bcnt=0;
    string S;
    cin>>A>>B>>S;

    string As=S.substr(0,A);
    string Bs=S.substr(A+1,S.size()-1);
    string hs=S.substr(A,1);

    for(int i=0;i<As.size();i++){
        if(As[i]>='0'&&As[i]<='9')
            Acnt++;
    }
    for(int i=0;i<Bs.size();i++){
        if(Bs[i]>='0'&&Bs[i]<='9')
            Bcnt++;
    }
    if(Acnt==A&&Bcnt==B&&hs[0]=='-'){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll N,M;
	cin >> N >> M;
	vector<ll> a(N);
	FOR(i,0,N) cin >> a[i];

	ll lcma = a[0];

	FOR(i,0,N) lcma = lcm(lcma,a[i]);

	vector<ll> twocount(N,0);
	FOR(i,0,N){
		ll x = a[i];
		while(x%2==0){
			twocount[i]++;
			x/=2;
		}
	}
	SORT(twocount);

	if(twocount[0] != twocount[N-1]){
		cout << 0 << endl;
		return 0;
	}

	lcma/=2;

	ll ans = M/lcma;
	ll ansm = M/(lcma*2);
	cout << ans-ansm << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

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

    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a=input()
if a[0]==a[1] and a[2]==a[3] and a[0]!=a[2]:
  print("Yes")
elif a[0]==a[2] and a[1]==a[3] and a[0]!=a[1]:
  print("Yes")
elif a[0]==a[3] and a[1]==a[2] and a[0]!=a[1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9040
# s = input()
# n = len(s) - 1
# ans = 0
# for i in range(1 << n):
#     formula = s[0]
#     for j in range(n):
#         if ((i >> j) & 1):
#             formula += '+' + s[j + 1]
#         else:
#             formula += s[j + 1]
#     ans += eval(formula)
# print(ans)
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, k = nm()
    A = [0] * (10 ** 5 + 1)
    for i in range(n):
        a, b = nm()
        A[a] += b

    sum_num = 0
    for i, a in enumerate(A):
        sum_num += a
        if sum_num >= k:
            print(i)
            return


if __name__ == '__main__':
    main()


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

int main(){
    int n,k,count;
    cin>>n>>k;
    count=0;
    vector<int>h(n);

    for(int i=0;i<n;i++){
        cin >> h.at(i);
        if(h.at(i)>=k)count++;
    }

    cout << count <<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long N;
    cin >> N;
    long long M = sqrt(N);
    long long ans = 1LL<<60;
    for(long long i=1; i<=M+10; i++){
        if(N%i==0){
            long long j = N/i;
            ans = min(ans, i+j-2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int n,p;
    scanf("%d%d",&n,&p);
    int a,x=0,y=0;
    long long res=1;
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if(a%2==0){x++;
        }
        else {y++;}
        res *= 2ll;
    }
    if(p==1&&y==0)printf("0");
    else if(y==0)printf("%lld",res);
    else printf("%lld",res/2ll);
    return 0;
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    double A, B, N;
    cin >> A >> B >> N;
    double X = min(B-1,N);
    int ans = A * (1.0*X/B - floor(X/B));

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3704
N = int(input())
ans = 0

for i in range(1,N+1,2):
  count = 1
  for j in range(1,int(i/3+1)):
    if i%j == 0:
      count +=1
  if count == 8:
    ans += 1
    #print(i)
print(ans)
        

Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

/**
 * 重み付きUnionFind
 * 
 * https://qiita.com/drken/items/cce6fc5c579051e64fab
 */
template<typename T>
class WeightedUnionFind
{
    private:
        vector<T> parents;
        vector<T> rank;
        vector<T> diff_weight;
        
    public:
        WeightedUnionFind(T n)
        {
            parents.resize(n);
            rank.resize(n);
            diff_weight.resize(n);
            for (T i = 0; i < n; i++) {
                parents[i] = i;
            }
        }

        T root(T x)
        {
            if (parents[x] == x) return x;
            T r = root(parents[x]);
            diff_weight[x] += diff_weight[parents[x]];
            return parents[x] = r;
        }

        bool same(T x, T y)
        {
            return root(x) == root(y);
        }

        T weight(T x)
        {
            root(x);
            return diff_weight[x];
        }

        // xからyへの重みを求める
        T diff(T x, T y)
        {
            // (1) x => root の重み
            // (2) root => y の重み
            // とした時、xからyへの重みは(1) + (2)である。
            // ここで(2)について、diff_weightに保持しているのはy => rootなので、符号反転させている。
            return diff_weight[x] + (-diff_weight[y]);
        }

        // xからyへの重みをwにする
        // ここのロジックについては以下記事がわかりやすい
        // https://at274.hatenablog.com/entry/2018/02/03/140504
        void unite(T x, T y, T w)
        {
            T rx = root(x);
            T ry = root(y);
            if (rx == ry) return;

            if (rank[rx] < rank[ry]) {
                rank[ry] += rank[rx];
                parents[rx] = ry;
                diff_weight[rx] = w + diff_weight[y] - diff_weight[x];
            } else {
                rank[rx] += rank[ry];
                parents[ry] = rx;
                diff_weight[ry] = diff_weight[x] - w - diff_weight[y];
            }
        }

        void show()
        {
            for (T i = 0; i < parents.size(); i++) {
                cout << "i: " << i << ", p[i]: " << parents[i] << ", rank[i]: " << rank[i] << ", w[i]: " << diff_weight[i] << endl;
            }
        }
};

int main() {
    int N, M;
    cin >> N >> M;
    vi L(M), R(M), D(M);
    rep(i, M) {
        cin >> L[i] >> R[i] >> D[i];
        L[i]--; R[i]--;
    }

    WeightedUnionFind<ll> uni(N);
    bool ok = true;
    rep(i, M) {
        int l = L[i];
        int r = R[i];
        int d = D[i];
        if (uni.same(l, r)) {
            if (uni.diff(l, r) != d) {
                ok = false;
                break;
            }
        } else {
            uni.unite(l, r, d);
        }
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 7892
#!/usr/bin/python
# coding: UTF-8


#import scipy.optimize
#import numpy as np

    
##################################################################

if __name__ == "__main__":

    Input1 = [input() for i in range(1)]
    N,K,Q = list(map(int,Input1[0].split()))
    A = [int(input()) for i in range(Q)]

    count = [0 for i in range(N)]
    for i in range(Q):
        count[A[i]-1] += 1
    for i in range(N):
        if count[i] > Q-K:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 8632
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//素因数分解
vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int N; cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

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

    ll ans=0;
    REP(i,N-1){
        if(i==0) ans+=A[0];
        else if(i%2==0){
            ans += A[i/2];
        }else{
            ans += A[(i+1)/2];
        }
        //cout << "ans= " << ans << endl; 
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    string s;
    cin >> s;
    if (s.size() == 1) {
        cout << 1 << '\n';
        return 0;
    }   
    if (s.size() == 2) {
        cout << 1 + (s[0] != s[1]) << '\n';
        return 0;
    }
    int n = s.size();
    int ans = 0;
    int cur = 1;
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i - 1]) {
            if (i == n - 1) continue;
            if (i == n - 2) {
                ++cur;
                break;
            }
            cur += 2;
            i += 2;
        }
        else {
            ++cur;
        }
    }
    ans = cur;
    cur = 2;
    for (int i = 3; i < n; ++i) {
        if (s[i] == s[i - 1]) {
            if (i == n - 1) continue;
            if (i == n - 2) {
                ++cur;
                break;
            }
            cur += 2;
            i += 2;
        } else {
            ++cur;
        }
    }
    ans = max(ans, cur);
    cout << ans << '\n';
}

Measured memory_bytes: 720
#include<stdio.h>
#include<math.h>
int search(int *, int,int);
void swap(int *, int*);
int main() {
	int A[100],n,i,minj = 0,tail = 0,count = 0;
	scanf("%d", &n);
	for ( i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}
	for ( i = 0; i < n; i++)
	{
		minj = search(A, tail, n);
		if (tail != minj) {
			swap(&A[tail], &A[minj]);
			count++;
		}
		tail++;
	}
	for ( i = 0; i < n; i++)
	{
		if (i == 0)
		{
			printf("%d", A[i]);
		}
		else
		{
			printf(" %d", A[i]);
		}
	
	}
	printf("\n");
	printf("%d", count);
	printf("\n");
	return 0;
}
int search(int *A, int tail, int n) {
	int minj = tail;
	int i;
	for (i = tail; i < n; i++)
	{
		if (A[minj] > A[i]) {
			minj = i;
		}
	}
	return minj;
}
void swap(int *x, int *y) {
	int temp;
	temp = *x;
	*x = *y;
	*y = temp;
}


Measured memory_bytes: 2048
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int count = 0;
    if(a>=13) {
      count += b;
    } else if(a<=12&&a>=6) {
      count += (b/2);
    } else {
      count = 0;
    }
    System.out.println(count);
  }
}

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

int main()
{
    long int a,b,c;
    cin>>a;
    b=pow(a,2);
    c=pow(a,3);
    cout<<(a+b+c)<<endl;
    
    return 0;
}


Measured memory_bytes: 4100
let _ = read_int ()
let s, ans = read_line (), ref 0
let f n = Char.chr (48 + n)
let _ = for i = 0 to 9 do for j = 0 to 9 do for k = 0 to 9 do try String.(index_from s (index_from s (index s (f i) + 1) (f j) + 1) (f k)) |> ignore; incr ans with _ -> () done done done; Printf.printf "%d\n" !ans

Measured memory_bytes: 2432
using System;
using System.Collections.Generic;

namespace abc125_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var v = CIn.ReadIntArray(n);
      var c = CIn.ReadIntArray(n);

      var dp = new int[n + 1];

      for (var i = 0; i < n; i++)
      {
        dp[i + 1] = Math.Max(dp[i], dp[i] + v[i] - c[i]);
      }

      Console.WriteLine(dp[n]);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 11220
def examC():
    N, K = LI()
    a = N//K
    ans = a**3
    if K%2==0:
        b = (N + K//2)//K
        ans +=b**3
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()

Measured memory_bytes: 38256
n=int(input());t,x,y=[],[],[]
for _ in range(n):
  a,b,c=map(int,input().split())
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  m,k=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (m>=k and m%2==k%2): print('No');break
else:
  print('Yes')

Measured memory_bytes: 17484
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

struct Query {
  int T;
  int F;
  char C;
};

int main()
{
  string S;
  int Q;
  vector<Query> query;

  cin >> S >> Q;

  query.resize(Q);
  for (int i = 0; i < Q; i++) {
    cin >> query[i].T;
    if (query[i].T == 2) {
      cin >> query[i].F;
      cin >> query[i].C;
    }
  }

  deque<char> deque_S;
  for (auto &&i : S) {
    deque_S.push_back(i);
  }

  bool flip_flag = false;

  for (int i = 0; i < Q; i++) {
    if (query[i].T == 1) {
      flip_flag = !flip_flag;
    }
    else if ((query[i].F == 1 && !flip_flag) || (query[i].F == 2 && flip_flag)) {
      deque_S.push_front(query[i].C);
    }
    else {
      deque_S.push_back(query[i].C);
    }
  }

  if (flip_flag) {
    reverse(deque_S.begin(), deque_S.end());
  }

  for (auto &&i : deque_S) {
    cout << i;
  }

  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC166E();

#if 1
int main()
{
	ABC166E();
	fflush(stdout);
	return 0;
}
#endif


static void ABC166E()
{
	int N;
	getint(N);

	std::vector<std::pair<int, int>> ai(N);
	std::map<int, std::set<int>> amn, apn;
	for (int i = 0; i < N; i++) {
		ai[i].first = i + 1;
		getint(ai[i].second);
		
		int aplusn = ai[i].first + ai[i].second;
		apn[aplusn].insert(ai[i].first);

		int aminusn = ai[i].first - ai[i].second;
		if (aminusn > 0) {
			amn[aminusn].insert(ai[i].first);
		}
	}
	
	LLONG ans = 0;
	for (int i = 0; i < N; i++) {
		int aplusn = ai[i].first + ai[i].second;
		int pair = amn[aplusn].size();
		int aminusn = ai[i].first - ai[i].second;
		int pair2 = apn[aminusn].size();
		ans += (LLONG)(pair + pair2);
	}
	printf("%lld\n", ans / 2LL);
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),k=read();
	map<int,int> cnt;
	REP(i,n)cnt[read()]++;
	vi w;
	for(auto kv:cnt)w.PB(kv.second);
	sort(ALL(w),greater<int>());
	chmin(k,w.size());
	cout<<n-accumulate(w.begin(),w.begin()+k,0LL)<<endl;
}

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

using namespace std;
typedef long long LL;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if(A==B&&A!=C) cout << "Yes" << endl;
	else if(A==C&&A!=B) cout << "Yes" << endl;
	else if(B==C&&B!=A) cout << "Yes" << endl;
	else cout << "No" << endl;
		
	return 0;
}

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

int main(){
	int N;
	int K;
	scanf("%d",&N);
	scanf("%d",&K);
	long long X[50];
	long long Y[50];
	for(int i=0;i<N;i++){
		scanf("%lld", &X[i]);
		scanf("%lld", &Y[i]);
	}

	long long min=9223372036854775807;
	for(int xi=0;xi<N;xi++){
		long long xs = X[xi];
		for(int xj=0;xj<N;xj++){
			long long xe = X[xj];
			for(int yi=0;yi<N;yi++){
				long long ys = Y[yi];
				for(int yj=0;yj<N;yj++){
					long long ye = Y[yj];
					if(xs < xe && ys < ye){
						int cnt=0;
						for(int i=0;i<N;i++){
							if(xs<=X[i] && X[i]<=xe && ys<=Y[i] && Y[i]<=ye){
								cnt+=1;
							}
						}
						if(cnt>=K && min>(xe-xs)*(ye-ys)){
							min = (xe-xs)*(ye-ys);
						}
					}
				}
			}
		}
	}
	printf("%lld\n", min);
}



Measured memory_bytes: 128
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let _n = {
        let i = read::<usize>();
        (i[0])
    };

    // 一列の数値
    let array = read::<u64>();

    let mut count = 0;

    for a in array {
        let mut aa = a;
        'loop_label: loop {
            if aa % 2 != 0 {
                break 'loop_label;
            }

            count += 1;
            aa = aa / 2;
        }
    }

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


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    ll x;
    cin >> x;
    ll count = 0;
    ll i = 100;
    while (i < x) {
        i *= 1.01;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
ll D, G;
ll dp[12][1201];
int main() {
	cin >> D >> G;
	vector<ll>P(D + 1), C(D + 1);
	for (int i = 1; i <= D; ++i) {
		cin >> P[i] >> C[i];
	}
	for (int i = 1; i <= D; ++i) {
		for (int j = 0; j <= 1010; ++j) {
			for (int k = 0; k <= P[i]; ++k) {
				if (k == P[i]) {
					dp[i][j + k] = max(dp[i][j + k], dp[i - 1][j] + 100 * i*k + C[i]);
				}
				else {
					dp[i][j + k] = max(dp[i][j + k], dp[i - 1][j] + 100 * i*k);
				}
			}
		}
	}
	for (int j = 0; j < 1010; ++j) {
		if (dp[D][j] >= G) {
			cout << j << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
/*ex5_3
  kt125 */

#include<stdio.h>
#define SIZE 100

int main(void){
    int height, width, //縦、横
        count, //'.'をカウントする変数
        i=0, j=0, k=0, //カウンタ変数
        row_del_num, //消去する行の数
        col_del_num, //消去する列の数
        height_ans, //答えとなる配列の縦の長さ
        width_ans, //答えをなる配列の横の長さ
    	col_del[SIZE], //消去する列の番号を記憶する配列
        row_del[SIZE];  //消去する行の番号を記憶する配列
  
    char board[SIZE][SIZE], //与えられたマス目の配列
         ans_row[SIZE * SIZE], //答えとなるマス目の文字を一列に並べた配列
    	 ans[SIZE][SIZE];  //答えとなる配列
  
    scanf("%d %d", &height, &width);

    for(i=0; i < height;i++){
        for (j=0; j < width; j++){
            scanf(" %c", &board[i][j]);
        }  
    }

    for(i=0; i < height; i++){
        for(j=0; j < width; j++){
            if(board[i][j]== '.'){
                count++;
            }
        }
        if (count == width){ //i行が全て'.'だった場合
            row_del[k] = i; //配列の最初から順に用いるためにkを使う
            k++;
        }
        count = 0; //各行ごとにリセット
    }  
    row_del_num = k; //消去する行の数

    k = 0; //リセット

    for(i=0; i < width; i++){
        for(j=0; j < height; j++){
            if(board[j][i]== '.'){
                count++;
            }
        }
        if (count == height){ //i列が全て'.'だった場合
            col_del[k] = i;
            k++;
        }
      	count = 0; //各列ごとにリセット
    } 

    col_del_num = k; //消去する列の数
    
    for(i=0; i < row_del_num; i++){
        for (j=0; j < width; j++){
            board[row_del[i]][j] = 'o'; //消去する行の文字を'o'に置き換える
        }
    }
    for(i=0; i < col_del_num; i++){
        for (j=0; j < height; j++){
            board[j][col_del[i]] = 'o'; //消去する列の文字を'o'に置き換える
        }
    }
    k = 0; // リセット
    
    for(i=0; i < height; i++){
        for(j=0; j < width; j++){
            if (board[i][j] != 'o'){ //'o'を飛ばす
                ans_row[k] = board[i][j];
              	k++;
            }
        }
    }

    height_ans = height - row_del_num; //答えとなる配列の縦の長さ
    width_ans = width - col_del_num; //答えとなる配列の横の長さ

    for(i=0; i < height_ans; i++){
        for(j=0; j < width_ans;j++){
            ans[i][j] = ans_row[j + i * (width_ans)]; //一次元の配列をマス目に合うように二次元に直す
        }
    }
  
    for(i=0; i < height_ans;i++){
        for (j=0; j < width_ans; j++){
            printf("%c", ans[i][j]); //マス目をprint
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    double odd = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2 == 1){
            odd ++;
        }
    }
    printf("%lf\n", odd / n);
    return 0;

}

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

UL N, K;
UL A[200000];
UL S[200001];

void F() {
	K--;
	rep(i, N) S[i] = 0;
	rep(i, N) {
		S[max(i, A[i]) - A[i]]++;
		S[min(i + A[i] + 1, N)]--;
	}
	rep(i, N) S[i + 1] += S[i];
	bool res = true;
	rep(i, N) {
		A[i] = S[i];
		if (A[i] != N) res = false;
	}
	if (res) K = 0;
}

int main() {
	scanf("%u%u", &N, &K);
	rep(i, N) scanf("%u", A + i);
	while (K) F();
	rep(i, N - 1) printf("%u ", A[i]);
	printf("%u\n", A[N - 1]);
	return 0;
}


Measured memory_bytes: 5332
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	char s[20];
	cin>>s;
	rep(i,19){
		if(i==5 ||i==13){
			cout<<" ";
		}else{
			cout<<s[i];
		}
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define ll              long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define sort(x)         sort(all(x))
#define umii            unordered_map<int,int>
#define lli             list<int>             
#define gcd(m,n)        __gcd(m,n)   
#define mib             map<int,bool>

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

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

int32_t main()
{
  fast();
  
  double r;
  cin>>r;
  
 double ans = 6.28318530717958623200 * r;
 cout<<ps(ans,20);


}

Measured memory_bytes: 3796
import java.util.*;

public class Main {
    
    static Scanner sc = new Scanner(System.in);
    static int H = Integer.parseInt(sc.next());
    static int W = Integer.parseInt(sc.next());
        
    public static void main(String[] args) {
        
        long[][] hyo = new long[H][W];
        String line;
        String[] sp;
        
        for(int i = 0; i < H; i++) {
            line = sc.next();
            sp = line.split("");
            for(int j = 0; j < W; j++) {
                if(sp[j].equals(".")) {
                    hyo[i][j] = 0;
                }else {
                    hyo[i][j] = -1;
                }
            }
        }
        
        for(int j = 0; j < W; j++) {
            if(hyo[0][j] == -1) {
                break;
            }else {
                hyo[0][j] = 1;
            }
        }
        
        for(int i = 0; i < H; i++) {
            if(hyo[i][0] == -1) {
                break;
            }else {
                hyo[i][0] = 1;
            }
        }
        
        
        for(int i = 1; i < H; i++) {
            for(int j = 1; j < W; j++) {
                if(hyo[i][j] == -1) {
                    continue;
                }else if(hyo[i-1][j] == -1 && hyo[i][j-1] == -1) {
                    continue;
                }else if(hyo[i-1][j] == -1 || hyo[i][j-1] == -1) {
                    hyo[i][j] = max(hyo[i-1][j], hyo[i][j-1]) % 1000000007;
                }else {
                    hyo[i][j] = (hyo[i-1][j] + hyo[i][j-1]) % 1000000007;
                }
                
            }
        }
        
        /*
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                System.out.print(hyo[i][j]+" ");
            }
            System.out.println("");
        }
        */
        
        
        System.out.println(hyo[H-1][W-1]);
        
    }

    
    public static long max(long a, long b) {
        if(a >= b) {
            return a;
        }else {
            return b;
        }
    }
    
    public static int max(int a, int b) {
        if(a >= b) {
            return a;
        }else {
            return b;
        }
    }
    
    public static long min(long a, long b) {
        if(a >= b) {
            return b;
        }else {
            return a;
        }
    }
    
    public static int min(int a, int b) {
        if(a >= b) {
            return b;
        }else {
            return a;
        }
    }
}

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  for(int i=0;i<S.size()-1;i++){
    if(S.at(i)==S.at(i+1)){
      N--;
    }
  }
  cout<<N<<endl;
}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<complex>
#include<vector>
#include<cstdio>
#include<string>
#include<bitset>
#include<ctime>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define Cpy(x,y) memcpy(x,y,sizeof(x))
#define Set(x,y) memset(x,y,sizeof(x))
#define FILE "4911"
#define mp make_pair
#define pb push_back
#define RG register
#define il inline
using namespace std;
typedef unsigned long long ull;
typedef vector<int>VI;
typedef long long ll;
typedef double dd;
const int N=100010;
const int base=26;
const dd eps=1e-6;
const int inf=1e9;
const ll INF=1ll<<60;
const int mod=1e9+7;
il ll read(){
  RG ll data=0,w=1;RG char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}
il void file(){
  srand(time(NULL)+rand());
  freopen(FILE".in","r",stdin);
  freopen(FILE".out","w",stdout);
}

int n,ans;ll s[N];
map<ll,ll>M;map<ll,ll>::iterator tmp;
map<ll,int>P;
il ll pdsqrt(ll x){return ((ll)pow((ll)sqrt(x),2))==x;}
il ll fact(ll x){
  RG ll t1=1,t2=1,r=x;
  for(RG ll i=2,t;1ll*i*i*i<=x;i++)
    if(r%i==0)while(r%(i*i*i)==0)r/=i*i*i;
  for(RG ll i=2,t;1ll*i*i*i<=x;i++)
    if(x%i==0){
      t=0;while(x%i==0)t++,x/=i;t%=3;
      if(t==1)t1*=i;if(t==2)t2*=i;
    }
  if(pdsqrt(x))t2*=(ll)sqrt(x);else t1*=x;
  //printf("ins:%lld,%lld\n",r,t1*t1*t2);
  M[r]=t1*t1*t2;P[r]++;
}
int main()
{
  n=read();for(RG int i=1;i<=n;i++)s[i]=read(),fact(s[i]);
  for(tmp=M.begin();tmp!=M.end();tmp++){
    if(tmp->first==1)ans++;
    else{
      RG bool f1=P.find(tmp->first)==P.end(),f2=P.find(tmp->second)==P.end();
      if(f1&&f2)continue;
      else if(f1&&!f2)ans+=P[tmp->second],P[tmp->second]=0;
      else if(!f1&&f2)ans+=P[tmp->first],P[tmp->first]=0;
      else ans+=max(P[tmp->first],P[tmp->second]),P[tmp->first]=P[tmp->second]=0;
      //printf("%lld,%lld:ans=%d\n",tmp->first,tmp->second,ans);
    }
  }
  printf("%d\n",ans);return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
vector<int>AdjList[200001];
unsigned long long cost[200001];
int flag[200001];
void DFS(int u){
    flag[u]=1;
    for(int i=0;i<AdjList[u].size();i++){
        int v=AdjList[u][i];
        if(flag[v]==0){
            cost[v]+=cost[u];
            DFS(v);
        }
    }
}
int main(){
    int n,q;
    cin>>n>>q;
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        AdjList[a].push_back(b);
        AdjList[b].push_back(a);
    }
    for(int i=1;i<=q;i++){
        int a,b;
        cin>>a>>b;
        cost[a]+=b;
    }
    DFS(1);
    for(int i=1;i<=n;i++){
        cout<<cost[i]<<" ";
    }
    cout<<endl;

}


Measured memory_bytes: 25088
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int cnt;

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;
        for ( int i = 0; i < n; i++ ) {
            int a;
            read a;
            cnt += a&1;
        }
        if ( cnt&1 ) {
            echo "NO" fin;
        }
        else {
            echo "YES" fin;
        }

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
const int MaxN=1050;
struct Node
{
	int val;
	int mask;
}a[MaxN];
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
int f[(1<<12)+5];
int n,m;
signed main(void)
{
	fill(f,f+(1<<12),1e15);
	cin>>n>>m;
	for(int i=1;i<=m;++i)
	{
		int x,y;
		cin>>a[i].val>>x;
		for(int j=1;j<=x;++j)
			cin>>y,a[i].mask|=(1<<(y-1));
	}
	f[0]=0;
	for(int i=0;i<(1<<n);++i)
	{
		for(int j=1;j<=m;++j)
			f[i|a[j].mask]=min(f[i|a[j].mask],f[i]+a[j].val);
	}
	if(f[(1<<n)-1]==1e15)
		cout<<-1<<endl;
	else
		cout<<f[(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using  namespace std;

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << endl;

using db = long double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define scl1(a)             scanf(“%I64d", &a)
#define scl2(a, b)          scanf("%lld %lld", &a, &b)

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;
const int inf = 0x3f3f3f3f;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main(){

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x,j,y,z,k,n;
cin>>x>>y;
if(x/10>0||y>=10)ce(-1)
else ce(x*y)
}


Measured memory_bytes: 256