akhauriyash/Code-Regression huggingface dataset:
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    double sum=0;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
        sum+=temp;
    }
    double sum1=sum/(4*m);
    int count=0;
    rep(i,n){
        if(sum1<=a[i])count++;
    }
    if(count>=m)yes;
    else no;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

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

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  ll sa = a / c + a / d - a / lcm(c, d);
  ll sb = b / c + b / d - b / lcm(c, d);
  cout << b - a - (sb - sa) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.StringBuilder;

public class Main {

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        while(true) {
            int height = scan.nextInt();
            int width = scan.nextInt();

            if(height == 0 && width == 0){
                break;
            }

            StringBuilder sb = new StringBuilder(width);
            for(int i = 0; i < width; i++) {
                sb.append("#");
            }

            String line = sb.toString();
            for(int i = 0; i < height; i++) {
                System.out.println(line);
            }
            System.out.println("");
        }
    }
}



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

int main()
{
  int N ;
  cin>>N ;
  vector<vector<int>>A(2,vector<int>(N)) ;
  for(int i=0;i<2;i++) for(int j=0;j<N;j++) cin>>A.at(i).at(j) ;
  
  int max ;
  for(int i=0;i<N;i++){
    int sum=0 ;
    for(int j=0;j<=i;j++) sum+=A.at(0).at(j) ;
    for(int j=i;j<N;j++) sum+=A.at(1).at(j) ;
    if(i==0) max=sum ;
    else max=(max>sum?max:sum) ;
  }
  cout<<max<<endl ;
  return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;


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

    if(a>b){
        for(int i=0;i<a;i++){
            cout<<b;
        }
        cout<<endl;
    }else{
        for(int i=0;i<b;i++){
            cout<<a;
        }
        cout<<endl;
    }
   
    //cout<<fixed << setprecision(15)<<max<<endl;
    //cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

Taro = 0; Hanako = 0
for i in range(n):
    cards = input().split()
    Tcard = list(cards[0]); Hcard = list(cards[1])
    if Tcard == Hcard:
        Taro += 1
        Hanako += 1
        continue

    for c in range(min(len(Tcard), len(Hcard))):
        if Tcard[c] > Hcard[c]:
            Taro += 3
            break
        elif Tcard[c] == Hcard[c]:
            if c+1 == len(Tcard):
                Hanako += 3
            elif c+1 == len(Hcard):
                Taro += 3
            continue
        elif Tcard[c] < Hcard[c]:
            Hanako += 3
            break
            
print(Taro, Hanako)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;
const int inf=1e9;
const ll Inf=1e18;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int to[N<<1],ww[N<<1],cost[N<<1],nxt[N<<1],tt=1,h[N],s,t,cur[N];
ll dis[N],ans=0;
bool vis[N];

void adde(int u,int v,int w,int c) {
	to[++tt]=v,ww[tt]=w,cost[tt]=c,nxt[tt]=h[u],h[u]=tt;
	to[++tt]=u,ww[tt]=0,cost[tt]=-c,nxt[tt]=h[v],h[v]=tt;
}

bool spfa() {
	memset(dis,0x3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	deque<int> q;q.push_back(s);dis[s]=0;
	while(!q.empty()) {
		int u=q.front();q.pop_front();vis[u]=0;
		for(int i=h[u],v;v=to[i],i;i=nxt[i]) {
			if(ww[i]&&dis[v]>dis[u]+cost[i]) {
				dis[v]=dis[u]+cost[i];
				if(!vis[v]) vis[v]=1,cost[i]<0?q.push_front(v):q.push_back(v);
			}
		}
	}
	return dis[t]<Inf;
}

int dfs(int u,int flow) {
	if(u==t) return flow;
	int ret=0;vis[u]=1;
	for(int &i=cur[u],v;v=to[i],i;i=nxt[i])
		if(ww[i]&&dis[v]==dis[u]+cost[i]&&!vis[v]) {
			int d=dfs(v,min(flow,ww[i]));
			ww[i]-=d,ww[i^1]+=d,ret+=d,flow-=d;ans+=1ll*cost[i]*d;
			if(!flow) { vis[u]=0;break; }
		}
	return ret;
}

int n;

int main() {
	cin>>n;t=10*n+5;
	for(int i=1;i<=n;i++) {
		int x=gi(),y=gi(),z=gi();
		adde(s,i+4,z,0);
		adde(i+4,i+n+4,z,x+y);
		adde(i+4,i+2*n+4,z,x-y);
		adde(i+4,i+3*n+4,z,y-x);
		adde(i+4,i+4*n+4,z,-x-y);
		for(int j=1;j<=4;j++) adde(i+j*n+4,j,z,0);
	}
	for(int i=1;i<=n;i++) {
		int x=gi(),y=gi(),z=gi();
		adde(i+9*n+4,t,z,0);
		adde(i+5*n+4,i+9*n+4,z,x+y);
		adde(i+6*n+4,i+9*n+4,z,x-y);
		adde(i+7*n+4,i+9*n+4,z,y-x);
		adde(i+8*n+4,i+9*n+4,z,-x-y);
		for(int j=1;j<=4;j++) adde(5-j,i+(j+4)*n+4,z,0);
	}
	
	while(spfa()) memcpy(cur,h,sizeof(h)),dfs(s,inf);
	cout<<-ans;
	return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <set>
#include <vector>
#include <queue>

#include <algorithm>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

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

	switch (N%10)
	{
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon";
		break;
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon";
		break;
	case 3:
		cout << "bon";
	default:
		break;
	}

	return 0;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n;
	scanf("%d", &n);

	int p[20];
	REP(i, n) {
		scanf("%d", &p[i]);
	}

	int cnt = 0;
	REPS(i, n - 2) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1])cnt++;
		if (p[i - 1] > p[i] && p[i] > p[i + 1])cnt++;
	}
	PRINTD(cnt);
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n);
	for (int& i : a) cin >> i;
	for (int& i : b) cin >> i;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int c = min(a[i], b[i]);
		ans += c;
		a[i] -= c;
		b[i] -= c;
		c = min(a[i + 1], b[i]);
		ans += c;
		a[i + 1] -= c;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    int n;
    ll a[MAXN];
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>n;
        for(int u=0;u<n;u++)cin>>a[u];
        sort(a,a+n);
        ll s=a[n-1],t=a[n-2];
        for(int u=n-3;u>=0;u--){
            if(abs(s/2-t)>abs(s/2-a[u])){
                t=a[u];
            }
        }
        cout<<s<<" "<<t;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 1024
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()

