akhauriyash/Code-Regression huggingface dataset:
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n;
map<int,int> factor;
int th,fi,fif,tw,sv;

void fact(int i){
    if (i == 1) return;
    int v = sqrt(i) + 10;
    FOR(c,2,v+1){
        if(i%c == 0){
            factor[c]++;
            return fact(i/c);
        }
    }
    factor[i]++;
}

signed main(){
    cin >> n;
    REPS(i,n) fact(i);
    //75 3,5,5 / 15,5 / 25,3 / 75
    for(auto pv:factor){
        auto u = pv.first;
        auto v = pv.second;
        // cerr << u << " " << v << endl;
        th += v >= 2;
        fi += v >= 4;
        fif += v >= 14;
        tw += v >= 24;
        sv += v >= 74;
    }
    int tff = fi * (fi-1) * (fi-2) / 2 + (th-fi) * fi * (fi-1) /2;
    int fiff = fif * (fif-1) + (fi-fif) * fif;
    int twt = tw * (tw-1) + (th-tw) * tw;
    
    cerr << th << " " << fi << " " << fif << " " << tw << " " << sv << endl;
    cout << tff + fiff + twt + sv << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 
#define JUUHATIPLUS 1000000000000000001 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string S;
    cin >> S;
    if(S == "MON")
        cout << 6 << endl;
    else if(S == "TUE")
        cout << 5 << endl;
    else if(S == "WED")
        cout << 4 << endl;
    else if(S == "THU")
        cout << 3 << endl;
    else if(S == "FRI")
        cout <<  2 << endl;
    else if(S == "SAT")
        cout << 1 << endl;
    else
    {
        cout << 7 << endl;
    }
    
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main (void)
{
	int N;
	cin >> N;
	vector<long> L;
	L.resize (N);
	for (auto &e: L)
		cin >> e;

	sort (L.begin (), L.end ());
	long sum = 0, count = 0;
	
	for (int i = 0; i < N; i++)
		for (int j = i+1; j < N; j++)
		{
			if (L[i] == L[j])
				continue;
			long sum = L [i] + L [j];
			for (int k = j+1; k < N && L [k] < sum; k++)
			{
				if (L [k] == L [j])
					continue;
				count++;
			}
		}
	
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3604
n,m=map(int,input().split())
array=[]
for i in range(n):
    k=input().split()
    k=list(map(int,k))
    array.append(k[1:])
items=[]
s=0
for v in array:
    for item in v:
        items.append(item)  
for i in range(1,m+1):
    cnt=0
    for j in range(len(items)):
        if items[j]==i:
            cnt+=1
    if cnt==n:
        s+=1
print(s)        
#print(items)

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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(int i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define f(n)                for (ll i=0;i<n;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define N                   100005
ll MOD=pow(10,9)+7;
ll INF=1ll<<60;

int main()
{
    int n;
    scanf("%d",&n);
    int h[n+1];
    rep(i,1,n+1)
    scanf("%d",&h[i]);
    ll dp[n+1];
    mem(dp,0);
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    rep(i,3,n+1)
    {
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }
    printf("%lld",dp[n]);
}


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

int main()
{
  ll n,i;
  cin>>n;
  ll arr[n];
  for(i=0; i<n; i++)
    cin>>arr[i];
  sort(arr, arr+n);
  ll sum=arr[n-1];
  ll c=1;
  ll counter=0;
  i=n-2;
  while(i>=0)
  {
    if(c>=n-1)
      break;
    else
    {
      sum+=arr[i];
      c++;
      counter++;
      if(counter==2)
      {
        counter=0;
        i--;
      }
    } 
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 5200
N, A, B = map(int, input().split())
S = input()
a = 0
b = 0
for s in S:
    if s == "c":
        print("No")
    elif s == "a":
        if a < A + B:
            print("Yes")
            a += 1
        else:
            print("No")
    else:
        b += 1
        if a < A + B and b <= B:
            a += 1
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int tmp;
  int ans = x + n;
  rep (i, n) {
    cin >> tmp;
    for (int j = 1; j <= d; ++j) {
      if (d < j) break;
      if (d >= j * tmp + 1) ans++;
    }
  }
  P(ans);

  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);

    string s, t;

    cin >> s >> t;

    cout << (s == t.substr(0, s.size()) ? "Yes" : "No") << "\n";

    return 0;
}


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

const int maxi = 522;
int c[maxi], s[maxi], f[maxi], n;

int solve(int pos, int time) {
    if(pos == n) return time;

    int ret = max(time, s[pos]);
    ret = (ret + f[pos] - 1) / f[pos]*f[pos] + c[pos];

    //cout<<pos<<" "<<ret<<" "<<time<<endl;
    return solve(pos + 1, ret);
}

int main() {
    cin>>n;

    for(int i=1; i<n; i++) {
        cin>>c[i]>>s[i]>>f[i];
    }

    //cout<<solve(1, 0)<<endl;
    for(int i=1; i<=n; i++) {
        cout<<solve(i, 0)<<endl;
    }

    return 0;
}


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

int mod = 1000000007;
int n;
int a[100000];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int cnt[3] = {0, 0, 0};
	int ans = 1;
	
	rep(i, n) {
		int c = 0;
		rep(j, 3) if (a[i] == cnt[j]) c++;
		if (c == 0) { cout << 0 << endl; return 0; }
		
		ans *= c;
		ans %= mod;
		
		rep(j, 3) if (a[i] == cnt[j]) break;
		cnt[j]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

int minimum_steiner_tree(const vector<int>& T, const vector<vector<int> > &g) {
  const int n = g.size();
  const int numT = T.size();
  if (numT <= 1) return 0;

  vector<vector<int> > d(g); // all-pair shortest
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        d[i][j] = min( d[i][j], d[i][k] + d[k][j] );

  int OPT[(1 << numT)][n];
  for (int S = 0; S < (1 << numT); ++S)
    for (int x = 0; x < n; ++x)
      OPT[S][x] = inf;

  for (int p = 0; p < numT; ++p) // trivial case
    for (int q = 0; q < n; ++q)
      OPT[1 << p][q] = d[T[p]][q];

  for (int S = 1; S < (1 << numT); ++S) { // DP step
    if (!(S & (S-1))) continue;
    for (int p = 0; p < n; ++p)
      for (int E = 0; E < S; ++E)
        if ((E | S) == S)
          OPT[S][p] = min( OPT[S][p], OPT[E][p] + OPT[S-E][p] );
    for (int p = 0; p < n; ++p)
      for (int q = 0; q < n; ++q)
        OPT[S][p] = min( OPT[S][p], OPT[S][q] + d[p][q] );
  }
  int ans = inf;
  for (int S = 0; S < (1 << numT); ++S)
    for (int q = 0; q < n; ++q)
      ans = min(ans, OPT[S][q] + OPT[((1 << numT)-1)-S][q]);
  return ans;
}

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

int main()
{
  while(cin >> H >> W,W|H)
    {
      vvi G(H*W,vi(H*W,0));
      rep(i,H*W)rep(j,H*W)G[i][j] = inf;
      rep(i,H*W)          G[i][i] = 0;
      vi T;
      bool c;
      rep(i,H)rep(j,W)
	{
	  cin >> c;
	  rep(k,4)
	    {
	      int nx = j + dx[k];
	      int ny = i + dy[k];
	      if(!(0 <= nx && nx < W && 0 <= ny && ny < H))continue;
	      G[i*W+j][ny*W+nx] = G[ny*W+nx][i*W+j] = 1;
	    }
	  if(c)T.push_back(i*W+j);
	}
      cout << H*W - minimum_steiner_tree(T,G) - 1 << endl;
	

    }
  return 0;
}

Measured memory_bytes: 1416
import sys,collections as cl,bisect as bs,copy
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

h,w = m()

k = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
	l = list(input())
	for j in range(w):
		if l[j] != "#":
			k[i][j] = 1

kk = copy.deepcopy(k)
ma = 0
for i in range(h):
	for j in range(1,w):
		if k[i][j] != 0:
			k[i][j] += k[i][j-1]
	for j in range(w-2,-1,-1):
		if k[i][j] != 0 and k[i][j+1]  != 0:
			k[i][j] = k[i][j+1]

for i in range(w):
	for j in range(1,h):
		if kk[j][i] != 0:
			kk[j][i] += kk[j-1][i]
	for j in range(h-2,-1,-1):
		if kk[j][i] != 0 and kk[j+1][i] != 0:
			kk[j][i] = kk[j+1][i]

for i in range(h):
	for j in range(w):
		if ma <= kk[i][j] + k[i][j] - 1:
			ma = kk[i][j] + k[i][j] - 1
print(ma)

Measured memory_bytes: 121180
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


vector<pair<int, ll>> RLE(vector<int>& s) {
	ll cnt = 0;
	vector<pair<int, ll>> res;
	for (ll i = 0; i < s.size(); i++) {
		cnt++;
		if (i == (ll)s.size() - 1) {
			res.push_back(make_pair(s[i], cnt));
			break;
		}
		if (s[i] != s[i + 1]) {
			res.push_back(make_pair(s[i], cnt));
			cnt = 0;
		}
	}
	return res;
}
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		if (a == b) v.emplace_back(1);
		else v.emplace_back(0);
	}
	auto vp = RLE(v);
	for (auto p : vp) {
		if (p.first == 1 and p.second >= 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3648
def d(a,b);(a[0]-b[0]).abs+(a[1]-b[1]).abs;end
n,m=(S=$<.map{|l|l.split.map &:to_i}).shift
M=S.pop(m)
puts S.map{|s|(1..m).min_by{|i|d(M[i-1],s)}}

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

const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nParnt;
  int m_nLChd;
  int m_nRSib;

  StNod() :
    m_nDept(END), m_nParnt(END), m_nLChd(END), m_nRSib(END)
  { }
};

void fnInput(vector<StNod>& rvoNod)
{
  StNod oNod;
  int nMaxSiz;

  cin >> nMaxSiz;
  rvoNod.resize(nMaxSiz, oNod);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nCCnt, nChd, nBChd = END;
    cin >> nParnt >> nCCnt;
    for (int j = 0; j < nCCnt; j++)
    {
      cin >> nChd;
      rvoNod[nChd].m_nParnt = nParnt;
      if (nBChd != END) rvoNod[nBChd].m_nRSib = nChd;
      if (!j)          rvoNod[nParnt].m_nLChd = nChd;
      nBChd = nChd;
    }
  }
}

void fnSetDepth(vector<StNod>& rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nRSib != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRSib, nDept);

  if (rvoNod[nx].m_nLChd != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLChd, nDept + 1);
}

void fnRtdTree(vector<StNod>& rvoNod)
{
  int nx = 0, nDept = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  fnSetDepth(rvoNod, nx, nDept);
}

void fnResult(const vector<StNod>& cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", depth = " << cnrvoNod[i].m_nDept;

    if (!cnrvoNod[i].m_nDept)            cout << ", root, ";
    else if (cnrvoNod[i].m_nLChd == END) cout << ", leaf, ";
    else                                 cout << ", internal node, ";

    cout << "[";
    if (cnrvoNod[i].m_nLChd != END)
    {
      int nx = cnrvoNod[i].m_nLChd;
      cout << nx;
      while (cnrvoNod[nx].m_nRSib != END)
      {
        cout << ", " << cnrvoNod[nx].m_nRSib;
        nx = cnrvoNod[nx].m_nRSib;
      }
    }
    cout << "]" << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnRtdTree(voNod);
  fnResult(voNod);
  return 0;
}

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

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

class team {
  public:
    long long tid;
    long long correct;
    long long penalty;
    void print();
    bool operator < (const team&);
};

void team::print() {
  cout << tid << ' ' << correct << ' ' << penalty << endl;
}

bool team::operator < (const team &right) {
  if (correct != right.correct) return correct > right.correct;
  else if (penalty != right.penalty) return penalty < right.penalty;
  else return tid < right.tid;
}

int main() {
  long long t, p, r;
  long long tid, pid, time_;
  long long point;
  string message;

  while (cin >> t >> p >> r && t && p && r) {
    vector<team> teams(t);
    vector<long long> corrects(t, 0);
    vector<long long> penalties(t, 0);
    vector<vector<long long>> wrongs(t);
    rep (i, t) wrongs[i].resize(p);

    rep (i, r) {
      cin >> tid >> pid >> time_ >> message;
      tid--; pid--;

      if (message == "CORRECT") {
        corrects[tid]++;
        point = wrongs[tid][pid] * 1200 + time_;
        // cout << "team id: " << tid << endl;
        // cout << "penalty: " << penalties[tid] << endl;
        // cout << "wrongs[tid][pid]: " << wrongs[tid][pid] << endl;
        // cout << "point: " << point << endl;
        penalties[tid] += point;
      }
      else if (message == "WRONG") {
        wrongs[tid][pid]++;
      }
    }

    rep (i, t) {
      teams[i].tid = i+1;
      teams[i].correct = corrects[i];
      teams[i].penalty = penalties[i];
    }

    sort(teams.begin(), teams.end());
    // reverse(teams.begin(), teams.end());
    rep (i, t) teams[i].print();
  }
}

Measured memory_bytes: 3204
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 100100;
struct Edge {
	int to;
	Edge *next;
}*h[N], e[N<<2];
int _;
int ans = 0, n, k, a[N];
int dep[N];
void add_edge(int u, int v) {
	Edge *tmp = &e[++_];
	tmp -> to = v;
	tmp -> next = h[u];
	h[u] = tmp;
}
void dfs(int p) {
	dep[p] = 1;
	for(Edge *i = h[p]; i; i=i->next) {
		dfs(i->to);
		dep[p] = max(dep[p], dep[i->to]+1);
	}
	if(dep[p] >= k && a[p] > 1) {
		dep[p] = 0; 
		ans ++;
	}
}
int main() {
	scanf("%d%d",&n ,&k);
	for(int i = 1; i <= n; i ++ ) {
		scanf("%d", &a[i]);
	}
	if(a[1]!=1) ans ++, a[1] = 1;
	for(int i = 2; i <= n; i ++ ) add_edge(a[i], i);
	dfs(1);
	printf("%d\n", ans);
}


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

int main()
{
    string S;
    cin >> S;
    sort(S.begin(), S.end());

    rep(i, S.size()-1)
    {
        if(S.at(i) == S.at(i+1))
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const int M = 3000;
ll comb[M][M];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll p;
    cin >> p;
    rep(i, p)rep(j, i+1){
        if(j == 0 || j == i){
            comb[i][j] = 1;
        }else{
            comb[i][j] = (comb[i-1][j]+comb[i-1][j-1])%p;
        }
    }
    vll a(p);
    rep(i, p){
        cin >> a[i];
    }
    vll b(p, 0);
    b[p-1] += p-a[0];
    //dump(b);
    rep(i, p){
        b[0] += a[i];
    }
    b[0] %= p;
    b[p-1] %= p;
    rep(j, p){
        repr(i, 1, p){
            b[j] -= comb[p-1][j]*powmod(p-i, p-1-j, p)*a[i];
        }
        b[j] = (b[j]+LONG_MAX/(2*p)*p)%p;
    }
    rep(i, p){
        cout << b[i] << " \n"[i==p-1];
    }
    return 0;
}

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

ll cntSwap(ll x, ll sum) {
  ll cnt = 0;
  ll num = x;
  if (3 * x == sum)
    return inf;
  while (!((sum - num) % 2)) {
    cnt++;
    num = (sum - num) / 2;
  }
  return cnt;
}

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

  ll sum = a + b + c, ca = cntSwap(a, sum), cb = cntSwap(b, sum),
     cc = cntSwap(c, sum);
  if ((a == 1) && (b == 1) && (c == 1))
    cout << 0 << endl;
  else if ((ca == inf) && (cb == inf) && (cc == inf))
    cout << -1 << endl;
  else
    cout << min(min(ca, cb), cc) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll INF = 1e18;
int N;
ll a[200005], SUM[200005];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> a[i];
  SUM[0] = a[0];
  rep(i, N) {
    if (i==0) continue;
    SUM[i] = SUM[i-1]+a[i];
  }
  ll MIN = INF;
  rep(i, N) {
    MIN = min(MIN, abs(SUM[N-1]-2*SUM[i]));
  }
  cout << MIN << "\n";
  return 0;
}

Measured memory_bytes: 3328
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    x = int(input())

    exponentiation5_list = [i**5 for i in range(-200,200)]

    ex5_dict = {}
    for i in range(0, 400):
        ex5_dict[str(exponentiation5_list[i])] = i - 200

    for a in exponentiation5_list:
        for b in exponentiation5_list:
            if a - b == x:
                print(ex5_dict[str(a)], ex5_dict[str(b)])
                exit()






if __name__ == "__main__":
    resolve()



Measured memory_bytes: 63640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,x=7;
    cin>>k;
    for(int i=1;i<=20000000;i++){
        x%=k;
        if(x==0){
            cout<<i<<endl;
            return 0;
        }
        x=x*10+7;
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 3624
N = int(input())

eng = "abcdefghijklmnopqrstuvwxyz"

def range_dic(inp_dic):
    ans_dic = {}
    for key, value in inp_dic.items():
        for i in range(30):
            if i <= key:
                w = eng[i]
                _value = [v + w for v in  value]
                if not key in ans_dic:
                    ans_dic[key] = []
                ans_dic[key].extend(_value)
            elif i == key + 1:
                w = eng[i]
                _value = [v + w for v in  value]
                if not i in ans_dic:
                    ans_dic[i] = []
                ans_dic[i].extend(_value)
    return ans_dic


inp_dic = {0: ["a"]}

for i in range(N-1):
    inp_dic = range_dic(inp_dic)
results = []
for words in inp_dic.values():
    results.extend(list(words))

results.sort()
for result in results:
    print(result)


Measured memory_bytes: 14216
#include <bits/stdc++.h>
 
#define INT_INF (2 * 1e9)
#define LL_INF  (2LL * 1e18)
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#endif
 
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9 + 7;

ll k, a, b;

ll f(ll i)
{
	return 1 + i + ((k - i) / 2) * (b - a);
}

void solve()
{
	cin >> k >> a >> b;

	ll ans = -LL_INF;
	const ll stp = 1e5;

	ll i = a - 1;

	while(i + stp <= k && f(i + stp) > f(i))
		i += stp;

	for(ll j = i; j <= i + 2 * stp && j <= k; ++j)
		ans = max(ans, f(j));

	cout << ans << endl;
}

int main(int argc, char** argv)
{
	FAST_IO;
	solve();

	return 0;
}


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

int main(){
	long long n,m,d;
	long long ans;
	double doubleans;
	scanf("%lld %lld %lld",&n,&m,&d);
	
	if(d==0){
		ans = (n-d)*(m-1);
	} else {
		ans = (n-d)*2*(m-1);
	}
	
	doubleans =(double) ans / pow(n,2);
	
	printf("%lf\n",doubleans);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
t, x, y = 0, 0, 0
for i in range(n):
  ti, xi, yi = map(int, input().split())
  d = abs(xi - x) + abs(yi - y)
  dt = ti - t
  if d > dt or d % 2 != dt % 2:
    print("No")
    break
  t, x, y = ti, xi, yi
else:
  print("Yes")

Measured memory_bytes: 3064
#include<string>
#include<iomanip>
#include<iostream>
#include<math.h>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;
#define NUM 100001
typedef long long ll;

bool desc(pair<string, int > a, pair<string, int > b)
{
	if (a.first != b.first)
		return a.first < b.first;
	else
		return (a.second > b.second);
}

int main() {
	ll N;
	
	cin >> N;
	vector< pair<string, int >>SP(N);
	vector< pair<string, int >>SP2(N);
	string str;
	int p;

	for (int i = 0; i < N; i++) {
		
		cin >> str >> p;
		SP[i] = make_pair(str,p);
		SP2[i] = make_pair(str, p);
	}

	sort(SP2.begin(), SP2.end(),desc);

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++)
		{
			if (SP2[i] == SP[j]) {
				cout << j+1 << endl;
				break;
			}
		}
	}

	return 0;
}




Measured memory_bytes: 256
using System;

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int a = int.Parse(input.Split(' ')[0]);
            int b = int.Parse(input.Split(' ')[1]);
            int c = int.Parse(input.Split(' ')[2]);
            if((b - a) == (c - b))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[][] dp=new long[2*k][2*k];
		for(int i = 0; i<n; i++){
			long x = sc.nextLong();
			long y = sc.nextLong();
			String c = sc.next();
			if(c.charAt(0)=='W'){
				x+=k;
			}
			x%=2*k;
			y%=2*k;
			dp[(int)y][(int)x]++;
		}
		for(int i = 0; i<2*k; i++){
			for(int j = 1; j<2*k; j++){
				dp[i][j]+=dp[i][j-1];
			}
		}
		for(int i = 0; i<2*k; i++){
			for(int j = 1; j<2*k; j++){
				dp[j][i]+=dp[j-1][i];
			}
		}
		long ans = 0;
		for(int i = 0; i<k; i++){
			for(int j = 0; j<k; j++){
				long an=0;
				an+=dp[i][j];
				an+=dp[i+k][j+k]-dp[i][j+k]-dp[i+k][j]+dp[i][j];
				an+=dp[i][2*k-1]-dp[i][j+k];
				an+=dp[2*k-1][j]-dp[i+k][j];
				an+=dp[2*k-1][2*k-1]-dp[i+k][2*k-1]-dp[2*k-1][j+k]+dp[i+k][j+k];
				ans=Math.max(ans,Math.max(an,n-an));
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 127656
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

cnt = 0
for i in [i for i in range(1,n+1) if i%2 != 0]:
    if len(make_divisors(i)) == 8:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/rope>

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);

clock_t time_p=clock();
void printTime(){
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
 

const int mod = 1e9 + 7;
const int N = 3e5 + 5;
template <typename T>
long long myrand(T m) {
    long long mod = m;
    long long x = mt()%mod;

    return x;
}

int main(){
    io();
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> earliest(k + 1), last(k + 1);
    int i = 0, j = 0;
    while(i < n and j < k) {
        if(s[i] == 'o') {
            earliest[j] = i;
            j++;
            i += c + 1;
        }
        else
            i++;
    }
    i = n - 1;
    j = 0;
    while(i >= 0 and j < k) {
        if(s[i] == 'o') {
            last[j] = i;
            j++;
            i -= (c + 1);
        }
        else
            i--;
    }
    for(int i = 0; i < k; i++) {
        if(earliest[i] == last[k - i - 1]) {
            cout << earliest[i] + 1 << "\n";
        }
    }
}



Measured memory_bytes: 3348
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    while (cin >> A >> B) {
        string S;
        cin >> S;
        int ok = 1;
        rep(i, A + B + 1) {
            if (i == A && S[i] != '-')ok = 0;
            if (i != A && !isdigit(S[i]))ok = 0;
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int n;
    while (cin >> n, n) {
        map<string, vector<string>> m;
        string fst = "";
        REP (t, 0, n) {
            string s;
            cin >> s;
            int bef = 0;
            string key = "";
            REP (i, 0, s.size()) {
                if (s[i] == ':') {
                    key = s.substr(0, i);
                    bef = i + 1;
                    if (t == 0) fst = key;
                } else if (s[i] == ',' || s[i] == '.') {
                    m[key].push_back(s.substr(bef, i - bef));
                    bef = i + 1;
                }
            }
        }
        map<string, bool> used;
        function<int(string&)> rec = [&](string &s) -> int {
            if (used.count(s) > 0) return 0;
            used[s] = true;
            if (m.count(s) == 0) return 1;
            int res = 0;
            for (auto &k : m[s]) {
                res += rec(k);
            }
            return res;
        };
        cout << rec(fst) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3352
#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 ll long long
#define int ll
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define All(a, b) for(auto &a : b)
#define Rep(a, b, c) for(int a = b; a < c; ++a)
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define reset(a, b) memset(a, b, sizeof(a))
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bitone(i) __builtin_popcountll(i)
#define bitl(i) __builtin_clz(i)
#define bitr(i) __builtin_ctz(i)
/********************************************************

Digvijay Bahadur Singh
MNNIT

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


const int MOD=1e9+7;
const int N = 1e6+100;
/********************************************************************/
                 /* GRAPH*/
//vector<vector<ll>> g;
//vector<bool> vis1,vis2;
/*******************************************************************/
ll power(ll a,ll b)
{
   ll ans =1;
   while(b>0){
   if(b&1) ans = (ans * a);
   a = (a * a);
   b=b>>1;
   }
   return ans;
}

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
  // ifstream cin("a1.in");
  // ofstream cout("a1.out");
	ll T;
 // cin>>T;
  
    T=1;
    
    while(T--)
  {
    
        int n,r;
        cin>>n>>r;
        if(n>=10)
        {
          cout<<r<<"\n";
        }
        else
        {
          cout<<(r+100*(10-n))<<"\n";
        }
       







  
  }
}


Measured memory_bytes: 256
import sys
N, M = map(int, input().split())
li = [-1] * N
for i in range(M):
    s, c = map(int, input().split())
    if li[s-1] == -1 or li[s-1] == c:
        li[s-1] = c
    else:
        print(-1)
        sys.exit()
if N == 1:
    if li[0] == -1:
        ans = 0
    else:
        ans = li[0]
elif N == 2:
    if li[0] == 0:
        print(-1)
        sys.exit()
    else:
        if li[0] == -1:
            li[0] = 1
        if li[1] == -1:
            li[1] = 0
        ans = li[0]*10 + li[1]
else:
    if li[0] == 0:
        print(-1)
        sys.exit()
    else:
        if li[0] == -1:
            li[0] = 1
        if li[1] == -1:
            li[1] = 0
        if li[2] == -1:
            li[2] = 0
        ans = li[0]*100 + li[1]*10 + li[2]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    char picture[110][110];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> picture[i][j];
        }
    }

    for(int i=0; i<w+2; i++){
        cout << '#';
    }
    cout << endl;

    for(int i=0; i<h; i++){
        cout << '#';
        for(int j=0; j<w; j++){
            cout << picture[i][j];
        }
        cout << '#' << endl;
    }

    for(int i=0; i<w+2; i++){
        cout << '#';
    }
    cout << endl;
    return 0;
}

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

int main() {
    int n;
    int sum=0;
    int ans;
    cin>>n;
    while(sum<n){
        sum+=1000;
    }
    ans=sum-n;
    cout<<ans;
    return 0;
}

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

int main(){

    int a, b, sum, mult, sub, maxv;
    cin >> a >> b;

    sum = a + b;
    sub = a - b;
    mult = a * b;
    maxv = max(sum, sub);
    maxv = max(maxv, mult);
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n;
ll x[1010],y[1010];
ll b[50];
void make_bit(){
  ll a=1;
  rep(i,40){
    b[i]=a;
    a*=2;
  }
}
void solve(){
  ll p=(abs(x[0])+abs(y[0]))%2;
  rep1(i,n-1){
    if((abs(x[i])+abs(y[i]))%2!=p){
      prin(-1);
      return ;
    }
  }
  if(p==0){
    rep(i,n){
      x[i]--;
    }
  }
  ll u[1010],v[1010];
  ll mx=0;
  rep(i,n){
    u[i]=x[i]+y[i];
    mx=max(mx,abs(u[i]));    
    v[i]=x[i]-y[i];
    mx=max(mx,abs(v[i]));
  }
  make_bit();
  int k;
  rep(i,40){
    if(mx<b[i]){
      k=i-1;
      break;
    }
  }
  int of=0;
  if(p==0){
    of=1;
  }
  prin(k+of+1);
  if(of==1) cout<<1<<" ";
  rep(i,k+1){
    cout<<b[i]<<" ";
  }
  cout<<"\n";
  char res[1010][40];
  rep(i,n){
    bool fx=true,fy=true;
    ll uu=abs(u[i]),vv=abs(v[i]);
    for(int j=k;j>=0;j--){
      int dx=1,dy=1;
      if(fx){
	if(u[i]<0){
	  dx=-1;
	}
      }
      else{
	if(u[i]>0){
	  dx=-1;
	}
      }
      if((uu>>j)&1){
	fx=true;
      }
      else{
	fx=false;
      }
      if(fy){
	if(v[i]<0){
	  dy=-1;
	}
      }
      else{
	if(v[i]>0){
	  dy=-1;
	}
      }
      if((vv>>j)&1){
	fy=true;
      }
      else{
	fy=false;
      }
      if(dx==1){
	if(dy==1){
	  res[i][j+of]='R';
	}
	else{
	  res[i][j+of]='U';
	}
      }
      else{
	if(dy==1){
	  res[i][j+of]='D';
	}
	else{
	  res[i][j+of]='L';
	}
      }
    }
  }
  if(!of){
    rep(i,n){
      rep(j,k+1){
	cout<<res[i][j];
      }
      cout<<"\n";
    }
  }
  else{
    rep(i,n){
      cout<<'R';
      rep1(j,k+1){
	cout<<res[i][j];
      }
      cout<<"\n";
    }
  }
}
int main(){
  cin>>n;
  rep(i,n) cin>>x[i]>>y[i];
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int A[1000000], n;

//二分探索
int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;

  while(left < right)
  {
    mid=(left+right)/2;

    if(key == A[mid])
      return 1;
    if(key > A[mid])
      left=mid+1;
    else if(key < A[mid])
      right=mid;
  }

  return 0;
}

int main(){
  int i, q, k, sum=0;

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

  scanf("%d", &q);
  for(i=0; i<q; i++)
  {
    scanf("%d", &k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 998244353;
long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}
int main(void){
    int n, dmax = 0;
    long long ans = 1;
    vector<int> e;
    bool flg = true;
    cin >> n;
    e.assign(n, 0);
    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        if(i == 0 && d > 0)flg = false;
        if(i != 0 && d == 0)flg = false;
        e[d]++;
        dmax = max(dmax, d);
    }
    if(!flg){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1;i<=dmax;i++){
        ans *= mod_pow(e[i-1], e[i]);
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,cnt=0;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
  { 
    cin>>arr[i];
    if(arr[i]>=k)
    cnt++;
  }
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>

#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

//C
int main(void) {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	//if (min(100 * a + c, 100 * a + d) > f && min(100 * b + c, 100 * b + d) > f) cout << 0 << 0 << endl;
	int ans_water = 0;
	int ans_sugar = 0;
	double ans_percent = 0;
	for (int ai = 0; ai * 100 * a < f; ai++) {
		for (int bi = 0; ai * 100 * a + bi * 100 * b < f; bi++) {
			int now_water = ai * 100 * a + bi * 100 * b;
			int can_sugar = min((a * ai + b * bi)*e, f - now_water);
			for (int ci = 0; ci * c <= can_sugar; ci++) {
				for (int di = 0; di * d + ci * c <= can_sugar; di++) {
					int now_sugar = ci*c + di*d;
					if (now_water + now_sugar == 0) continue;
					double percent = (now_sugar * 100) / (double)(now_water + now_sugar);
					if (percent > ans_percent) {
						ans_sugar = now_sugar;
						ans_water = now_water + now_sugar;
						ans_percent = percent;
					}
				}
			}
		}
	}
	if (ans_sugar == 0) ans_water = 100 * a;
	cout << ans_water << " " << ans_sugar << endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a==b) {
        if (b==c) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        if ((a==c)||(b==c)) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N;
bool Check(int A, int B){
  int cnt = 0;
  for (int i = N - 1; i >= 0; i--){
    if (A % 2 != B % 2) cnt++;
    A /= 2; B /= 2;
  }
  if (cnt % 2 != 0) return true;
  else return false;
}

int ans[200000][17];

int DFS(int L_index, int R_index){
  if (R_index == L_index + 1) return 0;
  
  int mid = (L_index + R_index) / 2;
  int next;
  for (int i = 0; i < N; i++){
    if (ans[L_index + 1][i] == -1 && ans[L_index][i] != ans[R_index][i]){
      next = i; break;
    }
  }
  
  for (int i = L_index + 1; i <= mid; i++){
    ans[i][next] = ans[L_index][next];
  }
  for (int i = mid + 1; i < R_index; i++){
    ans[i][next] = ans[R_index][next];
  }
  

  bool flag = false;
  for (int i = 0; i < N; i++){
    if (ans[mid][i] == -1) {
      if (flag == true) ans[mid][i] = ans[L_index][i];
      else{
        ans[mid][i] = 1 - ans[L_index][i];
        flag = true;
      }
    }
  }


  for (int i = 0; i < N; i++){
    if (ans[mid + 1][i] == -1){
      ans[mid + 1][i] = ans[mid][i];
    }
  }
  
  DFS(L_index, mid);
  DFS(mid + 1, R_index);
  return 0;
}

int main(){
  int A, B; cin >> N >> A >> B;
  if (!Check(A, B)){
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;

  int all = pow(2, N);
  fill((int*)ans, (int*)(ans + all), -1);
  for (int i = 0; i < N; i++){
    ans[0][i] = A % 2; A /= 2;
  }
  for (int i = 0; i < N; i++){
    ans[all - 1][i] = B % 2; B /= 2;
  }
  DFS(0, all - 1);
  
  for (int i = 0; i < all; i++){
    int now = 0, cnt = 1;
    for (int j = 0; j < N; j++){
      now += ans[i][j] * cnt;
      cnt *= 2;
    }
    cout << now;
    if (i == all - 1) cout << endl;
    else cout << " ";
  }
  
  return 0;
}

Measured memory_bytes: 11392
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, A;
  cin >> N >> A;
  cout << N * N - A << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s, t;
  cin >> s >> t;
  if(s == t) cout << "EQUAL" << endl;
  else if(s.size() > t.size())cout << "GREATER" << endl;
  else if(s.size() < t.size())cout << "LESS" << endl;
  else if(s > t) cout << "GREATER" << endl;
  else cout << "LESS" << endl;
  system("pause");
}

Measured memory_bytes: 504