akhauriyash/Code-Regression huggingface dataset:
from itertools import product

H, W, K = map(int, input().split(' '))

C = []
for _ in range(H):
    C.append(list(input()))

ans = 0
for h_bits in product((True, False), repeat=H):
    for w_bits in product((True, False), repeat=W):
        blacks = 0
        for i in range(H):
            for j in range(W):
                if h_bits[i] and w_bits[j] and C[i][j] == '#':
                    blacks += 1
        if blacks == K:
            ans += 1

print(ans)


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

int main(){
  int n;
    cin >> n;
  ll memo[87], ans=0;
    memo[0]=2, memo[1]=1;
    for(int i=2; i<=n; i++){
      memo[i] = memo[i-1]+memo[i-2];
    }
    cout << memo[n] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n-1][3];
    for(int i =0;i < n-1;i++){
        for(int j =0;j<3;j++){
            cin>>arr[i][j];;
        }
    }
    int time=0;
    for(int i =0;i<n-1;i++){
        time = arr[i][1] +  arr[i][0];
        for(int j =i+1;j<n-1;j++){
            if(time <=  arr[j][1]) {
                time = arr[j][1] + arr[j][0] ;
            }
            else{
                //bool divi=false;
                if((time - arr[j][1])%arr[j][2]==0){
                    time+=arr[j][0];
                }
                else{
                    time = (time/arr[j][2] + 1)*arr[j][2] + arr[j][0];
                }
            }
        }
        cout<<time<<endl;

    }
    cout<<0<<endl;







}






























































Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,M;
    cin >> N >> M;
    ll A[N];
    ll i,j;
    for(i=0;i<N;i++){
        A[i]=0;
    }
    ll d,a;
    for(i=0;i<M;i++){
        cin >> d;
        for(j=0;j<d;j++){
            cin >> a;
            A[a-1]=1;
        }
    }
    ll ans=0;
    for(i=0;i<N;i++){
        if(A[i]==0)ans++;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    ll m = 1e18;
    for(int i = 0; i < 5; i++){
        ll tmp;
        cin >> tmp;
        chmin(m, tmp);
    }

    ll ans = 4LL + (N/m) + (N%m != 0);
    cout <<  ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int main() {
    int N, W;
    scanf("%d%d", &N, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value with weight exactly i
    for (int i = 0; i < N; ++i) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        for (int weight_already = W - weight; weight_already >= 0; --weight_already) {
            chmax(dp[weight_already + weight], dp[weight_already] + value);
        }
    }
    printf("%lld\n", *max_element(dp.begin(), dp.end()));

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x;
    cin >> x;
    if (x < 4) {
        cout << 1 << endl;
        return 0;
    }
    ll b_max = floorl(sqrt(x));
    vll ans_list;
    for (int b = 2; b <= b_max; b++) {
        ll p = 2;
        while (true) {
            if (pow(b, p) > x) break;
            ans_list.push_back(pow(b, p));
            p++;
        }
    }
    sort(ALL(ans_list));
    cout << ans_list.at(ans_list.size()-1) << endl;
    return 0;
}

Measured memory_bytes: 640
//#define _CRT_SECURE_NO_WARNINGS
//#include<stdio.h>
#include <stdlib.h>
#include<iostream>
#include<math.h>

using namespace std;

int a,b;

int main(void) {
	cin >> a>> b;
	int k = a - 2 * b;
	cout << fmax(0,k);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> d(4);
  for(int i=0;i<=3;i++){
    d[i]=n%10;
    n/=10;
  }
  if(d[3]+d[2]+d[1]+d[0]==7) cout << d[3]<<'+'<<d[2]<<'+'<<d[1]<<'+'<<d[0]<<"=7" << endl;
  else if(d[3]+d[2]+d[1]-d[0]==7) cout << d[3]<<'+'<<d[2]<<'+'<<d[1]<<'-'<<d[0]<<"=7" << endl;
  else if(d[3]+d[2]-d[1]+d[0]==7) cout << d[3]<<'+'<<d[2]<<'-'<<d[1]<<'+'<<d[0]<<"=7" << endl;
  else if(d[3]+d[2]-d[1]-d[0]==7) cout << d[3]<<'+'<<d[2]<<'-'<<d[1]<<'-'<<d[0]<<"=7" << endl;
  else if(d[3]-d[2]+d[1]+d[0]==7) cout << d[3]<<'-'<<d[2]<<'+'<<d[1]<<'+'<<d[0]<<"=7" << endl;
  else if(d[3]-d[2]+d[1]-d[0]==7) cout << d[3]<<'-'<<d[2]<<'+'<<d[1]<<'-'<<d[0]<<"=7" << endl;
  else if(d[3]-d[2]-d[1]+d[0]==7) cout << d[3]<<'-'<<d[2]<<'-'<<d[1]<<'+'<<d[0]<<"=7" << endl;
  else if(d[3]-d[2]-d[1]-d[0]==7) cout << d[3]<<'-'<<d[2]<<'-'<<d[1]<<'-'<<d[0]<<"=7" << endl;
}

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

typedef long long ll;
int main() {
	
	ll n,a,b;
	
	cin >> n >> a >> b;
	
	ll k = n / (a + b);
	
	ll ans = k * a + min(a,n % (a + b));
	
	cout << ans << endl;
	return 0;
}

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

namespace _0525
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() == 0) break;
                bool[,] osenbei = new bool[x[0],x[1]];
                for (int i = 0; i < x[0]; i++)
                {
                    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    for (int j = 0; j < x[1]; j++) osenbei[i,j] = a[j] == 1;
                }
                int ret = 0;
                for (int i = 0; i < Math.Pow(2,x[0]); i++)
                {
                    int n = i; int[] now = new int[x[1]];
                    for (int j = 0; j < x[0]; j++)
                    {
                        bool rev = n % 2 == 1;
                        for (int k = 0; k < x[1]; k++)
                        {
                            if (osenbei[j,k] != rev) now[k]++;
                        }
                        n /= 2;
                    }
                    int a = 0;
                    for (int k = 0; k < x[1]; k++)
                    {
                        a += Math.Max(now[k],x[0] - now[k]);
                    }
                    ret = Math.Max(ret,a);
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 11684
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, t, a, b;
  ll ans = INF;
  scanf("%lld%lld", &n, &t);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld%lld", &a, &b);
    if (b <= t)
    {
      if (ans > a)
        ans = a;
    }
  }
  if (ans != INF)
    printf("%lld\n", ans);
  else
    puts("TLE");
  return 0;
}

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

