akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
char a[60][60],memo[60][60];
int ans,gx,gy;
set<tuple<int,int,int>> dp;
void move(int x,int y,int direc){
  int count=0;
  while(1){
    decltype(dp)::iterator it =dp.find(make_tuple(x,y,direc));
    if(it!=dp.end()) return;
    dp.insert(make_tuple(x,y,direc));
    if(memo[x][y]==0){
      count++;
      memo[x][y]=1;
    }
    if(x==gx&&y==gy){
      ans=count;
      return;
    }
    if(direc==1){
      if(a[x][y+1]=='.'){
	y++;
	direc=4;
      }
      else{
	if(a[x+1][y]=='#') direc=2;
	else x++;
      }
    }
    else if(direc==2){
      if(a[x+1][y]=='.'){
	x++;
	direc=1;
      }
      else{
	if(a[x][y-1]=='#') direc=3;
	else y--;
      } 
    }
    else if(direc==3){
      if(a[x][y-1]=='.'){
	y--;
	direc=2;
      }
      else{
	if(a[x-1][y]=='#') direc=4;
	else x--;
      } 
    }
    else if(direc==4){
      if(a[x-1][y]=='.'){
	x--;
	direc=3;
      }
      else{
	if(a[x][y+1]=='#') direc=1;
	else y++;
      }
    }
  }
  return;
}
    
int main(){
    int n,m;
    cin>>n>>m;
    lp(i,60){
      lp(j,60){
	a[i][j]='#';
	memo[i][j]=0;
      }
    }
    int direc,sx,sy;
    lp(i,n+1){
      if(i==0) continue;
      lp(j,m+1){
	if(j==0) continue;
	cin>>a[j][i];
	if(a[j][i]=='G'){
	  gx=j;
	  gy=i;
	  a[j][i]='.';
	}
	if(a[j][i]=='<'){
	  sx=j;
	  sy=i;
	  direc=3;
	  a[j][i]='.';
	}
	if(a[j][i]=='^'){
	  sx=j;
	  sy=i;
	  direc=2;
	  a[j][i]='.';
	}
	if(a[j][i]=='>'){
	  sx=j;
	  sy=i;
	  direc=1;
	  a[j][i]='.';
	}
	if(a[j][i]=='v'){
	  sx=j;
	  sy=i;
	  direc=4;
	  a[j][i]='.';
	}
      }
    }
    ans=0;
    dp.clear();
    move(sx,sy,direc);
    if(ans==0) cout<<"-1"<<endl;
    else cout<<ans<<endl;
  return 0;
}



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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = -1;
    for(int i = 1; i <= 10000; i++){
        if((int)(i * 0.08) == a && (int)(i * 0.1) == b){
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

string str;
int p;
map<string,int> tbl;

bool isopen(int p){
    return str[p] == '(';
}

bool isclose(int p){
    return str[p] == ')';
}

int isdig(int p){
    return isdigit(str[p]);
}

int num(){
    int n = 0;
    while(p < str.size() && isdig(p)){
        n*=10;
        n+=str[p++] - '0';
    }
    return n;
}
        

int atom(){
    if(p == str.size()) return 0;
    string atm = "XXX";
    if(p+1 < str.size() && isupper(str[p]) && islower(str[p+1])){
        atm = string(str,p,2);
        p+=2; // jump Aa
    } else if(isupper(str[p])){
        atm = string(str,p,1);
        p++;  // jump A
    }
    if(tbl.count(atm) == 0){
        throw "";
    }
    return tbl[atm];
}

int mol(){
    int m;
    if(isclose(p)){
        return 0;
    }else if(isopen(p)){
        p++; // jump (
        m = mol();
        p++; // jump )
        m *= num();
        m += mol();
    } else {
        m = atom();
        if(m == 0) return 0;
        if(isdig(p)) m *= num();
        m += mol();
    }
    
    return m;
}

int main(){
    string atm;
    while(cin >> atm, atm != "END_OF_FIRST_PART"){
        cin >> tbl[atm];
    }
    while(cin >> str, str != "0"){
        p=0;
        try{
            cout << mol() << endl;
        } catch(const char* c){
            cout << "UNKNOWN" << endl;
        }
    }
}

Measured memory_bytes: 1300
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n, e, t;
int x[maxn];
long long st[2][4 * maxn];
long long dp[maxn];

int read() {
  if (scanf("%d%d%d", &n, &e, &t) < 3) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  return true;
}

void buildst(int t, int v, int tl, int tr) {
  st[t][v] = infll;
  if (tl == tr - 1) {
    return;
  }
  int tm = (tl + tr) / 2;
  buildst(t, 2 * v, tl, tm);
  buildst(t, 2 * v + 1, tm, tr);
}

void update(int t, int v, int tl, int tr, int l, int r, long long val) {
  if (l == tl && r == tr) {
    st[t][v] = min(st[t][v], val);
    return;
  }
  int tm = (tl + tr) / 2;
  if (l < tm) {
    update(t, 2 * v, tl, tm, l, min(r, tm), val);
  }
  if (r > tm) {
    update(t, 2 * v + 1, tm, tr, max(l, tm), r, val);
  }
}

long long get(int t, int v, int tl, int tr, int pos) {
  long long res = st[t][v];
  if (tl == tr - 1) {
    return res;
  }
  int tm = (tl + tr) / 2;
  if (pos < tm) {
    res = min(res, get(t, 2 * v, tl, tm, pos));
  } else {
    res = min(res, get(t, 2 * v + 1, tm, tr, pos));
  }
  return res;
}

void solve() {
  buildst(0, 1, 0, n + 1);
  buildst(1, 1, 0, n + 1);
  {
    int l = 0, r = n;
    while (l < r - 1) {
      int m = (l + r) / 2;
      if (2 * (x[m] - x[0]) >= t) {
        r = m;
      } else {
        l = m;
      }
    }
    int pos = r;
    if (pos < n) {
      update(0, 1, 0, n, pos, n, -2 * x[0]);
    }
    if (0 < pos) {
      update(1, 1, 0, n, 0, pos, t);
    }
  }
  for (int i = 0; i < n; i++) {
    dp[i] = min(get(0, 1, 0, n, i) + 3ll * x[i], get(1, 1, 0, n, i) + x[i]);
    if (i + 1 == n) {
      break;
    }
    int pos;
    {
      int l = i + 1, r = n;
      while (l < r - 1) {
        int m = (l + r) / 2;
        if (2 * (x[m] - x[i + 1]) >= t) {
          r = m;
        } else {
          l = m;
        }
      }
      pos = r;
    }
    if (pos < n) {
      update(0, 1, 0, n, pos, n, dp[i] - 2ll * x[i + 1] - x[i]);
    }
    if (i + 1 < pos) {
      update(1, 1, 0, n, i + 1, pos, dp[i] + t - x[i]);
    }
  }
  long long res = dp[n - 1] + e - x[n - 1];
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)


int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int x , y , z;
   cin >> x >> y >> z;
   cout << z << ' ' << x << ' ' << y << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932

#ifdef Voneone
#define TRACE
#endif
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;

}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); 
    cout.write(names, comma - names) << " : " << arg1 << " | "; 
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 

