akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

class LowestCommonAncestor
{
    //2^k >= n
    int n, k;
    vector<vector<int>> g, par;
    vector<int> dis;

    inline void build()
    {
        this->dfs();
        this->setpar();
    }

    void dfs(int v = 0, int p = -1)
    {
        this->par[0][v] = p;
        for (int nv : this->g[v])
        {
            if (nv != p)
            {
                this->dis[nv] = this->dis[v] + 1;
                this->dfs(nv, v);
            }
        }
    }

    void setpar()
    {
        for (int i = 0; i < this->k; i++)
        {
            for (int v = 0; v < this->n; v++)
            {
                if (this->par[i][v] != -1)
                {
                    this->par[i + 1][v] = this->par[i][par[i][v]];
                }
            }
        }
    }

public:
    LowestCommonAncestor(int n_, vector<vector<int>> &g_) : n(n_), g(g_)
    {
        k = log2(n + 1);
        this->par.resize(k + 1, vector<int>(n, -1));
        dis.resize(n);
        this->build();
    }

    int get(int u, int v)
    {
        //dis[u] <= dis[v]
        if (this->dis[u] > this->dis[v])
        {
            swap(u, v);
        }
        int d = this->dis[v] - this->dis[u];
        for (int i = k; i >= 0; i--)
        {
            if (d >> i & 1)
            {
                v = this->par[i][v];
            }
        }
        if (u == v)
        {
            return v;
        }
        for (int i = k; i >= 0; i--)
        {
            if (this->par[i][u] != this->par[i][v])
            {
                u = this->par[i][u];
                v = this->par[i][v];
            }
        }
        return this->par[0][v];
    }
};

int main(void)
{
    int n;
    vector<vector<int>> g;
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n; i++)
    {
        int k;
        cin >> k;
        while (k--)
        {
            int l;
            cin >> l;
            g[i].push_back(l);
            g[l].push_back(i);
        }
    }
    LowestCommonAncestor lca(n, g);
    int q;
    cin >> q;
    while (q--)
    {
        int u, v;
        cin >> u >> v;
        cout << lca.get(u, v) << endl;
    }
}


Measured memory_bytes: 24520
#include<iostream>
#include<cmath>
#include<vector>
#include <iomanip>

using ull = unsigned long long;

struct pos{
	signed int 	x, y, z;

	auto operator-( const pos& other )const->pos{
		pos t{ *this };

		t.x -= other.x;
		t.y -= other.y;
		t.z -= other.z;
		return t;
	}

	auto length()const->decltype(std::sqrt(std::declval<decltype(x)>())){
		return std::sqrt(x * x + y * y + z * z);
	}

	friend 
	auto operator<<( std::ostream& os, const pos& self )->std::ostream&{
		return
			os << "[" << self.x << ", " << self.y << ", " << self.z << "]";
	}

	auto dot(const pos& p)const->decltype( x*x ){
		return x * p.x + y * p.y + z * p.z;
	}

	auto cos( const pos& vec )const->double{
		return dot( vec ) / vec.length() / this->length();
	}
};


struct barrier
{
	pos pos_;
	ull r, l;//
	barrier(const pos&p, ull r_, ull l_)
		:pos_{ p }, r{ r_ }, l{ l_ }{}
};


auto distance( const pos& a, const pos& b ){
	const auto tx = a.x - b.x;
	const auto ty = a.y - b.y;
	const auto tz = a.z - b.z;
	return std::sqrt(
		tx*tx + ty*ty + tz*tz
	);
}

int main(){

	const auto mv = 0.00000001;

	int N{}, Q{};
	std::cin >> N >> Q;

	std::vector<barrier> barriers{};
	for( auto i=0; i < N; ++i )
	{
		int x, y, z, r;
		ull l;
		std::cin >> x>> y>> z>> r>> l;
		barriers.emplace_back( pos{ x,y,z}, r, l  );
		//std::cout << barriers[i].r << "," << barriers[i].l<<"\n";
	}


	std::vector<std::pair<pos, pos>> lines{};
	for( auto i = 0; i < Q; ++i )
	{
		int x, y, z, xx, yy, zz;
		std::cin >> x >> y >> z >> xx >> yy >> zz;
		lines.emplace_back( pos{x,y,z}, pos{ xx,yy,zz } );
	}

	for( const auto& line : lines )
	{
		ull cost{};
		const auto ab = line.second - line.first;// b-a => vec ab
		const auto ba = line.first - line.second;
		for( const auto& b : barriers )
		{

			//cosを見て判定するなら、|AB|が|AP|に比べてとても短いケースを考慮する必要がある
			//(線分ABは短いため点Pを中心とする円Oは接触しないが、点PからABの延長上に垂線を下ろしたときにその長さが円Oの半径より短いときに誤判定する)
			const auto ap = b.pos_ - line.first;
			const auto bp = b.pos_ - line.second;

			const auto cos_pab = ap.cos( ab );
			const auto cos_pba = bp.cos( ba );

			//std::cout << std::setprecision( 16 );
			//std::cout << v2 << "\n";
			//std::cout << inner << ", " << cos_v << "\n";
			//if( -mv < cos_v && cos_v < mv )
			//	continue;

			if( cos_pab <= 0 || cos_pba <= 0 )
				continue;

			const auto theta = std::abs( std::acos( cos_pab ) );
			const auto sin_ = std::sin( theta );
			//std::cout << sin_ << ", " << v2.length() << ", ";
			//std::cout <<  sin_ * v2.length() << "\n";

			cost +=
				(0<= sin_ && sin_ <=mv)  //直線上にある
				|| sin_ * ap.length()-mv <= b.r ? b.l : 0;
		}
		std::cout << cost << "\n";
	}

	return 0;
}