int findmax(map<int, int>mp, long long x, long long maxi)
{
	long long totalscore = 0;
	long long ct = 0;

	while (totalscore < maxi)
	{
		int y = mp[x];
		totalscore += y;
		ct++;
	}
	return ct;
}

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

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif


	long long x;
	cin >> x;
	long long zx = x / 11;
	long long y = x % 11;
	long long zc = 2 * zx + ceil(y / 6.0) ;
	cout << zc << endl;







	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int dp[100000] = {};
vector<int> edge[100000];

int calc(int tar){
  if(dp[tar] > 0) return dp[tar];
  for(int i: edge[tar]){
    dp[tar] = max(dp[tar], calc(i) + 1);
  }
  return dp[tar];
}

int main(){
  int n,m;
  cin >> n >> m;
  int x,y;
  for(int i=0;i<m;i++){
    cin >> x >> y;
    edge[--x].push_back(--y);
  }
  int mx = 0;
  for(int i=0;i<n;i++){
    calc(i);
    mx = max(mx, dp[i]);
  }
  cout << mx << endl;
}

Measured memory_bytes: 7424
#include <cstdio>
#include <map>
const long long MOD = 1e9 + 7;
std::map<long long, long long> dp;
long long f(long long x) {
    if (dp[x]) return dp[x] % MOD;
    return dp[x] = (f((x - 1) / 2) + f(x / 2) + f((x - 2) / 2)) % MOD;
}
int main() {
    long long n;
    scanf("%lld", &n);
    dp[0] = 1;
    dp[1] = 2;
    printf("%lld\n", f(n) % MOD);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}
using namespace io;
int main(){
	int n,a,b;
	in3(n,a,b);
	printf("%d %d",min(a,b),max(a+b-n,0));
	return 0;
}

Measured memory_bytes: 128
A, b, c = [], [], []
n, m = map(int, input().split())
for i in range(n):
    A.append([int(x) for x in input().split()])
for i in range(m):
    b.append(int(input()))
c = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i] += A[i][j] * b[j]
for i in range(n):
    print(c[i])


Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(void)
{
    int s;
    
    cin >> s;
    
    cout << s / 3600 << ":" << s % 3600 / 60 << ":" << s % 60 << endl;
    
    return 0;
}


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

int main(){
	int n, x = 0, y = 0;
	scanf("%d", &n);
	char a[110], b[110];
	for(int i = 0; i < n; i++) {
		scanf("%s%s", a, b);
		int p = strcmp(a, b);
		if(p > 0) x += 3;
		else if (p < 0) y += 3;
		else x++, y++;
	}
	printf("%d %d\n", x, y);
}



