akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll d, t, s;
	cin >> d >> t >> s;
	double a = (double)d / s;
	if (t >= a)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	cin >> a;
}



Measured memory_bytes: 3580
Matches = {num: c for num, c in zip([1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 5, 5, 4, 5, 6, 3, 7, 6])}


def solve(N, M, As):
    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for a in sorted(As, reverse=True):
        c = Matches[a]
        for i in range(N - c + 1):
            if dp[i] == -1:
                continue
            dp[i + c] = max(dp[i+c],
                            dp[i] * 10 + a)
    return dp[N]

if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, M, As))


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

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int num;
  cin >> num;
  switch(num % 10){
  case 2: case 4: case 5: case 7: case 9:
    cout << "hon" << '\n';
    break;
  case 0: case 1: case 6: case 8:
    cout << "pon" << '\n';
    break;
  case 3:
    cout << "bon" << '\n';
    break;
  default:
    cout << "?" << '\n';
    break;
  }
  return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> MakeVector2D(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

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

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  auto dp = MakeVector2D<int64>(n + 1, 5, 2E18);
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 4; j++) {
      for (int k = j; k <= 4; k++) {
        int64 delta = [&]() -> int64 {
          if (k ==0 || k == 4) {
            return xs[i - 1];
          } else if (k == 1 || k == 3) {
            if (xs[i - 1] == 0) return 2;
            if (xs[i - 1] % 2 == 0) return 0;
            else return 1;
          } else {
            if (xs[i - 1] % 2 == 1) return 0;
            else return 1;
          }
        }();
        UpdateMin(dp[i][k], dp[i - 1][j] + delta);
      }
    }
  }
  // for (int i = 0; i <= n; i++) {
  //   cout << dp[i] << endl;
  // }

  int64 ans = 2E18;
  for (int i = 0; i < 5; i++) {
    UpdateMin(ans, dp[n][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
n = int(input())
key = [[0]*9 for i in range(9)]

ans = 0
for v in range(1, n+1):
  l = str(v)
  if v%10 == 0:
    continue
  k1, k2 = int(l[0]), int(l[-1])
  key[k1-1][k2-1] += 1
  ans += key[k2-1][k1-1]*2
  for i in range(len(l)):
    if l[i] != l[-1-i]:
      continue
    if i == len(l)-1:
      ans -= 1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
//import java.util.Arrays ;

// import java.InputMismatchException;
// alds_5b, Aizu Online Judge accept only class name: Main


class Main {

    static void print_list(int [] A, int low, int high) {
        int i ;
        for (i=low; i<high; i++) {
            System.out.printf("%d ", A[i]) ;
        }
        System.out.println() ;
    }

    static long Merge(int [] A, int low, int mid, int high) {
        long swap_count = 0 ;
        int l_size = mid-low ;
        int h_size = high-mid ;
        int []L = new int[l_size] ;
        int []H = new int[h_size] ;

        for (int i=0; i<l_size; i++) {
            L[i] = A[low+i] ;
        }
        for (int i=0; i<h_size; i++) {
            H[i] = A[mid+i] ;
        }

        int a_pos=low, l_pos=0, h_pos=0 ;

        while (l_size != 0 && h_size != 0) {
            //if (L[l_pos] <= H[h_pos]) {
            if (L[l_pos] < H[h_pos]) {  // should be <= ?
                A[a_pos] = L[l_pos] ;
                l_size -= 1 ;
                l_pos += 1 ;
            }
            else {
                A[a_pos] = H[h_pos] ;
                h_size -= 1 ;
                h_pos += 1 ;
                swap_count += l_size ;
            }
            a_pos += 1 ;
        }
        
        while (l_size != 0) {
            A[a_pos] = L[l_pos] ;
            l_size -= 1 ;
            l_pos += 1 ;
            a_pos += 1 ;
        }
        
        while (h_size != 0) {
            A[a_pos] = H[h_pos] ;
            h_size -= 1 ;
            h_pos += 1 ;
            a_pos += 1 ;
        }
        
        return swap_count ;

    }

    static long Merge_sort(int [] A, int low, int high) {
        if (low + 1 < high) {
            int mid = (low + high) / 2 ;
            long v1 = Merge_sort(A, low, mid) ;
            long v2 = Merge_sort(A, mid, high) ;
            long v3 = Merge(A, low, mid, high) ;
            return v1+v2+v3 ;
        }
        else return 0 ;
    }

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in) ;
        String s = scanner.nextLine() ;

        int elem_count ;
        elem_count = Integer.parseInt(s) ;
        int A[] = new int[elem_count] ;

        for (int i=0; i<elem_count; i++) {
            A[i] = scanner.nextInt() ;
        }

        scanner.close() ;
        long swap_count = Merge_sort(A, 0, elem_count) ;

        /*
        for (int i=0; i<elem_count; i++) {
            String end_mark = " " ;
            if (i==elem_count-1) end_mark = "\n" ;
            System.out.print(A[i] + end_mark) ;
        }
        */
        System.out.println(swap_count) ;
    }
}



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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)