mp={}

for i in range(N):
    key = "".join(sorted(input()))
    if key in mp:
        mp[key] += 1
    else:
        mp[key] = 1

res = 0
for k, v in mp.items():
    if v >= 2: res += (v * (v-1) // 2)

print(res)


Measured memory_bytes: 60504
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }


struct bipartite_matching{
    int n, x, y;
    VVI e;
    VI match;
    vector<bool> used;

    void init(int a, int b){
        x = a;
        y = b;
        n = x + y;
        e.assign(n, VI(0));
        match.assign(n, -1);
        used.assign(n, false);
    }

    void add_edge(int u, int v){
        e[u].push_back(v + x);
        e[v + x].push_back(u);
    }

    bool dfs(int v){
        used[v] = true;
        for (int u : e[v]){
            int w = match[u];
            if (w < 0 || (!used[w] && dfs(w))){
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

    int calc_matching(){
        int res = 0;
        fill(ALL(match), -1);
        REP(v,n){
            if (match[v] < 0){
                used.assign(n, 0);
                if (dfs(v)) res++;
            }
        }
        return res;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    VVI a(n, VI(m));
    REP(i,n) REP(j,m) a[i][j] = in() - 1;
    VVI cnt(n, VI(n));
    REP(i,n) REP(j,m) cnt[i][a[i][j] / m]++;
    VVI b(n, VI(m, -1));
    bipartite_matching bm;
    REP(j,m){
        // REP(i,n){
        //     REP(j,n) cout << cnt[i][j] << " ";
        //     cout << endl;
        // }
        bm.init(n, n);
        REP(i,n){
            REP(x,n){
                if (cnt[i][x]) bm.add_edge(i, x);
            }
        }
        bm.calc_matching();
        REP(i,n){
            int p = bm.match[i] - n;
            cnt[i][p]--;
            // cout << p << endl;
            REP(x,m){
                if (a[i][x] / m == p){
                    b[i][j] = a[i][x];
                    a[i][x] = -m;
                    break;
                }
            }
        }
    }
    REP(i,n){
        REP(j,m) cout << b[i][j] + 1 << " ";
        cout << endl;
    }

    VVI c(n, VI(m));
    REP(j,m){
        VI tmp(n);
        REP(i,n) tmp[i] = b[i][j];
        sort(ALL(tmp));
        REP(i,n) c[i][j] = tmp[i];
    }
    REP(i,n){
        REP(j,m) cout << c[i][j] + 1 << " ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 640
def buble_sort(array, n)
    i = 0
    while i < n 
        j = n-1
        while i < j
            if array[j-1][1] > array[j][1]
                array[j-1],array[j] = array[j],array[j-1]
            end
            j -= 1
        end
        i += 1
    end
    return array
end

def selection_sort(array, n)
    i = 0
    while i < n-1 
        minj = i
        j = i+1
        while j < n
            if array[minj][1] > array[j][1]
                minj = j
            end
            j +=1
        end

        if array[minj] != array[i]
            array[minj],array[i] = array[i],array[minj]
        end
        i += 1
    end
    array
end

def isstable(array1,array2,n)
    i = 0
    while i < n
        return "Not stable" if array1[i] != array2[i]
        i += 1
    end
    "Stable"
end

n = gets.to_i
array = gets.split(" ")
bub = buble_sort(array.dup,n)
sel = selection_sort(array.dup,n)
puts bub.join(" ")
puts "Stable"
puts sel.join(" ")
puts isstable(bub,sel,n)


Measured memory_bytes: 6872
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  long long int n, ans=1;
  cin>>n;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end(),greater<int>());
  for(int i=0; i<n; i++){
    ans += max(0, h[i]-i/4);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1220
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for j in range(m)]

li=[[] for i in range(n+1)]

for a,b in ab:
    li[a].append(b)

li2=[]
for i in li[1]:
    li2.append(i)

ans=False
for i in li2:
    if n in li[i]:
        ans=True
print('POSSIBLE' if ans else 'IMPOSSIBLE')

Measured memory_bytes: 58920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (int)(1e9+7)
#define EPS 1e-8
#define INF 1e9+10
#define INFL 1e18
typedef long long ll;
using namespace std;
ll dp[10010][101][2];
int main()
{
   string K;
   int D;
   cin >> K >> D;
   int L = K.size();
   dp[0][0][0]=1;
   rep(i,L){
       int nx = K[i] - '0';
       rep(j,D){
           dp[i+1][(j+nx)%D][0]+=dp[i][j][0];
           dp[i+1][(j+nx)%D][0]%=MOD;

           rep(k,nx){
               dp[i+1][(j+k)%D][1]+=dp[i][j][0];
               dp[i+1][(j+k)%D][1]%=MOD;
           }

           rep(k,10){
               dp[i+1][(j+k)%D][1]+=dp[i][j][1];
               dp[i+1][(j+k)%D][1]%=MOD;
           }
       }
   }
   cout << (dp[L][0][0]+dp[L][0][1]-1+MOD)%MOD << endl;
   
   return 0;
}


Measured memory_bytes: 16000
N, K = [int(i) for i in input().split()]
h = []
for _ in range(N):
    h.append(int(input()))
h.sort()

c_sum = [0]
for i in range(len(h)-1):
    c_sum.append(c_sum[-1] + h[i+1]-h[i])

ans = float('inf')
for i in range(len(h)-K+1):
    ans = min(ans, c_sum[i+K-1] - c_sum[i])

print(ans)


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

int main(){

    int n = 0;
    int h,w;
    
    cin >> n;
    cin >> h;
    cin >> w;
    
    vector<int> a(n),b(n);

    
    int c = 0;
    int d = 0;
    int sum = 0;

    for(int i = 0;i<n;i++){
        cin >> a[i];
        cin >> b[i];

        c = a[i] / h;
        d = b[i] / w;

        if(c < 1 || d < 1){
            continue;
        }

        if(c > d){
            sum += d;
        }else{
            sum += c;
        }

    }

    cout << sum;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class DICE {
public:
	string top;
	string bottom;
	string left;
	string right;
	string front;
	string back;
	void TF();
	void TB();
	void TL();
	void TR();
	void TurnL();
	void TurnR();
	bool HANTEI(DICE d2);
	bool CHECK(DICE d2);
};

void DICE::TF() {
	string kari = front;
	front = top;
	top = back;
	back = bottom;
	bottom = kari;
}

void DICE::TB() {
	TF();
	TF();
	TF();
}

void DICE::TL() {
	string kari = left;
	left = top;
	top = right;
	right = bottom;
	bottom = kari;
}

void DICE::TR() {
	TL();
	TL();
	TL();
}

void DICE::TurnL() {
	string kari = left;
	left = back;
	back = right;
	right = front;
	front = kari;
}

void DICE::TurnR() {
	TurnL();
	TurnL();
	TurnL();
}

bool DICE::HANTEI(DICE d2) {
	if ((top==d2.top)&&(bottom==d2.bottom)&&(left==d2.left)&&(right==d2.right)&&(front==d2.front)&&(back==d2.back)) {
		return true;
	}
	return false;
}

bool DICE::CHECK(DICE d2) {
	DICE d3 = d2;
	for (int i = 0; i < 4; i++) {
		d3.TurnL();
		if (HANTEI(d3)) {
			return true;
		}
	}
	d3 = d2;
	d3.TF();
	d3.TF();
	for (int i = 0; i < 4; i++) {
		d3.TurnL();
		if (HANTEI(d3)) {
			return true;
		}
	}
	d3 = d2;
	d3.TF();
	for (int i = 0; i < 4; i++) {
		d3.TL();
		if (HANTEI(d3)) {
			return true;
		}
	}
	d3 = d2;
	d3.TB();
	for (int i = 0; i < 4; i++) {
		d3.TL();
		if (HANTEI(d3)) {
			return true;
		}
	}
	d3 = d2;
	d3.TL();
	for (int i = 0; i < 4; i++) {
		d3.TF();
		if (HANTEI(d3)) {
			return true;
		}
	}
	d3 = d2;
	d3.TR();
	for (int i = 0; i < 4; i++) {
		d3.TF();
		if (HANTEI(d3)) {
			return true;
		}
	}
	return false;
}

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector<DICE> dd;
		for (int i = 0; i < n; i++) {
			DICE d;
			cin >> d.top >> d.front >> d.right >> d.left >> d.back >> d.bottom;
			bool h = true;
			for (int j = 0; j < dd.size(); j++) {
				if (dd[j].CHECK(d)) {
					h = false;
					break;
				}
			}
			if (h) {
				dd.push_back(d);
			}
		}
		int sz = dd.size();
		cout << n-sz << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i64>();
    let (mut n, k) = (line[0], line[1]);
    let mut ans = 0;
    while n > 0{
        n /= k;
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> b(n+1);

	b[0]=10000000;
	b[n]=10000000;

	long long ans=0;

	for(int i=1;i<n;i++)
		cin >> b[i];
	
	for(int i=0;i<n;i++)
		ans+=(min(b[i],b[i+1]));
	
	cout << ans << endl;





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N,K;
  cin>>N>>K;
  vector<int>D(K);
  for(int i=0;i<K;i++){
    cin>>D[i];
  }
  for(int i=N;i<=10*N;i++){
    bool ok=true;
    string t=to_string(i);
    int n=t.size();
    for(int j=0;j<n;j++){
      for(int k=0;k<K;k++){
        if(t[j]==D[k]+'0'){ok=false;}
      }
    }
    if(ok){cout<<i<<endl;return 0;}
  }
  return 0;
}

Measured memory_bytes: 3652
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]



K = I()

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(A[K - 1])


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;
ll N,Q;
string s;
vector<char> t,d;

//愚直にシミュレーション
//Xが左に落ちないときtrue
bool checkl(ll X){
    rep(i,Q){
        if(t[i] == s[X]){
            if(d[i] == 'R'){
                X++;
            }
            else{
                X--;
            }
        }
        if(X == -1){
            return false;
        }
    }
    return true;
}
//Xが右に落ちないときtrue
bool checkr(ll X){
    rep(i,Q){
        if(t[i] == s[X]){
            if(d[i] == 'R'){
                X++;
            }
            else{
                X--;
            }
            if(X == N){
                return false;
            }
        }
    }
    return true;
}
int main() {
    cin>>N>>Q>>s;
    t.resize(Q);d.resize(Q);
    rep(i,Q){
        cin>>t[i]>>d[i];
    }
    //左に落ちるとき
    ll ng = -1;ll ok = N;
    while(ok - ng > 1){
        ll mid = (ok+ng)/2;
        if(checkl(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    ll l = ok;
    //右に落ちるとき
    ok = -1; ng = N;
    while(ng - ok > 1){
        ll mid = (ok+ng)/2;
        if(checkr(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    ll r = ok;
    //cerr<<l<<" "<<r<<endl;
    cout<<r-l+1<<endl;
}

Measured memory_bytes: 900
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}


void func() {
  LL N;
  cin >> N;
  vector<LL> D(N);
  REP(i, N) {
    cin >> D[i];
  }
  //PRINTLN(D);

  LL sum = 0;
  for (LL i = 0; i < N; i++) {
    for (LL j = i + 1; j < N; j++) {
      sum += D[i] * D[j];
    }
  }
  cout << sum;
}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,j;
    cin>>n;
    while(n--){
        set<string> s;
        string st;
        cin>>st;
        s.insert(st);
        for(int i=1;i<st.size();i++){
            string q1,q2,q3,q4;
            q1=st.substr(0,i);
            q3=st.substr(i);
            q2=q1;
            q4=q3;
            reverse(q2.begin(),q2.end());
            reverse(q4.begin(),q4.end());
            s.insert(q1+q3);
            s.insert(q1+q4);
            s.insert(q2+q3);
            s.insert(q2+q4);
            s.insert(q3+q1);
            s.insert(q3+q2);
            s.insert(q4+q1);
            s.insert(q4+q2);
        }
        cout<<s.size()<<endl;
    }
    return 0;
}
 

Measured memory_bytes: 1296
li=[]
for i in range(5):
    li.append(int(input()))

k=int(input())
f=1

for i in range(len(li)):
    for j in range(i+1, len(li)):
        if abs(li[i]-li[j])>k:
            f=0

if f:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
int main(){
  char s[100],p[100],r[200];
  scanf("%s",s);
  scanf("%s",p);
  strcpy(r,s);
  strcat(r,s);
  if(strstr(r,p)){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

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

int main() {
   int N;
   cin >> N;
   vector<int> X(N);
   vector<int> Y(N);
   for (int i=0; i<N; i++) {
       cin >> X.at(i) >> Y.at(i);
   }
   int n[N];
   for (int i=0; i<N; i++) {
       n[i]=i;
   }
   double total=0;
   do{
       for (int i=0; i<N; i++) {
           if (i!=0) {
               double m=pow(X.at(n[i])-X.at(n[i-1]),2)+pow(Y.at(n[i])-Y.at(n[i-1]),2);
               total+=sqrt(m);
           }
       }
   }while (next_permutation(n,n+N));
   int j=1;
   for (int i=1; i<=N; i++) {
       j*=i;
   }
   double ave=total/j;
   cout << fixed << setprecision(7);
   cout << ave << endl;
}

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

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i=a; i<b; ++i)
#define dbg(x) { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 105;

int w[N],v[N],k[N][100005];

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n, x;
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <=x; j++) {
            if(w[i] <= j)
                k[i][j] = max(v[i]+k[i-1][j-w[i]],k[i-1][j]);
            else
                k[i][j] = k[i-1][j];
        }
    }
    cout << k[n][x];
    

    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, cnt = 0;
  string s, ans;
  cin >> n >> s;
  ans = s;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') cnt++;
    else if (s[i] == ')') cnt--;

    if (cnt < 0) {
      ans = "(" + ans;
      cnt = 0;
    }
  }
  while (cnt--) ans+= ")";
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	int n,m;
	bool like[31][31];
	for(int i=0;i<31;i++){
		for(int j=0;j<31;j++) like[i][j] = false;
	}
	cin >> n >> m;

	for(int i=0;i<n;i++){
		int k;
		cin >> k;
		for(int j=0;j<k;j++){
			int a;
			cin >> a;
			like[i][a] = true;
		}
	}

	int cnt = 0;
	for (int i = 1; i <= m; i++){
		bool ok = true;
		for (int j = 0; j < n; j++){
			if(!like[j][i]){
				ok = false;
			}
		}
		if(ok) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------


// 絶対値
ll llabs(ll &a) { return (a < 0) ? (-a) : (a); }

// main -----------------------------------------------

int main() {
    ll x, n;
    cin >> x >> n;
    vector<ll> p(n);
    REP(i, n){
        cin >> p[i];
    }
    ll kouho;
    bool flag; 
    REP(dx, 1000){
        // -
        flag = true;
        kouho = x - dx;
        REP(i, n){
            if(kouho == p[i]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << kouho << endl;
            return 0;
        }
        // +
        flag = true;
        kouho = x + dx;
        REP(i, n){
            if(kouho == p[i]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << kouho << endl;
            return 0;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		long X = in.nextLong();
		long a = X / 500;
		long amari = X % 500;
		long b = amari / 5;

		System.out.println(a*1000 + 5*b);

	}


	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 23508
#include<iostream>
using namespace std;
int main(){
	int n,sum=0,L,total=0,N;
	cin>>n;
    for(int i=1;i<=n;i++){
    	N=i;
		while(N)
		{
			sum++;
			N/=10;
		 } 
		 if(sum%2)total++;
		 sum=0;
    }
    cout<<total;
    
	return 0;
}
//9 89 899 8999 89999 899999
//9
//899
//89999


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int k = fs.nextInt();
        final int[] arr = fs.nextIntArray(n);
        long L = arr[0];
        long R = arr[k - 1];
        long res = R - L + Math.min(Math.abs(L), Math.abs(R));
        for (int i = 0; i < n - k; i++) {
            L = arr[i + 1];
            R = arr[k + i];
            final long curr = R - L + Math.min(Math.abs(L), Math.abs(R));
            res = Math.min(res, curr);
        }
        System.out.println(res);
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 44864
I = input()
A = I[0:1]
B = I[1:2]
C = I[2:3]
D = I[3:4]

op_dict = {}
for i in range(2**3):
    # [op1, op2, op3]
    if ((i >> 0) & 1):
        op3 = "+"
    else:
        op3 = "-"
    
    if ((i >> 1) & 1):
        op2 = "+"
    else:
        op2 = "-"
        
    if ((i >> 2) & 1):
        op1 = "+"
    else:
        op1 = "-"
    op_dict[i] = [op1, op2, op3]

for k in op_dict:
    op1 = op_dict[k][0]
    op2 = op_dict[k][1]
    op3 = op_dict[k][2]
    siki_str = A + op1 + B + op2 + C + op3 + D
    
    if eval(siki_str) == 7:
        print('{}={}'.format(siki_str, eval(siki_str)))
        break;

Measured memory_bytes: 3064
import sys

N,K=map(int,input().split())
S=input()


d=0
for s in S:
    if int(s) == 1:
        d+=1
    else:
        break

S1=[d]
S0=[0]
ic=0
st=0
for i,s in enumerate(S):
    if int(s)==0 and st==1 and i>d:
        S0.append(i-d)
        S1.append(ic)
        ic=0
    if int(s)==1 and i>d:
        ic+=1
    st=int(s)
S0.append(i+1-d)

if st==1:
    S1.append(ic)
else:
    S1.append(0)
    
if K>=(len(S0)-1):
    print(N)
    sys.exit()

ans=[]
for i in range(len(S0)-K):
    tmp=S0[i+K]-S0[i]+S1[i]
    ans.append(tmp)
    
print(max(ans))


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;
  vector<ll> cards(n);
  scan(cards);
  vector<ll_ll> ps(m);
  rep(i, 0, m) { cin >> ps[i].second >> ps[i].first; }

  sort(all(cards));
  sort(all(ps), greater<ll_ll>());

  ll ans = 0;
  auto first = begin(cards);
  auto last = end(cards);
  int index = 0;
  for (ll_ll p : ps) {
    ll num = p.second;
    ll value = p.first;

    auto itr = lower_bound(first, last, value);
    int count = min(int(itr - first), int(num));
    index += count;
    ans += value * count;
    first += count;
  }

  rep(i, index, n) { ans += cards[i]; }
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    S = input()

    ans = 0
    # for i in range(len(S)):
    if S[0]==S[1]==S[2]=='R':
        print(3)
    elif S[0]==S[1]=='R':
        print(2)
    elif S[1]==S[2]=='R':
        print(2)
    elif 'R' in S:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;

    vi ans(6*n+1);

    for(int i=1;i*i<=n;i++){
        for(int j=1;j*j<=n;j++){
            for(int k=1;k*k<=n;k++){
                ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }

    repa(i,1,n+1)cout<<ans[i]<<"\n";

    return 0;

}

Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//25min
int main(void){
  int s;
  int a[100001];

  scanf("%d", &s);

  a[1] = s;
  int i = 2;
  while(s % 1 == 0){
    if(s % 2 == 0){
      a[i] = s / 2;
    }else{
      a[i] = 3 * s + 1;
    }
    //printf("a[%d]=%d\n",i,a[i]);

    //i++;
    for(int j = i - 1; j > 0; j--){
      if(a[j] == a[i]){
	printf("%d\n", i);
	return 0;
      }
    }
    s = a[i];
    i++;
  }
  
  return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;

void main() {
  long X, Y, Z;
  scanln(X, Y, Z);
  swap(X, Y);
  swap(X, Z);
  writeln(X, " ", Y, " ", Z);
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


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

void out(int a[],int n){
    rep(j,n){
        cout << a[j];
        if(j!=n-1) cout << " ";
    }
    cout << endl;
}

void merge(int *A, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1+1),R(n2+1);
    rep(i,n1) L[i] = A[left + i];
    rep(i,n2) R[i] = A[mid + i];
    L[n1] = INF; R[n2] = INF;
    int i = 0, j = 0;
    for(int k=left;k<right;k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int *A, int left, int right){
    if(left+1 < right){
        int mid = (left+right) / 2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

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

    int n;
    cin >> n;

    int s[n];
    rep(i,n) cin >> s[i];

    cnt = 0;
    mergeSort(s, 0, n);
    out(s,n);
    cout << cnt << endl;


    return 0;
}



Measured memory_bytes: 6876
/*
* @Author: wxyww
* @Date: 2020-03-31 11:02:37
* @Last Modified time: 2020-03-31 11:53:58
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 4010;
ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
struct node {
	int v,nxt;
}e[N];
int n,m,ejs,head[N],fa[N],dep[N],a[N],b[N],tot;
int du[N],c[N],f[N],flag[N],used[N];
void add(int u,int v) {
	e[++ejs].v = v;e[ejs].nxt = head[u];head[u] = ejs;
}
void dfs(int u,int father) {
	dep[u] = dep[father] + 1;
	fa[u] = father;
	for(int i = head[u];i;i = e[i].nxt) {
		int v = e[i].v;
		if(v == father) continue;
		dfs(v,u);
	}
}

void solve() {
	int u = 0;
	for(int i = 1;i <= n;++i) {
		if(flag[i]) continue;
		if(du[i] == 1) {
			u = i;break;
		}
	}


	if(!u) return;

	if(!c[u]) {
		for(int i = head[u];i;i = e[i].nxt) {
			int v = e[i].v;
			if(flag[v]) continue;
			du[v]--;
		}
		flag[u] = 1;
		solve();
		return;
	}

	if(c[u] == 1) {
		for(int i = head[u];i;i = e[i].nxt) {
			int v = e[i].v;
			if(flag[v]) continue;
			du[v]--;
		}
		flag[u] = 1;
		for(int i = 1;i <= tot;++i) {
			if(used[i]) continue;
			if(b[i] == u) swap(a[i],b[i]);
			if(a[i] != u) continue;
			int tmp = 0;
			for(int j = head[u];j;j = e[j].nxt) {
				int v = e[j].v;
				if(!flag[v]) {
					tmp = v; 
					break;
				}
			}
			if(b[i] != tmp) {
				a[i] = tmp;
				c[u]--;c[tmp]++;
				solve();
				if(a[i] == tmp) a[i] = u;
				else b[i] = u;
			}
			else {
				c[u]--;
				c[tmp]--;
				used[i] = 1;solve();
			}
			return;
		}
	}
	int x = 0,y = 0;
	for(int i = 1;i <= tot;++i) {
		if(used[i]) continue;
		if(b[i] == u) swap(a[i],b[i]);
		if(a[i] != u) continue;
		if(!x) x = i;
		else if(!y) y = i;
		else break;
	}
	used[x] = used[y] = 1;
	if(b[x] == b[y]) {
		swap(a[y],b[y]);
		c[u] -= 2;
		c[a[y]]--;c[b[x]]--;
		solve();
	}
	else {
		int now = ++tot;
		a[now] = b[x];
		b[now] = b[y];
		c[u] -= 2;
		solve();
		if(a[now] == b[x]) swap(a[x],b[x]);
		else swap(a[y],b[y]);
	}

}
int main() {
	// freopen("1.in","r",stdin);
	// freopen("me.out","w",stdout);
	n = read(),m = read();
	for(int i = 1;i < n;++i) {
		int u = read(),v = read();
		add(u,v);add(v,u);
		du[u]++;du[v]++;
	}
	dfs(1,0);

	for(int i = 1;i <= m;++i) {
		a[i] = read(),b[i] = read();
		if(dep[a[i]] < dep[b[i]]) swap(a[i],b[i]);
		int u = a[i],v = b[i];
		while(dep[u] > dep[v]) {
			f[u]++;u = fa[u];
		}
		while(u != v) {
			f[u]++;f[v]++;
			u = fa[u];v = fa[v];
		}
		c[a[i]]++;c[b[i]]++;
	}

	tot = m;
	solve();
	int ans = 0;
/*
	for(int i = 1;i <= n;++i) {
		printf("%d ",f[i]);
	}
	puts("");
*/

	for(int i = 1;i <= n;++i) ans += min(2,f[i]);
	printf("%d\n",ans);
	for(int i = 1;i <= m;++i)
		printf("%d %d\n",a[i],b[i]);
	return 0;
}

Measured memory_bytes: 512