akhauriyash/Code-Regression huggingface dataset:
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;

const int N=1e5+1 ; 
long long Dp[N][5],n,k;
int arr[N][3];
long long calc(int day,int last){
       if(day==n)return 0 ; 
       if (day>n)return -1e9 ;
        long long &ret = Dp[day][last] ; 
        if(ret!=-1)return  ret ; 
        ret = -1e9 ;
        if(last!=0)ret=max(ret , arr[day][0]+calc(day+1,0));
        if(last!=1)ret= max(ret,arr[day][1]+calc(day+1,1));
        if(last!=2)ret = max(ret,arr[day][2]+calc(day+1,2));
          
        return ret ; 
}
int main()
{ 
    cin>>n;
    for(int i =0;i<n;i++){
            for(int j =0;j<3;j++)cin>>arr[i][j]; 
    }
   // cout<<arr[0][2]; 
    memset(Dp,-1,sizeof Dp);
    cout<< calc(0,4);
}


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

using namespace std;

bool ok[1000][1000];

bool check(vector<string> &v, int n, int x, int y)
{
	if (v[x][y] == v[n - x - 1][y] && v[x][y] == v[x][n - y - 1] && v[x][y] == v[n - x - 1][n - y - 1])
		return true;
	return false;
}

int main()
{
	int c, n;
	cin >> c >> n;
	vector<string> p(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int def = 0;
	for (int i = 0; i < n / 2; i++)
		for (int j = 0; j < n / 2; j++)
			if (check(p, n, i, j))
				ok[i][j] = true;
			else
			{
				ok[i][j] = false;
				def++;
			}
	int ans = (def == 0 ? 1 : 0);
	while (--c)
	{
		int d, pr[100], pc[100];
		cin >> d;
		for (int i = 0; i < d; i++)
			cin >> pr[i] >> pc[i];
		for (int i = 0; i < d; i++)
		{
			pr[i]--;
			pc[i]--;
			p[pr[i]][pc[i]] = (p[pr[i]][pc[i]] == '1' ? '0' : '1');
			if (pr[i] >= n / 2)
				pr[i] = n - 1 - pr[i];
			if (pc[i] >= n / 2)
				pc[i] = n - 1 - pc[i];
			bool s = check(p, n, pr[i], pc[i]);
			if (s != ok[pr[i]][pc[i]])
			{
				if (s)
					def--;
				else
					def++;
			}
			ok[pr[i]][pc[i]] = s;
		}
		if (def == 0)
			ans++;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 4532
import bisect
import copy
import heapq
import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, M, C = read_values()
    B = read_list()

    res = 0
    for _ in range(N):
        A = read_list()
        if sum(a * b for a, b in zip(A, B)) + C > 0:
            res += 1

    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4080
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val d = sc.nextInt()
    val x = sc.nextInt()
    println((1..n).map {
        val a = sc.nextInt()
        (d - 1) / a + 1
    }.sum() + x)
}

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

int main() {
  int N,K;
  cin >> N >>K;
  int A = 1;
  for(int i = 0; i<N; i++) {
     if(A>K){A+=K;}
    else{A*=2;}
        }
  cout <<A;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define int long long
using namespace std;
const int INF = 1e9 + 7;

int N, C[200010];

int DP[200010], X[200010], M;

signed main()
{
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int x;
        cin >> x;
        if (x != C[M]) {
            M++;
            C[M] = x;
        }
    }
    DP[0] = 1;
    for (int i = 1; i <= M; i++) {
        DP[i] = DP[i - 1];
        if (X[C[i]] != 0) {
            DP[i] += DP[X[C[i]]];
            DP[i] = DP[i] % INF;
        }
        X[C[i]] = i;
    }
    cout << DP[M] << endl;
    return 0;
}


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

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

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

const int MAX = 1e5 + 5;
const ll INF = 1001001001001001;
const int MOD = 1e9 + 7;

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

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

    vector<ll> sum(N + 1);
    sum[N] = 0;
    for (int i = N - 1; i >= 0; --i) {
        sum[i] = sum[i + 1] + a[i];
    }

    ll ans = INF;
    ll cnt = 0;
    for (int i = 0; i < N - 1; ++i) {
        cnt += a[i];
        ans = min(ans, abs(cnt - sum[i + 1]));
    }

    cout << ans << endl;
}

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

const int N = 40;
const int LMT = 17;
const int MOD = 1e9 + 7;

long long modPow(long long base,int po) {
	long long ret = 1;
	while(po) {
		if(po & 1) ret = (ret * base) % MOD;
		base = (base * base) % MOD;
		po >>= 1;
	}
	return ret;
}

int pwr[N+5];
int dp[N+1][1<<LMT];
int x,y,z,n;

void prec() {
	pwr[0] = 1;
	for(int i = 1;  i <= N ; i++) {
		pwr[i] = (10ll * pwr[i-1]) % MOD;
		//cout << i << pwr[i] << endl;
	}
	memset(dp,-1,sizeof dp);
}

int solve(int sisa,int msk) {
	if(sisa == 0) return 0;
	int &ret = dp[sisa][msk];
	if(ret != -1) return ret;
	ret = 0;
	for(int i = 1 ; i <= 10 ; i++) {
		int zz = z - i;
		int yz = zz + y;
		int xyz = yz + x;
		if(zz >= 0 && (msk & (1<<zz)) > 0 && (msk & (1<<yz)) > 0 && (msk & (1<<xyz)) > 0)
			ret = (ret + pwr[sisa-1]) % MOD;
		else {
			int nexMask = msk << i;
			nexMask &= ((1<<LMT) - 1);
			nexMask |= 1;
			ret = (ret + solve(sisa-1,nexMask)) % MOD;
		}
	}
	return ret;
}

int main() {
	prec();
	cin >> n >> x >> y >> z;
	cout << solve(n,1) << endl;
	return 0;
}

Measured memory_bytes: 21248
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int[] h = new int[n];
            for (int i = 0; i < n; i++) {
                h[i] = Integer.parseInt(in.next());
            }

            int[] dp = new int[n];
            Arrays.fill(dp, Integer.MAX_VALUE);

            dp[0] = 0;
            dp[1] = dp[0] + Math.abs(h[1] - h[0]);
            for (int i = 2; i < n; i++) {
                for (int j = 1; j <= k; j++) {
                    if (j <= i) dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
                }
            }

            out.println(dp[n - 1]);

        }

    }
}