Measured memory_bytes: 3168
#include <stdio.h>
#include <string.h>
#include <math.h>
 int main(void){
    
   int a=0,i;
   char c[200];
   scanf("%s",&c);
    
   a=strlen(c);
     
   for(i=0;i<a;i++)
     printf("x");
  
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string s, t;
int dp[3030][3030];

pair<int, int> P[3030][3030];

int main(void) {

	cin >> s >> t;
	s = "#" + s;
	t = "%" + t;

	for (int i = 1; i <= (int)s.size(); i++) {
		for (int j = 1; j <= (int)t.size(); j++) {
			if (s[i] == t[j]) { dp[i][j] = dp[i - 1][j - 1] + 1; P[i][j] = pair<int, int>(i - 1, j - 1); }
			else if (dp[i - 1][j] >= dp[i][j - 1]) {
				dp[i][j] = dp[i - 1][j]; P[i][j] = pair<int, int>(i - 1, j);
			}else{
				dp[i][j] = dp[i][j - 1]; P[i][j] = pair<int, int>(i, j - 1);
			}
		}
	}

	int N = s.size();
	int M = t.size();

	//cout << dp[s.size()][t.size()] << endl;

	int i = N, j = M;

	string ans = "";

	while (i != 0 || j != 0) {

		//cout << "i= " << i << "  j= " << j << endl;
		int I = P[i][j].first;
		int J = P[i][j].second;
		if (I == i - 1 && J == j - 1) { ans += s[i]; }
		i = I; j = J;
	}

	//cout << ans << endl;
	ans = ans.substr(1);
	//cout << ans << endl;
	reverse(ans.begin(), ans.end());

	//cout << ans.size() << endl;
	cout << ans << endl;


	//system("pause");
	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root,NIL;
int max;

Node treeSearch(Node u,int k){
  while(u!=NIL && k!= u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
}
  return u;
}

void insert(int k){
  int H;
  Node y=NIL;
  Node x=root;
  Node z;

z=  malloc(sizeof(struct node));
  z->key=k;
  z->left =NIL;
  z->right=NIL;

  while(x != NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
}
}

  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right =z;
    }
  }
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,t;
  char com[20];
  scanf("%d",&n);
  max =0;
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&t);
      Node n = treeSearch(root,t);
      if(n!=NIL)printf("yes\n");
      else printf("no\n");
    }else if(com[0]=='i'){
      scanf("%d",&t);
      insert(t);
    }else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
}
}
  return 0;
}



Measured memory_bytes: 20440
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll s;
    cin>>s;
    map<ll,ll> m;
    m[s]++;
    rep(i,1,1000010){
        if(s%2 == 0){
            s/=2;
        }
        else{
            s = 3*s +1;
        }

        if(m[s] > 0){
            cout<<i+1;
            break;
        }
        else m[s]++;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]
dp = [[0 for i in range(3)] for j in range(n+1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k: #同じことを2日連続はできない
                continue
            dp[i+1][k] = max(dp[i+1][k], li[i][k] + dp[i][j])

print(max(dp[n]))

Measured memory_bytes: 74712
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
 
    if(x==2 || y==2){
    	System.out.println("No");
    }else if(x==4 || x==6 || x==9 || x==11) {
    	if(y==4 || y==6 || y==9 || y==11) {
    	System.out.println("Yes");
    	}else {
    	System.out.println("No");
    	}
    }else{
    	if(y==4 || y==6 || y==9 || y==11) {
    	System.out.println("No");
    	}else {
    	System.out.println("Yes");
    	}
    }
}
}


Measured memory_bytes: 35652
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double r,a,l;
    cin >> r;
    a=r*r*3.141592653589;
    l=r*2*3.141592653589;
    
    cout << fixed << setprecision(6) << a;
    cout << " ";
    cout << fixed << setprecision(6) << l;
    cout << endl;
}



Measured memory_bytes: 3276
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>
#include<math.h>