void solve() 
{ 

    int n, m;
    cin >> n >> m;

    vi a(m);
    rep(i, m) cin >> a[i];

    int sum = 0;
    for(int x : a)
        sum += x;

    if(sum > n)
        cout << -1;
    else
        cout << n-sum;

} 
 
 
 
 
signed main()
{
 
    
    #ifdef Voneone
    inputFile;
    #endif
    #ifndef Voneone
    fast;
    #endif


    int T = 1;
    // cin >> T;
    while(T--){
        solve();
        cout << endl;
        
        

    }
    
    
    return 0;
 
}






Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 9;
const ll inf = 1e18;

ll dp[N], h[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> h[i], dp[i] = inf;
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = max(0, i-2); j < i; ++j)
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
  }
  cout << dp[n-1];
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long ans = 0;
		for (long i = 1; i <= N; i++) {
			long x = N / i;
			ans += i * x * (x + 1) / 2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35532
#include <stdio.h>
#define MAX 100000
#define NIL -1

typedef struct{
  int p,l,r;
}Node;

void setdepth(int, int);
int setheight(int);
void print(int);
int getsibling(int);

Node T[MAX];
int n,D[MAX],H[MAX];

int main(){
  int v,l,r,i,root=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p=NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)
      T[l].p=v;
    if(r!=NIL)
      T[r].p=v;
  }
  
  for(i=0;i<n;i++){
    if(T[i].p==NIL)
      root=i;
  }
  
  setdepth(root,0);
  setheight(root);
  
  for(i=0;i<n;i++)
    print(i);

  return 0;
}

void setdepth(int u, int d){
  if(u==NIL)
    return;
  D[u]=d;
  setdepth(T[u].l,d+1);
  setdepth(T[u].r,d+1);
}

int setheight(int u){
  int h1=0,h2=0;

  if(T[u].l!=NIL)
    h1=setheight(T[u].l)+1;
  if(T[u].r!=NIL)
    h2=setheight(T[u].r)+1;
  
  if(h1>h2)
    return H[u]=h1;
  else
    return H[u]=h2;
}

void print(int u){
  int deg=0;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getsibling(u));

  if(T[u].l!=NIL)
    deg++;
  if(T[u].r!=NIL)
    deg++;

  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p==NIL)
    printf("root\n");
  else if(T[u].l==NIL && T[u].r==NIL)
    printf("leaf\n");
  else
    printf("internal node\n");
}

int getsibling(int u){
  if(T[u].p==NIL)
    return NIL;
  if(T[T[u].p].l!=u && T[T[u].p].l!=NIL)
    return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=NIL)
    return T[T[u].p].r;
  return NIL;
}