Measured memory_bytes: 49092
import numpy as np

H, W = map(int, input().split())
masu = [input() for i in range(H)]
#temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
#masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]

#dp = np.zeros((H, W))
dp = [[0]*W for i in range(H)]
if masu[0][0] == "#":
    dp[0][0] = 1

for i in range(0,H):
    for j in range(0,W):
        if i == 0:
            a = 100000
        else:
            if masu[i][j] == "#" and masu[i-1][j] == ".":
                a = dp[i-1][j] + 1
            else:
                a = dp[i-1][j]
        if j == 0:
            b = 100000
        else:
            if masu[i][j] == "#" and masu[i][j-1] == ".":
                b = dp[i][j-1] + 1
            else:
                b = dp[i][j-1]
        if a != 100000 or b != 100000:
            dp[i][j] = min([a, b])
print(int(dp[H-1][W-1]))


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

int main() {
  int a,b;
   cin >> a >> b;
  int count = 0;
  int s = 0;
  int revs = 0;
  string str;
  string rts;
  for(int i=a; i<=b; i++){
    s = i;
    str = to_string(s);
    for(int i=0; i<5; i++){
      rts[i] = str[4-i];
    }
    revs = stoi(rts);
    if(s == revs) count++;
  }
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	if(a[0] != 0) {
		print(-1);
		return 0;
	}
	int sum = 0;
	int atleast = 0;
	for(int i=n-1;i>=1;i--) {
		atleast--;
		if(atleast>a[i]) {
			print(-1);
			return 0;
		}
		if(atleast<a[i]) {
			sum+=a[i];
		}
		atleast = a[i];
	}
	print(sum);

	return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

N = int(input())
S = input()

ans = 0
for i in range(1, N):

    str1 = S[:i]
    str2 = S[i:]
    list1 = list(set(str1))
    list2 = list(set(str2))

    tmp = 0
    for s in list1:
        if s in list2:
            tmp += 1
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3064
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
string s;
int n;

int ok(int C) {
  array<array<int,2>,2> dp;
  for (int it = 0; it < 2; it++) {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        dp[i][j] = 0;
    dp[0][0] = 1 + it;
    dp[0][1] = C;
    if (dp[0][1] % 2 != (it ^ 1))
      dp[0][1]--;
    int ok = dp[0][0] <= dp[0][1];
    for (int i = 0; i < n && ok; i++) {
      dp[1][0] = dp[1][1] = 0;
      if (s[i] == '0') {
        dp[1][0] = dp[0][0] + 1;
        dp[1][1] = dp[0][1] + 1;
      } else if (s[i] == '1') {
        dp[1][0] = dp[0][0] - 1;
        dp[1][1] = dp[0][1] - 1;
      } else {
        dp[1][0] = dp[0][0] - 1;
        dp[1][1] = dp[0][1] + 1;
      }
      swap(dp[0], dp[1]);
      if (dp[0][0] < 1)
        dp[0][0] += 2;
      if (dp[0][1] > C)
        dp[0][1] -= 2;
      ok &= dp[0][0] <= dp[0][1];
      ok &= dp[0][0] <= C && dp[0][1] > 0;
    }
    if (ok)
      return 1;
  }
  return 0;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> s; n = sz(s);
  int lo = 1, hi = n;
  while (lo <= hi) {
    int mi = (lo+hi) / 2;
    if (ok(mi))
      hi = mi - 1;
    else
      lo = mi + 1;
  }
  cout << lo-1 << "\n";
  return 0;
}


Measured memory_bytes: 4232
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#define MIN 1<<31-1
#define HMAX 1000000000000000000
#define MOD 1000000007
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RSET(s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
typedef long long int ll;
using namespace std;
int poww(int k)
{
	ll re=1;
	while(k--)
	{
		re*=2;
	}
	return re;
}
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll d=max(c,max(a,b));
	ll ans=a+b+c-d+d*poww(k);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long n,k;
    cin >> n >> k;
    long ans = 0;
    for(long c=k;c<=n+1;c++){
        long r = (2*n-c+1)*c/2 - (c-1)*c/2 + 1;
        ans += r;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	int d, a;
	int deg = 90.;
	double x = 0., y = 0.;
	while(1)
	{
		if (scanf("%d,%d", &d, &a) == EOF) break;
		if (d == 0 && a == 0) break;
		double rad = (double)deg / 180. * M_PI;
		x += d * cos(rad);
		y += d * sin(rad);
		deg -= a;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

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

int main(){
string S;
cin >> S;
if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
    cout << "Bad" << endl;
} else {
    cout << "Good" << endl;
}
}

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

using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B(M);
    for (int i = 0; i < M; ++i)
        cin >> B[i];

    int number_of_accepted = 0;
    for (int i = 0; i < N; ++i) {
        int sum = C;
        for (int j = 0; j < M; ++j) {
            int a;
            cin >> a;
            sum += a * B[j];
        }
        if (sum > 0)
            ++number_of_accepted;
    }
    cout << number_of_accepted << '\n';
}


Measured memory_bytes: 256
import java.lang.Long.max

//

fun main() {
    abc176c()
}

fun abc176c() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    var d = 0L
    var p = a[0]
    for (l in a) {
        if (l < p) {
            d += (p - l)
        }
        p = max(p, l)
    }
    println(d)
}


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<ll,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005


int main(){
sp;
int n,k;
cin>>n>>k;
pi p[n+1];
for(int i=1; i<=n; ++i)cin>>p[i].s>>p[i].f;
vector<ll> a,b;
sort(p+1,p+n+1);
reverse(p+1,p+n+1);
map<int,int> mp;
for(int i=1; i<=n; ++i){
    if(mp.find(p[i].s)==mp.end()){
        a.pb(p[i].f);
        mp[p[i].s];
    }
    else b.pb(p[i].f);
}
sort(a.rbegin(),a.rend());
sort(b.rbegin(),b.rend());



for(int i=1; i<max(a.size(),b.size()); ++i){
    if(i<a.size())a[i]+=a[i-1];
    if(i<b.size())b[i]+=b[i-1];
}

ll ans=0;
for(int i=0; i<a.size(); ++i){
    ll taken=i+1;
    if(taken>k)break;
    ll sum=a[i];
    ll sum1=0;
ll duplicate=k-taken;
if(duplicate>b.size())continue;
if(duplicate>0)sum1=b[duplicate-1];
sum+=1LL*taken*taken+sum1;
ans=max(ans,sum);
}
cout<<ans;
return 0;}


Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
int a[105],sum=0;
int p,x,n,m;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
	{
    	cin>>a[i];
        sum+=a[i];
    }
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>p>>x; cout<<sum-a[p]+x<<endl;
    }
}