int main(){
	long long ans=0;

	int n;
	std::cin>>n;

	std::vector<std::string> sList(n);
	for(int i=0; i<n; i++)
		std::cin>>sList[i];
	
	for(int i=0; i<n; i++)
		std::stable_sort(sList[i].begin(), sList[i].end(), [](const char &x, const char &y){return x< y;});

	std::stable_sort(sList.begin(), sList.end(), [](std::string x, std::string y){return x< y;});

	long long numMember= 1;
	for(int i=0; i< n-1; i++){		
		if(sList[i]== sList[i+1]){
			numMember++;
		}else{
			ans+= numMember*(numMember-1)/2;

			numMember=1;
		}

	}

	ans+= numMember*(numMember-1)/2;

	std::cout<<ans<<std::endl;


	return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    ll a, b;
    cin >> b >> a;
    ll n = a/k;
    ll m = (b-1)/k;
    if(n > m) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define INF 1000000000000
using namespace std;
using ll=long long;
using ld=long double;
using vs=vector<string>;


/*int combination(vector<ll> l,ll n){
    int ans=0;
    for(ll i=0;i<n-2;i++){
        for(ll j=i+1;j<n-1;j++){
            for(ll k=j+1;k<n-2;k++){
                if((l[i]!=l[j])&&(l[i]!=l[k])&&(l[j]!=l[k])){
                    if(((l[i]+l[j])>l[k])&&((l[j]+l[k])>l[i])&&((l[k]+l[i])>l[j])){
                        ans++;
                    }
                }
            }
        }
    }
    return ans;
}
*/
int main() {
    ll n;
    int ans=0;
    cin>>n;
    vector<ll> l(n);
    rep(i,n)cin>>l[i];
    if(n<=2){
        cout<<0;
        return 0;
    }
 //ans=combination(l,n);
    for(ll i=0;i<n-2;i++){
        for(ll j=i+1;j<n-1;j++){
            for(ll k=j+1;k<n;k++){
                if((l[i]!=l[j])&&(l[i]!=l[k])&&(l[j]!=l[k])){
                    if(((l[i]+l[j])>l[k])&&((l[j]+l[k])>l[i])&&((l[k]+l[i])>l[j])){
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
  return 0;
}


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



int main() {
    ios::sync_with_stdio(false);
    int n;
    int a[100];
    int alice, bob;
    alice = bob = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0)
            alice += a[i];
        else
            bob += a[i];
    }
    cout << abs(alice-bob);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    char s[20];
    scanf("%s",s);
    for(int i=0; i<20; ++i)
    {
        if(s[i]==',') s[i]=' ';
    }
    puts(s);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
 
int main()
{
    string s;
    int k;
    cin >> s >> k;
    for(int i = 0; i < s.size(); i++)
    {
        int d = 'z' + 1 - s[i];
        if(d > k || d > 25)
            continue;
        k -= d;
        s[i] = 'a';
    }
    s[s.size() - 1] += k % 26;
  
    cout << s << endl;
}

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

int main()
{
string S;cin>>S;string ans="yes";
set<char> Set;
for(int i=0;i<S.size();i++)
{
  if(!Set.count(S[i]))Set.insert(S[i]);
  else ans="no";
}
cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }

    int bestI = -1;
    double bestDistance = 1e99;
    for (int i = 0; i < N; ++i) {
        int t = T * 1000 - H[i] * 6;
        if (abs(t - A * 1000) < bestDistance) {
            bestDistance = abs(t - A * 1000);
            bestI = i;
        }
    }

    cout << (bestI + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

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

    vector<int64_t> dp(N + 1, INF);
    dp[0] = 1, dp[1] = 1;
    rep(i, M)
    {
        dp[a[i]] = 0;
    }
    rep2(i, 2, N + 1)
    {
        if (dp[i] != 0)
        {
            dp[i] = (dp[i - 2] + dp[i - 1]) % BG;
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

//2部最大マッチング verified AOJ GRL_7_A
#define MAX_V 200
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
    G[u].pb(v);
    G[v].pb(u);
}

// 増大路をDFSで探す
bool dfs(int v){
    used[v]=true;
    rep(i,G[v].size()){
        int u=G[v][i],w=match[u];           //u:vからの移動先の頂点 , w:uとマッチングしている頂点
        if(w<0 || (!used[w] && dfs(w))){    //uがフリーか、このdfsではwを使っておらず かつwの別のペアが見つかった(=増大路発見) 場合
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(int V){
    int res=0;
    rep(i,MAX_V)match[i]=-1;
    rep(v,V){
        if(match[v]<0){
            rep(i,MAX_V)used[i]=0;
            if( dfs(v) ) res++;       //増大路が見つかればres+=1
        }
    }
    return res;
}

int main(){
    int n;
    cin>>n;
    vector<pii> a(n),b(n);
    
    rep(i,n){
        int y,x;
        cin>>y>>x;
        a[i] = pii(y,x);
    }
    rep(i,n){
        int y,x;
        cin>>y>>x;
        b[i] = pii(y,x);
    }
    
    rep(i,a.size()){
        rep(j,b.size()){
            if(a[i].first<b[j].first && a[i].second<b[j].second){
                add_edge(i,100+j);
            }
        }
    }
    cout<<bipartite_matching(200)<<endl;
}


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

int main(){
  vector<char> a(6);
  vector<char> b(3);
  
  for(int i = 0; i < 3; i++){
   cin >> a.at(i);
  }
  
  for(int i = 0; i < 3; i++){
    cin >> b.at(i);
  }
  
  if(a.at(0) == b.at(2) && a.at(1) == b.at(1) && a.at(2) == b.at(0)){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
  
  

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

int map[N][N], ans = 0;

int toInt(string str, int n);
int search();
int loop(int x, int y);

int main(){
    string str;
    while(cin >>str){
        toInt(str, 0);
        for(int i = 1; i < N; i++){
            ans = 0;
            cin >>str;
            toInt(str, i);
        }
        search();
        cout <<ans <<endl;
    }
}

int toInt(string str, int n){
    for(int i = 0; i < N; i++){
        map[n][i] = str[i] - '0';
    }
}

int search(){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(map[i][j] == 1){
                ans++;
                loop(j, i);
            }
        }
    }
}

int loop(int x, int y){
    int xm[] = {0, 1, 0, -1}, ym[] = {-1, 0, 1, 0};
    if(map[y][x] == 1){
        map[y][x] = 0;
        for(int i = 0; i < 4; i++){
            int xn = x + xm[i], yn = y + ym[i];
            if(xn >= 0 && yn >= 0 && xn < N && yn < N && map[yn][xn] == 1) loop(xn, yn);
        }
    }
}

Measured memory_bytes: 0
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();
        int a = int.Parse(cin[0]);
        int b = int.Parse(cin[1]);
        int c = int.Parse(cin[2]);
        int x = int.Parse(cin[3]);
        int y = int.Parse(cin[4]);

        int max = Math.Max(x, y) * 2;
        int ans = a * x + b * y;

        for (int i = 2; i <= max; i += 2)
        {
            if (0 < x) x--;
            if (0 < y) y--;
            ans = Math.Min(ans, a * x + b * y + c * i);
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	int B[100] = {};
	for (int i = 0; i < n-1; ++i)
	{
		cin >> B[i];
	}
	int ans = B[0] + B[n-2];
	for (int i = 0; i < n-2; ++i)
	{
		ans += min(B[i], B[i+1]);
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll,ll> > vpll;
typedef vector< vector<int> > matrix;

#define SET(Ar,val) memset(Ar,val,sizeof(Ar))
#define rep(i,val,n)  for(int i=val;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LMAX LONG_LONG_MAX
#define LMIN LONG_LONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define Modulo 1000000007ll

/*--------------------------------------------------------------------------------------------------------------------------------*/

template <class T> T modpower(T a,T b,T MOD)
{
    T ans=1;
    while(b!=0)
    {
        if(b%2==1)
        ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}


void init()
{
    string s;
    cin >> s;
    int l = s.size(),fg = 0;
    if(s[0] != 'A')
    {
        fg = 1;
    }
    int cnt = 0;
    rep(i,1,l)
    {
        if(i>=2 && i<= l-2)
        {
            if(s[i] == 'C')
                cnt++;
            else
            {
                if(s[i] < 'a')
                {
                    fg = 1;
                    break;
                }
            }
        }
        else
        {
            if(s[i] < 'a')
            {
                fg = 1;
                break;
            }
        }
    }
    if(fg || cnt > 1 || cnt < 1)
        cout << "WA";
    else
        cout << "AC";
}

int main()
{
    clock_t time1 = clock();
		ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    init();
    clock_t time2 = clock();
    cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC * 100000 <<" seconds" <<endl;
	return 0;
    }


Measured memory_bytes: 256
L, R = map(int, input().split(" "))
p1, p2 = 3, 673
if (L <= p2 <= R and R - L >= p1) or (R - L >= p2):
    print(0)
else:
    mods = []
    mods_append = mods.append
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % 2019
            mods_append(m)
            if m == 1:
                break
        if m == 1:
            break

    print(min(mods))


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
int num,pnum,rem, cnt=0,dgt=2;
scanf("%d",&num);
pnum=num;
while(pnum>0){
        rem=pnum%10;
    if(rem==dgt)
    cnt++;
    pnum/=10;}
printf("%d",cnt);
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

vector<int> f0, f1, i1;
void init(int n) {
    i1.resize(n + 1);
    i1[1] = 1;
    for (int i = 2; i <= n; i++) {
        i1[i] = (ll)i1[P % i] * (P - P / i) % P;
    }

    f0.resize(n + 1);
    f1.resize(n + 1);
    f0[0] = f1[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
        f1[i] = (ll)f1[i - 1] * i1[i] % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

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

    init(n);

    ll r = 0, b = 0;
    for (int k = (n + 1) / 2; k <= n - 1; k++) {
        ll a = comb(k - 1, n - 1 - k) * fact(k) % P * fact(n - 1 - k) % P;
        r += (a - b) * k % P;
        b = a;
    }
    r %= P; if (r < 0) r += P;

    cout << r << endl;

    return 0;
}

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

ll n,x;
ll c[55],d[55];
void input(){
    cin >> n >> x;
    c[0]=1;
    d[0]=1;
    rep(i,n){
        c[i+1]=2*c[i]+1;
        d[i+1]=2*d[i]+3;
    }
}

ll dfs(ll a, ll b){
    if(a==0 && b>0) return 1;
    if(b<=1) return 0;
    if(b<=1+d[a-1]) return dfs(a-1,b-1);
    if(b==d[a-1]+2) return c[a-1]+1;
    if(b > d[a]) return c[a];
    else return c[a-1]+1+dfs(a-1,b-2-d[a-1]);
}

int main(){
    input();
    ll ans = dfs(n,x);
    cout << ans << endl;
}



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

int main() {
  int ans=0;
  int cnt=0;
  int n;
  cin>>n;
  FOR(i,1,n+1){
    cnt=0;
    FOR(j,1,i+1){
      if(i%j==0){
        cnt++;
      }
    }
    if(cnt==8){
      ans++;
    }
    i++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n;cin>>n;
        n=n+n*n+n*n*n;
        cout<<n;
}


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

int main(){
  int h, w;
  while(1){
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    else{
      for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
          cout << "#";
        }
        cout << "\n";
      }
      cout << "\n";
    }
  }
  return 0;
}



Measured memory_bytes: 3080
import java.util.Arrays;
import java.util.Scanner;

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

		boolean[] isPrime = new boolean[555556];
		Arrays.fill(isPrime, true);
		isPrime[0] = false;
		isPrime[1] = false;
		for (int i = 2; i * i < 55555; i++) {
			for (int k = 2; k * i < 555556; k++) {
				isPrime[i * k] = false;
			}
		}

		int count = 0;
		int[] answer = new int[n];
		for (int i = 0; i < 555556; i++) {
			if (i % 5 == 1 && isPrime[i]) {
				answer[count++] = i;
			}
			if (count >= n) break;
		}
		for (int i = 0; i < answer.length; i++) {
			System.out.print(answer[i]);
			System.out.print(" ");
		}
		System.out.println();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
using namespace std;
#define rep2(i,from,to) for(int i=(from); i<(to); ++(i))
#define rep(i,to) rep2(i,0,to)
int main() {
	int n;
	cin >> n;
	while(n--) {
		double x[2], y[2], r[2];
		double EPS = 1e-10;
		cin >> x[0] >> y[0] >> r[0] >> x[1] >> y[1] >> r[1];
		if(pow(x[1] - x[0], 2.0) + pow(y[1] - y[0], 2.0) - pow(r[1] + r[0], 2.0) > EPS) {
			cout << "0" << endl;
		} else {
			if(r[1] - r[0] - sqrt(pow(x[1] - x[0], 2.0) + pow(y[1] - y[0], 2.0)) > EPS) {
				cout << "-2" << endl;
			} else if(r[0] - r[1] - sqrt(pow(x[1] - x[0], 2.0) + pow(y[1] - y[0], 2.0)) > EPS) {
				cout << "2" << endl;
			} else cout << "1" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 100000;

int n, ls[N + 2] = {},ans=0;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int v; cin >> v;
		if (v == 0)ans++;
		else ls[v - 1]++; 
		ls[v]++; ls[v + 1]++;
	}
	for (int i = 0; i < N+2; i++)ans = max(ans, ls[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int a,b,n,x,y,m[17][17],p[17][17],i,k;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0 && b==0) break;
		scanf("%d",&n);
		for(i=1;i<=b;i++){
			for(k=1;k<=a;k++){
				m[i][k]=0; p[i][k]=0;
			}
		}
		for(i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			m[y][x]=1;
		}
		p[1][1]=1;
		for(i=1;i<=b;i++){
			for(k=1;k<=a;k++){
				if(k+1<=a && m[i][k+1]!=1) p[i][k+1]+=p[i][k];
				if(i+1<=b && m[i+1][k]!=1) p[i+1][k]+=p[i][k];
			}
		}
		printf("%d\n",p[b][a]);
	}
	return 0;
}

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

namespace ABC_078_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');
            string X = word[0];
            string Y = word[1];
            char x = X[0];
            char y = Y[0];
            if (x > y)
            {
                Console.WriteLine(">");
            }
            else if (x < y)
            {
                Console.WriteLine("<");
            }
            else if (x == y)
            {
                Console.WriteLine("=");
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF=1e18+10;
const int inf=1e9+10,dx[]= {0,0,1,-1,1,-1,1,-1},dy[]= {1,-1,0,0,1,1,-1,-1};
ll MOD=1e9+7;
ld eps=1e-7,pi=acos(-1);

int n,h[100100];

int mem[100100][3];

ll solve(int i,int step)
{
if(i==n)return 0;
if(mem[i][step]!=-1)return mem[i][step];
ll res=0;
if(i+1<n)
res=solve(i+1,0)+abs(h[i]-h[i+1]);
if(i+2<n)
res=min(res,solve(i+2,1)+abs(h[i]-h[i+2]));

return mem[i][step]=res;

}

int main()
{

scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&h[i]);

memset(mem,-1,sizeof mem);

printf("%lld",solve(0,0));

return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  vi v(n);
  REP(i,n) cin >> v[i];
  int r = min(n,k);
  int ans = 0;
  REP(a,r+1){
    REP(b,r+1){
      if(a+b>r) continue;
      V<int> sum;
      REP(i,n){
        if(i<a||n-b<=i) sum.eb(v[i]);
      }
      sort(rALL(sum));
      int osz = sum.size();
      assert(osz==a+b);
      RREP(i,osz){
        if(osz-i-1>=k-a-b) break;
        if(sum[i]<0) sum.pop_back();
        else break;
      }
      int cand = accumulate(ALL(sum),0);
      maxs(ans,cand);
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {

	if (b == 0) {

		return a;

	}

	return gcd(b, a % b);

}

ll lcm(ll a, ll b) {

	return a / gcd(a, b) * b;

}

int main(void) {

	int n; cin >> n;
	ll ans = 1;

	for (int i = 0; i < n; ++i) {

		ll num; cin >> num;

		ans = lcm(ans, num);

	}

	cout << ans << endl;

	return 0;

}

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

const int N = 2e5 + 10;

int n , m , fa[N] , v[N] , ans;

int Find(int x){
	if(x != fa[x]) fa[x] = Find(fa[x]);
	return fa[x];
}

int main(){
	scanf("%d %d" , &n , &m);
	for(int i = 1; i <= n; i++) fa[i] = i , v[i] = 1;
	for(int s , t , i = 1; i <= m; i++){
		scanf("%d %d" , &s , &t);
		int x = Find(s) , y = Find(t);
		if(x == y) continue;
		fa[x] = y , v[y] += v[x] , v[x] = 0;
		ans = max(ans , v[y]);
	}
	printf("%d" , ans == 0 ? 1 : ans);
	return 0;
}

Measured memory_bytes: 5384
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int e[4];
    for (int i = 0; i < 4; i++) {
        cin >> e[i];
    }
    sort(e, e + 4);
    cout << (e[0] == e[1] && e[2] == e[3] ? "yes" : "no") << endl; 
    return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  for(int i=1;i<=1e4;i++){
     int a2 = i*8/100;
     int b2 = i*10/100;
     if(a2==a&&b2==b){
	    cout<<i<<endl;
		return 0;
	 }	 
  }
   cout<<"-1"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    int ans=0,a;
    vector<int> vec(n,0);
    for(int x=1;x<=100;x++){
        for(int y=1;y<=100;y++){
            for(int z=1;z<=100;z++){
                a=x*x+y*y+z*z+x*y+y*z+z*x;
                    if(a<=n){
                        vec[a-1]++;
                    }
            }
        }
    }
    rep(i,n){
        out(vec[i]);
    }
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll p(n);
  rep(i,n) cin>>p[i], p[i]--;
  UnionFind uf(n);
  rep(i,m) {
    ll a,b; cin>>a>>b;
    a--,b--;
    uf.connect(a,b);
  }
  ll ans=0;
  rep(i,n){
    if(uf.isSame(p[i],p[p[i]])) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
#define ll long long 
#include<bits/stdc++.h>
#define mod 1000000007
//Recursive approach
/*
double mul = 0;
void coins_pr(double* a, int n, double sum,int i ,int c,int x)
{
    if(i>=n)
    return;

    for(int j=i;j<n;j++)
    {
        if(c<x)
        {

         double sum1 = (sum/a[j])*(1-a[j]);
         mul += sum1;
         coins_pr(a,n,sum1,j+1,c+1,x);
        }
        else
        break;
    }
    return;
}*/
//Dp approcah
int main()
{
 	int n;
     cin>>n;
     double a[n];
     double sum=1.0;
     for(int i=0;i<n;i++)
    {
    cin>>a[i];
    sum*=a[i];
    }
    /*int x = n%2==1?n/2:n/2-1;
    coins_pr(a,n, sum,0,0,x);
    mul += sum;
    cout<<mul<<endl;*/
    cout<<fixed;
    cout<<setprecision(10);
    double dp[n+1][n+1];
    dp[0][0] = 1.0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        dp[i][j] = 1.0;
    }
for(int i=1;i<=n;i++)
{
    for(int j=0;j<=i;j++)
    {
            if(j==0)
            {
                dp[i][j] = dp[i-1][j]*(1-a[i-1]);
            }
            else if(i==j)
            {
                dp[i][j] = dp[i-1][j-1]*a[i-1];
            }

            else
            {
                dp[i][j] = dp[i-1][j]*(1-a[i-1]) + dp[i-1][j-1]*a[i-1];
            }
    }
}
double mul = 0;
for(int i=n/2+1;i<=n;i++)
mul += dp[n][i];
cout<<mul<<endl;
}

Measured memory_bytes: 74080
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<ll> cnt(5,0);
    vector<int> num(5); rep(i,5) num[i] = i;

    rep(i,n){
        string s; cin >>s;
        if(s[0] == 'M') cnt[0]++;
        if(s[0] == 'A') cnt[1]++;
        if(s[0] == 'R') cnt[2]++;
        if(s[0] == 'C') cnt[3]++;
        if(s[0] == 'H') cnt[4]++;
    }

    ll ans = 0;
    
    do{
        ans += cnt[num[0]] * cnt[num[1]] * cnt[num[2]];
    }
    while(next_permutation(all(num)));

    ans /= 12;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define N 602
#define M 200005
#define pi pair<int, int>
#define fi first
#define se second
#define mkp make_pair

using namespace std;

int n, d1, d2, cnt, sz[2];
int vis1[N][N], vis2[N][N], sq[M];

int sqr(int);
void bfs(int ,int ,int ,int [N][N]);
void solve(int ,int [N][N]);

int main(){
	scanf("%d%d%d", &n, &d1, &d2);
	for(int i = 1; i <= max(d1, d2); ++i) sq[i] = sqrt(i);
	solve(d1, vis1); solve(d2, vis2);
	for(int i = 0; i < 2 * n && cnt < n * n; ++i)
		for(int j = 0; j < 2 * n && cnt < n * n; ++j)
			if(vis1[i][j] && vis2[i][j])
				printf("%d %d\n", i, j), ++cnt;
	return 0;
}

int sqr(int x){
	return x * x;
}

void solve(int d, int vis[N][N]){
	memset(vis, -1, (N * N) << 2);
	sz[0] = sz[1] = 0;
	for(int i = 0; i < 2 * n; ++i)
		for(int j = 0; j < 2 * n; ++j)
			if(vis[i][j] == -1) bfs(i, j, d, vis);
	int p = 0;
	if(sz[0] < sz[1]) p = 1;
	for(int i = 0; i < 2 * n; ++i)
		for(int j = 0; j < 2 * n; ++j)
			if(vis[i][j] == p) vis[i][j] = 1;
			else vis[i][j] = 0;
	return ;
}

void bfs(int X, int Y, int d, int vis[N][N]){
	queue<pi> Q; Q.push(mkp(X, Y)); vis[X][Y] = 0;
	int p = ceil(sqrt(d));
	while(!Q.empty()){
		pi tmp = Q.front(); Q.pop();
		int x = tmp.fi, y = tmp.se;
		++sz[vis[x][y]];
		int l = max(0, x - p), r = min(2 * n - 1, x + p);
		for(int i = l; i <= r; ++i){
			int dy = d - sqr(i - x);
			if(dy < 0) continue;
			int sy = sq[dy];
			if(sqr(sy) != dy) continue;
			if(y - sy >= 0 && vis[i][y - sy] == -1)
				vis[i][y - sy] = vis[x][y] ^ 1, Q.push(mkp(i, y - sy));
			if(y + sy < 2 * n && vis[i][y + sy] == -1)
				vis[i][y + sy] = vis[x][y] ^ 1, Q.push(mkp(i, y + sy));
		}
	}
	return ;
}

Measured memory_bytes: 4448
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N+2);
    for(int i = 1; i < N+1; i++) cin >> A[i];
    ll Allsum = 0;
    for(int i = 1; i < N+2;i++){
        Allsum += abs(A[i]-A[i-1]);
    }
    for(int i = 1; i < N+1; i++){
        cout << Allsum - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 2048