Measured memory_bytes: 624
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T, class S> inline int Digit_L(T n, S b){
  int res = 0;
  while(n){
    res++;
    n /= b;
  }
  return res;
}
template<class T, class S> inline int Digit_L(T n, S res[]){
  int sz = 0;
  while(n){
    res[sz++] = n % 10;
    n /= 10;
  }
  return sz;
}
int main(){
  int N;
  int K;
  rd(N);
  rd(K);
  wt_L(Digit_L(N,K));
  wt_L('\n');
  return 0;
}
// cLay varsion 20200217-1

// --- original code ---
// {
//   int N, K;
//   rd(N,K);
//   wt(Digit(N,K));
// }


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
  int ans=0, minans=2000;
  char s[1010], t[1010];
  scanf("%s%s", &s, &t);
  for(int i=0;i<=strlen(s)-strlen(t);i++) {
    ans = 0;
    for(int j=0;j<strlen(t);j++) {
      if(s[i+j] != t[j]) ans++;
    }
    minans = min(minans, ans);
  }
  printf("%d", minans);
  return 0;
}

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

int func1(int a,int b){
    while(a != b){
        if(a>b)a-=b;
        else b-=a;
    }
    return a;
}

int func2(const int a,const int b){
    int a2=a,b2=b;
    while(a2 != b2){
        if(a2>b2)b2+=b;
        else a2+=a;
    }
    return a2;
}

int main(){
    int a,b;
    while(cin >> a >> b){
        cout << func1(a,b) << " " << func2(a,b) << endl;
    }
    return 0;
}

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

int main() {
  int W,H,N;
  cin >> W >> H >> N;
  vector<vector<int> > X(N,vector<int>(3));
  for (int i=0; i<N; i++) {
    cin >> X.at(i).at(0) >> X.at(i).at(1) >> X.at(i).at(2);
  }
  int count=0;
  vector<vector<int> > vec(W,vector<int> (H));
  for (int i=0; i<W; i++) {
    for (int j=0; j<H; j++) {
      vec.at(i).at(j)=0;
    }
  }
  for (int i=0; i<N; i++) {
    if (X.at(i).at(2)==1) {
      for (int j=0; j<X.at(i).at(0); j++) {
        for (int k=0; k<H; k++) {
          vec.at(j).at(k)=1;
        }
      }
    }
    else if (X.at(i).at(2)==2) {
      for (int j=X.at(i).at(0); j<W; j++) {
        for (int k=0; k<H; k++) {
          vec.at(j).at(k)=1;
        }
      }
    }
    else if (X.at(i).at(2)==3) {
      for (int j=0; j<X.at(i).at(1); j++) {
        for (int k=0; k<W; k++) {
          vec.at(k).at(j)=1;
        }
      }
    }
    else {
      for (int j=X.at(i).at(1); j<H; j++) {
        for (int k=0; k<W; k++) {
          vec.at(k).at(j)=1;
        }
      }
    }
  }
  for (int i=0; i<W; i++) {
    for (int j=0; j<H; j++) {
      if (vec.at(i).at(j)==0) count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

void main() {
	auto n = readNum();
	auto lines = readNums();
	auto maxLen = lines.maxElement;
	writefln(maxLen < (lines.sum - maxLen) ? "Yes" : "No");
}


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

const ll INF = 1001001001;

int main(){
    int a, b; cin >> a >> b;
    vector<vector<char>> ans(100, vector<char>(100, '.'));
    for(int i = 50; i < 100; i++){
        for(int j = 0; j < 100; j++){
            ans[i][j] = '#';
        }
    }
    a--; b--;
    int cnt = 0;
    for(int i = 0; i < 49; i += 2){
        for(int j = 0; j < 100; j += 2){
            if(cnt == b) break;
            ans[i][j] = '#';
            cnt++;
        }
        if(cnt == b) break;
    }
    cnt = 0;
    for(int i = 51; i < 100; i += 2){
        for(int j = 0; j < 100; j += 2){
            if(cnt == a) break;
            ans[i][j] = '.';
            cnt++;
        }
        if(cnt == a) break;
    }
    cout << 100 << " " << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << ans[i][j];
        }
        cout << '\n';
    }
}


Measured memory_bytes: 3628
import java.util.BitSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static BitSet primes() {
		int SIZE = 1 << 15;
		BitSet ret = new BitSet(SIZE);
		ret.set(2, SIZE);
		for (int i = 2; i < SIZE; ++i) {
			if (!ret.get(i)) continue;
			for (int j = i * i; j < SIZE; j += i) {
				ret.clear(j);
			}
		}
		return ret;
	}

	public static void main(String[] args) {
		BitSet psset = primes();
		int[] ps = new int[psset.cardinality()];
		int idx = 0;
		for (int i = 0; i < psset.size(); ++i) {
			if (psset.get(i)) ps[idx++] = i;
		}
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int ans = 0;
			for (int i = 0; i < ps.length && ps[i] <= N / 2; ++i) {
				if (psset.get(N - ps[i])) ++ans;
			}
			System.out.println(ans);
		}
	}

}

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

