akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/abc123/tasks/abc123_c
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;


int main()
{
int r,D,x;
cin >> r >> D >> x;

int g = 0;
for (int i = 0; i < 10; i++)
{
    /* code */
    x = r * x - D;
    cout << x << endl;
}

}


Measured memory_bytes: 256
//KING NIKAN
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
int a[100010] ;
int main() 
{
	ios::sync_with_stdio(false) ;
	cin.tie(0) ;
	cout.tie(0) ;
	int n ;
	cin >> n ;
	int cnt_4=0 ,cnt_2=0 ,cnt_1=0 ;
	for(int i=0 ;i<n ;i++)
	{
		cin >> a[i] ;
		if(a[i]%4==0)
		{
			cnt_4++ ;
		}
		else if(a[i]%2==0)
		{
			cnt_2++ ;
		}
		else
		{
			cnt_1++ ;
		}
	}
	if(cnt_1>cnt_4+1)
	{
		cout << "No" ;
		return 0 ;
	}
	if(cnt_1==cnt_4+1 && cnt_2>0)
	{
		cout << "No" ;
		return 0 ;
	}
	cout << "Yes" ;
	return 0 ;
}


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

#define LL long long

LL n, m;

int main()
{
	scanf("%lld %lld", &n, &m);
	if(n == 1 || m == 1) { puts("1"); return 0; }
	LL a = (m + 1) / 2, b = m - a, c = (n + 1) / 2, d = n - c;
	printf("%lld", a * c + b * d);
	return 0;
}


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

using namespace std;

const int N = 100;
bool G[N][N];
enum Color {WHITE, BLACK, GRAY} color[N];
int d[N], f[N];
int tt;
int n;

