akhauriyash/Code-Regression huggingface dataset:
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

char op[2]={'+','-'};

int main(){
    int a,b,c,d;
    string s;
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    //REP(i,2)
    REP(j,2)REP(k,2)REP(l,2){

        int sum=a;
        //sum+= (i==0) ?a:-a;
        sum+= (j==0) ?b:-b;
        sum+= (k==0) ?c:-c;
        sum+= (l==0) ?d:-d;

         if(sum==7){
             cout<<a<<op[j]<<b<<op[k]<<c<<op[l]<<d<<"=7"<<endl;
             return 0;
         }
         
         
    }





}


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

int gcd( int a, int b ){
  if( a < b ) return gcd( b, a );
  if( b == 0 ) return a;
  return gcd( b, a % b );
}

int main(void){
  int a, b;
  scanf("%d %d", &a, &b );
  printf("%d\n", gcd( a, b ) );
  return 0;
}


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

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

signed main() {
	double ans = 0;
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		int j;
		for (j = 0; i * pow(2., j) < k; ++j);
		ans += pow(2, -j)/n;
	}
	exact_say(ans);
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10001
#define INF 10000000
#define NIL -1

#define WHITE 0
#define BLACK 1 

int n;
int Graph[MAX][MAX];

void prim(void);

int main(){

  int i, j, k, u, v, w;

  scanf("%d", &n);

  for(i = 0; i < n; i++){

    for(j = 0; j < n; j++){

      Graph[i][j] = INF;

    }

  }

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

    for(j = 0; j < k; j++){

      scanf("%d %d", &v, &w);

      Graph[u][v] = w;

    }

  }

  prim();

  return 0;

}

void prim(){

  int u, v, mincost, i, sum;
  int d[MAX];
  int pi[MAX];
  int color[MAX];

  sum = 0;

  for(u = 0; u < n; u++){

    d[u] = INF;
    
    pi[u] = NIL;

    color[u] = WHITE;

  }

  d[0] = 0;

  while(1){

    mincost = INF;

    for(i = 0; i < n; i++){

      if((color[i] != BLACK) && (d[i] < mincost)){

	mincost = d[i];

	u = i;

      }

    }

    if(mincost == INF)
      break;

    color[u] = BLACK;

    for(v = 0; v < n; v++){

      if(d[v] > d[u] + Graph[u][v]){

	d[v] = d[u] + Graph[u][v];

	pi[v] = u;

      }

    }

  }

  for(i = 0; i < n; i++){

    printf("%d %d\n", i, d[i]);

  }

}

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

using namespace std;
const int N = 200200;
int p[N];
int r[N];
int s[N];

int findset(int x) {
    return x == p[x] ? x : p[x] = findset(p[x]);
}

pair<pair<int, int>, int> a[N];

void unite(int x, int y) {
    x = findset(x);
    y = findset(y);
    if (rand() & 1) swap(x, y);

    r[y] = min(r[x], r[y]);
    s[y] += s[x];
    p[x] = y;
}

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first.first >> a[i].first.second;
        a[i].second = i;
        r[i] = a[i].second;
        p[i] = i;
        s[i] = 1;
        r[i] = a[i].first.second;
    }
    sort(a + 1, a + n + 1);

    set<pair<int, int> > s;
    for (int i = 1; i <= n; i++) {
        int x = a[i].first.first;
        int y = a[i].first.second;
        int ind = a[i].second;
        vector<int> v;
        while (!s.empty() && s.begin()->first < y) {
            v.push_back(s.begin()->second);
            s.erase(s.begin());
        }
        for (auto j:v) {
            unite(j, ind);
        }
        s.insert({r[findset(ind)], findset(ind)});
    }
    for (int i = 1; i <= n; i++) {
        cout << ::s[findset(i)] << endl;
    }

}

int main() {
#ifdef QWERTY
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    int TC = 1;
    for (int i = 1; i <= TC; i++) {
        // cout << "Case #" << i << endl;
        solve();
    }

    return 0;
}