int main() {

    int N;
    cin >> N;

    vector<string> s(N);
    map<string,ll> mp;

    ll ans = 0;
    rep(i,N){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
        ans+=(mp[s[i]]-1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 18176
// https://atcoder.jp/contests/abc138/tasks/abc138_e
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

vector<int> al[26];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    REP(i, (int)s.size()) al[s[i] - 'a'].push_back(i);
    int pos = -1;
    ll cnt = 0;
    for (auto x : t) {
        int c = x - 'a';
        if (al[c].size() == 0) {
            cout << "-1\n";
            return 0;
        }
        auto it = upper_bound(ALL(al[c]), pos);
        if (it == al[c].end()) {
            cnt++;
            it = al[c].begin();
        }
        pos = *it;
    }

    cout << cnt * s.size() + pos + 1 << endl;

    return 0;
}


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


int main() {
  int N,X,Y;
  cin >> N >> X >> Y;

  int R[N];
  memset(R,0,sizeof(R));

  for ( int I=1 ; I<=N ; ++I ) {
    for ( int J=I ; J<=N ; ++J ) {
      int A = abs(J - I);
      int B = abs(X - I) + abs(Y - J) + 1;
      int C = abs(Y - I) + abs(X - J) + 1;
      int D = (A<B)? A : B;
      D = (D<C)? D : C;
      R[D] += 1;
    }
  }

  for ( int k=1 ; k<N ; ++k ) {
      cout << R[k] << endl;
  }

}



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

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int n = ia[0];
		int a = ia[1];
		int b = ia[2];
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			int v = i;
			int s = 0;
			while (v > 0) {
				s += v % 10;
				v /= 10;
			}
			if (a <= s && s <= b) {
				ans += i;
			}
		}
		pln(ans);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 20564
import * as fs from 'fs';

namespace AtCoder.abc112 {

    class Program {
        /**
         * in
         *
         * out
         *
         */
        main(inp: string): void {

            const [n, a, b]: number[] = inp.split('\n').map(Number);

            if (n === 1) {
                console.log('Hello World');
            } else if (n === 2) {
                console.log(a + b);
            }
        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}




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

using namespace std;

int main()
{
    long n;
    cin >> n;
    map<long, long> a;
    long tmp;
    for(long i = 0; i < n; ++i) {
        cin >> tmp;
        a[tmp]++;
        if(a[tmp] != 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>

unsigned int calc(void);

int main(void){
  unsigned int w_point,k_point;
  w_point=calc();
  k_point=calc();
  printf("%u %u\n",w_point,k_point);
  return 0;
}

unsigned int calc(void){
  unsigned int p1,p2,p3,p,i;
  p1=p2=p3=0;
  for(i=0;i<10;i++){
    scanf("%u",&p);
    if(p>p1){
      p3=p2;
      p2=p1;
      p1=p;
    }else if(p>p2){
      p3=p2;
      p2=p;
    }else if(p>p3){
      p3=p;
    }
  }
  return p1+p2+p3;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	if(n%10==n/100) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

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

        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        if(s1.charAt(0) == s2.charAt(2) && s1.charAt(1) == s2.charAt(1) && s1.charAt(2) == s2.charAt(0)){
            out.println("YES");
        }else{
            out.println("NO");
        }
        out.flush();
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <cstdlib>
#include <stack>

using namespace std;

stack<int>s;
char ch[10];

int main()
{
    while(cin>>ch)
    {
        
        if(ch[0] == '+')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(a+b);
        }
        else if(ch[0] == '-')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(b-a);
        }
        else if(ch[0] == '*')
        {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(a*b);
        } else{
            s.push(atoi(ch));
        }
    }
    cout << s.top() << endl;
    return 0;
}



Measured memory_bytes: 3116
def solve(x):
    x = str(x)
    if len(x) != N:
        return False
    for s, c in P:
        if x[s - 1] != str(c):
            return False
    return True

if __name__ == "__main__":
    N, M = map(int, input().split())
    P = [list(map(int, input().split())) for i in range(M)]
    ans = 10**N
    for i in range(10 ** N - 1, -1, -1):
        if solve(i):
            ans = min(ans, i)
            
    print(ans if ans != 10**N else -1)

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

int main() {
	long int n,k;
	cin >> n >> k;
	int f=0;
	int a=1;
	while(f==0){
		if(n/k>0){
			n=n/k;
			a++;
		}else{
			f=1;
		}
	}
	cout << a << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      
      long a = sc.nextLong();	
	   long b = sc.nextLong();
	   long k = sc.nextLong();      
         if(a>=k){
            System.out.println((a-k)+" "+b);                    
        }else if(b>=k-a){
            System.out.println("0"+" "+(b-(k-a)));               
        }else{
               System.out.println("0 0");    
        }          
	}
}

Measured memory_bytes: 38732
n = gets.chomp.to_i

odd_max_x = -1
odd_second_x = -1
even_max_x = -1
even_second_x = -1
h_odd = { -1 => 0 }
h_even = { -1 => 0 }
gets.chomp.split(' ').map(&:to_i).each.with_index(0) do |x, i|
  even =  i.zero? || i.even?
  h = even ? h_even : h_odd
  if h.key?(x)
    h[x] += 1
  else
    h[x] = 1
  end

  if even
    if x != even_max_x
      if h[x] > h[even_max_x]
        even_second_x = even_max_x
        even_max_x = x
      elsif h[x] > h[even_second_x]
        even_second_x = x
      end
    end
  else
    if x != odd_max_x
      if h[x] > h[odd_max_x]
        odd_second_x = odd_max_x
        odd_max_x = x
      elsif h[x] > h[odd_second_x]
        odd_second_x = x
      end
    end
  end
  even
end

if even_max_x != odd_max_x
  puts n - h_even[even_max_x] - h_odd[odd_max_x]
  exit
end

def single?(h)
  h.keys.length == 2
end

if single?(h_even) && single?(h_odd)
  puts n / 2
elsif single?(h_even) && !single?(h_odd)
  puts (n / 2) - h_odd[odd_second_x]
elsif !single?(h_even) && single?(h_odd)
  puts (n / 2) - h_even[even_second_x]
else
  use_max_even = h_even[even_max_x] + h_odd[odd_second_x]
  use_max_odd = h_odd[odd_max_x] + h_even[even_second_x]

  puts n - [use_max_even, use_max_odd].max
end


Measured memory_bytes: 16652
#include <iostream>

using namespace std;

int main() {
    while(true) {
    	int h, w;
    	cin >> h >> w;
    	if(h==0 && w==0) {
    		break;
    	}
    	for(int i=1; i<=h; i++) {
    		if(i%2==0) {
    			for(int j=1; j<=w; j++) {
    				if(j%2==0) {
    					cout << "#";	
    				}else {
    					cout << ".";
    				}
    			}
    		}else {
    			for(int k=1; k<=w; k++) {
    				if(k%2==0) {
    					cout << ".";
    				}else {
    					cout << "#";	
    				}
    			}
    		}
    		cout << endl;
    	}
    	cout << endl;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct edge{
	int to,cost;
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<vector<edge>> g(n);
	rep(i,n-1){
		int u,v,w;
		cin>>u>>v>>w;
		u--,v--;
		g[u].push_back({v,w});
		g[v].push_back({u,w});
	}
	vector<int> ans(n);
	auto dfs=[&](auto &dfs,int v,int pre,int c)->void{
		for(auto itr:g[v]){
			if(itr.to==pre) continue;
			if(itr.cost%2==0){
				ans[itr.to]=c;
				dfs(dfs,itr.to,v,c);
			}else{
				ans[itr.to]=!c;
				dfs(dfs,itr.to,v,!c);
			}
		}
	};
	dfs(dfs,0,-1,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 10624
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll N, K, t;
	cin >> N >> K;
	--K;
	vector<ll> P(N);
	vector<ll> C(N);
	rep(i,N){
		cin >> t;
		P[i] = --t;
	}
	rep(i,N)cin >> C[i];
	ll ans = -INF;
	rep(i,N){
		vector<ll> sum;
		vector<bool> visited(N, false);
		int nt = P[i];
		ll sum_element = 0;
		int cnt = 0;
		while(!visited[nt]){
			visited[nt] = true;
			sum_element += C[nt];
			sum.push_back(sum_element);
			nt = P[nt];
		}

		ll role = K / sum.size();
		ll tail = K % sum.size();
		ll e_ans = -INF;
		for(int j = 0; j <= tail; ++j){
			e_ans = max(e_ans, sum[j]);
		}
		if(sum[sum.size()-1] > 0){
			e_ans += sum[sum.size()-1] * role;
		}

		ll e_ans2 = -INF;
		if(role > 0){
			--role; tail = sum.size()-1;
		}
		for(int j = 0; j <= tail; ++j){
			e_ans2 = max(e_ans2, sum[j]);
		}
		if(sum[sum.size()-1] > 0){
			e_ans2 += sum[sum.size()-1] * role;
		}


		//{
		//	cout << line << endl;
		//	printf("[start = %d] -> [e_ans = %lld]\n", i, e_ans);
		//	printf("[role = %lld], [tail = %lld]\n", role, tail);
		//	show(sum);
		//	cout << line << endl;
		//}
		
		ans = max(ans, e_ans);
		ans = max(ans, e_ans2);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  bool ok = true;
  for (int i = 0; i + 1 < n; ++i) {
    if (a[i] == a[i + 1]) {
      ok = false;
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		int alphabet[];
		alphabet = new int[26];
		for(int i = 0;i < 26; i++) {
			alphabet[i] = 0;
		}
		while(sc.hasNext()) {
			String str = sc.next();
			str = str.toLowerCase();
			for(int i = 0;i < str.length();i++) {
				if(97 <= str.charAt(i) && str.charAt(i) <= 122) alphabet[str.charAt(i) - 97]++;
			}
		}
		for(int i = 0;i < 26;i++) {
			System.out.printf("%c : %d\n",i + 97,alphabet[i]);
		}
		sc.close();
	}
}


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


int main(){
  int n,m;
  cin >>n>>m;
  priority_queue<int> price;
  rep(i,n){
    int a;
    cin >> a;
    price.push(a);
  }
  rep(i,m){
    int a= price.top();
    price.pop();
    a = a >>1;
    price.push(a);
  }
  ll ans=0;
  rep(i,n){
    int a=price.top(); price.pop();
    ans+=a;
  }
 
  cout<<ans;

}



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

int main() {
    int a, b; cin >> a >> b;
    a--, b--;

    vector<string> ans(98, string(99, '.'));
    for(int i = 0; i < 49; ++i) {
        for(int j = 0; j < 99; ++j) {
            ans[i][j] = '#';
        }
    }
    for(int i = 1; i < 49 && a > 0; i += 2) {
        for(int j = 1; j < 99 && a > 0; j += 2) {
            ans[i][j] = '.';
            a--;
        }
    }
    for(int i = 50; i < 98 && b > 0; i += 2) {
        for(int j = 1; j < 99 && b > 0; j += 2) {
            ans[i][j] = '#';
            b--;
        }
    }

    cout << 98 << ' ' << 99 << endl;
    for(auto s : ans) {
        cout << s << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
const int INF = 1 << 30;
using namespace std;

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

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

  int n, k; cin >> n >> k;
  vector<int> h(100100);
  rep(i, n) cin >> h[i];

  int dp[100100] = {};
  rep(i, 100100) dp[i] = INF;
  dp[0] = 0;

  rep(i, n) {
    for(int j = 1; j <= k; ++j) {
      chmin(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
    }
  }
  cout << dp[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#define ll long long 
using namespace std;
struct node 
{
	int a[1000]={0};
	int num;
	
 }s[1005]; 
int main()
{	
	s[0].a[0]=2;s[0].num=0;
	s[1].a[0]=1;s[1].num=0;
	for(int i=2;i<=1000;i++)
	{
		for(int k=0;k<=s[i-1].num;k++)
		{
			s[i].a[k]+=s[i-1].a[k]+s[i-2].a[k];
			if(s[i].a[k]>=10)
			{
				s[i].a[k+1]++;
				s[i].a[k]-=10;
			}			
		}
		if(s[i].a[s[i-1].num+1]!=0)
		s[i].num=s[i-1].num+1;
		else
		s[i].num=s[i-1].num;
	}
		int n;
		scanf("%d",&n);
		for(int i=s[n].num;i>=0;i--)
		printf("%d",s[n].a[i]);
		puts("");
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int x;
    cin >> x;
    array<int, 100> v{};
    for (auto &&i : v) scanf("%d", &i);
    int A[] = {0, 9, 10, 11, 20};
    int B[] = {0, 1, 2, 10, 11, 12, 20, 21, 22};
    int C[] = {0, 9, 10, 11, 18, 19, 20, 21, 22, 29, 30, 31, 40};
    auto dfs = [&](int cur, int cnt, auto &&f) -> bool {
        if(cnt == 0){
            int ok = !*max_element(v.begin(),v.end());
            if(ok) return 1;
        }
        for (int i = cur; i < 100; ++i) {
            int y = i/10, x = i%10;
            if(y <= 5 && 2 <= x && x <= 7) {
                int ok = 1;
                for (auto &&p : C) if(!v[i+p]) ok = 0;
                if(ok){
                    for (auto &&p : C) v[i+p]--;
                    if(f(i,cnt-1, f)){
                        printf("%d %d 3\n", x, y+2);
                        return 1;
                    }
                    for (auto &&p : C) v[i+p]++;
                }
            }
            if(y <= 7 && x <= 7) {
                int ok = 1;
                for (auto &&p : B) if(!v[i+p]) ok = 0;
                if(ok){
                    for (auto &&p : B) v[i+p]--;
                    if(f(i,cnt-1, f)){
                        printf("%d %d 2\n", x+1, y+1);
                        return 1;
                    }
                    for (auto &&p : B) v[i+p]++;
                }
            }
            if(y <= 7 && 1 <= x && x <= 8) {
                int ok = 1;
                for (auto &&p : A) if(!v[i+p]) ok = 0;
                if(ok){
                    for (auto &&p : A) v[i+p]--;
                    if(f(i,cnt-1, f)){
                        printf("%d %d 1\n", x, y+1);
                        return 1;
                    }
                    for (auto &&p : A) v[i+p]++;
                }
            }


        }
        return 0;
    };
    dfs(0, x, dfs);

    return 0;
}



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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  set<int> st;
  int cur = 0;
  while(true){
    st.insert(cur);
    if(cur % b == c){
      cout << "YES" << endl;
      return 0;
    }
    cur += a;
    cur %= b;
    if(st.count(cur)){
      cout << "NO" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int N = Integer.parseInt(sc.next());
       ArrayList<Robot> robotList = new ArrayList<>();
       for(int i=0;i<N;i++){
           Robot robot = new Robot();
           int X = Integer.parseInt(sc.next());
           int L = Integer.parseInt(sc.next());
           robot.rangeMin = X - L;
           robot.rangeMax = X + L;
           robotList.add(robot);
       }
        robotList.sort((s1,s2) -> s1.rangeMax - s2.rangeMax);
        ArrayList<Robot> res = new ArrayList<>();
        res.add(robotList.get(0));
        for(int i=1;i<N;i++){
            Robot robot1 = robotList.get(i);
            Robot robot2 = res.get(res.size() - 1);
            if(robot1.rangeMin >= robot2.rangeMax){
                res.add(robot1);
            }
        }
        System.out.println(res.size());
    }
}

class Robot{
    public int rangeMin;
    public int rangeMax;
}

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

int main ()
{
	string s, t, u;
  	int a, b;
  	cin >> s >> t >> a >> b >> u;
  	if (s == u)
    {
    	cout << a-1 << " " << b << endl;
    }
  	else
    {
    	cout << a << " " << b-1 << endl;
    }
}


Measured memory_bytes: 256
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const S = input.slice(1, N+1);

  let arr = {};
  let max = 0;
  for(let i=0; i<N; i++){
    arr[S[i]] = arr[S[i]] ? arr[S[i]] + 1 : 1;
    if(arr[S[i]] > max) max = arr[S[i]];
  }

  let keys = Object.keys(arr);
  let ret = [];
  for(let i=0; i<N; i++){
    if(arr[keys[i]] === max) ret.push(keys[i]);
  }

  console.log(ret.sort().join('\n'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 97364
N = int(input())
red = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x:-x[1])
blue = sorted([list(map(int,input().split())) for _ in range(N)])

ans = 0
for b in blue:
  for r in red:
    if(r[0] < b[0] and r[1] < b[1]):
      ans += 1
      red.remove(r)
      break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str,st[11]={"h","i","j","k","l","m","n","o","p","y","u"};
	while(1){
		str.clear();
		cin>>str;
		int s=0,ans=0,f=0;
		if(str=="#")
		break;
		for(int i=0;i<11;i++){
			if(str[0]==st[i][0]){
				f=1;
				s=2;
			}
		}
		if(f==0)
		s=1;
		for(int i=1;i<str.size();i++){
			f=0;
			for(int j=0;j<11;j++){
				if(str[i]==st[j][0]){
					f=1;
					break;
				}
			}
			if(f==0 && s==2 || f==1 && s==1)
			ans++;
			if(f==1)
			s=2;
			else
			s=1;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int n, k;
	vector<int> h, dp;
	cin>>n>>k;
	h.assign(n, 0);
	dp.assign(n, 0);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	dp[n-1] = 0;
	for(int i=n-2;i>=0;i--){
		dp[i] = INT_MAX;
		for(int j=1;i+j<n && j<=k;j++){
			dp[i] = min(dp[i], dp[i+j]+abs(h[i]-h[i+j]));
		}
	}
	cout<<dp[0]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main() {
	int num;
	int T, K, H, N;	// ?£????????±??????¨?±???????
	std::cin >> num;

	int official_house[4][3][10] = { 0 };

	// ??\???
	for (int i = 0; i < num; i++)
	{
		std::cin >> T >> K >> H >> N;
		official_house[T-1][K-1][H-1] += N;
	}

	// ??????
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				std::cout << " " << official_house[i][j][k];
			}
			std::cout << std::endl;
		}
		if(i != 3) std::cout << "####################" << std::endl;
	}
	return 0;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll n ;
  cin >> n;
  
  //  1  4  16
  // -2 -8 -32
  
  //-2 + 1
  
  // 1      16  
  //-2  -8    
  
  string ans;
  ll pow = 1;
  while(abs(n)>0){
    if(n%(pow*2)==0) ans += "0";
    else{
      ans += "1";
      n -= pow;
    }
    pow *= -2;
  }
  
  if(ans.length()==0) ans="0";

  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 3720
/**
 *    author        : Saurav Paul 
 *    created       : August 02, 2020 6:38 PM
 *    Problem Name  : D - Alter Altar
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc174/tasks/abc174_d
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);


    int n;
    cin >> n;
    string s;
    cin >> s;

    int cnt = 0 ;
    for(auto x : s){
        if(x == 'R')
            cnt ++ ;
    }

    int ans =  cnt ;
    for(int i = 0 ; i < cnt ; i++){

        if(s[i]=='R')
            ans -- ;

    }

    cout << ans << endl ;

    return 0 ;
}


Measured memory_bytes: 3768
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut a = HashSet::new();
    for i in 0..m {
        a.insert(read::<usize>());
    }
    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    for i in 1..n + 1 {
        if a.contains(&i) {
            continue;
        }
        if i == 1 {
            dp[i] = dp[i - 1];
        } else {
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        dp[i] %= 1000_000_007;
    }
    println!("{}", dp[n]);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 3860
import Control.Monad
import Data.List
import Data.Maybe

main = do
  [d,g] <- map read . words <$> getLine                    :: IO [Int]
  pcs   <- map (map read . words) <$> replicateM d getLine :: IO [[Int]]
  print $ solve d g 1 0 1 0 pcs

solve _ g _ ui up a [] = a + fromMaybe 1001 (inner ui up g)
  where inner i p r = findIndex (>=r) $ map ((100*i)*) [0..p-1]
solve d g i ui up a ([p,c]:pcs)
  = min (solve d (g-100*i*p-c) (i+1) ui up (a+p) pcs) (solve d g (i+1) i p a pcs)


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
//#define endl '\n'
typedef long long ll;
ll oo = 0x3f3f3f3f3f3f3f3f;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> g(n);
  vector<int> indeg(n);
  for(int i = 0, a, b; i < m; ++i)
  {
  	cin >> a >> b;
    --a, --b;
    indeg[b]++;
    g[a].push_back(b);
  }
  
  vector<int> order;
  stack<int> q;
  for(int i = 0; i < n; ++i)
    if(indeg[i] == 0)
      q.push(i);
  
  while((int)q.size())
  {
  	int t = q.top();
    q.pop();
    order.push_back(t);
    
    for(auto &x:g[t])
    {
      indeg[x]--;
      if(indeg[x] == 0)
        q.push(x);
    }
  }
  
  reverse(order.begin(), order.end());
  
  vector<int> dp(n);
  
  for(auto &x:order)
  	for(auto &u:g[x])
      dp[x] = max(dp[x], dp[u] + 1);

  int mx = 0;
  for(auto &x:dp) mx = max(x, mx);
  
  cout << mx << endl;
}


Measured memory_bytes: 7032
#include <stdio.h>

int main(void)
{
	double max, min;
	double temp;
	int flag;
	
	flag = 0;
	while (scanf("%lf", &temp) != EOF){
		if (flag == 0){
			min = max = temp;
			flag = 1;
		}
		
		if (temp > max){
			max = temp;
		}
		
		else if (temp < min){
			min = temp;
		}
	}
	
	printf("%f\n", max - min);
	
	return (0);
}

Measured memory_bytes: 0
def nearlist(N, LIST):  # 隣接リスト
    NEAR = [{} for _ in range(N)]
    for a, b, c in LIST:
        NEAR[a - 1][b - 1] = c
        NEAR[b - 1][a - 1] = c
    return NEAR


def dfs(NEAR, S, N):  # 深優先探索  # スタック
    DIST = [-1 for _ in range(N)]  # 前処理
    DIST[S] = 0
    stack, frag = [S], set([S])

    while len(stack) > 0:
        q = stack.pop()
        for i, c in NEAR[q].items():  # 移動先の候補
            if i in frag:  # 処理済みか否か
                continue
            DIST[i] = DIST[q] + c
            stack.append(i), frag.add(i)
    return DIST


n = int(input())
abc = [list(map(int, input().split())) for _ in range(n - 1)]
q, k = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(q)]

near = nearlist(n, abc)
dist = dfs(near, k - 1, n)
for x, y in xy:
    print(dist[x - 1] + dist[y - 1])


Measured memory_bytes: 166736
#include <stdio.h>
int main(){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d = a / b;
    r = a % b;
    f = (double) a / b;
    printf("%d %d %.6f\n",d,r,f);
    return 0;
}

Measured memory_bytes: 1068
fun main(args: Array<String>) {
    val mod = 1000000007L

    val n = readLine()!!.toInt()
    var sum = 0L
    val a = readLine()!!.split(' ').map {
        val num = it.toLong()
        sum = (sum + num) % mod
        num
    }

    var ans = 0L
    for (i in 0 until n) {
        sum = (sum - a[i]) % mod
        if(sum < 0) sum += mod
        ans += (a[i]*sum) %mod
        ans %= mod
    }
    println(ans)
}


Measured memory_bytes: 64816
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<P> G[100005];
int col[100005];

void dfs(int v,int c){
	col[v]=c;
	for(int i=0;i<G[v].size();i++){
		if(col[G[v][i].first]!=-1)continue;
		if(G[v][i].second==0){
			dfs(G[v][i].first,c);
		}else{
			dfs(G[v][i].first,1-c);
		}
	}
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		c%=2;
		a--;
		b--;
		G[a].push_back(P(b,c));
		G[b].push_back(P(a,c));
	}
	memset(col,-1,sizeof(col));
	dfs(0,1);
	for(int i=0;i<n;i++){
		printf("%d\n",col[i]);
	}
	return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    string S;
    cin >> N >> S;
    int cnt = 0;
    rep(i, N) cnt += S[i]-'0';
    int a[2];
    a[0] = cnt-1, a[1] = cnt+1;
    int x[N][2], sum[2];
    rep(i, 2){
        if(a[i] <= 0) continue;
        x[N-1][i] = 1%a[i], sum[i] = 0;
        if(S[N-1] == '1') sum[i] = 1;
        rep3(j, N-2, 0){
            x[j][i] = (x[j+1][i]*2)%a[i];
            if(S[j] == '1') sum[i] += x[j][i], sum[i] %= a[i];
        }
    }
    rep(i, N){
        int j = S[i] == '0';
        if(a[j] == 0) {cout << 0 << endl; continue;}
        int now = sum[j], ans = 1;
        if(!j) now += (a[j]-x[i][j]);
        else now += x[i][j];
        now %= a[j];
        while(now){
            now %= (__builtin_popcount(now));
            ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5284
# -*- codinf: utf-8 -*-

# コマンドラインの入力文字をリストに格納
# input().split() -> 入力文字を空白区切りで取得　※inputは文字列として取得する。split()でリスト型に変換
# for num in input().split() -> 取得した入力文字を一つずつnum変数に格納
# int(num)で格納されたnum変数を数値に変換
numList = [int(num) for num in input().split()]

# 入力文字の乗算
productNumList = numList[0] * numList[1]

# 奇数／偶数の判定
if ((productNumList % 2) == 0 ):
    print("Even")
else:
    print("Odd")


Measured memory_bytes: 2940
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

use std::collections::HashMap;

fn main() {
    let (n, k) = input!(usize, i64);
    let a_lst = input!(i64; n);
    let mut map = HashMap::new();

    for a in a_lst.iter() {
        if map.contains_key(a) {
            if let Some(x) = map.get_mut(a) {
                *x += 1;
            }
        } else {
            map.insert(a, 1_i64);
        }
    }

    let delta = map.len() as i64 - k;
    if delta <= 0 {
        println!("0");
    } else {
        let mut values = map.values().collect::<Vec<_>>();
        values.sort();
        println!("{:?}", values.iter().take(delta as usize).fold(0, |acc, &x| acc + x));
    }
}

Measured memory_bytes: 18060
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define pii pair<int,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ll long long 
#define mod 1000000007
#define barn cin.sync_with_stdio(0);cin.tie(0)
vector<int> adj[N];
pair<int,int> mark[N][12];
int visit[N][12];
int ve[N],ce[N],de[N];
pii p;
void solve(int v,int d,int c,int t)
{
    if(visit[v][d]==1)
      return;
    visit[v][d]=1;
    mark[v][d]=mp(c,t);
    if(d>0)
    {
     for(int i=0;i<adj[v].size();i++)
     {
      solve(adj[v][i],d-1,c,t);
     }
    }
}
int main()
{
  barn;
  //freopen("inputf.in","r",stdin);
  //freopen("outputf.in","w",stdout);
  int n,m,i,j,a,b,qe;
  cin>>n>>m;
  for(i=0;i<N;i++)
    for(j=0;j<11;j++)
      mark[i][j]=mp(0,0);
  for(i=0;i<N;i++)
  {
    for(j=0;j<11;j++)
    {
      visit[i][j]=0;
    }
  }
  for(i=1;i<=m;i++)
  {
    cin>>a>>b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  cin>>qe;
  for(i=1;i<=qe;i++)
  {
     cin>>ve[i]>>de[i]>>ce[i];
  }
  for(i=qe;i>=1;i--)
  {
    solve(ve[i],de[i],ce[i],i);
  }
  for(i=1;i<=n;i++)
  {
     int maxi=0,c;
     for(j=0;j<11;j++)
     {
        if(mark[i][j].ss>=maxi)
        {
          maxi=mark[i][j].ss;
          c=mark[i][j].ff;
        } 
     }
     cout<<c<<"\n";
  }
  return 0;
}

Measured memory_bytes: 21752
s=input()
for _ in range(int(input())):
    o=input().split()
    a,b=map(int,o[1:3]);b+=1
    c=o[0][2]
    if c=='p':s=s[:a]+o[3]+s[b:]
    elif c=='i':print(s[a:b])
    elif c=='v':s=s[:a]+s[a:b][::-1]+s[b:]

Measured memory_bytes: 7688
/* -------------------------------------------------

Author :- Vaibhav Pal
College :- Northern India Engineering College, New Delhi
Coding Handle :- underdog_eagle
Title :-

----------------------------------------------------*/
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000000000000          // 10^18
#define nl '\n'
#define sp ' '
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define fo(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)

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

int main()
{
	FAST_IO
    /*#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
    #endif*/
	string n;
	cin >> n;
	if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[1] == n[3])) cout << "Yes\n";
	else cout << "No\n";
				
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); double[] v = new double[n];
		for(int i = 0; i< n; i++) {
			v[i] = sc.nextDouble();
		}
		Arrays.parallelSort(v);
		double value = (v[0] + v[1])/2;
		for(int i = 1; i < n-1; i++) {
			value = (value + v[i+1])/2;
		}
		System.out.println(value);
		sc.close();
	}
}

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

int main()
{

	///freopen("in.txt","r",stdin);
		int x;
		cin>>x;
		if(x>=400 and x<=599)
			cout<<8;
		else if(x>=600 and x<=799)
			cout<<7;
		else if(x>=800 and x<=999)
			cout<<6;
		else if(x>=1000 and x<=1199)
			cout<<5;
		else if(x>=1200 and x<=1399)
			cout<<4;
		else if(x>=1400 and x<=1599)
			cout<<3;
		else if(x>=1600 and x<=1799)
			cout<<2;
		else if(x>=1800 and x<=1999)
			cout<<1;



	
	return 0;
}

Measured memory_bytes: 3640
<?php
list($w,$h,$x,$y,$r) = explode(' ', trim(fgets(STDIN)));
if (( 0 <= $x-$r && $x+$r <= $w ) && ( 0 <= $y-$r && $y+$r <= $h )) {
  print "Yes" . PHP_EOL;
} else {
  print "No" . PHP_EOL;
}

Measured memory_bytes: 15424