Measured memory_bytes: 256
def main():
    input()
    a = set(input().split())
    input()
    b = set(input().split())
    print(len(a.intersection(b)))


if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Measured memory_bytes: 7960
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n;
double a,ans,cnt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>a;
		cnt=cnt+1.0/a;
	}
	ans=1.0/cnt;
	cout<<setprecision(8)<<fixed<<ans;
	return 0;
}

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

int main()
{
    int n, m; cin>>n>>m;
    if (max(n, m)>min(n, m)+1) return cout<<0<<endl, 0;

    const int mod=1e9+7;
    long res=1+(n==m);
    for(int i=1; i<=n; ++i) res=res*i%mod;
    for(int i=1; i<=m; ++i) res=res*i%mod;
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime> 
#include <queue>
#include <stack>
#include <bitset> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

template <class T>
inline void rd(T &x) {
    char c = getchar(), f = 0; x = 0;
    while (!isdigit(c)) f = (c == '-'), c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    x = f ? -x : x;
}

const int MAXN = (1 << 18) + 7;

int val[MAXN], wei[MAXN], f[(1 << 10) + 7][100000 + 7], lg[MAXN];
int n, q;

// void upd(int &x, int y) { x = (x < y ? x : y); }
void upd(int &x, int y) {
    if (x < y) x = y;
}

void dfs(int u) {
    if (lg[u] > 8) return;
    // printf("u = %d\n", u);
    per(i, 100000, 0) f[u][i] = std::max(f[u >> 1][i], i >= wei[u] ? (f[u >> 1][i - wei[u]] + val[u]) : 0);
    // rep(i, 0, 6) printf("i = %d, f = %d\n", i, f[u][i]);
    if (u * 2 <= n) dfs(u << 1);
    if ((u << 1 | 1) <= n) dfs(u << 1 | 1);
}

int main() {
    lg[0] = -1;
    rep(i, 1, MAXN - 7) lg[i] = lg[i >> 1] + 1;

    rd(n);
    rep(i, 1, n) rd(val[i]), rd(wei[i]);
    // CL(f, ~0x3f);
    dfs(1);
    rd(q);
    while (q--) {
        int u, l;
        rd(u), rd(l);
        int tmp = u;
        std::vector<PII> v;
        while (lg[tmp] > 8) v.pb(MP(val[tmp], wei[tmp])), tmp >>= 1;
        int lim = (1 << (v.size()));
        int ans = 0;
        rep(i, 0, lim - 1) {
            int vv = 0, ww = 0;
            // printf("i = %d\n", i);
            rep(j, 0, (int)(v.size() - 1)) if (i & (1 << j)) vv += v[j].fi, ww += v[j].se;
            // printf("ww = %d, vv = %d, tmp = %d, val = %d\n", ww, vv, tmp, f[tmp][l - ww] + vv);
            if (ww <= l) upd(ans, vv + f[tmp][l - ww]);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 206384
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int A, B, M, ans = 1000000007;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    for (int i = 0; i < A; i++){
        cin >> a.at(i);
    }
    for (int j = 0; j < B; j++){
        cin >> b.at(j);
    }
    for (int i = 0; i < M; i++){
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a.at(x - 1) + b.at(y - 1) - c);
    }
    sort(ALL(a));
    sort(ALL(b));
    ans = min(ans, a.at(0) + b.at(0));
    cout << ans << endl;


}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = (a+b)*2;
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26136
#include <cstdio>
#include <cstring>
#include <algorithm>
const char *Alice = "Alice", *Bob = "Borys", *Eval = "Draw";

int n, a, b;
namespace solver1 {
  void main() {
    if ((b - a) & 1) {
      puts(Bob);
    } else {
      puts(Alice);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &a, &b);
  solver1::main();
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0; i<n; ++i) {
		cin>>a[i];
	}
	if(k >= 60) {
		for(int i=0; i<n; ++i) {
			cout<<n<<' ';
		}
		return 0;
	}
	for(int z=0; z<k; ++z) {
		vector<int> cnt(n+1);
		for(int i=0; i<n; ++i) {
			cnt[max(0, i-a[i])] ++;
			cnt[min(n, i+a[i]+1)]--;
		}
		int sweep=0;
		for(int i=0; i<n; ++i) {
			sweep += cnt[i];
			a[i] = sweep;
		}
	}
	for(int i=0; i<n; ++i) {
		cout<<a[i]<<' ';
	}
}


Measured memory_bytes: 4944
N=int(input())
W=list(map(int,input().split()))
A=W[0]
B=sum(W[1:N])
tmp=[]
tmp.append(abs(A-B))
for i in range(N):
  A=sum(W[0:i+1])
  B=sum(W[i+1:N])
  tmp.append(abs(A-B))
print(min(tmp))

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for (int b = 1; b <= n; b++) {
    if (b <= k) continue;
    ans += n / b * (b - k) + max(0ll, n % b - k + (k > 0));
    // cout << b << " " << n / b * (b - k) << " " << max(0ll, n % b - k + (k > 0)) << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a= in.nextInt();
        int b = in.nextInt();
        int count=1;
        int socks=a;
        if(b==1){
            System.out.println(0);
        }
        else {

            if(b>1 && b<a)
                System.out.println(1);
            else {
                while (socks < b) {
                    socks += a - 1;
                    count++;
                }
                System.out.println(count);
            }
        }
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

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

typedef long long ll;
using namespace std;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define MAX 3500
int lookup[MAX][MAX];

string LCS(string X, string Y, int m, int n)
{
	if (m == 0 || n == 0)
		return string("");
	if (X[m - 1] == Y[n - 1])
	{
		return LCS(X, Y, m - 1, n - 1) + X[m - 1];
	}

	if (lookup[m - 1][n] > lookup[m][n - 1])
		return LCS(X, Y, m - 1, n);

	else

		return LCS(X, Y, m, n - 1);
}
void LCSLength(string X, string Y, int m, int n)
{
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (X[i - 1] == Y[j - 1])
				lookup[i][j] = lookup[i - 1][j - 1] + 1;
			else
				lookup[i][j] = max(lookup[i - 1][j], lookup[i][j - 1]);
		}
	}
}
int main()
{
	string X,Y;
	cin>>X>>Y;
	int m = X.length(), n = Y.length();
	LCSLength(X, Y, m, n);
	cout << LCS(X, Y, m, n);

	return 0;
}


Measured memory_bytes: 71680
def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def sieve(n): # エラトステネスの篩ですよ
  num = [True]*n
  num[0] = num[1] = False
  for i in range(2,int(n**0.5)+1):
    if num[i]:
      for j in range(i**2, n, i):
        num[j] = False
  return [i for i in range(2,n) if num[i]]

def main():
  q = int(input())
  l , r = [0]*q, [0]*q
  for i in range(q):
    l[i], r[i] = m()
  rr = max(r) 
  prime = sieve(rr+1)
  # print(prime)
  likp = [0]*rr
  for i in prime:
    if (i+1) // 2 in prime:
      likp[i-1] = 1
  # print(likp)
  sm = [0]*(rr+1)
  for i in range(rr):
    sm[i+1] = sm[i] + likp[i]
  # print(sm)
  for i in range(q):
    print(sm[r[i]] - sm[l[i]-1])

if __name__ == '__main__':
  main()


Measured memory_bytes: 15912
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 09:50-

            int k = sc.nextInt();
            int x = sc.nextInt();

            for (int i = Math.max(-2_000_000, x - (k - 1)); i <= Math.min(2_000_000, x + (k - 1)); i++) {
                out.println(i);
            }

        }
    }

}


