akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main(){
    ll n, k;
    string s;
    cin >> n >> k >> s;
    vector<pair<ll, ll>> v;
    bool f = s[0] == '1';
    ll cnt = 0;
    REP(i, s.size()){
        if(f){
            if(s[i] == '1'){
                cnt++;
            }
            else{
                v.push_back({cnt, 1});
                f = false;
                cnt = 1;
            }
        }
        else{
            if(s[i] == '0'){
                cnt++;
            }
            else{
                v.push_back({cnt, 1});
                f = true;
                cnt = 1;
            }
        }
    }
    v.push_back({cnt, f? 1 : 0});
    if(s[0] == '1'){
        if(k >= v.size() / 2){
            cout << n << endl;
            return 0;
        }
        ll sum = 0;
        REP(i, k * 2 + 1){
            sum += v[i].first;
        }
        ll ans = sum;
        for(ll i = k * 2 + 2; i < v.size(); i += 2){
            sum += v[i].first + v[i - 1].first;
            sum -= v[i - k * 2 - 2].first + v[i - k * 2 - 1].first;
            ans = max(ans, sum);
        }
        if(v.size() % 2 == 0){
            ll l = v.size() - 1;
            sum += v[l].first;
            sum -= v[l - 2 * k - 1].first + v[l - 2 * k].first;
            ans = max(ans, sum);
        }
        cout << ans << endl;
    }
    else{
        if(k >= (v.size() + 1) / 2){
            cout << n << endl;
            return 0;
        }
        ll sum = 0;
        REP(i, k * 2){
            sum += v[i].first;
        }
        ll ans = sum;
        if(k * 2 + 1 < v.size()){
            sum += v[k * 2].first + v[k * 2 + 1].first - v[0].first;
            ans = max(ans, sum);
        }
        for(ll i = k * 2 + 3; i < v.size(); i += 2){
            sum += v[i].first + v[i - 1].first;
            sum -= v[i - k * 2 - 2].first + v[i - k * 2 - 1].first;
            ans = max(ans, sum);
        }
        if(v.size() % 2 == 1){
            ll l = v.size() - 1;
            sum += v[l].first;
            sum -= v[l - 2 * k].first;
            ans = max(ans, sum);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2548
n=int(input())
 
ab = []
for _ in range(n):
    a, b, c = (int(x) for x in input().split())
    ab.append([a, b, c])
 
dp = [[0]*3 for j in range(n+1)]
 
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max([dp[i+1][k], dp[i][j]+ab[i][k]])
 
print(max(dp[n]))


Measured memory_bytes: 104196
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[101],t[101];
    int n,i,j;
    scanf("%d%s%s",&n,s,t);
    for(i=strlen(s);i>0;i--){
        for(j=0;i>j;j++)if(s[strlen(s)-i+j]!=t[j])break;
        if(j==i)break;
    }
    printf("%d",strlen(s)*2-i);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>


int right_side_table[ 6 ][ 6 ] =
{
	//front=
	// 1    2    3    4    5    6
	{ -1 ,  3 ,  5 ,  2 ,  4 , -1 },	//top=1
	{  4 , -1 ,  1 ,  6 , -1 ,  3 },	//2
	{  2 ,  6 , -1 , -1 ,  1 ,  5 },	//3
	{  5 ,  1 , -1 , -1 ,  6 ,  2 },	//4
	{  3 , -1 ,  6 ,  1 , -1 ,  4 },	//5
	{ -1 ,  4 ,  2 ,  5 ,  3 , -1 },	//6
};

int judge( const int* number_table1 , const int* number_table2 , int top , int front , int right )
{
	if( number_table1[ 0 ] != number_table2[ top ] )
	{
		return 0;
	}
	if( number_table1[ 1 ] != number_table2[ front ] )
	{
		return 0;
	}
	if( number_table1[ 2 ] != number_table2[ right ] )
	{
		return 0;
	}
	if( number_table1[ 3 ] != number_table2[ 5 - right ] )
	{
		return 0;
	}
	if( number_table1[ 4 ] != number_table2[ 5 - front ] )
	{
		return 0;
	}
	if( number_table1[ 5 ] != number_table2[ 5 - top ] )
	{
		return 0;
	}
	return 1;
}

int main( int argc , char** argv )
{

    int number_table1[ 6 ];
    scanf( "%d %d %d %d %d %d" ,
        &number_table1[ 0 ] ,
        &number_table1[ 1 ] ,
        &number_table1[ 2 ] ,
        &number_table1[ 3 ] ,
        &number_table1[ 4 ] ,
        &number_table1[ 5 ] );

	int number_table2[ 6 ];
    scanf( "%d %d %d %d %d %d" ,
        &number_table2[ 0 ] ,
        &number_table2[ 1 ] ,
        &number_table2[ 2 ] ,
        &number_table2[ 3 ] ,
        &number_table2[ 4 ] ,
        &number_table2[ 5 ] );
 
	for( int top = 0 ; top < 6 ; top++ )
	{
		for( int front = 0 ; front < 6 ; front++ )
		{
			int right = right_side_table[ top ][ front ] - 1;
			if( right < 0 )
			{
				continue;
			}
			if( judge( number_table1 , number_table2 , top , front , right ) )
			{
				printf( "Yes\n" );
				return 0;
			}
		}
	}
	printf( "No\n" );
	return 0;
}

Measured memory_bytes: 1012
n = gets.chomp.to_i
s = gets.chomp.split("")

wsum = []
esum = []
wsum[0] = 0
esum[n-1] = 0
(n-1).times do |i|
  wsum[i+1] = wsum[i] + (s[i]=="W" ? 1 : 0)
  esum[n-1-(i+1)] = esum[n-1-i] + (s[n-1-i]=="E" ? 1 : 0)
end
max = n
n.times do |i|
  max = wsum[i] + esum[i] if max > wsum[i] + esum[i]
end
printf("%d\n",max)

Measured memory_bytes: 34180
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <utility>

using namespace std;
typedef long long ll;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) < (abs(x-b))) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>a>>b;
	b=b/n*n;
	if(a<=b)cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[50],sum=0,b,c;
    cin>>b;
    cin>>c;
    for(int i=0;i<b; i++)
    {
        cin>>a[i];
    }
    sort(a,a+b);
    for(int i=b-1;i>=(b-c); i--)
    {
        sum=sum+a[i];
    }
    cout<<sum<<endl;


    return 0;
}


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

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

