akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)


int main(){
    string s;
    cin >> s;
    int n = s.size();
    string ans = "";
    for(int i = 0; i < n; i++){
        if(s[i] == 'B'){
            if(ans.size() == 0) continue;
            else{
                ans = ans.substr(0,ans.size()-1);
            }
        }else{
            ans += s[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc101/tasks/abc101_b

#include <cmath>
#include <iostream>

bool solve(int n) {
  int sum = 0;
  int a = n;
  while (a > 0) {
    sum += a % 10;
    a /= 10;
  }

  return (n % sum) == 0;
}

int main() {
  using namespace std;

  int n;
  cin >> n;

  cout << (solve(n) ? "Yes" : "No") << std::endl;

  return 0;
}


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

int main(){
  int r,g,b;
  cin >>r>>g>>b;
  
  int sum = 100*r+10*g+b;
  
  string ans;
  sum%4==0 ? ans="YES" : ans="NO";
  
  cout <<ans<< endl;
}


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

namespace Program
{
    public class AGC033A
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }

        static public void Main(string[] args)
        {
            var H = Console_.NextInt();
            var W = Console_.NextInt();

            var blackTable = new bool[H, W];
            var list = new List<Tuple<int, int>>();
            for (int i = 0; i < H; ++i)
            {
                var ws = Console_.NextString().ToArray();
                for (int j = 0; j < W; ++j)
                {
                    if (ws[j] == '#')
                    {
                        blackTable[i, j] = true;
                        list.Add(Tuple.Create(i, j));
                    }
                }
            }

            var count = 0;
            while (list.Count != 0)
            {
                ++count;
                var nextList = new List<Tuple<int, int>>();
                foreach (var item in list)
                {
                    if (item.Item1 > 0)
                    {
                        if (!blackTable[item.Item1 - 1, item.Item2])
                        {
                            blackTable[item.Item1 - 1, item.Item2] = true;
                            nextList.Add(Tuple.Create(item.Item1 - 1, item.Item2));
                        }
                    }
                    if (item.Item1 < H - 1)
                    {
                        if (!blackTable[item.Item1 + 1, item.Item2])
                        {
                            blackTable[item.Item1 + 1, item.Item2] = true;
                            nextList.Add(Tuple.Create(item.Item1 + 1, item.Item2));
                        }
                    }
                    if (item.Item2 > 0)
                    {
                        if (!blackTable[item.Item1, item.Item2 - 1])
                        {
                            blackTable[item.Item1, item.Item2 - 1] = true;
                            nextList.Add(Tuple.Create(item.Item1, item.Item2 - 1));
                        }
                    }
                    if (item.Item2 < W - 1)
                    {
                        if (!blackTable[item.Item1, item.Item2 + 1])
                        {
                            blackTable[item.Item1, item.Item2 + 1] = true;
                            nextList.Add(Tuple.Create(item.Item1, item.Item2 + 1));
                        }
                    }
                }
                list = nextList;
            }

            Console.WriteLine(count - 1);
        }
    }
}


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

int main(){
  std::vector<int> data;
  int a, b, c;
  std::cin >> a >> b >>c;
  data.push_back(a);
  data.push_back(b);
  data.push_back(c);
  std::sort(data.begin(),data.end());
  for (std::vector<int>::iterator i = data.begin(); i != data.end(); ++i) {
  	std::cout << *i;
  	if(i != data.end()-1)
  	  std::cout << ' ';
  }
  std::cout << std::endl;
  return 0;
}

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

int main(){
        int n, ans=0;
        int *tmp;
        scanf("%d",&n);
        tmp=(int *)malloc(sizeof(int)*n-1);
        for(int i=0;i<n-1;i++) scanf("%d",&tmp[i]);
        for(int i=n-2;i>-2;i--){
                if((i!=n-2&&tmp[i]>tmp[i+1])||i==-1){
                        ans+=tmp[i+1];
                }
                else{
                        ans+=tmp[i];
                }
        }
        printf("%d\n",ans);
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int n;
  cin >>n;
  rep(i,n){
    int x;
    cin >>x;
    if(x%2 == 0){
      if(x%3 == 0 || x%5 == 0){
      }else{
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

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

const int N = 200005;
const int logN = 20;
vector<int> con[N];
int parent[N],depth[N];
void dfs(int s, int d, int p){
    depth[s] = d;
    parent[s] = p;
    for(int v:con[s])
        if(v!=p)
            dfs(v,d+1,s);
}

int val[N];

int perm[N];
int mn[N];
vector<int> child[N];
int cnt[2][N];

struct cmpr{
    bool operator() (const pair<pii, int> & A, const pair<pii, int> & B) const {
    	pii X = A.F, Y = B.F;
    	if(X.F * (ll) Y.S < X.S * (ll) Y.F) return 1;
    	else if (X.F * (ll) Y.S == X.S * (ll) Y.F) return A < B;
    	return 0;
    }
};

pii store[N];

set<pair<pii, int>, cmpr> my_st;

int par[N], one[N], zero[N];

int root(int x){return (x == par[x]) ? x : par[x] = root(par[x]);}

long long ans = 0;

void merge(int x, int y){
	x = root(x), y = root(y);
	if(x == y) return;
	par[x] = y;
	my_st.erase({{one[y], zero[y]}, y});
	my_st.erase({{one[x], zero[x]}, x});
	ans += one[y] * (ll) zero[x];
	one[y] += one[x];
	zero[y] += zero[x];
	one[x] = zero[x] = 0;
	my_st.insert({{one[y], zero[y]}, y});
}

int main(){
	int n;
	sd(n);
	for(int i = 2; i <= n; i++) {
		int x;
		sd(x);
		con[i].push_back(x);
		con[x].push_back(i);
	}
	for(int i = 1; i <= n; i++){
		sd(val[i]), perm[i] = i;
		if(val[i] == 1) one[i]++;
		else zero[i]++;
		par[i] = i;
		if(i != 1) my_st.insert({{one[i], zero[i]}, i});
	}

	dfs(1, 1, 0);

	for(int i = 1; i <= n - 1; i++){
		auto it = my_st.begin();
		int ind = it->S;
		if(ind == 1){
			it++;
			ind = it->S;
		}
		merge(ind, parent[ind]);
	}
	printf("%lld\n", ans);
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
string s;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    cin>>s;


    auto print_ans = [](vector<int> v) {
	for (int x: v) {
	    cout<<(x==0? 'W': 'S');
	}
	cout<<endl;
    };

    for (int a=0;a<2;a++) {
	for (int b=0;b<2;b++) {
	    vector<int> ans(n);
	    ans[0]=a;
	    ans[1]=b;
	    bool ok = true;
	    for (int i=1; i<n-1; i++) {
		if (s[i]=='o') {
		    ans[i+1]=ans[i-1];
		} else {
		    ans[i+1]=1-ans[i-1];
		}
		
		if (ans[i] == 0) {
		    //wolf: flip
		    ans[i+1]=1-ans[i+1];
		}
	    }

	    
	    for (int i=0; i<n; i++) {
		int nxt=(i+1)%n;
		int prv=(i-1+n)%n;
		if (ans[prv] == ans[nxt]) {
		    if (ans[i] == 1) {
			if (s[i]=='x') ok=false;
		    } else {
			if (s[i]=='o') ok=false;
		    }
		} else {
		    if (ans[i] == 1) {
			if (s[i]=='o') ok=false;
		    } else {
			if (s[i]=='x') ok=false;
		    }
		}
	    }
	    
	    
	    if (ok) {
		print_ans(ans);
		return 0;
	    }
	}
    }

    cout<<-1<<endl;
  

    return 0;
}


Measured memory_bytes: 1360
package main

import (
	"fmt"
)

const tax8, tax10 = 0.08, 0.1

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	for i := 0; i < 1100; i++ {
		if int(float64(i)*tax8) == a {
			if int(float64(i)*tax10) == b {
				fmt.Println(i)
				return
			}
		}
	}
	fmt.Println(-1)
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
using namespace std;

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

	if (A < C && C < B) {
		cout << "Yes" << endl;
	}
	else if (A > C && C > B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
struct Edge{
	int to,money,cost;
};
struct Data{
	int v,money,dist;
};

const int INF = 1e18;
vector<Edge> g[55];
signed main(){
	int n,m,s;cin >> n>> m >> s;
	rep(i,m){
		int u,v,a,b;cin >> u >> v >> a >> b;
		u--;v--;
		g[u].push_back((Edge){v,a,b});
		g[v].push_back((Edge){u,a,b});
	}
	vector<int> c(n),d(n);
	vector<vector<int>> dist(n,vector<int>(2551,INF));
	rep(i,n)cin >>c[i] >> d[i];
	auto comp = [](const Data &a,const Data &b){
		if(a.dist == b.dist)return a.money < b.money;
		return a.dist > b.dist;
	};
	priority_queue<Data,vector<Data>,decltype(comp)> pq{comp};
	auto push = [&](int v,int cur,int cost){
		if(dist[v][cur] <= cost)return;
		if(cur < 0)return;
		if(cur >= 2550)return;
		dist[v][cur] = cost;
		pq.push((Data){v,cur,cost});
	};
	int tmp = min(s,2510ll);
	push(0,tmp,0);
	while(pq.size()){
		auto now = pq.top();pq.pop();
		// trace(now.v,now.money,now.dist);
		if(dist[now.v][now.money] != now.dist)continue;
				
		//両替
		int cur = now.money;
		int time = now.dist;
		// while(cur < 2550){
		// 	cur += c[now.v];
		// 	time += d[now.v];
		// 	push(now.v,cur,time);
		// }
		push(now.v,cur+c[now.v],time+d[now.v]);
		//街を移る
		for(auto next:g[now.v]){
			push(next.to,now.money - next.money,now.dist + next.cost);
		}
	}
	for(int i = 1;i < n ;i++){
		int ret = INF;
		rep(j,2551){
			ret = min(ret,dist[i][j]);
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 7364
#include <bits/stdc++.h>
using namespace std;
namespace IO
{
	const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
	inline char getc()
	{
		if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
		if(__H==__T) return -1;return *__H++;
	}
	template <class __I>inline void read(__I &__x)
	{
		__x=0;int __fg=1;char __c=getc();
		while(!isdigit(__c)&&__c!='-') __c=getc();
		if(__c=='-') __fg=-1,__c=getc();
		while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
		__x*=__fg;
	}
	inline void readd(double &__x)
	{
		__x=0;double __fg=1.0;char __c=getc();
		while(!isdigit(__c)&&__c!='-') __c=getc();
		if(__c=='-') __fg=-1.0,__c=getc();
		while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
		if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
		double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
		__x=__x*__fg;
	}
	inline void reads(char *__s,int __x)
	{
		char __c=getc();int __tot=__x-1;
		while(__c<'!'||__c>'~') __c=getc();
		while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
		__s[++__tot]='\0';
	}
	char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
	inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
	inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
	template <class __I>inline void print(__I __x)
	{
		if(!__x) putc('0');
		if(__x<0) putc('-'),__x=-__x;
		while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
		while(__qr) putc(__qu[__qr--]);
	}
	inline void prints(const char *__s,const int __x)
	{
		int __len=strlen(__s+__x);
		for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
	}
	inline void printd(double __x,int __d)
	{
		long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
		while(__d--)
		{
			double __y=__x*10.0;__x*=10.0;
			int __c=(int)floor(__y);
			putc(__c+'0');__x-=floor(__y);
		}
	}
	inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
#define ll long long
int n,m,tot;ll x,t[200005],a[200005],f[200005],ans[200005];stack<ll>sta;
void gao(ll x,ll y)
{
	if(!x) return;int t=upper_bound(a+1,a+tot+1,x)-a-1;
	if(!t) ans[1]+=y,ans[x+1]-=y;else f[t]+=x/a[t]*y,gao(x%a[t],y);
}
int main()
{
	read(n);read(m);a[++tot]=n;
	for(int i=1;i<=m;i++){read(x);while(tot&&a[tot]>=x) tot--;a[++tot]=x;}
	f[tot]=1;for(int i=tot;i>=2;i--) f[i-1]+=f[i]*(a[i]/a[i-1]),gao(a[i]%a[i-1],f[i]);
	ans[1]+=f[1];ans[a[1]+1]-=f[1];for(int i=1;i<=n;i++) ans[i]+=ans[i-1];
	for(int i=1;i<=n;i++) print(ans[i]),el();flush();
}

Measured memory_bytes: 7168
list1=[]
list2=[]
sum=0
for i in range(4):
    n1=int(input())
    list1.append(n1)
for j in range(2):
    n2=int(input())
    list2.append(n2)
list1.sort(reverse=True)
for x in range(3):
    sum+=list1[x]
list2.sort(reverse=True)
sum+=list2[0]
print(sum)


Measured memory_bytes: 5600
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  A = [int(input()) for _ in range(N)]

  set_ = set()
  set_.add(0)
  cur = 0
  next_ = 0
  cnt = 0

  while True:
    # push
    cnt += 1
    cur = next_
    next_ = A[cur] - 1
    if next_ == 1:
      print(cnt)
      break
    if next_ in set_:
      print(-1)
      break
    set_.add(next_)


if(__name__ == '__main__'):
  main()

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



int main(){
    int c = 1,m,n,i;
    cin >> n;
    while( c<=n ){
        cin>>m;
        cout<<"Case "<<c<<":\n";
        for(i=0;i<10;i++){
            m=m*m/100%10000;
            cout<<m<<endl;
        }
        c++;
    }

    return 0;
}

Measured memory_bytes: 1160
from copy import copy
n, *a = map(int, open(0).read().split())

b = copy(a)
c = copy(a)

for i in range(1, n):
    b[i] = max(b[i], b[i - 1])
for i in range(n - 2, -1, -1):
    c[i] = max(c[i], c[i + 1])
b.append(-1)
c.append(-1)

for i in range(n):
    print(max(b[i - 1], c[i + 1]))


Measured memory_bytes: 33196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;

template <class T>
ostream& operator <<(ostream& os, vector<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

int main() {
    int N;
    cin >> N;
    V<ll> A_list;
    int num_negatives = 0;
    ll min_abs_item = (1 << 29);

    for (int i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        if (tmp < 0) num_negatives += 1;
        min_abs_item = min(min_abs_item, abs(tmp));
        A_list.emplace_back(tmp);
    }
    // cout << A_list << "\n";
    // cout << num_negatives << "\n";
    // cout << min_abs_item << "\n";
    ll max_sum = 0;
    for (ll A : A_list) max_sum += abs(A);
    if (num_negatives % 2 == 1) {
        max_sum -= min_abs_item * 2;
    }
    cout << max_sum << "\n";
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t h, w, n;
    cin >> h >> w >> n;

    cout << min((n - 1) / w + 1, (n - 1) / h + 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     f0(n)     for(int i=0;i<n;i++)
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))

int a;
int main()
{
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif  */
     __

    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='2') a++;
    }
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()
    s = []

    for x in S:
        if (ord(x) + N) > 90:
            s.append(chr(ord(x) + N - 26))
        else:
            s.append(chr(ord(x) + N))

    print(*s, sep='')


if __name__ == '__main__':
    main()


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

using namespace std;

#define ll long long
#define int long long
//#define TEST

signed main(){
    /* 入力の受け取り */
    int n;
    cin >> n;
    int* x = new int[n];
    for (int i = 0;i < n;++i)
        cin >> x[i];
    int m;
    ll k;
    cin >> m >> k;
    int* a = new int[m];
    for (int i = 0;i < m;++i){
        cin >> a[i];
        --a[i]; // ウサギは0-indexedで管理する
    }
#ifdef TEST // xとaの確認用出力
    cout << "----------x----------" << endl;
    for (int i = 0;i < n;++i)
        cout << x[i] << " ";
    cout << endl;
    cout << "----------a----------" << endl;
    for (int i = 0;i < m;++i)
        cout << a[i] << " ";
    cout << endl;
#endif

    /*
            y[i] = (x[i+1] - x[i])の初期状態
        とy[i]を定義する.
        また、
            d[i] : 1セット分の体操で、x[i+1]-x[i]が初期のy[j]に変化するようなj
        とする.
     */
    int* y = new int[n - 1];
    for (int i = 0;i < n - 1;++i)
        y[i] = x[i + 1] - x[i];
    int* d = new int[n - 1];
    for (int i = 0;i < n - 1;++i) // dの初期化
        d[i] = i;
    for (int i = 0;i < m;++i){ // dの計算
        d[a[i] - 1] ^= d[a[i]];
        d[a[i]] ^= d[a[i] - 1];
        d[a[i] - 1] ^= d[a[i]];
    }
#ifdef TEST // yとdの確認用出力
    cout << "----------y----------" << endl;
    for (int i = 0;i < n - 1;++i)
        cout << y[i] << " " << endl;
    cout << "----------d----------" << endl;
    for (int i = 0;i < n - 1;++i)
        cout << d[i] << " " << endl;
#endif

    /*
            dp[i][l] : x[i+1]-x[i]が2^l回の体操でy[j]に変化するようなj
        を求める.(ダブリング)
     */
    int** dp = new int*[n - 1];
    for (int i = 0;i < n - 1;++i)
        dp[i] = new int[65];
    for (int i = 0;i < n - 1;++i) // dpの初期化
        dp[i][0] = d[i];
    for (int l = 1;l < 65;++l) // dpの計算
        for (int i = 0;i < n - 1;++i)
            dp[i][l] = dp[dp[i][l - 1]][l - 1];
#ifdef TEST // dpの確認用出力
    cout << "----------dp---------" << endl;
    for (int i = 0;i < n - 1;++i){
        for (int j = 0;j < 65;++j)
            cout << dp[i][j] << " ";
        cout << endl;
    }
#endif

    /*
            df[i] : x[i+1]-x[i]がkセットの体操の後、y[j]に一致するようなj
        を求める.
     */
    int* df = new int[n - 1];
    for  (int i = 0;i < n - 1;++i) // dfの初期化
        df[i] = i;
    for (int l = 0;l < 65;++l){
        bool f = k & 1; // kの下からlビット目
        k /= 2;
        if (!f) continue;
        for (int i = 0;i < n - 1;++i)
            df[i] = dp[df[i]][l];
        if (k == 0) break;
    }
#ifdef TEST
    cout << "----------df---------" << endl;
    for (int i = 0;i < n - 1;++i)
        cout << df[i] << " ";
    cout << endl;
#endif

    /*
            x[i+1] - x[i] = y[df[i]]
        という関係から、最終的なxを求める.
     */
    for (int i = 0;i < n - 1;++i){
        x[i + 1] = x[i] + y[df[i]];
    }

    /* 答えの出力 */
#ifdef TEST
    cout << "----------ans--------" << endl;
#endif
    for (int i = 0;i < n;++i)
        cout << x[i] << " ";
    cout << endl;

    /* メモリの開放、プログラムの終了 */
    delete[] x,a,y,d,df;
    for (int i = 0;i < n - 1;++i)
        delete[] dp[i];
    delete[] dp;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/16  Problem: ABC 130 E / Link: http://abc130.contest.atcoder.jp/tasks/abc130_e  ----- */

const int mod = 1e9 + 7;
LL dp[2003][2003];
int CommomSubsequencesCount(vector<int> s, vector<int> t)
{
	int n1 = s.size();
	int n2 = t.size();

	for (int i = 0; i <= n1; i++) {
		for (int j = 0; j <= n2; j++) {
			dp[i][j] = 0;
		}
	}

	for (int i = 1; i <= n1; i++) {

		// for each charcater in T 
		for (int j = 1; j <= n2; j++) {
			if (s[i - 1] == t[j - 1])
				dp[i][j] = 1 + dp[i][j - 1] + dp[i - 1][j];
			else
				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] + mod -
					dp[i - 1][j - 1]) % mod;
			dp[i][j] %= mod;
		}
	}
	dp[n1][n2] += 1;
	dp[n1][n2] %= mod;
	return dp[n1][n2];
}


// Driver Program 
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	vector<int> b(M);
	for (int i = 0; i < M; ++i) {
		cin >> b[i];
	}
	cout << CommomSubsequencesCount(a, b) << endl;
	return 0;
}

Measured memory_bytes: 31616
import java.io.IOException;
import java.io.PrintStream;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		PrintStream out = System.out;

		int val1, val2;
		do {
			val1 = scan.nextInt();
			val2 = scan.nextInt();
			if (val1 > val2) {
				int temp = val1;
				val1 = val2;
				val2 = temp;
			}
			if (val1 == 0 && val2 == 0) {
				break;
			}
			out.println(val1 + " " + val2);
		} while (val1 != 0 || val2 != 0);
	}
}

Measured memory_bytes: 27164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		String sharp = "";
		for(int i=0; i<w+2; i++) {
			sharp += "#";
		}
		StringBuilder sb = new StringBuilder();
		sb.append(sharp+"\n");
		for(int i=0; i<h; i++) {
			sb.append("#"+scan.next()+"#");			
			sb.append("\n");
		}
		scan.close();
		sb.append(sharp);
		System.out.println(sb.toString());
	}

}

Measured memory_bytes: 23764
package main

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

var sc = bufio.NewScanner(os.Stdin)
var count int

func trace(A []int, N int) {
	for i := N-1; i >= 0; i-- {
		if i != N-1 {
			fmt.Printf(" ")
		}
		fmt.Printf("%d", A[i])
	}
	fmt.Printf("\n")
}

func traceln(A []int, N int) {
	for i := 0; i < N; i++ {
		fmt.Println(A[i])
	}
}

func nextInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func insertionSort(A []int, N, g int) {
	for i := g; i < N; i++ {
		tmp := A[i]
		j := i - g
		for j >= 0 && A[j] > tmp {
			A[j+g] = A[j]
			j = j - g
			count++
		}
		A[j+g] = tmp
	}
}

func ShellSort(A []int, N int, m int, G []int) []int {
	sorted := append([]int{}, A...)	
	for i := m-1; i >= 0; i-- {
		insertionSort(sorted, N, G[i])
	}
	return sorted
}

func main() {
	sc.Split(bufio.ScanWords)
	length := nextInt()

	array := make([]int, length)
	for i := 0; i < length; i++ {
		array[i] = nextInt()
	}

	// create G and m
	var G []int
	h := 1
	for h <= length {
		G = append(G, h)
		h = 3*h + 1
	}


	sorted := ShellSort(array, length, len(G), G)
	
	fmt.Println(len(G))
	trace(G, len(G))
	fmt.Println(count)
	traceln(sorted, length)
}


Measured memory_bytes: 24508
import math

N = int(input())

ans = N
for i in range(N+1):
    tmp_ans = 0
    tmp_N = i
    while tmp_N > 0:
        tmp_ans += tmp_N % 9
        tmp_N //= 9
    tmp_N = N-i
    while tmp_N > 0:
        tmp_ans += tmp_N % 6
        tmp_N //= 6
    ans = min(ans, tmp_ans)
print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
int main(){
  string s;cin>>s;
  ll n=s.size(),p=0,g=0,ans=0;
  
  rep(i,0,n){
    if(p==g){
      g++;
      if(s[i]=='p')ans--;
    }
    else if(p<g){
      if(s[i]=='g'){
        p++;ans++;
      }
      else {
        p++;
      }
    }
    
  }
  cout<<ans<<endl;
}



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

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

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)

int main(){
	ll n,k;
	cin>>n>>k;
	
	ll ret=(n/k)*(n/k)*(n/k);
	if(k%2==0){
		ll x=(n+k/2)/k;
		ret+=x*x*x;
	}
	cout<<ret<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

    cout << min(a,b) + min(c,d) << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int N=109;
int a[N],b[N],n,mx;
int rd(){
	char ch=getchar();int x=0;
	while(ch<48||ch>57)ch=getchar();
	while(ch>47&&ch<58)
		x+=(x<<3)+x+ch-48,ch=getchar();
	return x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		a[i]=rd(),mx=max(mx,a[i]),++b[a[i]];
	if(mx&1){
		for(int i=mx;i>=(mx+1)/2;--i)
			if(b[i]<2)puts("Impossible"),exit(0);
		for(int i=1;i<(mx+1)/2;++i)
			if(b[i])puts("Impossible"),exit(0);
		if(b[(mx+1)/2]>2)
			puts("Impossible"),exit(0);
	}
	else{
		for(int i=mx;i>mx/2;--i)
			if(b[i]<2)puts("Impossible"),exit(0);
		for(int i=1;i<mx/2;++i)
			if(b[i])puts("Impossible"),exit(0);
		if(b[mx/2]^1)puts("Impossible"),exit(0);
	}
	puts("Possible"),exit(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[100009],lef,rig,mid,i,j,pas,ans,pasmid,pasans,jm[100009];
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    for(i=1; i<=a; i++) cin>>f[i];
    sort(f+1,f+a+1);
    for(i=a; i>=1; i--) jm[i]=jm[i+1]+f[i];
    if(a==1){
        cout<<f[1]*2;
        return 0;
    }
    lef=0;
    rig=f[a]+f[a-1]+4;
    f[0]=-300009;
    while(1){
        if(lef+1>=rig) break;
        mid=(lef+rig)/2;
//        cout<<mid<<endl;
        ans=0;
        j=a+1;
        for(i=1; i<=a; i++){
            while(f[j-1]>=mid-f[i]) j--;
            ans+=a-j+1;
        }
        if(ans==b){
            pasmid=mid;
            pasans=ans;
            break;
        }
        if(ans>b){
            lef=mid;
        }else{
            pasmid=mid;
            pasans=ans;
            rig=mid;
        }
    }
  //  cout<<pasmid<<" "<<pasans<<endl;
    if(pasmid>=1) pas=(b-pasans)*(pasmid-1);
    mid=pasmid;
    j=a+1;
    for(i=1; i<=a; i++){
        while(f[j-1]>=mid-f[i]) j--;
        pas+=jm[j]+f[i]*(a-j+1);
    }
    cout<<pas;
    return 0;
}

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

int main() {
	// your code goes here
	string word;
	cin>>word;
	int n = word.size();
	int freq[26] = {0};
	for(int i=0;i<n;i++) freq[word[i]-'a']++;
	bool beautiful = true;
	for(int i=0;i<26 and beautiful;i++) if(freq[i]&1) beautiful = false;
	printf("%s\n", beautiful ? "Yes" : "No");
	return 0;
}

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

int main() {
    ll K;
    cin >> K;
    ll ans = -1;
    queue<ll> que;
    que.push(7);

    for (ll i=0; i<K; i++) {
        ll a = que.front();
        if (a%K == 0) {
            ans = i+1;
            break;
        }
        que.push((a*10+7)%K);
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N, Q;
    cin >> N >> Q;
    if (N == 0 && Q == 0){
      break;
    }
    vector<int> cnt(100, 0);
    for (int i = 0; i < N; i++){
      int M;
      cin >> M;
      for (int j = 0; j < M; j++){
        int D;
        cin >> D;
        cnt[D]++;
      }
    }
    int ans = 0;
    for (int i = 1; i < 100; i++){
      if (cnt[i] > cnt[ans]){
        ans = i;
      }
    }
    if (cnt[ans] < Q){
      cout << 0 << endl;
    } else {
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		String ans = "yes";
		char[] list = s.toCharArray();
		outside: for (int i = 0; i < list.length; i++) {
			for (int j = 0; j < list.length; j++) {
				if (i == j) {
					continue;
				}
				
				if (list[i] == list[j]) {
					ans = "no";
					break outside;
				}
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <iomanip>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
//#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    long long N;cin >> N;
    long long ans = 0;
    for(long long a = 1;a<=sqrt(N);a++){
        long long b = a;
        while(a*b < N){
            //cout << a << " " << b << endl;
            ans += 2;
            if(a == b) ans--;
            b++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3696
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	int N,M;
	cin>>N>>M;
	int sum = 0;
	for(int i = 0; i < M; i++){
		int a;
		cin>>a;
		sum += a;
	}
	if( sum > N){
		cout<<-1<<endl;
	}else{
		cout<< N - sum<<endl;
	}
	return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)
#define IN(v) cin>>v
#define OUT(v) cout<<v<<endl

vector<vector<LL> > v;
LL combination(int n, int r) {
  vector<vector<LL>> v(n + 1, vector<LL>(n + 1, 0));
  for (int i = 0; i <= n; i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j <= n; j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}

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

  vector<LL> V;
  REP(i, N) {
    LL v;
    cin >> v;
    V.PB(v);
  }

  sort(ALL(V), greater<LL>());
  LL sum = 0;
  bool is_same = true;
  REP(i, A) {
    sum += V[i];
    if (i > 0 && V[i] != V[i-1]) {
      is_same = false;
    }
  }
  sort(ALL(V));
  cout << fixed << setprecision(6) << ((double)sum / A) << endl;
  LL last = V[V.size() - A];
  int count = upper_bound(V.begin(), V.end() - A, last) - lower_bound(V.begin(), V.end() - A, last);
  int count_all = upper_bound(ALL(V), last) - lower_bound(ALL(V), last);
  // count_all個のなかからcount個を選ぶ
  if (is_same) {
    int n = count_all;
    LL res = 0;
    REP(i,B-A+1) {
      // 追加でi個選ぶ
      if (V[V.size() - (A+i)] != last)
        break;
      res += combination(n, (count_all-count) + i);
    }
    cout << res << endl;
  } else {
    int n = count_all;
    int m = max(count_all - count, count);
    cout << combination(n, m) << endl;
  }
  return 0;
}


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

int main()
{
    string a[4] = { "mew", "mnew", "menw", "mnenw" }, s;

    cin >> s;

    bool judge = true;
    while( judge )
    {
        judge = false;

        string t = "";
        for( int i = 0; i < s.size(); i++ )
        {
            string c = s.substr( i, 3 ), d = s.substr( i, 4 ), e = s.substr( i, 5 );
            if( c == a[0] )
            {
                s[i++] = 'n';
                s[i++] = ' ';
                s[i] = ' ';
                judge = 1;
            }
            if( d == a[1] || d == a[2] )
            {
                s[i++] = 'n';
                s[i++] = ' ';
                s[i++] = ' ';
                s[i] = ' ';
                judge = 1;
            }
            if( e == a[3] )
            {
                s[i++] = 'n';
                s[i++] = ' ';
                s[i++] = ' ';
                s[i++] = ' ';
                s[i] = ' ';
                judge = 1;
            }
        }
        for( int i = 0; i < s.size(); i++ )
        {
            if( s[i] == 'm' || s[i] == 'n' || s[i] == 'e' || s[i] == 'w' )
                t += s[i];
        }
        s = t;
    }

    if( s == "n" )
        cout << "Cat" << endl;
    else
        cout << "Rabbit" << endl;

    return 0;
}


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

lli h;
lli attack(lli x){
	if(x == 1) return 1;
	return 2*attack(x/2)+1;
}

int main(void){
	cin >> h;
	cout << attack(h) << endl;
	return 0;
}


Measured memory_bytes: 3632
//Bit full search.
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int>   vi;
typedef vector<vi >   vvi;

int main(){
	int n,m;
	cin>>n>>m;
	
	vvi v(m);
	REP(i,m){
		int k;
		cin>>k;
		v[i].resize(k);
		REP(j,k){
			cin>>v[i][j];
			v[i][j]--;
		}
	}
	
	vi p(m);
	REP(i,m) cin>>p[i];
	
	int ans=0;
	REP(i,(1<<n)){//スイッチの付き方を全探索.
		bool jud=true;
		REP(j,m){//全ての電球を試す.
			int cnt=0;
			for(auto &elem:v[j]){
				if((i>>elem)&1) cnt++;
			}
			if(cnt%2!=p[j]){
				jud=false;
				break;
			}
		}
		if(jud) ans++;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
map<ll, int> prime_factor(ll n)
{
    map<ll, int> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] = 1;
    }
    return res;
}

int main()
{
    ll N, ans = 0;
    cin >> N;
    map<int, int> divs;
    for (size_t i = 2; i <= N; i++)
    {
        auto d = prime_factor(i);
        for (auto &&i : d)
        {
            divs[i.first] += i.second;
        }
    }
    for (auto &&p : divs)
    {
        if(p.second>=74)
        {
            ans++;
        }
        for (auto &&q : divs)
        {
            if(p == q)
            continue;
            if (p.second >= 24 and q.second >= 2)
            {
                ans++;

            }
             if (p.second >= 14 and q.second >= 4)
            {
                ans++;

            }
            for (auto &&r : divs)
            {
                if (p == q or p == r or q == r)
                    continue;

                if (p.second >= 4 and q.second >= 4 and r.second >= 2 and p.first > q.first)
                {
                    ans++;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	string a,b;
	cin >> a >> b;
	cout << b << a << endl;

	return 0;
}


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

wa=a[0]
ans1,ans2=0,0
if a[0]==0:
    ans1+=1
    wa=-1

for i in range(1,n):
    # print(wa)
    if wa>0:
        if wa+a[i]<0:
            wa+=a[i]
        else:
            ans1+=abs(wa+a[i])+1
            wa=-1
    else:
        if wa+a[i]>0:
            wa+=a[i]
        else:
            ans1+=abs(wa+a[i])+1
            wa=1

if a[0]>0:
    ans2+=a[0]+1
    wa=-1
else:
    ans2+=-a[0]+1
    wa=1

for i in range(1,n):
    if wa>0:
        if wa+a[i]<0:
            wa+=a[i]
        else:
            ans2+=abs(wa+a[i])+1
            wa=-1
    else:
        if wa+a[i]>0:
            wa+=a[i]
        else:
            ans2+=abs(wa+a[i])+1
            wa=1
print(min(ans1,ans2))

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    ll N,M;
    cin >> M >> N;
    ll a[N];
    ll b[N];
    ll ans = 0;
    ll res = 0;
    Rep(i,N){
        cin >> a[i];
        b[i] = a[i];
    }
    if(M == 2){
        Rep(i,N){
            if(a[i] != (i%2)+1)ans++;
            if(a[i] != (i+1)%2 +1)res++;
        }
    }else{
        Rep(i,N-1){
            if(a[i] == a[i+1]){
                ans++;
                a[i+1] = 0;
            }
        }
        Rep(i,N-1){
            if(b[N-1-i] == b[N-2-i]){
                res++;
                b[N-2-i] = 0;
            }
        }
    }
    cout << min(ans,res) << endl;
    //cin >> N;
}


Measured memory_bytes: 4648
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int maxn = (int)1e6 + 5;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 9;
using namespace std;

ll x[maxn];
int v[maxn];
ll c[maxn], cc[maxn];
ll cmx[maxn], ccmx[maxn];
 
int main()
{
	int n; ll C; scanf("%d %lld", &n, &C);
	for(int i = 1; i <= n; i++){
		scanf("%lld %d", &x[i], &v[i]);
		c[i] = c[i-1] + v[i] - (x[i] - x[i-1]);
		cmx[i] = max(cmx[i-1], c[i]);
	}
	x[n+1] = C;
	for(int i = n; i >= 1; i--){
		cc[n-i+1] = cc[n-i] + v[i] - (x[i+1] - x[i]);
		ccmx[n-i+1] = max(ccmx[n-i], cc[n-i+1]);
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++){
		ans = max(ans, c[i] - x[i] + ccmx[n-i]);
		ans = max(ans, cc[i] - (C - x[n-i+1]) + cmx[n-i]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main()
{
  string s,t;
  int i,k=0;
  getline(cin,s);
  getline(cin,t);
  for(i=0;i<3;i++)
  {
    if(t[i]==s[i])
      k++;
  }
  
  cout<<k<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int a,b,q;
    cin >> a >> b >> q;
    vl s(a+2),t(b+2);
    s[0] = -linf;
    t[0] = -linf;
    rep(i,a) cin >> s[i+1];
    rep(i,b) cin >> t[i+1];
    s[a+1] = linf;
    t[b+1] = linf;
    rep(_,q) {
        ll ans = linf;
        ll x;
        cin >> x;
        auto sit = lower_bound(all(s),x);
        auto tit = lower_bound(all(t),x);
        chmin(ans,max(*sit,*tit)-x);
        chmin(ans,x-min(*(sit-1),*(tit-1)));
        chmin(ans,*sit-*(tit-1)+min(*sit-x,x-*(tit-1)));
        chmin(ans,*tit-*(sit-1)+min(*tit-x,x-*(sit-1)));
        cout << ans << endl;
    }
}


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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);

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

    REP(i,3)
    {
        if ( S.at(i) == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628