Measured memory_bytes: 3476
while 1:
    n=int(input())
    if n==0:break
    for i in range(n):
        a,b,c=map(int,input().split())
        if a==100 or b==100 or c==100 or a+b>=180 or a+b+c>=240:
            print("A")
        elif a+b+c>=210 or a+b+c>=150 and (a>=80 or b>=80):
            print("B")
        else:
            print("C")


Measured memory_bytes: 5612
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <climits>

using namespace std;

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

const ll MOD = 1000000007;
const ll INF = LLONG_MAX;
const ll MAX_E = 3000;
const ll MAX_V = 2000;

struct edge { ll from, to, cost; };

edge es[MAX_E];

ll d[MAX_V];
ll V, E;

bool solve(int s) {
	for (int i = 0; i < V; i++)d[i] = -INF;
	d[s] = 0;
	ll cnt = 0;
	while (true) {
		bool update = false;
		cnt++;
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != -INF && d[e.to] < d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if (cnt >= V && e.to == V - 1)return false;
			}
		}
		if (!update)break;
		if (cnt > V * 3 + 10) return true;

	}
	return true;
}

int main() {
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		es[i] = { a,b,c };

	}
	if (solve(0)) cout << d[V - 1] << endl;
	else cout << "inf" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, gasto, saldo;
    scanf("%d", &n);
    gasto = n*800;
    if (n < 15)
        printf("%d\n", gasto);
    else{
        saldo = (n / 15) * 200;
        printf("%d\n", gasto - saldo);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	int n;
	cin >> n;
	ll arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	ll dp[n][n];// dp[be][en] is maximum X-Y the current player can get with remaining sequence from be....en
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			dp[i][j] = 0;
	}
	for(int en = 0;en < n;en++){
		for(int be = n-1;be >= 0;be--){
			if(be > en)
				continue;
			if(be == en){
				dp[be][en] = arr[be];
			}
			else{
				dp[be][en] = max(arr[be]-dp[be+1][en],arr[en]-dp[be][en-1]);
			}
		}
	}
	cout << dp[0][n-1] << "\n";
	return 0;
}

Measured memory_bytes: 73972
#include<bits/stdc++.h>
using namespace std;
int main()
{
                int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},n;
                cin>>n;
                n=a[n-1];
                cout<<n;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
typedef struct d{
  unsigned long long id;
  int pid;
}data;
void sortInsertionG(data *a,size_t n,int g){
  /*gはインターバル*/
  int i,j;
  data temp;
  for (i=g;i<n;i++){
    temp=a[i];
    j=i-g;
    while (j>=0&&a[j].id>temp.id){
      a[j+g]=a[j];
      j-=g;
    }
    a[j+g]=temp;
  }
}
void sortShell(data *a,size_t n){
  /* g[m]=g[m+1]*3+1 */
  int i,m;
  m=std::log(2*n+1.0)/std::log(3.0);
  int g[m];
  for (i = 0; i < m; i++)g[i]=(std::pow(3,m-i)-1)/2;
  for (i = 0; i < m; i++) {
    sortInsertionG(a,n,g[i]);
  }
}