int main() {
  int bingo[3][3],n,b[10];
  rep(i,0,3){
    rep(j,0,3){
      cin >> bingo[i][j];
    }
  }
  
  cin >> n;
  
  rep(i,0,n) cin >> b[i];
  
  bool ans[3][3];
  rep(i,0,3){
    rep(j,0,3) {
      ans[i][j]=false;
      rep(k,0,n){
        if(bingo[i][j]==b[k]) ans[i][j]=true;
      }
    }
  }
  
  bool x=false;
  rep(i,0,3){
    if(ans[i][0]&&ans[i][1]&&ans[i][2]) x=true;
    else if(ans[0][i]&&ans[1][i]&&ans[2][i]) x=true;
  }
  if(ans[0][0]&&ans[1][1]&&ans[2][2]) x=true;
  if(ans[0][2]&&ans[1][1]&&ans[2][0]) x=true;

  if(x) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

class SegTree{
public:
  int N;
  vector<ll> dat;
  ll INF = 1LL << 40;

  //コンストラクタ
  SegTree(int n, ll* a){
    N = 1;
    while(N < n) N *= 2;
    for(int i = 0; i < 2 * N - 1; i++){
      dat.push_back(INF);
    }

    for(int i = 0; i < n; i++){
      int k = i + N - 1;
      dat[k] = a[i];
      while(k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
      }
    }
  }

  //k番目の値(0_indexed)をaに変更
  void update(int k, ll a){
    //葉の節点
    k += N - 1;
    dat[k] = a;
    //登りながら更新
    while(k > 0){
      k = (k - 1) / 2;
      dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  //[a,b)の最小値
  ll query(int a, int b){
    return Query(a, b, 0, 0, N);
  }

  ll Query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return dat[k];
    else{
      ll v1 = Query(a, b, k * 2 + 1, l, (l + r) / 2);
      ll v2 = Query(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(v1, v2);
    }
  }

  void print(){
    for(int i = 0; i < 2 * N - 1; i++){
      cout << "dat[" << i << "] " << dat[i] << endl;
    }
  }
};

int main(){
  int N, Q;
  cin >> N >> Q;
  ll a[N];
  fill(a, a + N, (1LL << 31) - 1);
  SegTree sg = SegTree(N, a);

  vector<ll> ans;
  for(int i = 0; i < Q; i++){
    int com;
    cin >> com;
    if(com == 0){
      int k;
      ll y;
      cin >> k >> y;
      sg.update(k, y);
    } else {
      int x, y;
      cin >> x >> y;
      ans.push_back(sg.query(x, y + 1));
    }
  }

  for(int i = 0; i < ans.size(); i++){
    cout << ans[i] << endl;
  }

  //cout << endl;
  //sg.print();

  //cout << endl;
  //cout << sg.query(0, 3);


  return 0;
}


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

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

int x;
void input() { cin >> x; }
void solve() { cout << (x >= 30 ? "Yes" : "No") << endl; }

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

Measured memory_bytes: 3640
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (W, H, x, y) = get!(u64, u64, u64, u64);
    let ans = (W*H) as f64 / 2f64;
    let mult: u8 = if x as f64 == W as f64 / 2f64 && y as f64 == H as f64 / 2f64 {
        1
    } else {
        0
    };
    println!("{} {}", ans, mult);
}


Measured memory_bytes: 4352
package main

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

//O(N^2)
func SelectionSort(a []int, n int) {
	var minj int //index of min value
	var count int

	for i := 0; i < n; i++ {
		minj = i
		for j := i; j < n; j++ {
			if a[j] < a[minj] {
				minj = j
			}
		}
		if i == minj {
			continue
		} else {
			a[i], a[minj] = a[minj], a[i]
			count++
		}
	}
	for k, p := range a {
		fmt.Print(p)
		if k == len(a)-1 {
			fmt.Printf("\n")
		} else {
			fmt.Print(" ")
		}
	}
	fmt.Println(count)

}

func main(){
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()

	var sl = make([]int, n)
	for i, s := range strings.Split(sc.Text(), " ") {
		sl[i], _ = strconv.Atoi(s)
	}

	SelectionSort(sl, n)
}



Measured memory_bytes: 1140
n, k = gets.split.map &:to_i

def times_challenge(dice, k)
    [0, Math.log2(k.to_f / dice.to_f).ceil.to_i].max
end


ps = 0.0

1.upto(n) do |i|
    ps +=  (1.0 / 2 ** (times_challenge(i, k)) ) * (1.0 / n.to_f)
end

puts ps 

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> p(m);
  rep(i,m) cin >> p[i].first >> p[i].second;
  rep(x,1000) {
    int keta = 1;
    int nx = x/10;
    vector<int> d(1,x%10);
    while (nx) {
      keta++;
      d.push_back(nx%10);
      nx /= 10;
    }
    if (keta != n) continue;
    bool ok = true;
    reverse(d.begin(), d.end());
    rep(i,m) {
      if (d[p[i].first-1] != p[i].second) ok = false;
    }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3608
S=input()
A = ""
B = ""
if len(S)%2 == 0:
    N = len(S)//2-1
else : N = len(S)//2
while True:
    for i in range(N):
        A += S[i]
        B += S[i+N]
    if A == B:
        print(len(A)*2)
        break
    else:
        N -= 1
        A = ""
        B = ""

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

int main() {

    int h, n;
    cin >> h >> n;

    int sum = 0;
    for(int i = 0; i < n; ++i) {
        int p;
        cin >> p;
        sum += p;

    }

    if(sum >= h)
        cout << "Yes";
    else
    {
        cout << "No";
    }
    
    cout << endl;

    return 0;

}

Measured memory_bytes: 256
X, Y = [int(x) for x in input().split(" ")]

x = (4*X-Y)/2
#print(x)

y = (-2*X+Y)/2
#print(y)

if x >= 0 and y >=0 \
   and x.is_integer() \
   and y.is_integer():
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

void search(int x, int *a, int *b) {
  *b = x % 10;
  while (x) {
    *a = x;
    x /= 10;
  }
}

int main(int argc, const char* argv[]) {
  int n, a, b, c, d;
  int count[10][10] = {0};
  int res = 0;
  cin >> n;

  for (int i = 1; i < n + 1; i++) {
    search(i, &a, &b);
    count[a][b]++;
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      res += count[i][j] * count[j][i];
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
$stdin = trim(fgets(STDIN));
 
$fh = floor($stdin / 3600);
$m = ($stdin - $fh*3600) / 60;
$fm = floor($m);
$fs = floor(($stdin - $fh*3600 - $fm*60));
 
$time = "$fh:$fm:$fs";
echo $time;
?>

Measured memory_bytes: 15264
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

vector<int> a;
map<int,int> ma;

int dp[5100][5100] = {0};
int rec(int i, int j) {
    if (dp[i][j] != 0) return dp[i][j];
    int val = a[i] * 2 - a[j];
    if (!ma.count(val)) return 2;
    int k = ma[val];
    int res = rec(k, i) + 1;
    return dp[i][j] = res;
}

int main() {
    int N; cin >> N;
    a.resize(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    
    for (int i = 0; i < N; ++i) ma[a[i]] = i;
    int res = 2;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            res = max(res, rec(i, j));
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 47796
#include<iostream>
#include<algorithm>
using namespace std;
int n, p;
int a[3][100011];
int dp[3][100011];
int main (void) {
	cin>>n;
	for(int i = 0; i < n; i++) cin>>a[0][i]>>a[1][i]>>a[2][i];
	dp[0][0] = a[0][0];
	dp[1][0] = a[1][0];
	dp[2][0] = a[2][0];
	for(int i = 1; i < n; i++){
		dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[0][i];
		dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + a[1][i];
		dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + a[2][i];
	}
	p = dp[0][n - 1];
	if(p < dp[1][n - 1]) p = dp[1][n - 1];
	if(p < dp[2][n - 1]) p = dp[2][n - 1];
	cout<<p;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,t,s1,p;
    cin>>n>>t;
    s1=0;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        cin>>p;
        v.push_back(p);
    }
    for(int i=0;i+1<n;i++)
    {
        if(v[i+1]-v[i]<t) s1+=v[i+1]-v[i];
        else s1+=t;
    }
    s1+=t;
    cout<<s1<<endl;
    return 0;
}




Measured memory_bytes: 1400
#include <stdio.h>


int main()
{
  int i, n;
  scanf("%d", &n);
  int a[n];
  for(i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for(i = n - 1; 0 <= i; i--) {
    printf("%d", a[i]);
    if(0 < i) {
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0,w = 0;
    rep(i,n){
        r += (s[i]=='R');
        w += (s[i]=='W');
    }
    int ans = min(r,w);
    int f = 0,e = n-1;
    int res = 0;
    while(f < e){
        if(s[f]=='W'&&s[e]=='R'){
            swap(s[f],s[e]);
            ++f;
            --e;
            ++res;
        }else if(s[f]=='R'){
            ++f;
        }else if(s[e]=='W'){
            --e;
        }
    }
    cout << min(ans,res) << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

signed main(){
    int a, b, x;
    cin >> a >> b >> x;
    cout << (a <= x && x <= a+b ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb push_back
#define x first
#define y second

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	string s;
	cin >> s;

	int a = 0;

	int ans(0);

	for(int i = 0; i < s.size(); ++i)
	{
		if(((i+1) < s.size()) and s[i] == 'B' and s[i+1] == 'C')
		{
			++i;
			ans += a;
		}
		else if(s[i] == 'A')
			a++;
		else
			a = 0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h> 
using namespace std; 
#include <ext/pb_ds/assoc_container.hpp>  
using namespace __gnu_pbds; 
typedef int tp;
typedef tree<tp,null_type,less<tp>,rb_tree_tag,tree_order_statistics_node_update> oSet; 
#define frt(i, s, t) for (int i = s; i <= t; i++)
#define fr(i, s, t) for (int i = s; i < t; i++)
#define frr(i, s, t) for (int i = s; i >= t; i--)
#define srt(a) sort(a.begin(),a.end());
#define mcp(a,b) memcpy ( a, b, b.size());
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lb lower_bound
#define ub upper_bound
#define prt(i,ans) cout<<"Case #"<<i<<": "<<ans<<endl
#define ld long double

int solve(int t) 
{
   int n;
   cin>>n;
   int v;
   vector<int> cnt(n+1,0);
   frt(x,1,sqrt(n))
   {
      frt(y,1,sqrt(n))
      {
         frt(z,1,sqrt(n))
         {
            v=x*x+y*y+z*z+x*y+y*z+z*x;
            if(v<=n)
            cnt[v]++;
         }
      }
   }
   frt(i,1,n)
   cout<<cnt[i]<<endl;
   return 0;
} 
int main()
{ 
   ios_base::sync_with_stdio(false);cin.tie(NULL);    
   int t=1; 
   //cin>>t; 
   int p=t;
   while(t--) 
   { 
      solve(p-t); 
   } 
   
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
} 


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

#include <atcoder/all>
using namespace atcoder;

constexpr int O = 1e5;
constexpr int K = 100;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (auto& e : s) cin >> e;

  mcf_graph<int, int> graph(K + h * w + 2);
  for (int i = 0; i < K; i++) {
    graph.add_edge(0, 2 + i, 1, 0);
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      graph.add_edge(2 + K + i * w + j, 1, 1, 0);
    }
  }

  vector<pair<int, int>> v;
  vector<vector<bitset<K>>> b(h, vector<bitset<K>>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') continue;
      if (s[i][j] == 'o') {
        b[i][j][v.size()] = true;
        v.push_back({i, j});
      }
      if (i - 1 >= 0) b[i][j] |= b[i - 1][j];
      if (j - 1 >= 0) b[i][j] |= b[i][j - 1];

      for (int k = 0; k < v.size(); k++) {
        if (!b[i][j][k]) continue;
        graph.add_edge(2 + k, 2 + K + i * w + j, 1, O - ((i - v[k].first) + (j - v[k].second)));
      }
    }
  }

  auto r = graph.flow(0, 1);
  cout << O * r.first - r.second << endl;
}


Measured memory_bytes: 7336
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] t = new int[n];
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0; i < n; i++){
		    t[i] = sc.nextInt();
		    x[i] = sc.nextInt();
		    y[i] = sc.nextInt();
		}
		
		// 計算
		String result = "Yes";
		for(int i = 0; i < n; i++){
		    int dx = 0;
		    int dy = 0;
		    int dt = 0;
		    
		    if(i == 0){
		        dx = x[i];
		        dy = y[i];
		        dt = t[i];
		    }else{
		        dx = x[i] - x[i-1];
		        dy = y[i] - y[i-1];
		        dt = t[i] - t[i-1];
		    }
		    
		    int d = abs(dx) + abs(dy);
		    if(d > dt || d%2 != dt%2) result = "No";
		}
		
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 92376
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
char grid[1001][1001];
ll w, h;
struct edge {
  ll to;
  ll cost;
  edge() {}
  edge(ll to_, ll cost_) : to(to_), cost(cost_) {}
};
std::vector<edge> graph[101];

bool in(ll x, ll y) {
  if (x < 0 || y < 0 || x == w || y == h)
    return 0;
  return 1;
}
bool vis[5000];
// O(ElogV)ダイクストラ
ll D[5000];
void Dijkstra(uint32_t s) {
  using P = std::pair<ll, ll>; // cost pos
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;
  fill_all(D, (ll)INF);
  D[s] = 0;
  que.emplace(0, s);
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    const auto &nowpos = p.second;
    const auto &nowcost = p.first;
    vis[nowpos] = 1;
    if (D[nowpos] < nowcost) {
      continue;
    }
    ll x = nowpos % w;
    ll y = nowpos / w;
    REP(i, 4) {
      ll xy[] = {0, 1, 0, -1, 0};
      if (!in(x + xy[i], y + xy[i + 1]))
        continue;
      if (grid[y + xy[i + 1]][x + xy[i]] == '#') {
        continue;
      }
      ll cost = nowcost + 1;
      ll toplace = (y + xy[i + 1]) * w + x + xy[i];
      if (cost < D[toplace]) {
        D[toplace] = cost;
        que.emplace(cost, toplace);
      }
    }
  }
}

int main() {
  cin >> h >> w;
  ll cnt = 0;
  REP(i, h) {
    REP(j, w) {
      cin >> grid[i][j];
      cnt += (grid[i][j] == '#');
    }
  }
  Dijkstra(0);
  if (!vis[w * h - 1])
    cout << -1 << endl;
  else
    cout << w * h - D[w * h - 1] - cnt - 1 << endl;
}


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

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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int d = log10(i);
        if (!(d & 1)) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define llu long long unsigned
#define ll long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define ull unsigned long long int
#define pii pair<ll,ll>
#define vll vector<ll>
#define vp vector<pii>
#define mp make_pair
#define lb "\n"
#define ins insert
#define fon(i,n) for(int i = 0;i<n;i++)
#define foa(i,a) for(auto i = a.begin();i!=a.end();i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 100000007
#define sz size
#define len length
ll max(ll x,ll y){if(x>y)return x;else return y;}
ll min(ll x,ll y){if(x>y)return y;else return x;}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
ll i,j,k,m,n,q,p;
string s;
cin>>s;
if((s[5]==s[4])&&(s[3]==s[2]))
    cout<<"Yes";
else
    cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

#define rep1(i,x) for(int i=1;i<=(x);++i)

int a[100001];
int memo[100001];
int start[100001];

int main()
{
	int n, k;
	while (scanf("%d %d", &n, &k), n || k) {
		memset(a, 0, sizeof(a));
		memset(memo, 0, sizeof(memo));
		memset(start, 0, sizeof(start));

		bool f = false;

		rep1(i, k) {
			int tmp; scanf("%d", &tmp);
			if (tmp == 0) f = true;
			else a[tmp] = true;
		}

		rep1(i, n) {
			if (a[i]) {
				if (i - 1 >= 0 && a[i - 1]) {
					start[i] = start[i - 1];
					memo[start[i]]++;
				} else {
					start[i] = i;
					memo[start[i]]++;
				}
			}
		}

		int ma = 0;
		int now = -1;

		rep1(i, n) {
			if (a[i]) {
				if (now == start[i]) continue;
				if (ma < memo[start[i]]) {
					ma = memo[start[i]];
					now = start[i];
				}
			} else if (f) {
				int v;
				if (i + 1 <= n && a[i - 1] && a[i + 1]) {
					v = memo[start[i - 1]] + memo[start[i + 1]] + 1;
					if (ma < v) {
						ma = v;
						now = start[i + 1];
					}
				} else if (a[i - 1]) {
					v = memo[start[i - 1]] + 1;
					if (ma < v) {
						ma = v;
						now = start[i - 1];
					}
				} else if (i + 1 <= n && a[i + 1]) {
					v = memo[start[i + 1]] + 1;
					if (ma < v) {
						ma = v;
						now = start[i + 1];
					}
				}
			}
		}

		printf("%d\n", ma);
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;

ll n;
vector<string> s;

ll dfs(ll& i, ll d){
  char e = s[i][s[i].size()-1];
  // cerr << e << endl;
  i++;
  if(e >= '0' && e <= '9') return (e-'0');
  else{
    ll ret;
    if(e == '+'){
      ret = 0;
      while(i < n && s[i].size() == d+1){
        ret += dfs(i, d+1);
      }
    }else if(e == '*'){
      ret = 1;
      while(i < n && s[i].size() == d+1){
        ret *= dfs(i, d+1);
      }
    }
    // cerr << i << " " << ret << endl;
    return ret;
  }
}

int main(){
  while(cin >> n){
    if(n == 0) return 0;
    s = vector<string>(n);
    for(ll i = 0;i < n;i++){
      cin >> s[i];
    }
    ll i = 0;
    cout << dfs(i, 1) << endl;
  }
}



Measured memory_bytes: 3232
use proconio::{fastout, input, marker::Chars};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        s: Chars
    }
    let s: Vec<char> = s;
    let sum: usize = s
        .iter()
        .fold(0, |sum, &i| sum + i.to_string().parse::<usize>().unwrap());
    println!("{}", if sum % 9 == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 3044
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

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

		List<Integer> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			int h = sc.nextInt();
			list.add(h);
		}

		list.sort((a, b) -> a - b);

		int sub = Integer.MAX_VALUE;

		for (int i = 0; i <= n - k; i++) {
			int max = 0;
			int min = Integer.MAX_VALUE;

			min = list.get(i);
			max = list.get(i + k - 1);

			if (sub > max - min) {
				sub = max - min;
			}

		}
		System.out.println(sub);

		sc.close();
	}

}


Measured memory_bytes: 63256
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007


int32_t main()
{

    int n;
    cin>>n;
    string s;
    cin>>s;
    int r = 0, g = 0, b = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  int sum = r * g * b;
  //cout << sum << endl;
 
  for(int i = 0; i < n-2; i++){
    for(int j = i+1; j < n-1; j++){
      if(j+j-i < n && s[i] != s[j] && s[j] != s[j+j-i] && s[j+j-i] != s[i]) sum--;
    }
  }
  cout << sum << endl;
  return 0;
}
  

Measured memory_bytes: 3628
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	string s;
	cin >> s;

	sort(begin(s), end(s));
	cout << (s == "abc" ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	static int dp[] = new int[100100];
	static ArrayList<ArrayList<Integer>> edge = new ArrayList<>();
	static boolean used[];

	static ArrayList<Integer> ans = new ArrayList<>();

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int N = Integer.parseInt(str[0]);
		int M = Integer.parseInt(str[1]);

		used = new boolean[N];

		for (int i = 0; i < N; i++) {
			edge.add(new ArrayList<>());
		}

		for (int i = 0; i < M; i++) {
			str = br.readLine().split(" ");
			int x = Integer.parseInt(str[0]) - 1;
			int y = Integer.parseInt(str[1]) - 1;
			edge.get(x).add(y);
		}

		int ans = 0;
		for (int i = 0; i < N; i++) {
			visit(i);
			ans = Math.max(dp[i], ans);
		}
		System.out.println(ans);
	}

	static void visit(int now) {
		if (!used[now]) {
			used[now] = true;
			for (int i : edge.get(now)) {
				visit(i);
				dp[now] = Math.max(dp[now], dp[i] + 1);
			}
		}
	}
}


Measured memory_bytes: 58120
#define _USE_MATH_DEFINES  
#include <cmath>
#include<iostream>
#include<cstdio>
using namespace std;

int main(void) {
	double r;
	cin >> r;
	printf("%.10f %.10f\n", r * r * M_PI, 2.0 * r * M_PI);
	return 0;
}


Measured memory_bytes: 3280
#include<iostream>
using namespace std;
#include<cmath>
int main()
{
    int n;
    cin>>n;
    long double k;
    cin>>k;
    int ans=0;
    while(n--) {
        long double l,r,c,d;
        cin>>l>>r;
        c=(l*l);
        d=r*r;
        long double h=sqrtl(c+d);
        if(h<=k)ans++;
        
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3848
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int digit_ret(int x) {
    int digit_cnt = 0;
    while(x > 0) {
        x /= 10;
        digit_cnt++;
    }
    return digit_cnt;
}
int main() {
    int N; cin >> N;
    int count = 0;
    for (int i = N; i >= 1 ; --i) {
        if (digit_ret(i) % 2 != 0) count++;
    }
    printf("%d\n", count);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    map<int,int> mp;
    REP(i,N){
        int a;
        cin>>a;
        if(a%4==0) mp[4]++;
        else if(a%4==2) mp[2]++;
        else mp[1]++;
    }
    int flag = 0;
    REP(i,N){
        if(flag==0){
            if(mp[1]>0){
                mp[1]--;
                flag=1;
                continue;
            }
            else if(mp[2]>0){
                mp[2]--;
                flag=2;
                continue;
            }
            else break;
        }
        else if(flag==1){
            if(mp[4]>0){
                mp[4]--;
                flag=0;
                continue;
            }
            else{
                cout<<"No"<<endl;
                return 0;
            }
        }
        else if(flag==2){
            if(mp[2]>0){
                mp[2]--;
                continue;
            }
            else if(mp[4]>0){
                mp[4]--;
                flag=0;
                continue;
            }
            else{
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define H 500
 
int A[H],n;
 
int main(void){
 
  int k,p,l,r,i;
 
  scanf("%d",&n);
 
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
 
  for(i=1;i<=n;i++){
    k = A[i];
    p = A[i/2];
    l = A[2*i];
    r = A[(2*i)+1];
 
    printf("node %d: key = %d, ",i,k);
    if(p!=0 && i != 1) printf("parent key = %d, ",p);
    if(l!=0) printf("left key = %d, ",l);
    else{
      printf("\n");
      continue;
    }
    if(r!=0)  printf("right key = %d, ",r);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
const int N=2e5+100;
ll a[N];
ll koj[N];
ll dp[N];
int32_t main(){
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        koj[a[i]]=i;
    }
    ll ma=0;
    for (int i=n;i>0;i--){
        if (koj[a[i]+1]>i){
            dp[i]=dp[koj[a[i]+1]];
        }
        dp[i]++;
     //   cout << i << " " << dp[i] << " " << koj[a[i]+1] << endl;
        ma=max(ma,dp[i]);
    }
    cout << n-ma;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
struct hopcroft{
	vector<int> dist, pair_l, pair_r;
	vector<bool> seen;
	vector<vector<int>> to;
	int n1, n2;
	hopcroft(int n1, int n2) : n1(n1), n2(n2){
		to.resize(n1);
		pair_l.assign(n1, -1);
		pair_r.assign(n2, -1);
		dist.resize(n1);
		seen.resize(n1);
	}
	void add_edge(int u, int v){
		to[u].push_back(v);
	}
	bool bfs(){
		fill(dist.begin(), dist.end(), -1);
		queue<int> q;
		for (int i = 0; i < n1; i++){
			if (pair_l[i] == -1){
				dist[i] = 0;
				q.push(i);
			}
		}
		bool reach_minus = false;
		while (!q.empty()){
			int u = q.front();
			q.pop();
			for (int adj : to[u]){
				int radj = pair_r[adj];
				if (radj == -1){
					reach_minus = true;
				} else if (dist[radj] == -1){
					dist[radj] = dist[u] + 1;
					q.push(radj);
				}
			}
		}
		return reach_minus;
	}
	bool dfs(int u){
		seen[u] = true;
		for (int adj : to[u]){
			int radj = pair_r[adj];
			if (radj == -1 || (!seen[radj] && dist[radj] == dist[u] + 1 && dfs(radj))){
				pair_l[u] = adj;
				pair_r[adj] = u;
				return true;
			}
		}
		return false;
	}
	int max_matching(){
		int res = 0;
		while (bfs()){
			fill(seen.begin(), seen.end(), false);
			for (int i = 0; i < n1; i++)
				if (pair_l[i] == -1 && dfs(i))
					res++;
		}
		return res;
	}
};
int main(){
	int n; cin >> n;
	hopcroft hop(n, n - 1);
	vector<int> pu(n), pv(n);
	for(int i = 0; i < n - 1; i++){
		int x; cin >> x;
		for(int j = 0; j < x; j++){
			int y; cin >> y; y--;
			hop.add_edge(y, i);
		}
	}
	auto bad = [](){
		cout << -1 << endl;
		exit(0);
	};
	int mx = hop.max_matching();
	if(mx != n - 1) bad();
	vector<int> seen(n, -2);
	queue<int> q;
	int st = -1;
	for(int i = 0; i < n; i++) if(hop.pair_l[i] == -1) st = i;
	if(st == -1) bad();
	q.push(st); seen[st] = -1;
	while(!q.empty()){
		int u = q.front(); q.pop();
		for(int v : hop.to[u]){
			int nv = hop.pair_r[v];
			if(nv != -1 && seen[nv] == -2){
				pu[v] = nv;
				pv[v] = u;
				seen[nv] = u;
				q.push(nv);
			}
		}
	}
	for(int i = 0; i < n; i++) if(seen[i] == -2) bad();
	for(int i = 0; i < n - 1; i++) cout << pu[i] + 1 << " " << pv[i] + 1 << endl;
	return 0;
}


Measured memory_bytes: 11108
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Main m = new Main();
        m.q3();

    }

    void q3()
    {
        Scanner scan = new Scanner(System.in);
        int N = Integer.parseInt(scan.next());
        int[] a = new int[N-1];
        int[] answer = new int[N];
        for(int i = 0; i < N;i++)
        {
            answer[i] = 0;
        }

        for(int i = 0 ; i < N-1;i++)
        {
            answer[Integer.parseInt(scan.next()) - 1] += 1;
        }

        for(int i = 0; i < N; i++){
            System.out.println(answer[i]);
        }
    }


}


Measured memory_bytes: 60464
/*
  KUNAL ANAND
  MNNIT ALLAHABAD
*/  
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define debug1(x) cout << # x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define debug3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << endl;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
const ll INF=1e14;
const ll mod=1e9+7;
ll dp[100005][3],ans=LLONG_MIN,var=0;
vector<ll>graph[100005];
ll nod_val[100005];
ll power(ll x,ll y)
{
    if(y==0)
        return 1;
    ll a=power(x,y/2);
    a=(a*a);
    if(y%2)
        a=(a*x);
    return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t,x;
    ll i,j,k,a,b,n,m,q,y,flag=0,c,d,sum=0,cr=0,maxi=0,cl=0,temp,curr,l,r,sum1,sum2,sum3,low,high,mid;
    cin >> n;
    ll ans=n*n*n;
    cout << ans << endl;  
    return 0;
}    

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> input(n);
  for(int i=0;i<n;i++) cin >> input[i];
  vector<int> a = input;
  sort(a.begin(), a.end());
  map<int, int> b;
  for(int i=0;i<n;i++) {
    if(i % 2 == 0) b[a[i]] = 0;
    else b[a[i]] = 1;
  }
  int ans = 0;
  for(int i=0;i<n;i++) {
    if(i % 2 == 1 && b[input[i]] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


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


class UnionFind(object):
    '''Represents a data structure that tracks a set of elements partitioned
       into a number of disjoint (non-overlapping) subsets.
    Landau notation: O(α(n)), where α(n) is the inverse Ackermann function.
    See:
    https://www.youtube.com/watch?v=zV3Ul2pA2Fw
    https://en.wikipedia.org/wiki/Disjoint-set_data_structure
    https://atcoder.jp/contests/abc120/submissions/4444942
    '''

    def __init__(self, number_count: int):
        '''
        Args:
            number_count: The size of elements (greater than 2).
        '''
        self.parent_numbers = [-1 for _ in range(number_count)]

    def find_root(self, number: int) -> int:
        '''Follows the chain of parent pointers from number up the tree until
           it reaches a root element, whose parent is itself.
        Args:
            number: The trees id (0-index).
        Returns:
            The index of a root element.
        '''
        if self.parent_numbers[number] < 0:
            return number

        self.parent_numbers[number] = self.find_root(self.parent_numbers[number])
        return self.parent_numbers[number]

    def get_group_size(self, number: int) -> int:
        '''
        Args:
            number: The trees id (0-index).
        Returns:
            The size of group.
        '''
        return -self.parent_numbers[self.find_root(number)]

    def is_same_group(self, number_x: int, number_y: int) -> bool:
        '''Represents the roots of tree number_x and number_y are in the same
           group.
        Args:
            number_x: The trees x (0-index).
            number_y: The trees y (0-index).
        '''
        return self.find_root(number_x) == self.find_root(number_y)

    def merge_if_needs(self, number_x: int, number_y: int) -> bool:
        '''Uses find_root to determine the roots of the tree number_x and
           number_y belong to. If the roots are distinct, the trees are combined
           by attaching the roots of one to the root of the other.
        Args:
            number_x: The trees x (0-index).
            number_y: The trees y (0-index).
        '''
        x = self.find_root(number_x)
        y = self.find_root(number_y)

        if x == y:
            return False

        if self.get_group_size(x) >= self.get_group_size(y):
            self.parent_numbers[x] += self.parent_numbers[y]
            self.parent_numbers[y] = x
        else:
            self.parent_numbers[y] += self.parent_numbers[x]
            self.parent_numbers[x] = y
        return True


def main():
    n, q = map(int, input().split())
    uf = UnionFind(n)

    for i in range(q):
        ti, ui, vi = map(int, input().split())

        if ti == 0:
            uf.merge_if_needs(ui, vi)
        else:
            if uf.is_same_group(ui, vi):
                print(1)
            else:
                print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11768
#create date: 2020-06-27 21:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    a = ni()
    print(a + a**2 + a**3)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007
//////////////////////////////////////////

int main(){
  ini(a,b,c);
  out(a==b&&b==c ? "Yes" : "No");
}

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

using namespace std;

const int inf = 1000000000;

long long s;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> s;
    long long k = s / inf;
    long long b = s % inf;
    long long x3 = inf;
    long long y2 = k;
    long long x2 = 0;
    long long y3 = 0;
    if (b) {
        b = inf - b;
        ++y2;
        x2 = 1;
        y3 = b;
    }
    cout << 0 << " " << 0 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    //cout << -1LL * x2 * y3 + 1LL * x3 * y2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
using namespace std;

int main(void)
{
	int A, B, K;
	int D;
	scanf("%d%d%d", &A, &B, &K);
	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 == 1)
				A = A - 1;
			A = A / 2;
			B = B + A;
		}
		else {
			if (B % 2 == 1)
				B = B - 1;
			B = B / 2;
			A = A + B;
		}
	}

	printf("%d %d", A, B);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve(){
   ll n,a,b;
   cin>>n>>a>>b;
   if((b/n)*n>=a)
    cout<<"OK";
   else cout<<"NG";
}



int main(){
   ll t=1;
   //cin>>t;
   while(t--){
    solve();
    cout<<endl;
   }
}


Measured memory_bytes: 3624