Measured memory_bytes: 13196
fn main() {
    let x = read::<usize>();
    let a = read::<usize>();
    let b = read::<usize>();
    println!("{}", (x - a) % b);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

long long  gcd(long long  a, long long  b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
	long long  g = gcd(a, b);
	return a / g * b;
}

ll n, ans;
int main() {
	cin >> n;
	//odd
	if (n % 2 == 1) { cout << 0 << endl; return 0; }
	//even
	n /= 2;
	for (ll i = 5; n / i >= 1; i *= 5) { ans += n / i; }
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050]; //fenwick
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }
    ll Com[1051][1051];
    void pre()
    {

        ll i,j,n=1051;
        rep(i,0,n) Com[i][0]=Com[i][i]=1;
        rep(i,2,n)
        {
            rep(j,1,i)
            {
                Com[i][j]=Com[i-1][j]+Com[i-1][j-1];
                Com[i][j]%=hell;
            }
        }

    }
    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }


    void solve()
    {
    double i,j=0,r=200,p,q,k=0,d,y=0,n,h=10000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
     cin>>n;
     double pie=6.28318530717958623200;
     n*=pie;
     cout<<fixed<<setprecision(10)<<n;
    }
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
       // cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << ' ';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;
  ui A{}, B{}; std::cin >> A >> B;

  auto ans = 
    (A >= 13U)
    ? B
    : (A >= 6)
      ? B / 2
      : 0;

  using std::cout;
  cout << ans << '\n';
  
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	t := nextIntArray()
	n, m := t[0], t[1]
	g := make([][]bool, n)
	for i := range g {
		g[i] = make([]bool, n)
	}
	for i := 0; i < m; i++ {
		t = nextIntArray()
		g[t[0]-1][t[1]-1] = true
		g[t[1]-1][t[0]-1] = true
	}
	visited := make([]bool, n)
	visited[0] = true
	fmt.Println(dfs(g, 0, visited))
}

func all(visited []bool) bool {
	for _, v := range visited {
		if !v {
			return false
		}
	}
	return true
}

func dfs(g [][]bool, node int, visited []bool) int {
	if all(visited) {
		return 1
	}
	sum := 0
	for neigh, v := range g[node] {
		if v && !visited[neigh] {
			visited[neigh] = true
			sum += dfs(g, neigh, visited)
			visited[neigh] = false
		}
	}
	return sum
}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k < u->key){ return treeSearch(u->left,k);}
  else { return treeSearch(u->right,k);}
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

Node treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){ y=z;}
  else {y= treeSuccessor(z);}
  if(y->left!=NIL){ x=y->left;}
  else {x=y->right;}
  if(x!=NIL){ x->parent=y->parent;}
  if(y->parent==NIL){ root=x;}
  else if(y==y->parent->left){ y->parent->left=x;}
  else {y->parent->right=x;}
  if(y!=z){
    z->key=y->key;
    /*z->left=y->left;
    z->right=y->right;
    z->parent=y->parent;*/
  }
    return y;
}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  //printf("%d\n",x->key);
  while(x!=NIL){
    y=x;
    if(z->key < x->key){ x=x->left;}
    else{x=x->right;}
  }
  z->parent=y;
  if(y==NIL){ root = z;}
  else if(z->key < y->key){y->left=z;}
  else y->right=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  root=NIL;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
def combi_2(n)
  n * (n - 1)/2
end

n = gets.to_i
ss = Array.new(n) { |i| gets.chomp }
ans = 0

group = ss.group_by{|v| v.chars.sort.join}
group.each do |key, val|
  ans += combi_2(val.size)
end

puts ans

Measured memory_bytes: 37884
h,n=map(int,input().split())

lists=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append([a,b])
    
    
#dic[x]=y モンスターの体力をｘ減らすために必要な魔力
minimum=[10**9 for i in range(20001)]
#minimum[k]=ダメージｋを与えるために最小の魔力
minimum[0]=0
for i in range(1,20001):
    for j in range(n):
        if i>=lists[j][0]:
            minimum[i]=min(minimum[i-lists[j][0]]+lists[j][1],minimum[i])
        else:
            minimum[i]=minimum[i]
ans=10**8
for k in range(h,20001):
    ans=min(ans,minimum[k])
print(ans)

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