void dfs(int u) {
    color[u] = GRAY;
    d[u] = ++tt;
    for (int v = 0; v < n; ++v) {
        if (G[u][v] && color[v] == WHITE) {
            dfs(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}

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

    for (int i = 0; i < n; ++i) {
        int u, k;
        scanf("%d %d", &u, &k);
        --u;
        for (int j = 0; j < k; ++j) {
            int v;
            scanf("%d", &v);
            --v;
            G[u][v] = true;
        }
    }
    for (int u = 0; u < n; ++u) {
        if (color[u] == WHITE)
            dfs(u);
    }
    for (int u = 0; u < n; ++u) {
        cout << u + 1 << " " << d[u] << " " << f[u] << endl;
    }
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	long long k;
	ll n,i,a,b;
	cin>>n>>k;
	map<ll,ll > mp;
	for(i=0;i<n;i++){
		cin>>a>>b;
		mp[a]+=b;
	}
	long long count=0;
	for(map<ll,ll >::iterator it=mp.begin(); it!=mp.end(); it++){
		count+=(it->second);
		if(count>=k){
			cout<<it->first<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 4224
n, a, b = map(int, input().split())

allsum = 0

for i in range(1,n+1):
  l = list(str(i))
  li = [int(s) for s in l]
  tmpsum = sum(li)
  #for s in range(0,len(l)):
  #  print(s)
  if ((tmpsum >= a) and (tmpsum <= b)):
    allsum = allsum + i
print(allsum)

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n;
	cin >> n;
	const int mx = 1e6;
	vector<int> cnt(mx + 1);
	int g = 0;
	for(auto i = 0; i < n; ++ i){
		int x;
		cin >> x;
		g = gcd(g, x);
		++ cnt[x];
	}
	for(auto x = 2; x <= mx; ++ x){
		int cur = 0;
		for(auto y = x; y <= mx; y += x){
			cur += cnt[y];
		}
		if(cur >= 2){
			goto NOT_PAIRWISE;
		}
	}
	cout << "pairwise coprime\n";
	return 0;
	NOT_PAIRWISE:;
	g == 1 ? cout << "setwise coprime\n" : cout << "not coprime\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 7164
from sys import stdin

def toYen(btc):
  return btc * 380000.0

N = int(stdin.readline().strip())
total = 0
for i in range(N):
  inp = stdin.readline().split()
  money, currency = float(inp[0]), inp[1]
  if currency == 'JPY':
    total += money
  else:
    total += toYen(money)
    
print(total)

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

int main(){
	string s;
	cin>>s;
	int j=0;
	for(int i=0; i<(s.size()+1)/2; i++){
		if(j==2*(s.size()+1)/2-1)cout<<s[j]<<endl;
		else cout<<s[j];
		j+=2;
	}
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;
const int  INF = 1 << 30;
struct node {
	int x;
	int y;
	int c;
};

bool dis[1010][1010];
int nx[10];
int ny[10];
string maze[1010];
int hmax=1;

int main(void){
	int H,W,n;
	cin >> H >> W >> n;
	rep(i,H) cin >> maze[i];
	node init;
	rep(i,H) rep(j,W){
		if(maze[i][j]=='S'){
			nx[0]=j;
			ny[0]=i;
		}else if(isdigit(maze[i][j])){
			nx[maze[i][j]-'0']=j;
			ny[maze[i][j]-'0']=i;
		}
	}
	int ans=0;
	rep(j,n){
		rep(k,H)rep(l,W) dis[k][l]=false;
		init.x=nx[j];
		init.y=ny[j];
		init.c=0;
		queue <node > q;
		q.push(init);
		int dx[4]={1,0,-1,0};
		int dy[4]={0,1,0,-1};
		while(!q.empty()){
			node cur;
			cur=q.front();q.pop();
			// テァツ渉セテ・ツ慊ィテ、ツスツ催ァツスツョテ」ツ?ョテ・ツ按、テ・ツョツ堙・ツ?ヲテァツ青?
			if(dis[cur.y][cur.x])
				continue;
			else
				dis[cur.y][cur.x]=true;
			if(hmax==(maze[cur.y][cur.x]-'0')){
				ans+=cur.c;
				hmax++;
				break;
			}
			//テ」ツ??ヲツャツ。テ」ツ?ョテァツ環カテヲツ?凝」ツ?クテ」ツ?ョテゥツ?キテァツァツサ
			rep(i,4){
				node next;
				next.x=cur.x+dx[i];
				next.y=cur.y+dy[i];
				next.c=cur.c+1;
				if(0<=next.x&&next.x<W&&0<=next.y&&next.y<H&&maze[next.y][next.x]!='X')
					q.push(next);
			}	
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3256
import java.util.*;
public class Main {
	//定義関数から参照できる変数定義はこの辺
	//static Var_form Var_name;

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		//long Var_name = sc.nextLong();
		int ans=0;
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ary[]=new int[N+1];
		ary[0]=0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		for(int i=1;i<=K;i++){
			ans=ans+ary[i];
		}



		System.out.println(ans);
		//System.out.print(ans);
    }
}

Measured memory_bytes: 30192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    float R;
    cin >> R;
    cout << 2 * 3.141592 * R << endl;

    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b == c + d) cout << "Balanced" << endl;
    else if( a + b < c + d) cout << "Right" << endl;
    else cout << "Left" << endl;
    return 0;
}


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

ans = 0
s = float("inf")
for i in range(n):
  if abs(a - (t-h[i]*0.006)) < s:
    s = abs(a - (t-h[i]*0.006))
    ans = i+1
print(ans)

Measured memory_bytes: 9244
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>

//ABC161B
int main(void) {
  int n, m, k, i, sum=0, cou=0, tmp;
  scanf("%d %d", &n, &m);
  int a[n];
  for(i=0; i<n; i++){
    scanf(" %d", &a[i]);
    sum+=a[i];
  }
  for(i=0; i<n; i++){
    if(a[i]*4*m>=sum) cou++;
  }
  if(cou>=m) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 256
def solve(n, a):
    total = sum(a)
    best = total
    cur = 0
    for i in range(n):
        cur += a[i]
        best = min(best, abs(2*cur - total))
    return best

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

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

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

  if ( (a % 2) == 0 || (b % 2) == 0 ) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }

}
  


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	bool ans = false;
	inc(i, n) { ans |= (a[i] % 2 != 0); }
	
	cout << (ans ? "first" : "second") << endl;
	
	return 0;
}


Measured memory_bytes: 640
// while(cin>>s)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

int main(){
    int i,j;
    string s;
    while(cin>>s){
        int a=0,b=0;
        for(i=0;i<s.size()-2;i++){
            if(s.substr(i,3)=="JOI") a++;
            if(s.substr(i,3)=="IOI") b++;
        }
        cout<<a<<endl;
        cout<<b<<endl;
    }
}


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

string s;
string t;
int n;
int m;
string ans;
int dp[3000+ 1][3000 + 1];

//Recursive approach
string lcs(int i, int j, string ans) {

//cout<<i<< " " <<j<< " "<<ans<<" "<<"  called"<<endl;
	if (i == n || j == m)
	{
		return ans;
	}

	if (s[i] == t[j]) {
		return lcs(i + 1, j + 1, ans + s[i]);
	}

	else {

		string op1 = lcs(i + 1, j, ans);
		string op2 = lcs(i, j + 1, ans);

		if (op1.length() > op2.length())
			return op1;
		else
			return op2;
	}
}

//Dynamic Programming approach

int lcs_bu(int n, int m) {



	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {

			if (s[i - 1] == t[j - 1])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else {

				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

			}
		}
	}
	return dp[n][m];
}

string lcs_td(int i, int j) {

	if(i==0||j==0)
		return "";

	if(s[i-1] == t[j-1])
		return lcs_td(i-1,j-1) + s[i-1];

	if(dp[i][j-1]>dp[i-1][j])
		return lcs_td(i,j-1);
	else
		return lcs_td(i-1,j);


}






int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	cin >> s >> t;
	n = s.length();
	m = t.length();
	//ans="";
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			dp[i][j]=0;

	//cout<<lcs(0,0,ans)<<endl;
	lcs_bu(n,m);
	cout << lcs_td(n, m) << endl;


}

Measured memory_bytes: 39088
fun main(args :Array<String>){
  var input:String?=readLine()
  var nums:List<String> =input!!.split(" ")
  var odd=nums[0].toInt()
  var even=nums[1].toInt()
  var sum:Int =0
  if(odd>1){
    for(i in 1 until odd){
      sum+=i
    }
  }
  if(even>1){
    for(j in 1 until even){
      sum+=j
    }
  }
  println(sum)
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int h[N], cost[N];
  for (int i=0; i<N; i++) cin >> h[i];
  cost[0] = 0;
  for (int i=1; i<N; i++) {
    int min_c = abs(h[i] - h[i-1]) + cost[i-1];
    for (int j=2; j<=K; j++) {
      if (i-j < 0) break;
      int tmp = abs(h[i] - h[i-j]) + cost[i-j];
      if (tmp < min_c) min_c = tmp;
    }
    cost[i] = min_c;
  }
  cout << cost[N-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string KUROE;
  int YUNI, TIERU, OOT = 0;
  cin >> YUNI >> TIERU;
  
  if(YUNI <= 8 && TIERU <= 8){
    cout << "Yay!" << endl;
    }
  else{
    cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    if(A % 2 == 1 or B % 2 == 1 or C % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    if(A == B and B == C) {
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    while(true) {
        cnt++;
        ll tmpA, tmpB, tmpC;
        tmpA = (B + C) / 2;
        tmpB = (C + A) / 2;
        tmpC = (A + B) / 2;
        if(tmpA % 2 == 1 or tmpB % 2 == 1 or tmpC % 2 == 1) {
            cout << cnt << endl;
            return 0;
        }
        A = tmpA;
        B = tmpB;
        C = tmpC;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
const ll inf = (1LL << 60);
 
int n;
 
ll a[100002], dp[100002][2];
 
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
    cin >> n;
 
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
 
    dp[0][0] = a[0];
    dp[0][1] = -inf; //no puedo aplicar la operacion a un solo elemento
    dp[1][0] = a[0] + a[1];
    dp[1][1] = -(a[0] + a[1]);
 
    for(int i = 2; i < n; i++) {
        dp[i][0] = a[i] + a[i - 1] + max(dp[i - 2][0], dp[i - 2][1]);
        dp[i][0] = max(dp[i][0], a[i] + dp[i - 1][1]);
 
        dp[i][1] = -(a[i] + a[i - 1]) + max(dp[i - 2][0], dp[i - 2][1]);
        dp[i][1] = max(dp[i][1], dp[i - 1][1] - a[i] + a[i - 1] * 2);
    }
    cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int N = 200005;
const int M = 1000 * 1000 * 1000 + 7;
using namespace std;
int gcd(int f , int s){if(s==0)return f;else return gcd(s,f%s);}
stack<int> s;
ll ans;
void solve0(ll num){
	ans += num;
	return;
}
void solve1(ll num){
	while(num >= 10){
		ll count = num / 10;
		ll keep = num % 10;
		ans += (count * 10);
		num = keep + count;
	}
	for(int i = 0 ; i < num ; i++)s.push(1);
}
void solve2(ll num){
	while(num >= 10){
		ll count = num / 10;
		ll keep = num % 10;
		ans += (count * 11);
		num = keep + count;
	}
	for(int i = 0 ; i < num ; i++)s.push(2);
}
void solve3(ll num){
	while(num >= 4){
		ll count = num / 4;
		ll keep = num % 4;
		ans += (count * 4);
		num = keep + count;
	}
	for(int i = 0 ; i < num ; i++)s.push(3);
}
void solve4(ll num){
	ll three = 0;
	if(num >= 3){
		ll count = num / 3;
		ll keep = num % 3;
		ans += (count * 3);
		three += (count);
		num = keep;
	}
	for(int i = 0 ; i < num ; i++)s.push(4);
	solve3(three);
}
void solve5(ll num){
	ll too = 0;
	if(num >= 4){
		ll count = num / 4;
		ll keep = num % 4;
		ans += (count * 5);
		too = count;
		num = keep;
	}
	for(int i = 0 ; i < num ; i++)s.push(5);
	solve2(too);
}

void solve6(ll num){
	ll three = 0;
	if(num >= 2){
		ll count = num / 2;
		ll keep = num % 2;
		ans += (count * 2);
		three = count;
		num = keep;
	}
	for(int i = 0 ; i < num ; i++)s.push(6);
	solve3(three);
}

void solve7(ll num){
	ll one = 0;
	if(num >= 4){
		ll count = num / 4;
		ll keep = num % 4;
		ans += (count * 6);
		one = count;
		num = keep;
	}
	for(int i = 0 ; i < num ; i++)s.push(7);
	solve1(one);
}

void solve8(ll num){
	ll seven = 0;
	if(num >= 2){
		ll count = num / 2;
		ll keep = num % 2;
		ans += (count * 2);
		seven = count;
		num = keep;
	}
	for(int i = 0 ; i < num ; i++)s.push(8);
	solve7(seven);
}

void solve9(ll num){
	while(num >= 2){
		ll count = num / 2;
		ll keep = num % 2;
		ans += (count * 2);
		num = count + keep;
	}
	for(int i = 0 ; i < num ; i++)s.push(9);
}

int main(){
	
	int n;cin >> n;
	for(int i = 0 ; i < n ; i++){
		int num; ll temp;
		scanf("%d%lld",&num ,&temp);
		switch(num){
			case 0:solve0(temp);break;
			case 1:solve1(temp);break;
			case 2:solve2(temp);break;
			case 3:solve3(temp);break;
			case 4:solve4(temp);break;
			case 5:solve5(temp);break;
			case 6:solve6(temp);break;
			case 7:solve7(temp);break;
			case 8:solve8(temp);break;
			case 9:solve9(temp);break;
		}
	}
	while(!s.empty()){
		ll curr = s.top();
		s.pop();
		if(s.empty())break;
		ll nex = s.top();
		s.pop();
		ans++;
		ll temp = curr + nex;
		s.push(temp % 10);
		if(temp >= 10){
			s.push(temp / 10);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,n,x,y,z;
	int ans;
	String[] S1,S2;

	Main(){
		// 文字列の入力
		String s1 = sc.next();
		S1 = s1.split("");
		String s2 = sc.next();
		S2 = s2.split("");
		for(int i=0;i<3;i++){
			ans += S1[i].equals(S2[i])?1:0;
		}

		// 出力
		System.out.println(ans);
	}

	public static void main(String[] args){
		new Main();
	}
}

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

typedef long long ll;
#define endl "\n"

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

    int n, q;
    cin>>n;
    vector<int> cnt(1e5);
    vector<int> a(n);
    ll sum=0;
    for (auto &x: a){
    	cin>>x;
    	cnt[x]++;
    	sum+=x;
    }
    cin>>q;
    //count number of b's
	while (q--){
		int b,c;
		cin>>b>>c;
		ll change = cnt[b]*(c-b);
		sum+=change;
		cout<<sum<<endl;
		cnt[c]+=cnt[b];
		cnt[b]=0;
	}
    return 0;
}

Measured memory_bytes: 3868
import collections
d = collections.defaultdict(int)
N = int(input())
for _ in range(N):
  s = input()
  d[s] += 1
M = int(input())
for _ in range(M):
  s = input()
  d[s] -= 1
ret = 0
for k,v in d.items():
  ret = max(ret,v)
print(ret)

Measured memory_bytes: 3316
S = input()
T = input()
Sli = list(S)
Tli = list(T)
cli = []

for i in range(len(Sli) - len(Tli) + 1):
    c = len(Tli)
    for j in range(len(Tli)):
        if Sli[i + j] == Tli[j]:
            c -= 1
    cli.append(c)

print(min(cli))

Measured memory_bytes: 65312
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
    int n;
    cin >> n;
    int now;
    for(int i=1;i<2*n;i++){
        if(i*(i+1)>=2*n){
            now = i;
            break;
        }
    }
    vector<int> ans;
    ans.push_back(now);
    int sum = now;
    for(int i=now-1;i>=1;i--){
        if(sum+i<=n){
            ans.push_back(i);
            sum+=i;
        }
        if(sum==n) break;
    }
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> h(n);
	for (int i=0;i<n;i++){
		cin>>h[i];
	}
	h.push_back(0);
	sort(h.rbegin(), h.rend());
	for (int i=0;i<n+1;i++){
		if (h[i]==i+1){
			int c=0;
			for (int j=i+1;j<n;j++){
				if (h[j]==i+1) c++;
				else break;
			}
			if (c%2==0){
				cout<<"Second"<<endl;
			}
			else{
				cout<<"First"<<endl;
			}
			return 0;
		}
		if (h[i]<i+1){
			int d1=0;
			for (int j=i;j<n;j++){
				if (h[j]==i) d1++;
				else break;
			}
			int d2=h[i-1]-i;
			if (h[i]==i){
				if (d1%2==0&&d2%2==0){
					cout<<"Second"<<endl;
				}
				else {
					cout<<"First"<<endl;
				}
			}
			else {
				if (d2%2==0){
					cout<<"Second"<<endl;
				}
				else {
					cout<<"First"<<endl;
				}
			}
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<27
#define LINF 1LL<<60

/*
<url:>
?????????============================================================
JOI????????????n ??¶?????¶???????????? ?????¶?????? 1 ?????? n ?????§????????????????????????????????????
?????¨???JOI?????§????????¶??????????????¶???????¶??????´??????????????§?????????

????????????????????¶???????¬??????±??£??????????????±??????????????????????????????????????????
JOI??????????????¶????????£????????§???????????????????????? ??¶??¨??¶??????????????????????????¨???????????????????????¢?±±?????????
????????????????????°??¨????????°?????¨????\¨????¨???\???????????????????????¨??????????????£????????????
??????????????????????????¢????????¨????\¨??????????????£?????????????????? ????????????????????¶??????????¶??????§???
????????°??¨????????°????????¶??????????????§????????£??¨??????????????????????¨????????????¢?????????????????¨??§?????????
????????????????¨?????????£??????????????¶????????£????????????????????¨????????\????????´???????????????
????????¨??????????????¶????????£????????????????????¨????????\???????????¨??¢??????????????????????????????
?????????JOI?????§????????¶??¨??¶??????????????¶??°???????????¶???????¬??????¨?????????????§????????????????
?????????????????????????????±??????????????????????????? 
??¢???????????????????????????????????°????????±???????????????????????°???????????????

??\?????¨???????????¢?????¨????\¨?????°???????????????????§????????????¶??????????????±????????????????????¨????????? ??¢????????????????±???????????????°????????????????????????

=================================================================
?§£??¬=============================================================
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, k;
	while (cin >> n >> k, n | k) {
		vector<vector<int>> G(n, vector<int>(n, INF));
		bool update_flag = false;
		for (int i = 0; i < k;i++) {
			int com; cin >> com;
			if (com == 0) {
				int a, b; cin >> a >> b;
				a--; b--;
				if (update_flag) {
					for (int j = 0; j < n;j++) {
						for (int k = 0;k < n;k++) {
							for (int l = 0;l < n;l++) {
								G[k][l] = min(G[k][l], G[k][j] + G[j][l]);
							}
						}
					}
					update_flag = false;
				}
				cout << ((G[a][b] == INF) ? -1 : G[a][b]) << endl;
			}
			else {
				int c, d, e; cin >> c >> d >> e;
				c--; d--;
				if (G[c][d] > e) {
					G[c][d] = G[d][c] = e;
					update_flag = true;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3164
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans = -LINF, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll dp[ohara][4];

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

  cin >> n;
  rep(i, n) cin >> a[i];

  rep(i, n) rep(j, 3) dp[i][j] = -LINF;

  if (n % 2 == 0) {
    for (ll i = n - 2; i >= 0; i -= 2) {
      dp[i][0] = max(dp[i + 2][0], dp[i + 2][1]) + a[i];
      dp[i][1] = dp[i + 2][1] + a[i + 1];
    }
    ans = max(dp[0][0], dp[0][1]);
    Cout(ans);
  } else {
    for (ll i = n - 2; i >= 0; i -= 2) {
      dp[i][0] = max(dp[i + 2][0], dp[i + 2][1]) + a[i];
      dp[i][1] = dp[i + 2][1] + a[i + 1];
      dp[i][2] = max({dp[i + 2][0], dp[i + 2][1], dp[i + 2][2]}) + a[i - 1];
    }
    ans = max({ans, dp[1][0], dp[1][1], dp[1][2]});
    Cout(ans);
  }
  return 0;
}


Measured memory_bytes: 11424
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	map<char, int>mp;
	rep(i, 0, s.size())mp[s[i]]++;
	bool ans = true;
	for (auto p : mp) {
		for (auto q : mp) {
			if (p.first == q.first)continue;
			if (abs(p.second - q.second) > 1)ans = false;
		}
	}
	if (mp.size() != 3) {
		for (auto p : mp) {
			if (p.second > 1)ans = false;
		}
	}
	cout << (ans ? "YES" : "NO") << "\n";

	return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <string>

int main()
{
    std::string s;
    std::cin >> s;

    if (s == "hi" ||
        s == "hihi" || 
        s == "hihihi" || 
        s == "hihihihi" || 
        s == "hihihihihi") {
        
        std::cout << "Yes";
    } else {
        std::cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
char s1[11],s2[11],s3[11];
int L='a'-'A';

scanf("%s", s1);
scanf("%s", s2);
scanf("%s", s3);

putchar(s1[0]-L);
putchar(s2[0]-L);
putchar(s3[0]-L);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll H, W, N, ans[11];
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main()
{
    scanf("%d%d%d", &H, &W, &N);
    set<pair<int, int>> st, br;
    ans[0] = (H - 2) * (W - 2);
    for (int i = 0; i < N; i++)
    {
        int y, x;
        scanf("%d%d", &y, &x);
        br.insert({--y, --x}), st.insert({y, x});
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 1 || ny > H || nx < 1 || nx > W)
                continue;
            st.insert({ny, nx});
        }
    }
    for (auto &p : st)
    {
        ll y = p.first, x = p.second, cnt = 0;
        cnt += (br.find(p) != br.end());
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
            {
                cnt = -1;
                break;
            }
            cnt += (br.find({ny, nx}) != br.end());
        }
        if (cnt != -1)
            ans[cnt]++, ans[0]--;
    }
    for (int i = 0; i < 10; i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 47104
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
for x,y,h in xyh:
    if h>0:
        sx=x
        sy=y
        sh=h
        break
for i in range(101):
    for j in range(101):
        th=abs(i-sx)+abs(j-sy)+sh
        for x,y,h in xyh:
            if h!=max(th-abs(i-x)-abs(j-y),0):
                break
        else:
            break
    else:
        continue
    break
print(i,j,th)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] indexes = new int[n + 1];
		TreeSet<Integer> set = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			indexes[arr[i]] = i;
			set.add(i);
		}
		set.add(n);
		set.add(-1);
		long ans = 0;
		for (int i = n; i >= 1; i--) {
			int idx = indexes[i];
			long left = set.lower(idx) + 1;
			long right = set.higher(idx) - 1;
			ans += (idx - left + 1) * (right - idx + 1) * i;
			set.remove(idx);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 103172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg = 1000000007;
#define ff(i,n) for(i=0;i<n;i++) 
void dfs(ll i,ll vis[],ll p[],vector<vector<ll> > &adj,ll par)
{
	vis[i] = 1;
	p[i] = par;
	ll j;
	for(j=0;j<adj[i].size();j++)
	{
		if(vis[adj[i][j]]==0)
		{
			dfs(adj[i][j],vis,p,adj,i);
		}
	}
}
int main()
{
	ll i,n,k;
	cin>>n>>k;
	ll arr[n];
	ff(i,n)
	   cin>>arr[i];
	for(i=k;i<n;i++)
	{
		if(arr[i]>arr[i-k])
		   cout<<"Yes"<<endl;
		else
		   cout<<"No"<<endl;   	
	}     
	return 0;
} 

Measured memory_bytes: 5156
import sys

sys.setrecursionlimit(100000)

n = int(input())
edges = [[] for _ in range(n)]
color = [0 for _ in range(n - 1)]
for e in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append((b - 1, e))
    edges[b - 1].append((a - 1, e))

def dfs(i, p, pcol):
    col = 1
    ret = 0
    for c, e in edges[i]:
        if c != p:
            if col == pcol:
                col += 1
            color[e] = col
            ret = max(ret, dfs(c, i, col))
            col += 1
    return max(ret, col - 1)

print(dfs(0, -1, -1))
for i in range(n - 1):
    print(color[i])

Measured memory_bytes: 75580
/* ****revpro**** */

#include <iomanip>
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl       '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii        map<ll,ll>
using namespace std;

#define N  100005
long double dp[3000][3000];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        long double p[n+1];
        rep(i,1,n+1)
        cin>>p[i];
        dp[0][0]=1;
        rep(i,1,n+1)
        dp[i][0]=(1-p[i])*dp[i-1][0];
        rep(i,1,n+1)
        {
            rep(j,1,n+1)
            {
                dp[i][j]=p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j];
            }
        }
        long double ans=0;
        rep(i,(n+1)/2,n+1)
            ans+=dp[n][i];

   std::cout << std::fixed;
   std::cout << std::setprecision(14) << ans << '\n';

    }
    return 0;
}

Measured memory_bytes: 140928
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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=1e9+7;

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll x=0;
    ll ans=0;
    rep(i,n){
        if(s[i]=='I') x++;
        if(s[i]=='D') x--;
        ans=max(ans,x);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int r, d, x;
  cin >> r >> d >> x;
  rep(i, 0, 10) {
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define il inline
#define stt static
#define rg register
#define ll long long
#define db double
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define y1 substitute_of_y1
#define DEBUG(x) cerr<<#x" = "<<x<<endl;
using namespace std;

template<typename T> il T rd(){
	T nmb=0;int sgn=0;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')sgn=1;chr=getchar();}
	while(isdigit(chr)){nmb=(nmb<<3)+(nmb<<1)+chr-'0';chr=getchar();}
	return sgn?-nmb:nmb;
}
template<typename T> void wt(T nmb){
	if(nmb>9)wt(nmb/10);
	putchar(nmb%10+'0');
}
template<typename T> il void cmax(T &x,T y){x=x>y?x:y;}
template<typename T> il void cmin(T &x,T y){x=x<y?x:y;}
inline void proc_status(){
	ifstream t ("/proc/self/status");
	cerr<<string(istreambuf_iterator<char>(t),istreambuf_iterator<char>())<<endl;
	/*freopen("/proc/self/status","r",stdin);
	char ch[100];
	while(scanf("%s",ch)!=EOF)cerr<<ch<<endl;*/
}

const int N=410,M=1e5+10;

int n,m;
int a[M][3];
vector<int>f[N];

int Vis[N];

priority_queue<pii>q;

int Flg[N];

il void Sol(int y){
	memset(Vis,0,sizeof Vis);
	Vis[y]=1;
	while(!q.empty())q.pop();
	for(int i=f[y].size()-1;~i;--i){
		int k=f[y][i];
		if(!Vis[a[k][1]])q.push(mp(k,a[k][1]));
		else q.push(mp(k,a[k][2]));
	}
	while(!q.empty()){
		pii t=q.top();
		q.pop();
		if(Vis[t.snd])continue;
		Vis[t.snd]=1;
		for(int i=f[t.snd].size()-1;~i;--i){
			int k=f[t.snd][i];
			if(k>=t.fst)continue;
			if(Vis[a[k][1]]&&Vis[a[k][2]])return;
			if(!Vis[a[k][1]])q.push(mp(k,a[k][1]));
			else q.push(mp(k,a[k][2]));
		}
	}
	Flg[y]=1;
}

bitset<N>S[N];

int main(){
	n=rd<int>(),m=rd<int>();
	for(int k=1;k<=m;++k){
		a[k][1]=rd<int>(),a[k][2]=rd<int>();
		f[a[k][1]].pb(k);
		f[a[k][2]].pb(k);
	}
	for(int i=1;i<=n;++i){
		Sol(i);
		for(int j=1;j<=n;++j)
			S[i][j]=Vis[j];
	}
	int Ans=0;
	for(int i=1;i<n;++i)
		for(int j=i+1;j<=n;++j)
			if(Flg[i]&&Flg[j]&&(S[i]&S[j]).count()==0)
				++Ans;
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  for(int i=1; i<=n; i++){
    int ans=0;
    for(int x=1;x*x<i;x++){
      for(int y=1;y<=x;y++){
        for(int z=1;z<=y;z++){
          if(x*x+y*y+z*z+x*y+y*z+z*x == i){
            if(x==y && y==z) ans+=1;
            else if(x==y || y==z || z==x) ans+=3;
            else ans += 6;
          }
        }
      }
    }
    cout << ans << "\n";
  }

  return 0;
}



Measured memory_bytes: 3168
N = input()

T = [0]*1000
for i in range(1, N+1):
  f = 2
  while i>1:
    if i%f==0:
      T[f] += 1
      i /= f
    else:
      f += 1
ans = 1
for t in T:
  ans *= t+1
  ans %= 10**9+7
print ans


Measured memory_bytes: 2948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
const int MOD=1000000007;
const int INF=1000000000;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

class Parser{
public:

  int number(State &begin)
  {
    int ret=0;
    while(isdigit(*begin))
      {
	ret*=10;
	ret+=*begin-'0';
	begin++;
      }
    return ret;
  }

  int expression(State &begin)
  {
    int ret=term(begin);
    for(;;)
      {
	if(*begin=='+')
	  {
	    begin++;
	    ret+=term(begin);
	  }
	else if(*begin=='-')
	  {
	    begin++;
	    ret-=term(begin);
	  }
	else
	  {
	    break;
	  }
      }
    return ret;
  }

  int term(State &begin)
  {
    int ret=factor(begin);
    for(;;)
      {
	if(*begin=='*')
	  {
	    begin++;
	    ret*=factor(begin);
	  }
	else if(*begin=='/')
	  {
	    begin++;
	    ret/=factor(begin);
	  }
	else
	  {
	    break;
	  }
      }
    return ret;
  }

  int factor(State &begin)
  {
    int ret;
    if(*begin=='(')
      {
	begin++;
        ret=expression(begin);
	begin++;
      }
    else
      {
	ret=number(begin);
      }
    return ret;
  }
};


int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  cin.ignore();
  for(int data=0;data<n;data++)
    {
      Parser ps;
      string s;
      getline(cin,s);
      State begin=s.begin();
      int ans=ps.expression(begin);
      cout << ans << endl;
    }
  return 0;
}



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

void output(int n, int maxnum, string &s){
  if(n==0){
    cout << s << endl;
    return;
  }
  int x = maxnum;
  for(int i=0; i<x; ++i){
    s += 'a'+i;
    maxnum = max(maxnum, i+2);
    output(n-1, maxnum, s);
    s.pop_back();
  }
  return;
}

int main(){
  int n;
  cin >> n;
  string s;
  output(n,1,s);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define N 2000010
#define Mod 1000000007
char s[N];
int fac[N],inv[N];
inline void init(int n) {
    fac[0]=fac[1]=inv[0]=inv[1]=1;
    for (int i=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%Mod;
    for (int i=2;i<=n;i++) inv[i]=1LL*(Mod-Mod/i)*inv[Mod%i]%Mod;
    for (int i=2;i<=n;i++) inv[i]=1LL*inv[i-1]*inv[i]%Mod;
}
inline int Pow(int a,int b,int p=Mod) {
    int res=1;
    for (;b;b>>=1,a=1LL*a*a%p)
        if (b&1) res=1LL*res*a%p;
    return res;
}
inline int C(int n,int m) {
    return 1LL*fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
int main() {
    int n=read(); scanf("%s",s); int m=strlen(s),ans=0; n+=m; init(n);
    for (int i=m;i<=n;i++) (ans+=1LL*Pow(25,i-m)*Pow(26,n-i)%Mod*C(i-1,m-1)%Mod)%=Mod;
    return printf("%d\n",ans),0;
}

Measured memory_bytes: 20396
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0, tmp = 0;
  string s, t;
  cin >> n;
  vlli d(n), e(n - 1);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  rep(i, 1, n)
  {
    a = d[i - 1];
    if (a >= d[i])
    {
      // e[i - 1] = 1;
      count++;
    }
    else
    {
      count = 0;
    }
    ans = max(ans, count);
    // count = 0;
  }
  // rep(i, 1, n - 1)
  // {
  //   if (e[i - 1] == 1 && e[i] == 1)
  //   {
  //     count++;
  //   }
  //   else if (e[i - 1] == 1)
  //   {
  //     count++;
  //   }
  // }
  // if (count > 0)
  // {
  //   cout << count + 1 << endl;
  // }
  // else
  {
    cout << ans << endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
int main(){
    int n;
    cin>>n;
    map<string,int> li;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        li[s]++;
    }
    cout<<li.size()<<endl;
}

Measured memory_bytes: 19068
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define int LL
#define db double
using namespace std;
const int N   = 2e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

int n,a[N],b[N],A[N],B[N],ans;
signed main()
{
	read(n);
	rep(i,1,n) 	read(a[i]);
	rep(i,1,n)  read(b[i]);
	rep(i,0,29)
	{
		int T=1<<i;
		rep(i,1,n) A[i]=a[i]%(T*2),B[i]=b[i]%(T*2);
		sort(B+1,B+1+n);
		int tmp=0;
		rep(i,1,n) 
		{
			int t1=lower_bound(B+1,B+1+n,2*T-A[i])-lower_bound(B+1,B+1+n,T-A[i]);
			int t2=lower_bound(B+1,B+1+n,4*T-A[i])-lower_bound(B+1,B+1+n,3*T-A[i]);
			tmp+=t1+t2;
			tmp&=1;
		}
		ans+=(1<<i)*(tmp&1);
	}
	return printf("%lld",ans),0;
}


Measured memory_bytes: 6528
#include<cstdio>

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

using namespace std;

typedef	unsigned long long	ull;

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

struct Node{
	int p,q,l,r;
	Node(){}
	Node(int P,int Q,int L,int R):p(P),q(Q),l(L),r(R){}
} node[100];

ull dfs(int u){
	if(u==-1)	return 1;

	int p=node[u].p,q=node[u].q,l=node[u].l,r=node[u].r;
	ull wl=dfs(l),wr=dfs(r);
	ull g=gcd(p*wl,q*wr);
	ull m=q*wr/g,n=p*wl/g;

	return m*wl+n*wr;
}

int main(){
	for(int n;scanf("%d",&n),n;){	
		rep(i,n){
			int p,q,l,r;	scanf("%d%d%d%d",&p,&q,&l,&r);
			int g=gcd(p,q);
			node[i]=Node(p/g,q/g,l-1,r-1);
		}

		int root;
		bool b[100]={};
		rep(i,n){
			if(~node[i].l)	b[node[i].l]=true;
			if(~node[i].r)	b[node[i].r]=true;
		}
		rep(i,n)if(!b[i]){ root=i; break; }

		printf("%llu\n",dfs(root));
	}

	return 0;
}

Measured memory_bytes: 0