Measured memory_bytes: 21844
#include<stdio.h>
int N,T,H,L,t[100],h[100],c,n=0;

int main()
{
	scanf("%d%d%d%d",&N,&T,&H,&L);
	for(int i=0;i<N;i++)
		scanf("%d%d",&t[i],&h[i]);
	for(c=0;;c=(c+1)%N)
	{
		if(!t[c]&!h[c])break;
		if(!t[c])
		{
			h[c]--;
			n+=100;
			if(T<(n-90)/10)break;
			t[c]+=(n-90)/10;
			H++;T-=(n-90)/10;
			n=0;
		}
		else
		{
			t[c]--;T++;n+=10;
			if(L<T)break;
			
			if(n>=90)
				n=0;
		}
	}
	printf("%d\n",c+1);
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll= long long;
int main(){
    int n;
    cin>>n;
    int a,b,c;
    int dp[n][3];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    rep(i,n) {
        cin >>a>>b>>c;
        dp[i+1][0]=max(dp[i][1],dp[i][2])+a;
        dp[i+1][1]=max(dp[i][0],dp[i][2])+b;
        dp[i+1][2]=max(dp[i][0],dp[i][1])+c;
    }
    ll ans =max(max(dp[n][0],dp[n][1]),dp[n][2]);
    cout << ans;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int t;
const int maxn=1e6+5;
int n,m,f=0;
int res[maxn];
int main()
{
    int a,b,n,m;
    scanf("%d%d%d",&m,&a,&b);
    n=m;
    ll k=(ll)a*b;
    if(a+b-1>n || k<n)
    {
        printf("-1\n");
        return 0;
    }

    for(int i=m-a+1;i<=m;i++)
    {
        res[++f]=i;
        n--;
    }
    b--;
    int s=n;
    for(int i=b;i>0;i--)
    {
        int ans=min(a,n-i+1);
        for(int j=n-ans+1;j<=n;j++)
            res[++f]=j;
        n-=ans;
    }
    for(int i=1;i<=m;i++)
        printf(i==1?"%d":" %d",res[i]);
    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-10;

int solve(int a, int b, int c, int d, int n){

	return 0;
}

int main(){
	int n, cnt;

	while(cin >> n){
		cnt = 0;
		if(n <= 36)
			for(int i = 0; i < 10; i++)
				for(int j = 0; j < 10; j++)
					for(int k = 0; k < 10; k++)
						for(int l = 0; l < 10; l++)
							if(i+j+k+l == n) cnt++;

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int n = s.size();
    int ans = inf;
    for (int i = 'a'; i <= 'z'; i++) {
        int ct = 0;
        int mx = 0;
        rep(j,n) {
            if (s[j] == i) {
                mx = max(mx,ct);
                ct = 0;
            }
            else ct++;
        }
        mx = max(mx,ct);
        ans = min(ans,mx);
    }
    cout << ans << endl;
}

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

minno = 10 ** 9

for x in a:
    cheknow = 0
    while x % 2 == 0:
        x = x / 2
        cheknow += 1
    if cheknow < minno:
        minno = cheknow
print(minno)

Measured memory_bytes: 9088
import sys, math
from functools import lru_cache
import numpy as np
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    a, b = mi()
    if a+b == 15:
        print('+')
    elif a*b == 15:
        print('*')
    else:
        print('x')



if __name__ == '__main__':
    main()


Measured memory_bytes: 27184
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << c - a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
 
int cmp(void *a,void *b){
    return *(int*)a-*(int*)b;
}
 
int main(){
    int a,b,c,d,i,n;
    int flag,j,cnt;
    int s[N]={0};
    int p[N]={0};
    int t[N]={0};
 
    scanf("%d",&n);
 
    for(i=0;i<n*(n-1)/2;i++){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if(c<d){
            s[b]+=3;
        }else if(c>d){
            s[a]+=3;
        }else{
            s[a]++;
            s[b]++;
        }
    }
 
    for(i=1;i<=n;i++)t[i]=s[i];
    qsort(t,n+1,sizeof(int),cmp);
    for(i=n,cnt=0;flag=0,i>=0;i--){
        for(j=1;j<=n;j++){
            if(p[j]==0&&t[i]==s[j]){
                flag++;
                p[j]=cnt+1;
            }
        }
        if(flag)cnt+=flag;
    }
 
    for(i=1;i<=n;i++)printf("%d\n",p[i]);
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll x;
  cin >> x;
  ll ans=0;
  ans+=2*(x/11);
  x-=(x/11)*11;
  if(x>6)ans+=2;
  else if(0<x)ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <cmath>

using namespace std;

#define N 4
#define N2 16

struct Puzzle {
	int f[N2], space, MD, cost;

	bool operator<(const Puzzle& a) const {
		for (int i = 0; i < N2; ++i) {
			if (f[i] == a.f[i]) continue;
			return f[i] > a.f[i];
		}
		return false;
	}
};

static const int dx[] = { 0,-1,0,1 }, dy[] = { 1,0,-1,0 };
int MDT[N2][N2];

struct State {
	Puzzle puzzle;
	int estimated;
	bool operator<(const State& s) const {
		return estimated > s.estimated;
	}
};

int getAllMD(const Puzzle& pz) {
	int sum = 0;
	for (int i = 0; i < N2; ++i) {
		if (pz.f[i] == N2) continue;
		sum += MDT[i][pz.f[i] - 1];
	}
	return sum;
}

int astar(Puzzle s) {
	priority_queue<State> PQ;
	s.MD = getAllMD(s);
	s.cost = 0;
	map<Puzzle, bool> V;
	Puzzle u, v;
	State initial;
	initial.puzzle = s;
	initial.estimated = getAllMD(s);
	PQ.push(initial);
	while (!PQ.empty()) {
		State st = PQ.top(); PQ.pop();
		u = st.puzzle;
		if (u.MD == 0) return u.cost;
		V[u] = true;
		int sx = u.space / N, sy = u.space % N;
		for (int r = 0; r < 4; ++r) {
			int tx = sx + dx[r], ty = sy + dy[r];
			if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
			v = u;
			v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];
			v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];
			swap(v.f[sx * N + sy], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			if (!V[v]) {
				v.cost++;
				State news;
				news.puzzle = v;
				news.estimated = v.cost + v.MD;
				PQ.push(news);
			}
		}
	}
}

int main() {
	for (int i = 0; i < N2; ++i)
		for (int j = 0; j < N2; ++j)
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
	Puzzle in;
	for (int i = 0; i < N2; ++i) {
		cin >> in.f[i];
		if (in.f[i] == 0) {
			in.f[i] = N2;
			in.space = i;
		}
	}
	cout << astar(in) << endl;

	return 0;
}


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

int main() {
  int a, b, c;
  string y, n;
  y = "Yes";
  n = "No";
  cin >> a >> b;
  c = a % 500;
  if( c == 0 ) {
  	cout << y << endl;
    return 0;
  }
  if( c <= b ) {
  	cout << y << endl;
    return 0;
  }
  	cout << n << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int x,y;
	cin>>x>>y;
	if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)||(x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int T;
int n;
long long a[210],p[70];
char s[210];
void ins(long long x)
{
	for(int i=64;~i;--i)
		if(x>>i&1)
		{
			if(!p[i])p[i]=x;
			x^=p[i];
		}
}
bool ask(long long x)
{
	for(int i=64;~i;--i)
		if(x>>i&1)
		{
			if(!p[i])return 1;
			x^=p[i];
		}
	return 0;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
		scanf("%s",s+1);
		bool flag=0;
		for(int i=n;i;--i)
			if(s[i]=='0')ins(a[i]);
			else flag|=ask(a[i]);
		printf("%d\n",flag);
		memset(p,0,sizeof(p));
	}
	return 0;
}

Measured memory_bytes: 1728
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    double T, X;
    cin >> T >> X;

    printf("%lf\n", T / X);

    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a,0,sizeof(a))
#define sqr(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int mn = 2e5 + 5;
const int mm = 2100;
const int mod = 1e9 + 7;
#define P mod

int n, x;
int a[mn];

ll powmod(ll a, ll b, ll P) {
	ll t = 1;
	for (; b; b >>= 1, a = a * a % P)
		if (b & 1) t = t * a % P;
	return t;
}

int F[mn];
int inv[mn];

unordered_map<int,int> h[205];
ll sans;

inline void movelast(int pos){
	for(auto &i:h[pos]){
		int ans=i.first%a[pos];
		int calcpos=upper_bound(a+1,a+n+1,ans)-a-1;

		int cnt=i.second;
		if (calcpos==0){
			sans+= (ll)ans*cnt%mod;
			//printf("%d %d %d %d\n",pos,cnt,ans,cnt*ans);
		}
		for(int j=1;j<=calcpos;j++){
			h[j][ans]=(h[j][ans]+(ll)i.second*inv[calcpos]%mod)%mod;
		}
	}
}

int main() {
	//cin.sync_with_stdio(0);
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
#endif
	cin >> n >> x;
	for (int i = 1; i <= n; i++) cin >> a[i];
	F[0] = F[1] = 1;
	for (int i = 2; i <= n; i++) {
		F[i] = (ll) F[i - 1] * i % mod;
	}
	for(int i=1;i<=200;i++) inv[i]=powmod(i,P-2,P);
	sort(a + 1, a + n + 1);
	for(int i=1;i<=n;i++){
		h[i][x%a[i]]=F[n-1];
	}
	for(int i=n;i;i--){
		movelast(i);
	}

	printf("%lld\n",sans%mod);

	return 0;
}


Measured memory_bytes: 25600
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if w >= v:
    print("NO")
else:
    c = v-w
    kyori = abs(b-a)
    if t*c >= kyori:
        print("YES")
    else:
        print("NO")


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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >


ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<bool>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
	ll n, c = 0;
	
	cin>>n;
	vl a(MAX, 0);
	for(ll i = 1; i <= 100; i++)
	{
	    for(ll j = 1; j <= 100; j++)
	    {
	        for(ll k = 1; k <= 100; k++)
	        {
	            ll x = i*i + j*j + k*k + i*j + j*k + i*k;
	            a[x]++;
	        }
	    }
	}
	for(ll i = 1; i <= n; i++)
	    cout<<a[i]<<"\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();		
	}
	return 0;
}

ll mulmod(ll a, ll b)
{
	ll res = 0; 
	a = a % MOD;
	while(b > 0)
	{
		if (b % 2 == 1)
			res = (res + a) % MOD;
 
		a = (a * 2) % MOD; 
		b /= 2;
	} 
	return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a = (a * a) % MOD;
	}
	return res;
}