int main()
{
  int K;
  cin >> K;
  vector<int> num(100, 0);
  int now_d = 0, max_d = 0;
  while (K)
  {
    // cout << num.at(1) << num.at(0) << " " << K << " " << now_d << " " << max_d << endl;
    if (max_d == 0)
    {
      num.at(0)++;
      K--;
      if (!K) break;
      if (num.at(0) == 9)
      {
        max_d = 1;
        num.at(1) = 1;
        num.at(0) = -1;
      }
      continue;
    }
    if (now_d == 0)
    {
      // cout << num.at(1) << num.at(0) << " " << K << " " << now_d << " " << max_d << endl;

      if (num.at(0) == -1){
        num.at(0) = max(0, num.at(1) - 1);
        K--;
      }
      else if (num.at(0) <= num.at(1) && num.at(0) != 9)
      {
        num.at(0)++;
        K--;
      }
      else
        now_d = 1;
    }
    else
    {
      if (now_d == max_d)
      {
        if (num.at(now_d) != 9)
        {
          num.at(now_d)++;
          num.at(now_d-1) = -1;
          now_d--;
        }
        else
        {
          max_d++;
          num.at(max_d) = 1;
          num.at(max_d-1) = -1;
        }
      }
      else
      {
        if (num.at(now_d) == -1)
        {
          num.at(now_d) = max(0, num.at(now_d+1) - 1);
          num.at(now_d-1) = -1;
          now_d--;
        }
        else if (num.at(now_d) <= num.at(now_d+1) && num.at(now_d) != 9)
        {
          num.at(now_d)++;
          num.at(now_d-1) = -1;
          now_d--;
        }
        else
          now_d++;
      }
    }
  }
  for (int i = max_d; i >= 0; i--) cout << num.at(i);
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート 1,2,....9
}

int main(void){
    ll N, C, K, time[100100], ans=0, wait=0, x;
    scanf("%lld %lld %lld", &N, &C, &K);
    rep(i, N) scanf("%lld", time+i);
    if(C==1) {
        printf("%lld\n", N);
        return 0;
    }
    
    qsort(time, N, sizeof(ll), cmp);
    ll i=N-1;
    while(i>=0) {
        for(ll j=1; j<C; j++) {
            if( i-j>=0 && time[i]-time[i-j]<=K ){
                if(j==C-1) {
                    ans++;
                    i = i-j-1;
                }
            }
            else {
                ans++;
                i -= j;
                break;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
       int x,k,d;
       cin>>x>>k>>d;
       x=abs(x);
        if(k<=x/d){
            cout<<x-k*d;
        }
        else{
            if((k-x/d)%2)cout<<(d-x%d);
            else cout<<x%d;
        }
    }

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s, t string
	con.Scan(&s, &t)
	c := 0
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			c++
		}
	}
	con.Println(c)
	return nil
}


Measured memory_bytes: 3424
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

ll f(ll b, ll n){
    if(n < b) return n;
    return f(b, floor(n/b)) + (n % b);
}