typedef struct D
{
	int n,r,l,d,p,dep,h,sub,deg;
}D;

D node[30];
int i,j,N,r,l,n;

int dfs(int p,int d)
{
	int a,b;
	if(p==-1)return -1;
	node[p].dep=d;
	a=dfs(node[p].r,d+1);
	b=dfs(node[p].l,d+1);
	if(a==-1&&b==-1)
		node[p].h=0;
	else
		node[p].h=(a>b?a:b)+1;
	return node[p].h;
}

int main()
{
	memset(node,-1,sizeof(node));
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d%d",&n,&l,&r);
		node[n].l=l;
		node[n].r=r;
		node[n].deg=(r!=-1)+(l!=-1);
		node[l].sub=r;
		node[r].sub=l;
		if(l!=-1)node[l].p=n;
		if(r!=-1)node[r].p=n;
	}
	for(i=0;i<N;i++)
		if(node[i].p==-1)
			dfs(i,0);

	for(i=0;i<N;i++)
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
		i,node[i].p,node[i].sub,node[i].deg,node[i].dep,node[i].h,node[i].p==-1?"root":node[i].l==-1&&node[i].r==-1?"leaf":"internal node");
	return 0;
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
#define pi (acos(-1))
///#define for(i,a,b) for(i=(a);i<(b);++i)
///freopen("input.txt","r",stdin);
///   freopen("output.txt","w",stdout);
ll fre[500005];
ll a[500005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,k,l,m;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        fre[a[i]]++;
    }
    ll sum=0;
    for(i=1; i<=n; i++)
    {
        sum+=((fre[i])*(fre[i]-1))/2;
    }
    for(i=1; i<=n; i++)
    {
        ll kola=((fre[a[i]])*(fre[a[i]]-1))/2;
        ll res=sum-kola;
        res+=((fre[a[i]]-1)*(fre[a[i]]-2))/2;
        cout<<res<<"\n";
    }
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using ordered_multiset = tree <T, null_type, less_equal <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int siz = 1e2 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";

int a[siz];

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