void getprime(vector<bool>&prime)
{
	prime[0] = false;
	prime[1] = false;
	
	for(ll i = 2; i * i <= MAX; i++)
	{
		if(prime[i])
		{
			for(ll j = i*i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
	fact[0] = 1;
	ifact[0] = 1;
	
	for(ll i = 1; i <= MAX; i++)
	{
		fact[i] = (fact[i-1] * i)%MOD;
		ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
	}
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
	ll res;
	res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
	return res;
}

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

const int MOD = 1000000007;
const int N = 200005;

int n, m;
int par[N];
int cnt[N];

int root(int u) {
  if (u == par[u]) return u;
  return par[u] = root(par[u]);
}

int solve() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) par[i] = i;

  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;

    par[root(u)] = root(v);
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, ++cnt[root(i)]);
  }

  printf("%d\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


Measured memory_bytes: 10756
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>


using namespace std;

string s,a="";
int n;
double x,h;
int p=0;


void string_num(string str) {
	stringstream sstream;
	sstream << str;
	sstream >> n;
}

void string_x(string str) {
	stringstream sstream;
	sstream << str;
	sstream >> x;
}

void string_h(string str) {
	stringstream sstream;
	sstream << str;
	sstream >> h;
}



int main(){
	while(cin >> s){

		while(s[p] != ','){
			a += s[p];
			p++;
			if(s[p] == ','){
				p++;
				string_num(a);
				a="";
				break;
			}
		}

		while(s[p] != ','){
			a += s[p];
			p++;
			if(s[p] == ','){
				p++;
				string_x(a);
				a="";
				break;
			}
		}


		while(s[p] != '\0'){
			a += s[p];
			p++;
			if(s[p] == '\0'){
				p=0;
				string_h(a);
				a="";
				break;
			}
		}

		if((x/(h*h)) >= 25){
			cout << n << endl;
		}


	}

}

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

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  int low = 0;
  int center = 0;
  if(a <= b){
    low = a;
    if(b <= c){
      center = b;
    }
    else{
      center = c;
    }
  }
  else{
    low = b;
    if(a <= c){
      center = a;
    }
    else{
      center = c;
    }
  }
  cout << low+center << "\n";
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 2e5 + 3;
int N;
int A[MC];

bool eval(int z){
	stack<pair<int,int>> S;
	S.push(MP(0,0));
	for(int i = 0 ; i < N ; ++i){
		if(S.top().first == A[i]) ++S.top().second;
		if(S.top().first < A[i]) S.push(MP(A[i],1));
		while(S.top().first > A[i]){
			int p = S.top().first;
			int q = S.top().second;
			S.pop();
			int r = S.top().first;
			if(r < A[i]) p -= A[i];
			else p -= r;
			LL t = 1;
			if(z != 1){
				while(t < q && p > 0){
					t *= z;
					--p;
				}
			}
			if(r < A[i]){
				S.push(MP(A[i],(q-1)/t+2));
			} else {
				S.top().second += (q-1)/t;
				if(S.top().first == A[i]) ++S.top().second;
			}
		}
	}
	while(S.top().first > 1){
		int p = S.top().first;
		int q = S.top().second;
		S.pop();
		int r = S.top().first;
		if(r == 0) p -= 1;
		else p -= r;
		LL t = 1;
		if(z != 1){
			while(t < q && p > 0){
				t *= z;
				--p;
			}
		}
		if(r < 1) S.push(MP(1,(q-1)/t+1));
		else S.top().second += (q-1)/t;
	}
	return S.top().second <= z;
}

int BS(int x, int y){
	if(x-y<2) return x;
	int z = (x+y)/2;
	return eval(z) ? BS(z,y) : BS(x,z);
}

int main(){
	cin >> N;
	repp(i,0,N) cin >> A[i];
	cout << BS(N,0) << endl;
	return 0;
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

typedef struct quad{
    int a, b, c, d;
}quad;

ll ans = 0;

vi arr;
void calc(int mx, int idx, int m, int n, vector<quad> &vq){

    if(idx == n + 1){
        ll sum = 0;
        
        loop(z, vq){
            if(arr[z.b] - arr[z.a] == z.c) sum += z.d;
        }
        ans = max(ans, sum);

        return;
    }

    for(int i = mx; i <= m; i++){
        arr.pb(i);
        calc(i, idx + 1, m, n, vq);
        arr.pop_back();
    }
}

int main()
{
    boost;
    ll tt = 1, n, m, k = 0, i, j;
    ll q, l = 0, r = 0, x, y, z, h, a, b, c, d;

    bool poss = true;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n >> m >> q;

        quad t;
        vector<quad> vq;
        while(q--){
            cin >> t.a >> t.b >> t.c >> t.d;
            t.a--;
            t.b--;
            vq.pb(t);  
        } 

        calc(1, 1, m, n, vq);

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
  int k,a,b; cin >> a >> b >> k;
  vector<int> d;
  fore(i,1,min(a,b)+1) if(a%i==0&&b%i==0) d.pb(i);
  reverse(ALL(d));
  cout << d[k-1] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<vector<int>> v(n);
    forn(m) {
        int a, b;
        cin >> a >> b;
        v[a - 1].pb(b - 1);
        v[b - 1].pb(a - 1);
    }
    vector<bool> visited(n);
    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (!visited[i]) {
            queue<int> que;
            que.push(i);
            visited[i] = true;
            int curr = 0;
            while (!que.empty()) {
                auto temp = que.front();
                que.pop();
                visited[temp] = true;
                curr++;
                for (auto j : v[temp]) {
                    if (!visited[j]) {
                        que.push(j);
                        visited[j] = true;
                    }
                }
            }
            count = max(count, curr);
        }
    }
    cout << count << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 14920