int main()
{
    ll n,s;
    cin >> n >> s;

    if(s == n){
        cout << n+1 << endl;
        return 0;
    }

    for(ll b = 2; b <= sqrt(n); b++){
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }

    for(ll p = sqrt(n); p > 0; p--){
        ll b = ((n-s)/p) + 1;
        if(1 < b && f(b,n) == s){
            cout << b << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}



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

int A[200000];
int cnt[200001] = {0};

void Main()
{
  int N;
  cin >> N;
  int maxnum = 0;
  int secondmaxnum = 0;
  rep(i,N){
    cin >> A[i];
    if (maxnum < A[i]) maxnum = A[i];
    cnt[A[i]]++;
  }
  rep(i,N) {
    if (secondmaxnum < A[i] && A[i] != maxnum) secondmaxnum = A[i];
  }
  
  if (cnt[maxnum] > 1) {
    rep(i,N) cout << maxnum << endl;
  } else {
    rep(i,N) {
      if (A[i] == maxnum) cout << secondmaxnum << endl;
      else cout << maxnum << endl;
    }
  }
  
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T2;

int MOD=1e9+7;
ll INF=1e18;

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

int coin[12]={1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
int T[100010];

int main(){
    int n; cin>>n;
    for(int i=0; i<=100005; i++) T[i]=1e9;
    T[0]=0;
    for(int i=0; i<12; i++){
        for(int j=0; j+coin[i]<=n; j++){
            T[j+coin[i]]=min(T[j+coin[i]], T[j]+1);
        }
    }
    cout << T[n] << endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, a;
  cin >> n >> a;
  bool ans = n % 500 <= a;
  if (ans) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }

  return 0;
}

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

int main(){
    int n,ans;
    cin>>n;
    ans=0;
    vector<int>a(n);
    vector<int>b(n);
    vector<int>c(n-1);

    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }

    for(int i=0;i<n;i++){
        cin>>b.at(i);
    }

    for(int i=0;i<n-1;i++){
        cin>>c.at(i);
    }

    for(int i=0;i<n;i++)
        ans+=b.at(a.at(i)-1);

    for(int i=0;i<n-1;i++){
        if(a.at(i)==a.at(i+1)-1)
        ans+=c.at(a.at(i)-1);
    }

    cout<<ans<<endl;

    
}

Measured memory_bytes: 256
N, X = map(int, input().split())

p = [0]*(N+1)
a = [0]*(N+1)
p[0] = 1
a[0] = 1
for i in range(1, N+1):
    p[i] = 2 * p[i-1] + 1
    a[i] = 2 * a[i-1] + 3

def f(N, X):
    i = N
    if N == 0:
        if X <= 0:
            return 0
        if X >= 1:
            return 1
    if X == 1:
        return 0
    elif X > 1 and X <= 1 + a[i-1]:
        return f(N-1, X-1)
    elif X == 2 + a[i-1]:
        return p[i-1] + 1
    elif X > 2 + a[i-1] and X <= 2 + 2*a[i-1]:
        return p[i-1] + 1 + f(N-1, X-2-a[i-1])
    else:
        return 2*p[i-1] + 1

print(f(N, X))

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

#define INF (1e9)
#define INF_LL (1e17)

using LL = long long;
using ULL = unsigned long long;

using namespace std;

#define MAX_N 100005
int N;
LL C, K;
LL T[MAX_N];

int main()
{
  cin >> N;
  cin >> C >> K;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }

  sort(T, T+N);

  int ans = 0;
  LL t = -1;
  LL c = 0;
  for (int i = 0; i < N; i++) {
    if(c == 0){
      t = T[i] + K;
      c++;
      ans++;
    }
    else if(c < C){
      if(T[i] <= t){
        c++;
      }
      else{
        i--;
        c = 0;
      }
    }
    else{
      i--;
      c = 0;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
/**
 *   author: Shubham Srivastava
 *   created: 27 January 2020  12:34:09
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,m;cin>>n>>m;
    vector <string> grid(n);
    for(int i=0;i<n;i++){
    	cin>>grid[i];
    }
    vector <vector <int> > dp(n, vector <int> (m,0));
    for(int i=0;i<m;i++){
    	if(grid[0][i] == '#')
    		break;
    	dp[0][i] = 1;
    }
    for(int i=0;i<n;i++){
    	if(grid[i][0] == '#')
    		break;
    	dp[i][0] = 1;
    }
    for(int i=1;i<n;i++){
    	for(int j=1;j<m;j++){
    		if(grid[i][j] == '.'){
    			dp[i][j] = dp[i-1][j] + dp[i][j-1];
    			dp[i][j] %= MOD;
    		}
    	}
    }
    cout<<dp[n-1][m-1];
return 0;
}

Measured memory_bytes: 5248
n = int(input())
arr = list(map(int, input().split()))
su = sum(arr)
lst = [0]*100001
q = int(input())
for i in arr:
    lst[i] += 1
for _ in range(q):
    b, c = map(int, input().split())
    su += (c - b) * lst[b]
    print(su)
    lst[c] += lst[b]
    lst[b] = 0


Measured memory_bytes: 20988
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int (i)=0;(i)<n;(i)++)

#define Rrep(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=a;i<n;i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)

int N;

//              1
//              |
//              2
//            ／ ＼
//           3     4
//                                                             0    1    2   3
vector<int>tree[200005];//双方向リストを作成する 上の例だと、[[1][0,2,3][1],[1]] 
//　　　　　　　　　　　　　　　　　　　　　　　↑各頂点について、つながってる頂点が格納されている

vector<int>ans;//答えを格納する 頂点の数だけ要素があり、双方向リストと累積和を用いて計算を行う

void dfs(int v, int p = -1) {
	for (auto u : tree[v]) {
		if (u == p) {
			continue;
		}
		ans[u] += ans[v];
		//for (int i = 0; i < N; i++) cout << ans[i] << " ";
		//cout << endl;
		dfs(u, v);//現在のvにつながっている頂点の一つをuに設定し、親を現在調べている頂点の番号に設定する
	}
}
// 例えば、dfs(0,-1)のとき(tree[0]=1)、頂点0(図における頂点1)に隣接している頂点(頂点2)に頂点0に加算されるc[0]を加える
// そして、dfs(1,0)(tree[1]=0,2,3)により頂点2における親以外の隣接している頂点(頂点3,頂点4)に対してc[1]を加算する
// dfs(2,1)の時の隣接している頂点は親しか存在しないため、処理は行われない(dfs(3,1)も同様)


int main() {

	int Q;
	cin >> N >> Q;
	int a, b;
	int temp = 0;

	REP(i, N-1) {
		cin >> a >> b;
		--a; --b;          //                       0  1
		tree[a].push_back(b);//1,2が入力されたら、[[1][0]]
		tree[b].push_back(a);
	}

	ans.resize(N);

	for (int i = 0; i < Q; i++) {
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;//とりあえず、入力された頂点に加算する。後でdfsで加算を行う
	}

	dfs(0);

	REP(i, N) {
		cout << ans[i] << endl;
	}
	

	return 0;

}

Measured memory_bytes: 23424
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int x[100000];
int w[100000];

int main() {
    int n, l, t, p = 0, y, i;
    vector <int> v;
    
    scanf("%d %d %d", &n, &l, &t);
    
    for (i = 0; i < n; i++) scanf("%d %d", &x[i], &w[i]);
    
    for (i = 0; i < n; i++) {
        if (w[i] == 1) {
            v.push_back((x[i] + t) % l);
        } else {
            v.push_back(((x[i] - t) % l + l) % l);
        }
    }
    
    y = v[0];
    
    sort(v.begin(), v.end());
    
    t *= 2;
    
    for (i = 1; i < n; i++) {
        if (w[i] != w[0]) {
            if (w[0] == 1) {
                if (x[i] - x[0] > t) continue;
                
                p += (t - (x[i] - x[0])) / l + 1;
            } else {
                if (x[0] - x[i] + l > t) continue;
                
                p -= (t - (x[0] - x[i] + l)) / l + 1;
            }
            
            p = (p % n + n) % n;
        }
    }
    
    for (i = 0; i < n; i++) {
        if (v[i] == y) break;
    }
    
    if (i < n && v[i] == v[i + 1] && w[0] == 1) i++;
    
    p = (i - p + n) % n;
    
    for (i = p; i < n; i++) printf("%d\n", v[i]);
    for (i = 0; i < p; i++) printf("%d\n", v[i]);
    
    return 0;
}


Measured memory_bytes: 2424
using System;

namespace question1
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var line = Console.ReadLine();
            var a = int.Parse(line.Split(' ')[0]);
            var b = int.Parse(line.Split(' ')[1]);
            var t = int.Parse(line.Split(' ')[2]);

            Console.WriteLine(t/a*b);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main()
{
	int n, x, p, l, i, r[11];
	while (cin >> n, (x = n) != -1)
	{
		p = l = 0;
		while (x != 0)
		{
			r[p++] = x % 4;
			x /= 4;
			l++;
		}
		for (i = l-1; i >= 0; i--)
			cout << r[i];
		if (!n) cout << 0;
		cout << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std; 
int main() { 
	int n,ans,minn=999999999;
	cin>>n>>ans;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(y<=ans)
		{
			minn = min(minn,x);
		}
	}
	if(minn!=999999999)cout<<minn;
	else cout<<"TLE";
    return 0; 
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();
        int min = 999;
        for(int i = 2; i < S.length(); i++){
            int n = Integer.parseInt(S.substring(i-2, i+1));
            int diff = Math.abs(753 - n);
            if(diff < min){
                min = diff;
            }
        }
        System.out.println(min);
    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(n);
  for (auto &v : vec)
    cin >> v;

  sort(vec.begin(), vec.end());

  ll cnt = 0;
  for (ll i = 0; i < n; ++i) {
    for (ll j = i + 1; j < n; ++j) {
      for (ll k = j + 1; k < n; ++k) {
        ll a = vec[i];
        ll b = vec[j];
        ll c = vec[k];
        cnt += c < a + b && a != b && b != c;
      }
    }
  }

  cout << cnt << endl;
}


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

int main() {
	double w;
	while (cin >> w) {
		if (w <= 48.0) cout << "light fly";
		else if (w <= 51.0) cout << "fly";
		else if (w <= 54.0) cout << "bantam";
		else if (w <= 57.0) cout << "feather";
		else if (w <= 60.0) cout << "light";
		else if (w <= 64.0) cout << "light welter";
		else if (w <= 69.0) cout << "welter";
		else if (w <= 75.0) cout << "light middle";
		else if (w <= 81.0) cout << "middle";
		else if (w <= 91.0) cout << "light heavy";
		else cout << "heavy";
		cout << endl;
	}
	return 0;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int time[101] = {0};
    erep1(i, 100) {
        if (A < i && i <= B) time[i]++;
        if (C < i && i <= D) time[i]++;
    }
    int count = 0;
    erep1(i, 100) {
        if (time[i] == 2) count++;
    }
    cout << count << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

ll gcd(ll p, ll q){
    if(p%q==0)return q;
    else return gcd(q,p%q);
}

int main() {
    ll n,x,a,t=-1;
    cin >> n >> x;
    REP(i,n){
        ll a;
        cin >> a;
        if(t==-1)t = abs(a-x);
        t = gcd(t,abs(a-x));
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  vector<ll> h(n);
  rep(i,n) cin>>h[i];

  vector<ll> dp(n);

  ll ans=0;

  rep(i,n){
    if(i==0) dp[i]=0;
    else{
      if( h[i]<=h[i-1] ) dp[i]=dp[i-1]+1;
      else dp[i]=0;
    }
    ans=max(ans,dp[i]);
  }

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

int n,k;
vector<int> v[111111];
int d[111111],c[111111];

int dfs(int x,int p) {
  int z=1<<30;
  for(int i=0; i<v[x].size(); i++) {
    int y=v[x][i];
    z=min(z,dfs(y,x));
  }
  if(z==1<<30||p==-1) z=0;
  d[x]=z;
  return z+1;
}

int main() {
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    int x;
    cin >> x;
    if(x) {
      v[x-1].push_back(i);
      c[i]++;
    }
  }
  for(int i=0; i<n; i++) {
    if(!c[i]) dfs(i,-1);
  }
  int ans=0;
  for(int i=0; i<n; i++) {
    if(d[i]<k) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15868
import java.util.*
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (n, k) = readInts ()
    val a = readInts().toIntArray()

    println((k until n).joinToString("\n") {
        if (a[it - k] < a[it]) "Yes" else "No"
    })
}


Measured memory_bytes: 65200
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int N,res=0;
	cin>>N;

	multiset<int> st;
	rep(i,N){
		int a;
		cin>>a;

		auto itr = st.lower_bound(a);
		if(itr==st.begin()){
			res++;
			st.insert(a);
		}
		else{
			--itr;
			st.erase(itr);
			st.insert(a);
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define p_ pair<int,int>
#define mp_ make_pair
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int n,m,a[maxn];
vector<int> g[maxn];
int main()
{
    fastio();
    cin>>n>>m;
    rep(i,1,n) cin>>a[i];
    rep(i,1,m) {int u,v;cin>>u>>v;g[u].pb(v),g[v].pb(u);}
    int ans = 0;
    rep(i,1,n){
        int sz = g[i].size();
        int flag = 1;
        for(int v:g[i]) if(a[v]>=a[i]) {flag=0;break;}
        if(flag) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11520
#include <stdio.h>

typedef struct {
    int top;
    int bottom;
    int right;
    int left;
    int front;
    int back;
} Dice;

void roll(Dice *d, char direction)
{
    int present_top = d->top;
    int present_bottom = d->bottom;
    int present_right = d->right;
    int present_left = d->left;
    int present_front = d->front;
    int present_back = d->back;

    if (direction == 'N') {
        d->top = present_front;
        d->bottom = present_back;
        d->front = present_bottom;
        d->back = present_top;
    } else if (direction == 'S') {
        d->top = present_back;
        d->bottom = present_front;
        d->front = present_top;
        d->back = present_bottom;
    } else if (direction == 'E') {
        d->top = present_left;
        d->bottom = present_right;
        d->right = present_top;
        d->left = present_bottom;
    } else {
        d->top = present_right;
        d->bottom = present_left;
        d->right = present_bottom;
        d->left = present_top;
    }
}

void revolve(Dice *d, char direction)
{
    int present_top = d->top;
    int present_bottom = d->bottom;
    int present_right = d->right;
    int present_left = d->left;
    int present_front = d->front;
    int present_back = d->back;

    if (direction == 'R') {
        d->front = present_right;
        d->back = present_left;
        d->right = present_back;
        d->left = present_front;
    } else {
        d->front = present_left;
        d->back = present_right;
        d->right = present_front;
        d->left = present_back;
    }
}

int is_same(Dice *d1, Dice *d2)
{
    int i;

    for (i = 0; i < 6; i++) {
        if (d1->top == d2->top) {
            int j;
            for (j = 0; j < 4; j++) {
                if (d1->front == d2->front) {
                    if (d1->bottom == d2->bottom && d1->right == d2->right
                        && d1->left == d2->left) return 1;
                }
                else revolve(d2, 'R');
            }
        }
        if (i % 2 == 0) roll(d2, 'N');
        else roll(d2, 'W');
    }

    return 0;
}

int main(void)
{
    Dice dice1;
    Dice dice2;
    int i;

    for (i = 0; i < 6; i++) {
        switch (i) {
            case 0 : scanf("%d", &dice1.top); break;
            case 1 : scanf("%d", &dice1.front); break;
            case 2 : scanf("%d", &dice1.right); break;
            case 3 : scanf("%d", &dice1.left); break;
            case 4 : scanf("%d", &dice1.back); break;
            case 5 : scanf("%d", &dice1.bottom); break;
        }
    }

    for (i = 0; i < 6; i++) {
        switch (i) {
            case 0 : scanf("%d", &dice2.top); break;
            case 1 : scanf("%d", &dice2.front); break;
            case 2 : scanf("%d", &dice2.right); break;
            case 3 : scanf("%d", &dice2.left); break;
            case 4 : scanf("%d", &dice2.back); break;
            case 5 : scanf("%d", &dice2.bottom); break;
        }
    }

    if (is_same(&dice1, &dice2)) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
    int N;
    
    cin >> N;
    
    vector<int> p(N + 1);
    vector<int> a(N + 1);
    vector<int> b(N + 1);
    
    for (int i = 1; i <= N; i++)
    {
        cin >> p[i];
    }
    
    for (int i = 1; i <= N; i++)
    {
        a[i] = 30000 * i;
        b[i] = 30000 * (N - i);
    }
    
    for (int i = 1; i <= N; i++)
    {
        b[p[i]] += i;
    }
    
    for (int i = 1; i <= N; i++)
    {
        printf("%d", a[i]);
        if (i != N)
        {
            printf(" ");
        }
        else
        {
            printf("\n");
        }
    }

    for (int i = 1; i <= N; i++)
    {
        printf("%d", b[i]);
        if (i != N)
        {
            printf(" ");
        }
        else
        {
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 896
#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 int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

int dp[1 << 16], sum[1 << 16];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n][n];
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	sum[0] = 0;
	for(int mask = 1; mask < (1LL << n); mask++) {
		vi v;
		for(int i = 0; i < n; i++) {
			if(mask & (1LL << i)) {
				v.pb(i);
			}
		}
		for(int i = 0; i < v.size(); i++) {
			for(int j = i + 1; j < v.size(); j++) {
				sum[mask] += a[v[i]][v[j]];
			}
		}
	}
	memset(dp, -63, sizeof(dp));
	dp[0] = 0;
	for(int mask = 1; mask < (1LL << n); mask++) {
		for(int s = mask; s > 0; s = mask & (s - 1)) {
			dp[mask] = max(dp[mask], sum[s] + dp[mask ^ s]);
		}
	}
	cout << dp[(1 << n) - 1];

	return 0;
}

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

int main(void)
{
	int i, n, m, h;
	char N[201], Nw[201];
	
	while(1){
		scanf("%s", N);
		n = strlen(N);
		if(!strcmp(N, "-")) break;
		scanf("%d", &m);
		for(i = 0; i < m; i++){
			scanf("%d", &h);
			memcpy(Nw, N, h);
			memcpy(N, &N[h], n-h);
			memcpy(&N[n-h], Nw, h);
		}
		printf("%s\n", N);
	}
	
	return(0);
}



Measured memory_bytes: 1776