//    freopen ((file + ".INP").c_str(), "r", stdin);
//    freopen ((file + ".OUT").c_str(), "w", stdout);

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

    int ans = 0;
    for (int i = 1; i <= n - 2; i++) {
        for (int j = i + 1; j <= n - 1; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i]){
                    if (a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[k] + a[i] > a[j]) {
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans;

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<map>
#include<deque>
#include<list>
#include<forward_list>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define ll long long
#define v vector<ll>
const ll w = (1e9 + 7);
using namespace std;
void fireman()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
struct great {
	//descending order
	bool operator()(int x, int y)
	{
		return (x < y);
	}
};


struct small {
	//asecending order
	bool operator()(int x, int y)
	{
		return x > y;
	}
};

bool prime(int x)
{
	bool b = true;
	if (x == 2)
	{
		return true;
	}
	else if (x == 1 || x % 2 == 0)
	{
		return false;
	}
	for (int i = 3; i * i <= x; i += 2)
	{
		if (x % i == 0)
		{
			b = false;
			return false;
			break;
		}
	}
	return true;
}
bool great1(int a, int b)
{
	//descending order 
	return a > b;
}
bool small1(int a, int b)
{
	//asecending order 
	return a < b;
}
/*int sum_range(ll i, ll j, ll k, ll l, vector<vector<ll>>& S) {
	return S[k][l] - S[k][j - 1] - S[i - 1][l] + S[i - 1][j - 1];
}*/

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

int lcm(int a, int b)
{
	return a / gcd(a, b) * b;
}
int modpow(ll a, ll b, ll c)//fast_power log(n)
{
	if (b == 0)
		return 1 % c;
	ll u = modpow(a,b/2,c);
	u = (u * u) % c;
	if(b&1)
		u = (u * a) % c;
	return u;
}



int main()
{
	fireman();
	ll x;
	cin >> x;
	if (x % 1000 == 0)
		cout << 0 << endl;
	else
		cout << 1000 - (x % 1000) << endl;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int A[210000];
int main(void){
    int N;scanf("%d",&N);
 for(int i=0;i<N;i++)scanf("%d",A+i);
sort(A,A+N);
 for(int i=0;i<N-1;i++){
 if(A[i]==A[i+1]){
 printf("NO\n");return 0;
 }
 }
 printf("YES\n");
}

Measured memory_bytes: 4432
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		List<Integer> a = new ArrayList<>();
		for (int i = 0; i<n; i++) {
			a.add(sc.nextInt());
		}
	
		sc.close();
		
		
		int c = 0;
		int count = 0;
		Collections.sort(a);
		
		for (int i=0; i<n; i++,c=0) {
			while (a.get(i)%2 == 0) {
				c++;
				a.set(i, a.get(i)/2);
			}
			if (c == 0) {
				count = 0;
				break;
			} else {
				if (i==0) {
					count=c;
				}
				count = Math.min(count, c);
		        c=0;
			}
		
		}
		
		System.out.println(count);

		

	}

}


Measured memory_bytes: 21844
x,y=[int(j) for j in input().split()]
U = 2*10**6
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
 
for i in range(U,0,-1):
	fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def comb(n,k):
  if k < 0 or k > n:
    return 0
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x

if (2*y-x)//3==(2*y-x)/3 and (2*x-y)//3==(2*x-y)/3:
    i=(2*y-x)//3
    j=(2*x-y)//3
    print(comb(i+j,min(i,j)))
else:
    print(0)

Measured memory_bytes: 71532
import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
A, B = list(map(int, input().split()))
P = list(map(int, input().split()))

sum_list = [0]*3
for i in range(N):
	if P[i] <= A:
		sum_list[0] += 1
	elif P[i] <= B:
		sum_list[1] += 1
	else:
		sum_list[2] += 1

print(min(sum_list))

Measured memory_bytes: 38256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        long[] A = in.nl(n);
        Arrays.sort(A);
        long[] a = new long[n];
        a[0] = A[0];
        for (int i = 1; i < n; i++) {
            a[i] = a[i-1] + A[i];
        }
        int ans = 1;
        for (int i = n-1; i > 0; i--) {
            if((a[i]-a[i-1])<=2*a[i-1]) ans++;
            else break;
        }
        out.println(ans);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 40228
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main()
{	
	char str[20];
	
	for(int i=1;i<=19;i++)
	{
		scanf("%c",&str[i]);
		if(i==6||i==14)
		printf(" ");
		else
		 printf("%c",str[i]);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int M[2] , D[2];
  rep(i,2){
  cin >> M[i] >> D[i];
  }
  if (M[0] != M[1]){
    cout << '1' << endl;
  }else {

cout << '0' << endl;
  }
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
for i in range(n):
    p[i] -= 1
c = list(map(int,input().split()))
if max(c) <= 0:
    print(max(c))
    exit()
ans = 0
for begin in range(n):
    i = p[begin]
    s = c[i]
    round = 1
    score = 0
    kk = 0
    while i != begin:
        i = p[i]
        s += c[i]
        round += 1
    if k < round:
        kk = k
    else:
        if s > 0:
            score += s * (k // round)
            kk = k % round
        else:
            kk = round
    smax = 0
    now = 0
    i = begin
    while kk > 0:
        i = p[i]
        now += c[i]
        smax = max(now, smax)
        kk -= 1
    roundmax = 0
    if k // round >= 1 and s > 0:
        kk = round
        now = 0
        i = begin
        while kk > 0:
            i = p[i]
            now += c[i]
            roundmax = max(now, roundmax)
            kk -= 1
        ans = max(ans, score-s+roundmax, score+smax)
    else:
        ans = max(ans, score + smax)

print(ans)

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

using i64 = long long;
using u64 = unsigned long long;

const int mod = (int)1e9+7;

void __print() {cerr << "]\n";}

template<typename T, typename... V>
void __print(T t, V... v)
{ cerr << t; if(sizeof...(v)) cerr << ", "; __print(v...);}

#define dbg(x...) cerr << "[" << #x << "] = ["; __print(x);


int main()
{
    i64 a, b;
    scanf("%lld%lld", &a, &b);
    i64 g = __gcd(a, b);
    i64 sq = sqrt(g);
    int cnt = 0;
    for(i64 i = 2; i <= sq; i++){
        if(g%i==0) {
            while(g%i == 0) g/=i;
            cnt++;
        }
    }
    cnt++;
    if(g > 1) cnt++;
    printf("%d\n", cnt);
}


Measured memory_bytes: 3596
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;

const int mod = 1e9+7;

void add_self(int &a,int b)
{
  a+=b;
  if(a>=mod)
  {
    a-=mod;
  }
}



int main() 
{

int n;
cin>>n;
vector<vector<int>>ar(n,vector<int>(n));
for(int i=0;i<n;i++)
{
  for(int j=0;j<n;j++)
  {
    cin>>ar[i][j];
  }
}
//cout<<" n = "<<n<<endl;
vector<int> dp(1<<n);
//dp[i] represents the number of ways it women at state i are mached.
// i in binary means a subset of the set
//we need dp[1<<n-1] becuase every girl should be matched 
//with atleast one guy right!!

dp[0] = 1;
// for(int i=0;i<n;i++)
// {This for loop is unnecessary to move. (no need to move for every boy,it we have already matched k bits in the mask, it means, k boys are already matched)
  for(int mask=0;mask<(1<<n)-1;mask++)
  {
     int i = __builtin_popcount(mask);// counting the number of boys already matched.
    for(int j=0;j<n;j++)
    {
      // compatibility check and availablity check
     
      if(ar[i][j] && !(mask&(1<<j)))
      {
        //cout<<" i = "<<i<<" j = "<<j<<endl;
        int mask2 = mask^(1<<j);
        add_self(dp[mask2],dp[mask]);
      }
    }
  // }
}

//Errichto's code: i kept && in place of &
// for(int mask = 0; mask < (1 << n) - 1; ++mask) {
//         int a = __builtin_popcount(mask); // the number of bits set to 1
//         for(int b = 0; b < n; ++b) {
//             if(ar[a][b] && !(mask & (1 << b))) {
//                 int m2 = mask ^ (1 << b);
//                 //~ debug() << imie(mask) imie(m2) imie(dp[mask]);
//                 add_self(dp[m2], dp[mask]);
//             }
//         }
//     }
// for(auto c:dp)
// {
//   cout<<c<<" ";
// }
//cout<<endl;
cout<<dp[(1<<n) -1]<<endl;
}


Measured memory_bytes: 8448
//
// Created by munaiyi on 2020/3/28.
//
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5 + 5;
long long sum[maxn];
int a[maxn];

int main() {
    int n, m, v, p;
    scanf("%d%d%d%d", &n, &m, &v, &p);
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
    }
    sort(a + 1, a + 1 + n, [](int x, int y) -> bool {
        return x < y;
    });
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + a[i];
    }
    int ans = n;
    for (int i = 1; i <= n; i++) {
        if (n - i + 1 <= p) break;
        if (a[i] + m < a[n - p + 1]) {
            ans--;
            continue;
        }
        int tv = v - i - (p - 1);
        if (tv <= 0) {
            break;
        }
        long long tmp = sum[n - p + 1] - sum[i] + 1LL * m * tv;
        int chu = n - p + 1 - i;
        tmp = (tmp + chu - 1) / chu;
        if (a[i] + m >= tmp) {
            break;
        }
        ans--;

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


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

typedef long long ll;
#define EPSILON 1e-9
using namespace std;


int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("n.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1, 0), b(m + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];


    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        b[i] += b[i - 1];
    }

    int mx = 0;

    for (int i = 0; i <= n; i++) {
        if (a[i] <= k) {
            int x = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
            x--;
            mx = max(mx, i + x);
        }
    }
    cout << mx << endl;

    return 0;
}

Measured memory_bytes: 6360
# include <stdio.h>

int bubbleSort(int *A, int N) {
    int flag = 1, count=0;
    while(flag) {
        flag = 0;
        for (int j=N-1; j>0; j--) {
            if (A[j] < A[j-1]) {
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                count++;
                flag = 1;
            }
        }
    }
    return count;
}

void outputArray(int *A, int N) {
    printf("%d", A[0]);
    for (int i=1; i<N; i++) {
        printf(" %d", A[i]);
    }
    printf("\n");
}

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


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

using namespace std;

long long inf=1000000007;
vector<long long> ki(200001,-1),button(200001,0);
vector<vector<long long>> kankei(200001);

void dfs(long long now,long long point){
	point+=button.at(now);
	ki.at(now)=point;

	for(auto a:kankei.at(now)){
		if(ki.at(a)==-1){
			dfs(a,point);
		}
	}
}

int main(){
	long long n,q;
	cin>>n>>q;
	for(long long i=0;i<n-1;i++){
		long long a,b;
		cin>>a>>b;
		kankei.at(a).push_back(b);
		kankei.at(b).push_back(a);
	}
	for(long long i=0;i<q;i++){
		long long p,x;
		cin>>p>>x;
		button.at(p)+=x;
	}

	dfs(1,0);

	for(long long i=1;i<=n;i++){
		cout<<ki.at(i)<<endl;
	}

	return 0;
}


Measured memory_bytes: 23484
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;

int Y[MAX];
int X[MAX];
int W[MAX];
int t, l;

int getD(int x, int y, int d)
{
	if (d == 2) swap(x, y);
	if (x <= y) return y - x;
	return y + l - x;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n >> l >> t;
	FOR(i, 0, n)
	{
		cin >> X[i] >> W[i];
	}

	FOR(i, 0, n)
	{
		if (W[i] == 1)
		{
			Y[i] = (X[i] + t) % l;
			//Y[i] = MP((X[i] + t) % l, W[i]);
		}
		else
		{
			Y[i] = (X[i] - t % l + l) % l;
			//Y[i] = MP((X[i] - t % l + l) % l, W[i]);
		}
	}

	int cnt = 0;
	FOR(i, 1, n)
	{
		if (W[i] == W[0]) continue;
		int d = getD(X[0], X[i], W[0]);
		int c = (2 * t - d) / l;
		//if ((2 * t - d) % l == 0) c--;
		//if (c == -1) c = n - 1;
		if (d <= 2 * t) c++;
		c = c % n;
		cnt = (c + cnt) % n;
	}

	if (W[0] == 2) cnt = n - cnt;
	int y = Y[0];
	sort(Y, Y + n);
	int ind = lower_bound(Y, Y + n, y) - Y;
	if (ind + 1 < n && Y[ind] == Y[ind + 1])
	{
		if (W[0] == 1) ind++;
	}

	ind = (ind - cnt + n) % n;
	FOR(i, 0, n)
	{
		if (ind == n) ind = 0;

		cout << Y[ind] << "\n";
		ind++;
	}
}


Measured memory_bytes: 2432
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define st first
#define nd second

using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set =
	tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
#define shandom_ruffle random_shuffle
 
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

const int K = 9;
const int M = 40;
int cnt_nums[M][M];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(11);
	cerr << fixed << setprecision(6);

	int n;
	cin >> n;

	
	for (int i = 0; i < n; ++i) {
		long double s;
		cin >> s;
		ll num = llround(s * 1000 * 1000 * 1000);
		//~ string s;
		//~ cin >> s;
		//~ ll num = 0;
		//~ for (char ch : s) {
			//~ if (ch == '.') { continue; }
			//~ num *= 10;
			//~ num += ch - '0';
		//~ }

		int p2 = 0, p5 = 0;
		while (num % 2 == 0) {
			num /= 2;
			++p2;
		}
		while (num % 5 == 0) {
			num /= 5;
			++p5;
		}
		++cnt_nums[p2][p5];
	}

	ll ans = 0;

	for (int a2 = 0; a2 < M; ++a2) {
		for (int a5 = 0; a5 < M; ++a5) {
			if (!cnt_nums[a2][a5]) { continue; }
			ll c1 = cnt_nums[a2][a5];
			if (a2 >= K && a5 >= K) {
				ans += c1 * (c1 - 1) / 2;
			}

			for (int b2 = 0; b2 < M; ++b2) {
				for (int b5 = 0; b5 < M; ++b5) {
					ll c2 = cnt_nums[b2][b5];
					if (!c2) { continue; }
					if (make_pair(b2, b5) <= make_pair(a2, a5)) { continue; }
					if (a2 + b2 >= K*2 && a5 + b5 >= K * 2) {
						ans += c1 * c2;
					}
				}
			}
		}
	}

	cout << ans << "\n";
}


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

int main () {
  long N;
  cin >> N;
  int count = 0;
  bool x = true;
  while (N >= 10) {
    if (N%10 != 9) x = false;
    count++;
    N /= 10;
  }
  int ans = N-1+count*9;
  if (x) ans += 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

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


int main(){
	
	vector<double> a;
	double b;
	while(cin>>b){
		a.push_back(b);
	}
	
	sort(a.begin(),a.end());
	
	printf("%lf\n",a[a.size()-1]-a[0]);
}

Measured memory_bytes: 1252
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;

int main(){
  int n; cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    s.insert(k);
  }
  int surp = n - s.size();
  surp %= 2;
  if (surp == 1) cout << s.size() - 1 << endl;
  else cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 4992
//パケット法
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int[] a = new int[n];
    int[] aa = new int[n+1];
    int kind = 0;
    int sum = 0;

    for(int i = 0; i < n; i++){a[i] = scan.nextInt();}
    for(int i = 0; i < n; i++){aa[i] = 0;}
    for(int i = 0; i < n; i++){aa[a[i]]++;}
    for(int i = 1; i < n+1; i++){
      if(aa[i] > 0)
        kind++;
    }
    if(kind > k){
      Arrays.sort(aa);
      for(int i = 1; i <= aa.length-1-k; i++){sum += aa[i];}
    }
    System.out.println(sum);
  }
}


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

int main() {
	int N, H, W;
	cin >> N >> H >> W;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if (a >= H && b >= W) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    vector<int> A;
    int n, op, num;
    cin >> n;
    repi(i, n, 0)
    {
        cin >> op;
        if (op == 0)
        {
            cin >> num;
            A.push_back(num);
        }
        else if (op == 1)
        {
            cin >> num;
            cout << A[num] << endl;
        }
        else if (op == 2)
        {
            A.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 3896
#include<stdio.h>

 int main(void) {
   int r,g,b;
   scanf("%d%d%d",&r,&g,&b);
   
   if((r*100+g*10+b)%4 == 0) {
    printf("YES\n");
   }
   
   else {
    printf("NO\n");
   }
   
   return 0;
 }

Measured memory_bytes: 128
#include <iostream>
#include<string>
#define lli long long int
using namespace std;

int main() {
	// your code goes here
	lli x,k,n,c,las;
	c=0;
	cin>>k;
	string s;
	cin>>s;
	n=s.size()/2;
	if(s.size()%2!=0){
		cout<<"No";
		return 0;
	}
	for(lli i =0;i<s.size()/2;i++){
		// cout<<s[i];
		if(s[i]!=s[i+n]){
			
			c=1;
			break;
		}
	
	}
	
	if (c==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	// x='Z';
	// las=int('Z');
	// if('Z'-(s[0]+k)>=0)cout<<(char)(s[0]+2);
	// cout<<'Z'<<" "<<(s[0]+k);
	// SUN, MON, TUE, WED, THU, FRI, or SAT, 
	return 0;
}

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

struct BinaryIndexedTree {
  BinaryIndexedTree() {}
  BinaryIndexedTree(int n) : n(n), v(n + 1, 0) {}

  vector<int> v;
  int n;

  int sum(int i) {
    int ret = 0;
    while (i) {
      ret += v[i];
      i -= i & -i;
    }
    return ret;
  }

  void add(int i, int x) {
    while (i <= n) {
      v[i] += x;
      i += i & -i;
    }
  }
};

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

  BinaryIndexedTree bit(n);
  while (q--) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c) {
      cout << bit.sum(y) - bit.sum(x - 1) << endl;
    } else {
      bit.add(x, y);
    }
  }
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MOD ((ll)(1e9+7))
#define HSM ((ll)(307))
#define ARRS ((ll)(2e6+900))
#define pb push_back
#define mid ((l+r)>>1)
#define PI 3.14159265358979323846
#define MXN 500009
#define mep make_pair


int main(){
	ios::sync_with_stdio(0);
	string s;
	cin>>s;
	string b="AKIHABARA";
	ll n=s.size();
	ll i,j=0;
	for(i=0; i<n; i++){
		if(j==b.size()){
			cout<<"NO";
			return 0;
		}
		if(s[i]==b[j]){
			j++;
		}
		else if(b[j]=='A'){
			j++;
			i--;
		}
		else {
			cout<<"NO";
			return 0;
		}
	}
	if(j>=b.size()-1)
	cout<<"YES";
	else cout<<"NO";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String n = scan.next();
		int rn = Integer.parseInt(n.substring(n.length() - 1));

		switch (rn) {
		case 2 :
		case 4 :
		case 5 :
		case 7 :
		case 9 :System.out.println("hon");
		break;
		case 0 :
		case 1 :
		case 6 :
		case 8 : System.out.println("pon");
		break;
		case 3 : System.out.println("bon");
		}

		scan.close();

	}

}


Measured memory_bytes: 35704
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <cstring>

#define ll long long
#define MP make_pair
#define PB push_back
#define P push
#define f first
#define se second
#define S size()
#define B begin()
#define E end()
#define PI acos(-1)
#define fscan1(n)  scanf("%d",&(n));
#define fscan2(n,m)  scanf("%d %d",&(n),&(m));
#define fscan3(n,m,k)  scanf("%d %d %d",&(n),&(m),&(k));

const int N = 1e5 + 100;
const int M = 2e5 + 100;
const ll oo = 1e18;

int n, m, k, t, q, h, a, b, c, x, y, z;
using namespace std;

int ar[N][3];
int dp[N][3];


int main(){
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> ar[i][0] >> ar[i][1] >> ar[i][2];
	}
	
	for(int i = 0; i < n; i++){
		if( i == 0){
			dp[0][0] = ar[0][0], dp[0][1] = ar[0][1], dp[0][2] = ar[0][2];
			continue;
		}
		for(int c = 0; c < 3; c++){
			dp[i][c] = max(dp[i- 1][(c + 1) % 3], dp[i - 1][(c + 2) % 3]) + ar[i][c];
		}
	}

	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));

	return 0;
 }




Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N;
    cin >> N;
    ll ans = 10;
    ll tmp1, tmp2;
    ll cnt1, cnt2;
    for (ll i = 1; i*i <= N; i++) {
        if(N % i == 0){
            tmp1 = i;
            tmp2 = N / i;
            cnt1 = 0; cnt2 = 0;
            while(tmp1 > 0){
                tmp1 = tmp1 / 10;
                cnt1++;
            }
            while(tmp2 > 0){
                tmp2 = tmp2 / 10;
                cnt2++;
            }
            ans = min(max(cnt1, cnt2), ans);
        }
    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 3744
/* ITP1_10_B */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] str = br.readLine().split(" ");
      double a = Double.parseDouble(str[0]);
      double b = Double.parseDouble(str[1]);
      double c_angle = (2 * Math.PI) * (Double.parseDouble(str[2]) / 360);

      double space, length, height;
      height = b * Math.sin(c_angle);
      space = height * a / 2;
      length = a + b + Math.sqrt(a*a + b*b - 2*a*b*Math.cos(c_angle));

      System.out.println(space + "\n" + length + "\n" + height);
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24344
#include <stdio.h>
#include <ctype.h>

int main(int argc, char **argv)
{
    char s[16];
    for (int i = 0; i < 3; ++i) {
        scanf("%s", s);
        putchar(toupper((int)s[0]));
    }
    puts("");
    return 0;
}

Measured memory_bytes: 128