int main(){
  int n,m,i,temp,count=1;
  std::cin>>n>>m;
  int p[m],y[m];
  for (i=0;i<m;i++)std::cin>>p[i]>>y[i];
  data a[m];
  for (i=0;i<m;i++){
    a[i].id=p[i]*10000000000+y[i];
    a[i].pid=i;
  }
  sortShell(a,m);
  temp=0;
  for (i=0;i<m;i++){
    if (a[i].id/10000000000==temp){
      count++;
    }else{
      temp=a[i].id/10000000000;
      count=1;
    }
    y[a[i].pid]=count;
  }
  for (i=0;i<m;i++){
    std::cout << std::setfill('0')<<std::setw(6)<<p[i]<<std::setfill('0')<<std::setw(6)<<y[i] << '\n';
  }
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> s;
int main() {
  cin >> N;
  s.resize(N);
  rep(i, N) cin >> s[i];

  ll ans = 0;
  for (int c = 1; c <= N - 1; ++c) {
    ll score = 0;
    vector<bool> used(N, false);
    for (int i = 0; i < N - 1; i += c) {
      if (N - 1 - i - c <= 0) break;
      if (used[i] || used[N - 1 - i] || i == N - 1 - i) break;
      score += ll(s[i]) + s[N - 1 - i];
      used[i] = used[N - 1 - i] = true;
      ans = max(ans, score);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int a;
    cin >> a;
    
    cout << a + a*a + a*a*a << endl;
    

    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

string s,t;

cin>>s>>t;

ll cnt=0;

For(i,0,s.length())
{
    if (s[i]!=t[i])
        cnt+=1;
}

cout<<cnt;

return 0;
}

Measured memory_bytes: 3812
#include<stdio.h>
#include<stdlib.h>
 #include<string.h>
int main(){
  char s[150];
  int i,n,hag;
  scanf("%s",s);
  n=strlen(s);
  for(i=0;i<n;i++){
    if(s[i]!=s[n-i-1]){
      hag++;
    }
  }
   
  printf("%d",hag/2);
  return 0;
}
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	ll Q,H,S,D;
	cin >> Q >> H >> S >> D;
	ll N;
	cin >> N;
	H = min(Q*2,H);
	S = min(S,H*2);
	D = min(D,S*2);
	N*=4;
	ll cost=(N/8)*D+(N%8)/4*S+(N%4)/2*H+(N%2)*Q;
	cout << cost << endl; 
	return 0;
}

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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 500000;
const int mo = 998244353;

int fpm(int x, int y) {
    int res = 1;
    for (; y > 0; y >>= 1) {
        if(y & 1)
            res = 1ll * res * x % mo;
        x = 1ll * x * x % mo;
    }
    return res;
}

int fac[N + 5], inv[N + 5];

inline int binom(int n, int k) {
    if(n < 0 || k < 0 || n < k) return 0;
    return 1ll * fac[n] * inv[k] % mo * inv[n-k] % mo;
}

inline int calc(int x, int y, int t) {
    return (binom(x + y, x) - binom(x + y, y - t) + mo) % mo;
}

void init() {
    fac[0] = 1;
    for (int i = 1; i <= N; ++i) fac[i] = 1ll * fac[i-1] * i % mo;
    inv[N] = fpm(fac[N], mo - 2);
    for (int i = N; i >= 1; --i) inv[i-1] = 1ll * inv[i] * i % mo;
}

int n, k;

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    init();
    read(n), read(k);

    int ans = 0;
    for(int r = k; r * 2 >= k && r >= n; --r) {
        int b = k - r, t = r - n + 1;
        if(r == b) -- b;
        ans = (ans + calc(r, b, t)) % mo;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define M 2001

using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	if (x >= 1 && x <= 9 && y >= 1 && y <= 9)
		cout << x*y << endl;
	else
		cout << -1 << endl;

	return 0;
}

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

int main() {
    int n; double m;
    cin >> n >> m;
    int a[n];
    rep(i, n) cin >> a[i];
    double max = 0;
    rep(i, n){
        max += a[i];
    }
    int ans = 0;
    rep(i, n){
        if(max/(4*m) <= a[i]) ans++;
    }
    cout << ((ans >= m)? "Yes": "No") << endl;

}

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

using namespace std;

using ll = long long;
const ll INF = 1e18;

int main() {
   ios_base::sync_with_stdio(false);
   int N; ll tol, tor;
   cin >> N >> tor >> tol;
   vector<int> P(N + 2);
   for (int i = 1; i <= N; ++i) {
      cin >> P[i];
   }
   P[0] = 0;
   P[N + 1] = N + 1;
   vector<ll> dp(N + 2, INF);
   dp[0] = 0;
   for (int i = 1; i <= N + 1; ++i) {
      int cnt = 0;
      for (int j = i - 1; j >= 0; --j) {
         if (P[j] > P[i]) {
            cnt++;
         } else {
            dp[i] = min(dp[i], dp[j] + tor * cnt + tol * (i - j - 1 - cnt));
         }
      }
   }
   cout << dp[N + 1] << "\n";
   return 0;
}


Measured memory_bytes: 384
#!ruby -nrdate
a=Date;y,m,d=$_.split.map &:to_i
s=((b=a.new(y,m,d))<a.new(1912,7,30))?"meiji #{y-=1867}":(b<a.new(1926,12,25))?"taisho #{y-1911}":(b<a.new(1989,1,8))?"showa #{y-1925}":"heisei #{y-1988}"
puts (b<a.new(1868,9,8))?"pre-"+s[0,5] :s+" #{m} #{d}"

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

int n;
pair<int, int>p[300000];
bool ok(ll t) {
	priority_queue<int>Q; ll sum = 0;
	for (int i = n - 1; i >= n - t + 1; i--) {
		Q.push(p[i].second); sum += p[i].second;
	}
	for (int i = n - t; i >= 0; i--) {
		if (p[i].first*t >= sum + p[i].second)return 1;
		if (!Q.empty() && Q.top() > p[i].second) {
			sum -= Q.top() - p[i].second; Q.pop();
			Q.push(p[i].second);
		}
	}
	return 0;
}
int main() {
	scanf("%d", &n);
	rep(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		p[i] = { b,a };
	}
	sort(p, p + n);
	int a = 0, b = n;
	while (a != b) {
		int t = (a + b) / 2;
		if (b - a == 1)t = b;
		if (ok(t))a = t;
		else b = t - 1;
	}
	printf("%d\n", a);
}

Measured memory_bytes: 8280
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NK = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[] p = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            Array.Sort(p);
            long result = 0;
            for(int j = 0; j < NK[1]; j++)
            {
                result += p[j];
            }
            Console.WriteLine(result);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 28552
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll a[1000007];
int main() {
    ll i, j, k, l, test, n, x, y;
    map<ll,ll> m;

    cin>>n>>k;
    for(i=1;i<=n;i++) cin>>a[i];
    while(k--) {
        cin>>x>>y;
        if(a[x]>a[y]) {
            m[y]=2;
        }
        else if(a[x]==a[y]) {
            m[x]=2;
            m[y]=2;
        }
        else {
            m[x]=2;
        }
    }
    ll c=0;
    for(i=1;i<=n;i++) if(m[i]==2) c++;
    cout<<n-c;
}

Measured memory_bytes: 10664
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define mod 1000000007
#define inf 1e18
#define w(x) int x; cin>>x; while(x--)
using namespace std;
bool sieve[100007];
void sieve_make() 
{
	memset(sieve,true,sizeof(sieve));
	sieve[0]=sieve[1]=false;
	for(int i=2;i*i<=100006;i++)
	{
		if(sieve[i])
		{
			for(int j=2*i;j<=100006;j+=i)
				sieve[j]=false;
		}
	}
}

int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int modexp(int a,int b,int c)
{
	if(a==0) return 0;
	if(b==0) return 1;

	int ans;
	if(b%2==0)
	{
		int small=modexp(a,b/2,c);
		ans=(small*small)%c;
	}
	else
	{
		int small=modexp(a,b-1,c);
		ans=(a%c);
		ans=(small*ans)%c;
	}
	return (ans+c)%c;
}

string rev(string s)
{
	reverse(s.begin(), s.end());
	return s;
}
bool sign(int x)
{
	if(x>0)
		return true;
	return false;
}

int base3(string b)
{
	int ans=0,c=0;
	for(int i=b.length()-1;i>=0;i--)
	{
		ans+=(b[i]-'0')*pow(3,c++);
	}
	return ans;
}
vector<int>adj[100005];

int32_t main()
{
	ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
	
	
	int n,m;
	cin>>n>>m;
	vector<int>ans(n,-1);
	while(m--)
	{
		int a,b;
		cin>>a>>b;
		adj[a-1].push_back(b-1);
		adj[b-1].push_back(a-1);
	}
	bool vis[n];
	memset(vis,false,sizeof vis);
	
	queue<int>q;
	q.push(0);
	vis[0]=true;
	while(!q.empty())
	{
		int t=q.front();
		q.pop();
		for(auto i:adj[t])
		{
			if(!vis[i])
			{
				if(ans[i]==-1)
				ans[i]=t;
				q.push(i);
				vis[i]=true;
			}
		}
	}


	bool ok=true;
	for(int i=1;i<n;i++)
		if(ans[i]==-1)
		{
			ok=false;
			break;
		}

	if(ok)
	{
		cout<<"Yes"<<endl;
		for(int i=1;i<ans.size();i++)
			cout<<ans[i]+1<<endl;
	}
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 13060
#include<iostream>
using namespace std;
int N_MAX=200000;
int main()
{
  int n,k,i;
  int a[N_MAX];
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
    if(i>=k){
      if(a[i]>a[i-k]){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    char a,b;
    cin>>a>>b;
    if((a=='H'&&b=='H')||(a=='D'&&b=='D')){
        cout<<'H'<<endl;
    }else{
        cout<<'D'<<endl;
    }

return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int r =sc.nextInt(),g=sc.nextInt(),b=sc.nextInt();
    int num = 100*r + 10*g +b;
    if(num%4==0){
     System.out.println("YES"); 
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	// Code for B - 1 21
	var a, b string
	fmt.Scanf("%s %s", &a, &b)

	var S float64
	number, _ := strconv.Atoi(a + b)
	S = math.Sqrt(float64(number))

	if math.Round(S) == S {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define si size()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound

#define ask(i,m,n) for(lli i=m;i<n;i++)
#define anket ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
using namespace std;

#define prime1 1000000007
#define prime2 998244353

lli modadd(lli n,lli m , lli mod){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}

lli modsub(lli n,lli m,lli mod){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}

lli modpro(lli n,lli m, lli mod){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}

lli powmod(lli x,lli y,lli mod){
    x %= mod;
    y %= mod;
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}

lli moddiv(lli n,lli m,lli mod){
    //return n/m mod (mod) or n*(m)^-1 mod (mod)
    lli a = powmod(m,mod-2,mod);
    //this is because of fermats thm i.e. a^-1 = a^p-2 mod(p) check
    //multiplying p on both sides
    lli res = modpro(a,n,mod);
    return res;
}




int main() {
	anket;
	lli n;
	cin>>n;
	cout<<(n+1)/2;
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
using LL = long long;
using namespace std;

int main() {
	LL N;
	cin >> N;
	string C;
	cin >> C;
	vector<int> c_i(N);
	LL R_num = 0;
	for (int i = 0; i < N; i++) {
		if (C[i] == 'R') {
			c_i[i] = 0;
			R_num++;
		}
		else {
			c_i[i] = 1;
		}

	}
	int fixed_R = 0;
	for (int i = 0; i < R_num; i++) {
		if (c_i[i] == 0) {
			fixed_R++;
		}
	}
	LL ans = R_num - fixed_R;
	cout << ans << endl;

	return 0;


}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;


// max_rain = 2*A = 2*10^9;
// ans[]=

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

  vector<ll> r(n);

  r[n-1] = a[n-1];
  rep(i,n-1){
    r[n-1] += a[i]*pow(-1,i+1);
  }

  r[0] = 2*a[n-1]-r[n-1];

  for(int i = 1; i<n-1; i++){
    r[i] = 2*a[i-1]-r[i-1];
  }

  rep(i,n) cout << r[i] << " ";
  cout << endl;
  
  
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long lun[100020] = {0,1,2,3,4,5,6,7,8,9};
  long long i = 1, t = 9, k = 10, s = 10, j;

  while(1) {
    for(j = i; j <= t; j++) {
      if (k > 100000) break;

      if(lun[j] % 10==0){
        lun[k] =lun[j]*10;
        lun[k + 1] =lun[j]*10+1; k+=2;
      }
      else if(lun[j] % 10==9){
        lun[k] =lun[j]*10 + 8;
        lun[k + 1] =lun[j]*10+9; k+=2;
      }
      else{
        lun[k] =lun[j]*10 + (lun[j] % 10) - 1;
        lun[k + 1] =lun[j]*10+ (lun[j] % 10); 
        lun[k + 2] =lun[j]*10+ (lun[j] % 10) + 1; 
        k+=3;
      }

    }
      i = t+1;
      t = k-1; 
      if(k > 100000) break;


  }
  long long ans;
  scanf("%lld", &ans);
  printf("%lld", lun[ans]);

  return 0;
}

Measured memory_bytes: 1024
# 解説
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline

class BIT:
    def __init__(self, n):
        #A1 ... AnのBIT(1-indexed)
        self.BIT = [0] * (n + 1)
        self.n = n

    #A1 ~ Aiまでの和 O(logN)
    def query(self, idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx & (-idx)
        return res_sum

    #Ai += x O(logN)
    def add(self, idx, x):
        while idx <= self.n:
            self.BIT[idx] += x
            idx += idx&(-idx)
        return

n, q = map(int, input().split())
a = list(map(int, input().split()))
pi = [-1] * (n + 1)  # 各数について最後に出てきた場所
ps = [[] for i in range(n)]

for i in range(n):
    l = pi[a[i]]
    # 2つ目以降
    if l != -1:
        ps[l].append(i)
    # 1つ目
    pi[a[i]] = i

qs = [[] for i in range(n)]
for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    qs[l].append((r, i))

d = BIT(n)
ans = [0] * q

# x座標を後ろから見ていく
for x in range(n - 1, -1, -1):
    for y in ps[x]:
        d.add(y, 1)
    
    for r, i in qs[x]:
        # r以下のものがans
        ans[i] = (r - x + 1) - d.query(r)

print(*ans)
    

Measured memory_bytes: 241544
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define N 10000

int main(){

int i,j,n,a[N],count=0,count2=0;

scanf("%d",&n);

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

   for(j=2; j<=sqrt(a[i]); j++){

     if(a[i]%j == 0 || a[i]==j*j){
       count = -1;
       break;
     }
   }
   if(count == 0)count2++;
   count = 0;
 }
 printf("%d\n",count2);

 return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, t, a;
  cin >> n >> t >> a;
  double h[n];
  for (int i = 0; i < n; i++)
    cin >> h[i];
  double ans = 114514;
  int cnt;
  for (int i = 0; i < n; i++){
    if (ans > abs(a-t+h[i]*0.006)){
      ans = abs(a-t+h[i]*0.006);
      cnt = i;
    }
  }
  cout << cnt + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    constexpr i64 inf = std::numeric_limits<i64>::max();
    std::cin >> n;
    std::vector<i64> a(n + 1);
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
    }

    std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(5, inf));
    for (int i = 0; i < 5; i++) dp[0][i] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < 5; j++) {
            dp[i - 1][j] = std::min(dp[i - 1][j], dp[i - 1][j - 1]);
        }

        dp[i][0] = std::min(dp[i][0], dp[i - 1][0] + a[i]);
        dp[i][1] = std::min(dp[i][1], dp[i - 1][1] + (a[i] ? a[i] % 2 : 2));
        dp[i][2] = std::min(dp[i][2], dp[i - 1][2] + (a[i] + 1) % 2);
        dp[i][3] = std::min(dp[i][3], dp[i - 1][3] + (a[i] ? a[i] % 2 : 2));
        dp[i][4] = std::min(dp[i][4], dp[i - 1][4] + a[i]);
    }

    i64 ret = inf;
    for (int i = 0; i < 5; i++) ret = std::min(ret, dp[n][i]);
    std::cout << ret << std::endl;

    return 0;
}


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

map<int, int> cnt;
int main(){
	for(int i = 1; i <= 100; i ++)
		for(int j = 1; j <= 100; j ++)
			for(int k = 1; k <= 100; k ++){
				cnt[i*i + j*j + k*k + i*j + j*k + k*i]++;
			}
	int n; cin>>n;
	for(int i = 1;i <=n;i ++)
		cout << cnt[i] << endl;
}

Measured memory_bytes: 5416
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int I = 0; 
 
struct AdjListNode
{
    int dest;
    struct AdjListNode* next;
};
 
struct AdjList
{
    struct AdjListNode *head;  // pointer to head node of list
};
 
struct Graph
{
    int V;
    struct AdjList* array;
};
 
struct AdjListNode* newAdjListNode(int dest)
{
    struct AdjListNode* newNode =
            (struct AdjListNode*) malloc(sizeof(struct AdjListNode));
    newNode->dest = dest;
    newNode->next = NULL;
    return newNode;
}
 
struct Graph* createGraph(int V)
{
    struct Graph* graph = (struct Graph*) malloc(sizeof(struct Graph));
    graph->V = V;
 
    graph->array = (struct AdjList*) malloc(V * sizeof(struct AdjList));
 
    int i;
    for (i = 0; i < V; ++i)
        graph->array[i].head = NULL;
 
    return graph;
}
 
void rdfs(struct Graph* graph, int V, int src, int b[])
{
    struct AdjListNode* n = graph->array[src].head;
    b[src] = I;
    while(n)
    {
        if (b[n->dest] < I) {
            rdfs(graph, V, n->dest, b);
        }
        n = n->next;
    }
}
void dfs(struct Graph* graph, int V, int src, int a[], int b[])
{
    struct AdjListNode* n = graph->array[src].head;
    b[src] = 1;
    while(n)
    {
        if (b[n->dest] == 0) {
            dfs(graph, V, n->dest, a, b);
        }
        n = n->next;
    }
    a[I++] = src;
}
 
void addEdge(struct Graph* graph, int src, int dest)
{
    struct AdjListNode* newNode = newAdjListNode(dest);
    newNode->next = graph->array[src].head;
    graph->array[src].head = newNode;
}
 
void printGraph(struct Graph* graph)
{
    int v;
    for (v = 0; v < graph->V; ++v)
    {
        struct AdjListNode* pCrawl = graph->array[v].head;
        printf("\n Adjacency list of vertex %d\n head ", v);
        while (pCrawl)
        {
            printf("-> %d", pCrawl->dest);
            pCrawl = pCrawl->next;
        }
        printf("\n");
    }
}
 
int main()
{
    int V, E;
    scanf("%d", &V);
    scanf("%d", &E);
    int a[V];
    int b[V];
    int c[V];
    int i, j, k;
    struct Graph* graph = createGraph(V);
    struct Graph* rgraph = createGraph(V);
    for(i = 0; i < E; i++) { 
        scanf("%d", &j);
        scanf("%d", &k);
        addEdge(graph, j, k);
        addEdge(rgraph, k, j);
    }
    for(i = 0; i < V; i++) { 
        a[i] = 0;
        b[i] = 0;
    }
    for(i = 0; i < V; i++) { 
        if (b[i] == 0)
            dfs(graph, V, i, a, b);
    }
    for(i = 0; i < V; i++) { 
        b[i] = 0;
    }
    for(i = V - 1; i > -1; i--) { 
        if (b[a[i]] == 0) {
            rdfs(rgraph, V, a[i], b);
            I--;
        }
    }
    int q;
    scanf("%d", &q);
    for(i = 0; i < q; i++) { 
        scanf("%d", &j);
        scanf("%d", &k);
        printf("%d\n", b[j] == b[k]);
    }
  return 0;
}

Measured memory_bytes: 4796
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

enum struct Type
{
	ROOT,
	INTERNAL,
	LEAF
};

struct OwnNode
{
	int id;
	int parent;
	int depth;
	int height;
	int sibling;
	Type type;
	vector<int> children;
};

OwnNode tree[100001];
bool isChild[100001];
const string typeStr[] = { "root","internal node","leaf" };

int TrackTree(int parentid,int id, int depth)
{
	int height = 0;
	tree[id].parent = parentid;
	tree[id].depth = depth;
	for (int i = 0; i != tree[id].children.size(); i++)
	{
		height = max(height, TrackTree(id, tree[id].children[i], depth + 1));
	}
	if (tree[id].children.size() == 2)
	{
		tree[tree[id].children[0]].sibling = tree[tree[id].children[1]].id;
		tree[tree[id].children[1]].sibling = tree[tree[id].children[0]].id;
	}
	tree[id].height = height;
	return height + 1;
}

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

	for (int i = 0; i < n; i++)
	{
		int id;
		scanf("%d", &id);

		tree[id].id = id;
		tree[id].depth = 0;
		tree[id].sibling = -1;
		tree[id].parent = -1;

		for (int j = 0; j < 2; j++)
		{
			int cid;
			scanf("%d", &cid);
			if (cid == -1)continue;
			tree[id].children.push_back(cid);
			isChild[cid] = true;
		}
	}

	int rootID = -1;
	for (int i = 0; i < n; i++)
	{
		if (!isChild[i])
		{
			rootID = i;
			break;
		}
	}

	TrackTree(-1, rootID, 0);

	for (int i = 0; i < n; i++)
	{
		if (tree[i].parent == -1)
		{
			tree[i].type = Type::ROOT;
		}
		else if (tree[i].children.size() == 0)
		{
			tree[i].type = Type::LEAF;
		}
		else
		{
			tree[i].type = Type::INTERNAL;
		}
	}

	for (int i = 0; i < n; i++)
	{
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", tree[i].id, tree[i].parent, tree[i].sibling,tree[i].children.size(),tree[i].depth, tree[i].height,typeStr[(int)tree[i].type].c_str());
	}

	return 0;
}


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

int main() {
	int R;

	cin >> R;
	
	if (R < 1200) {
		cout << "ABC";
	}
	else if(R < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int h,w,d;
    cin >> h >> w >> d;
    
    if(d%2==1){
        rep(i,h){
            rep(j,w){
                if((i+j)%2==0){
                    cout << 'R';
                }else{
                    cout << 'B';
                }
            }
            cout << endl;
        }
    }else{
        char c[d*2][d*2];
        rep(i,d){
            rep(j,d){
                if(j < d/2) c[i][j] = 'G';
                else c[i][j] = 'Y';
            }
        }
        drep(i,d){
            int l = d - 1 - i;
            int r = i;
            srep(j,l,r+1)c[i][j] = 'R';
            l = i + 1;
            r = d - 2 - i;
            srep(j,l,r+1) c[i][j] = 'B';
        }
        rep(i,d){
            srep(j,d,d*2){
                if(c[i][j-d] == 'G') c[i][j] = 'Y';
                if(c[i][j-d] == 'Y') c[i][j] = 'G';
                if(c[i][j-d] == 'B') c[i][j] = 'R';
                if(c[i][j-d] == 'R') c[i][j] = 'B';
            }
        }
        srep(i,d,d*2){
            rep(j,d*2){
                if(c[i-d][j] == 'G') c[i][j] = 'Y';
                if(c[i-d][j] == 'Y') c[i][j] = 'G';
                if(c[i-d][j] == 'B') c[i][j] = 'R';
                if(c[i-d][j] == 'R') c[i][j] = 'B';
            }
        }


        char ans[h][w];
        rep(i,h){
            rep(j,w){
                cout << c[i%(d*2)][j%(d*2)];
            }
            cout << endl;
        }
    }


    return 0;
}
 
 


Measured memory_bytes: 7496
N=int(input())
S=input()

res=[]
tmp=""
for i in range(N):
    if i==0:
        tmp=S[0]
        res.append(S[0])
    else:
        if(tmp==S[i]):
            continue
        else:
            tmp=S[i]
            res.append(S[i])

print(len(res))

Measured memory_bytes: 3956
// Author - Saikat_7
#include <bits/stdc++.h> 
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define trav(i,cont) for(const auto& i:cont)
#define cs(x) cout<<x<<" "
#define cn(x) cout<<x<<" "<<endl
#define ll long long int
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007 //998244353 
#define inf 1e17
const int mx = 2000005; // 2* (10 to power 5);
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    int tc=1;
    // cin>>tc;
    while(tc-- > 0)
    {		
    		int n,k;
        	cin>>n>>k;
        	ll dp[n+1]={0},arr[n+1]={0};
        	for(int i=1;i<=n;i++)
        	{
        		cin>>arr[i];
        		// cout<<arr[i];
        	}
        	dp[0]=0;
        	dp[1]=0;
        	// cout<<dp[2];
        	//dp[2]=abs(arr[2]-arr[1]);
        	for(int i=2;i<=n;i++)
        	{	ll max1=inf;
        		for(int j=max(1,i-k);j<i;j++)
        		{
        		max1=min(max1,dp[j]+abs(arr[i]-arr[j]));
        		}
        		dp[i]=max1;
        		// cout<<dp[i]<<endl;
        	}
        	cout<<dp[n];

    }
    return 0;
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CMultiplication3 {
public:
    void solve(std::istream &in, std::ostream &out) {
        ll a;
        double b;
        in >> a >> b;
        int bb = (int) round(b * 100);
        ll res = a * bb / 100;
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CMultiplication3 solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3796
n, c, k = map(int, input().split())

t = sorted([int(input()) for i in range(n)])

count = 1
bus = 1
start = t[0]
for i in range(1, n):
    if count == c:
        start = t[i]
        count = 1
        bus += 1
        
    elif start <= t[i] <= start + k:
        count += 1
    else:
        start = t[i]
        bus += 1
        count = 1

print(bus)

Measured memory_bytes: 8280
import math

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

ans=H*W
for i in range(1,H):
	s=i*W
	h=H-i
	t1=(h//2)*W
	t2=math.ceil(h/2)*W
	if all([s,t1,t2]):
		ans=min(ans, max(s,t1,t2)-min(s,t1,t2))
	
	t1=(W//2)*h
	t2=math.ceil(W/2)*h
	if all([s,t1,t2]):
		ans=min(ans, max(s,t1,t2)-min(s,t1,t2))

for i in range(1,W):
	s=i*H
	w=W-i
	t1=(w//2)*H
	t2=math.ceil(w/2)*H
	if all([s,t1,t2]):
		ans=min(ans, max(s,t1,t2)-min(s,t1,t2))
	
	t1=(H//2)*w
	t2=math.ceil(H/2)*w
	if all([s,t1,t2]):
		ans=min(ans, max(s,t1,t2)-min(s,t1,t2))

print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

  private static List<List<Integer>> friend = new ArrayList<>();
  private static List<List<Integer>> block = new ArrayList<>();
  private static List<List<Integer>> connectedGraph = new ArrayList<>();
  private static int[] graphID;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int m = scanner.nextInt();
    int k = scanner.nextInt();
    graphID = new int[n];
    Arrays.fill(graphID, -1);
    for (int i = 0; i < n; i++) {
      friend.add(new ArrayList<>());
      block.add(new ArrayList<>());
    }
    for (int i = 0; i < m; i++) {
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      friend.get(a - 1)
          .add(b - 1);
      friend.get(b - 1)
          .add(a - 1);
    }
    for (int i = 0; i < k; i++) {
      int c = scanner.nextInt();
      int d = scanner.nextInt();
      block.get(c - 1)
          .add(d - 1);
      block.get(d - 1)
          .add(c - 1);
    }

    for (int i = 0; i < n; i++) {
      if (graphID[i] == -1) {
        connectedGraph.add(new ArrayList<>());
        constructConnectedGraph(i);
      }
    }

    for (int i = 0; i < n; i++) {
      final int finalI = i;
      final int finalI1 = i;
      System.out.print(connectedGraph.get(graphID[i])
          .size() - friend.get(i)
          .stream()
          .filter(e -> graphID[e] == graphID[finalI1])
          .count() - block.get(i)
          .stream()
          .filter(e -> graphID[e] == graphID[finalI1])
          .count()
          - 1 + " ");
    }
  }

  private static void constructConnectedGraph(final int p) {
    connectedGraph.get(connectedGraph.size() - 1)
        .add(p);
    graphID[p] = connectedGraph.size() - 1;
    for (int i : friend.get(p)) {
      if (graphID[i] == -1) {
        constructConnectedGraph(i);
      }
    }
  }
}




Measured memory_bytes: 198232
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	int n;
	int a, dp[100001] = {};
	int count = 0;

	cin >> n;
	FOR(i, 1, n) {
		cin >> a;
		dp[a]++;
	}
	FOR(i, 1, 100000) {
		if (dp[i] != 0) {
			count++;
		}
	}

	if (count % 2 == 0) {
		cout << count - 1 << endl;
	}
	else {
		cout << count << endl;
	}
	return 0;
}

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


int main() {

    int d;
    cin >> d;
    string ans;
    if (d == 25) ans = "Christmas";
    else if (d == 24) ans = "Christmas Eve";
    else if (d == 23) ans = "Christmas Eve Eve";
    else if (d == 22) ans = "Christmas Eve Eve Eve";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,z:Integer;
  s:string;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);

    for a := 1 to  Length(s) do
      if s[a]='A' then
        Break;

    for z := Length(s) downto 1 do
      if s[z]='Z' then
        Break;

    Writeln(z-a+1);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 384
local s = io.read()
local function j(z)
  local n = #z
  for i = 1, n do
    if z:sub(i, i) ~= z:sub(n + 1 - i, n + 1 - i) then
      return false
    end
  end
  return true
end

local s1 = s:sub(1, (#s - 1) // 2)
local s2 = s:sub((#s + 3) // 2, #s)
local f = j(s) and j(s1) and j(s2)
print(f and "Yes" or "No")


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

int main() {
    int N, T, A;
    cin >> N >> T >> A;

    int ans;
    double ans_tmp = 1e9;
    for (int i = 1; i <= N; i++) {
        int Hi;
        double tmp;
        cin >> Hi;
        tmp = T - Hi * 0.006;
        if (abs(A - tmp) < abs(A - ans_tmp)) {
            ans = i;
            ans_tmp = tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <cstdio>
#include <utility>

static const size_t H_MAX = 2000000;
static int A[H_MAX+1];

int main() {
  size_t H = 0;
  for (;;) {
    char s[8];
    scanf("%s", s);
    if (s[0] == 'e' && s[1] == 'n')
      return 0;
    if (s[0] == 'i') {
      int k;
      scanf("%d", &k);
      A[++H] = k;
      for (size_t i = H; i / 2 >= 1 && A[i] > A[i/2]; i /= 2)
        std::swap(A[i], A[i/2]);
    } else {
      printf("%d\n", A[1]);
      if (--H) {
        A[1] = A[H+1];
        for (size_t j = 1;;) {
          size_t l = 2 * j, r = 2 * j + 1, k;
          if (l <= H && A[l] > A[j])
            k = l;
          else
            k = j;
          if (r <= H && A[r] > A[k])
            k = r;
          if (j == k)
            break;
          std::swap(A[j], A[k]);
          j = k;
        }
      }
    }
  }
}

Measured memory_bytes: 6568
using System;
using System.Linq;
class program
{
  static void Main(string[] args)
  {
    char[] s = Console.ReadLine().ToArray();
    char start = 'A';
    char end = 'Z';
    int i_start = -1;
    int i_end = 0;
    for (int i = 0;i < s.Length;i++)
    {
      if (i_start == -1)
      {
        if (s[i] == start)
        {
          i_start = i;
        }
      }
      else
      {
        if (s[i] == end)
          i_end = i;
      }
    }
    Console.WriteLine((i_end - i_start) + 1);
  }
}

Measured memory_bytes: 27952
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;
    while (cin>>n,n) {
        vector<int> a(n);
        rep(i,n) cin>>a[i];
        sort(a.begin(), a.end());
        ll ans = 0;
        for (int i = 1; i < n-1; ++i) {
            ans += a[i];
        }
        cout << ans/(n-2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3100