akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

//Capitalize
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.nextLine().toCharArray();
		for(int i=0;i<s.length;i++)
			s[i] = Character.toUpperCase(s[i]);
		System.out.println(s);
	}
}

Measured memory_bytes: 11000
N = int(input())
A = list(map(int, input().split()))

count= 0
res = 0
right = 0
for left in range(N):
    while right < N and ((res ^ A[right]) == (res + A[right])):
        res += A[right]
        right += 1

    count += right - left

    if left == right:
        right += 1
    else:
        res -= A[left]

print(count)

Measured memory_bytes: 23560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        
        for(int i=0; i<N; i++){
            System.out.print(S.charAt(i));
            System.out.print(T.charAt(i));
        }
    }
}


Measured memory_bytes: 35616
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    double mu = 0.0;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    //
    rep(i, N)
    {
        mu += double(X[i]);
    }
    mu /= double(N);
    ll M = int(mu + 0.5);
    //
    ll total = 0;
    rep(i, N)
    {
        ll d = M - X[i];
        total += d * d;
    }
    cout << total;

    return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    long long int n, w;
    cin >> n >> w;
    vector<int> vw(n, 0), vv(n, 0);
    for (int i = 0; i < n; i++ ) {
        cin >> vw[i] >> vv[i];
    }
    int base = vw[0];
    for (int i = 0; i < n; i++) {
        vw[i] -= base;
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        long long int nw = min(w - (long long int)i * base, (long long int)i * 3);
        if (nw < 0) continue;
        vector<vector<int>> dp(i + 1, vector<int>(nw + 1, 0));
        for (int ii = 0; ii < n; ii++) {
            for (int j = i - 1; j >= 0; j--) {
                for (int k = 0; k + vw[ii] <= nw; k++) {
                    dp[j + 1][k + vw[ii]] = max(dp[j + 1][k + vw[ii]], dp[j][k] + vv[ii]);
                }
            }    
        }

        res = max(res, *max_element(dp[i].begin(), dp[i].end()));
    }
    cout << res << endl;
}


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

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut max_id = 0_usize;
    let mut max1 = 0_usize;
    let mut max2 = 0_usize;
    for (i, &j) in a.iter().enumerate() {
        if j > max2 {
            if j > max1 {
                max2 = max1;
                max1 = j;
                max_id = i;
            } else {
                max2 = j;
            }
        }
    }

    for i in 0..n {
        if i != max_id {
            println!("{}", max1);
        } else {
            println!("{}", max2);
        }
    }
}


Measured memory_bytes: 7676
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define hell 1000000007
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
 
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
char mat[1002][1002];
ll ans[1002][1002];
int main()
{
    _fast_
    ll t = 1;
  //  cin>>t;
    while(t--){
    ll h,w;
    cin>>h>>w;
    rep(i,1,h+1){
        rep(j,1,w+1)
        {
            cin>>mat[i][j];
        }
    }
    ll idx1,idx2;
    memset(ans,0,sizeof(ans));
    for(ll i = 1;i<=w;i++)
    {
        if(mat[1][i] != '#')
        {
            ans[1][i] = 1;
        }
        else
        {
            idx1 = i;
            break;
        }
        
    }
    for(ll i = 1;i<=h;i++)
    {
        if(mat[i][1] != '#'){
            ans[i][1] = 1;
        }
        else
        {
            idx2 = i;
            break;
        }
    }
    for(ll i = 2;i<=h;i++)
    {
        for(ll j = 2;j<=w;j++)
        {
            if(mat[i][j] == '#')
            {
                ans[i][j] = 0;
            }
            else
            {
                ans[i][j] = ans[i-1][j]%hell + ans[i][j-1]%hell;
                ans[i][j]%= hell;
            }
            
        }
    }
    cout<<ans[h][w]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 9088
(* 素集合データ構造 *)
module UnionFind : sig
  type t

  module Class : sig
    type t
    val compare : t -> t -> int
  end

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> Class.t
  (* 与えられた集合同士を合併する *)
  val unite : t -> Class.t -> Class.t -> unit
  (* 与えられた集合に属する要素の数を求める *)
  val cardinal : t -> Class.t -> int
end = struct
  type t = int array

  module Class = struct
    type t = int
    let compare = compare
  end

  let make n = Array.make n (-1)

  let rec find uf x =
    if uf.(x) < 0 then x
    else begin
      let y = find uf uf.(x) in
      uf.(x) <- y; y
    end

  let unite uf x y =
    if x <> y then begin
      let x, y = if uf.(x) <= uf.(y) then x, y else y, x in
      uf.(x) <- uf.(x) + uf.(y);
      uf.(y) <- x
    end

  let cardinal uf x = ~- (uf.(x))
end


let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let abs = Array.init m @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  let uf = UnionFind.make n in
  let ans = Array.make (m + 1) (n * (n - 1) / 2) in
  for i = m - 1 downto 0 do
    let ca = UnionFind.find uf (fst abs.(i) - 1) in
    let cb = UnionFind.find uf (snd abs.(i) - 1) in
    if UnionFind.Class.compare ca cb = 0
    then ans.(i) <- ans.(i + 1)
    else begin
      ans.(i) <- ans.(i + 1)
        - UnionFind.cardinal uf ca * UnionFind.cardinal uf cb;
      UnionFind.unite uf ca cb
    end
  done;
  for i = 1 to m do
    Printf.printf "%d\n" ans.(i)
  done



Measured memory_bytes: 9344
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include<numeric>
#include<functional>
#include<random>

using namespace std;
#define ll long long
#define ull unsigned long long
#define rrep(i,m,n) for(ll (i)=(ll)(m);(i)>=(ll)(n);(i)--)
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
constexpr long double m_pi = 3.1415926535897932L;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 61;
constexpr long double EPS = 1e-10;
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector2<T>>;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

class AhoCorasick {
private:
	vector2<int> nxt;//現在のノードにchを追加した場合のノード　存在しなければsuffix linkを辿る
	vector<int> fail, end;//suffix link,そのノードに存在する文字列の数
	int root;
	int p;//ノードの数
	int maxn;//文字の合計サイズ
	vector<int> gen, num;
public:
	AhoCorasick(int maxn) 
		:maxn(maxn), nxt(maxn, vector<int>(26, -1)), fail(maxn), end(maxn, 0), p(1), root(0) ,gen(maxn,0),num(maxn,0){}

	inline void insert(const string& s) {
		int now = root;
		for (int i = 0; i < s.size(); i++) {
			if (nxt[now][s[i] - 'a'] == -1) nxt[now][s[i] - 'a'] = p++, gen[p-1] = gen[now] + 1;
			now = nxt[now][s[i] - 'a'];
		}
		end[now]++;
	}
	pair<int,int> dfs(int now) {
		pair<int, int> ret = { end[now],now };
		int cnt = 0;
		REP(i, 26) {
			if (nxt[now][i] == -1)continue;
			auto tmp = dfs(nxt[now][i]);
			nxt[now][i] = tmp.second;
			ret.first += tmp.first;
			cnt++;
		}
		num[now] = ret.first;
		if (end[now] == 0 && cnt == 1) {
			REP(i, 26)if (nxt[now][i] != -1) {
				ret.second = nxt[now][i];
			}
		}
		return ret;
	}
	inline int solve(string& s,string &t,int now) {
		ll g = gen[now];
		if (g == s.size())return 0;
		int ret = end[now];
		REP(i, 26) {
			if (s[g] == t[i]) {
				ret += solve(s, t, nxt[now][s[g] - 'a']);
				break;
			}
			if (nxt[now][t[i] - 'a'] == -1)continue;
			ret += num[nxt[now][t[i] - 'a']];
		}
		return ret;
	}
};

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

	ll n;
	cin >> n;
	AhoCorasick ac(404040);
	vector<string> s(n);
	for (auto& e : s)cin >> e, ac.insert(e);
	ac.dfs(0);
	ll q;
	cin >> q;
	while (q--) {
		ll k;
		string t;
		cin >> k >> t;
		k--;
		cout << ac.solve(s[k], t, 0) + 1 << "\n";
	}

	return 0;
}

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

int main() {
  
  int k;
  int a, b;
  cin >> k >> a >> b;
  
  int c = 0;
  for(int i = a; i <= b; i++){
    if(i % k == 0){
      c = 1;
      break;
    }
  }
  
  if(c != 0){
    cout << "OK"  << endl;
  }
  else{
    cout << "NG" << endl;
  }

}



Measured memory_bytes: 3620
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    vector<intmax_t> x(N), sorted(N);
    for (size_t i = 0; i < N; ++i) {
        cin >> x[i];
        sorted[i] = x[i];
    }

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

    intmax_t mid = N / 2 - 1;
    for (size_t i = 0; i < N; ++i) {
        if (x[i] <= sorted[mid]) {
            cout << sorted[mid + 1] << "\n";
        } else {
            cout << sorted[mid] << "\n";
        }
    }

    return 0;
}


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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  long long N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  long long ferro = 0;
  long long anti = 0;
  for (size_t i = 0; i < N - 1; i++) {
    if (S[i] == S[i + 1])
      ferro += 1;
    else
      anti += 1;
  }
  cout << ferro + min(2 * K, anti) << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int main(void){
  int n,k;
  scanf("%d",&n);
  int x[n+1],y[n+1];
  for(k=1;k<=n;k++) scanf("%d",&x[k]);
  for(k=1;k<=n;k++) scanf("%d",&y[k]);

  double D1=0,D2=0,D3=0;
  double sum=0,Din=0;

  for(k=1;k<=n;k++){
    D1 += abs(x[k]-y[k]);
  }

  for(k=1;k<=n;k++){
    sum += pow(abs(x[k]-y[k]),2);
  }
  D2 = sqrt(sum);
  sum = 0;

  for(k=1;k<=n;k++){
    sum += pow(abs(x[k]-y[k]),3);
  }
  D3 = cbrt(sum);
  sum = 0;

  for(k=1;k<=n;k++){
    if(abs(x[k]-y[k])>Din){
        Din = abs(x[k]-y[k]);
    }
  }


  printf("%lf %lf %lf %lf\n",D1,D2,D3,Din);
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w; cin>>h>>w;
    if (h>=2 && w>=2){
        cout<<(h*w+1)/2<<endl;
    }else{
        cout<<"1\n";
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    ans = []
    for i in range(k,n):
        ans.append("Yes" if a[i] > a[i-k] else "No")

    print("\n".join(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 31420
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int ans = c - (a - b);
		if (ans < 0) ans = 0;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
def main() :
    a = input()
    L = len(a)
    ans = L*(L-1)//2 + 1
    alp = "abcdefghijklmnopqrstuvwxyz"

    for c in alp :
        cnt = a.count(c)
        ans -= cnt*(cnt-1)//2
    
    print(ans)

main()

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
struct cmp{
	bool operator () (const int &a,const int &b)
	{return a>b;}
};
multiset<int,cmp> s;
int n,a[N],ans;
int lowbit(int x){return x&(-x);}
int count(int x)
{
	int res=0;
	while (x) x/=2,res++;
	return res;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),s.insert(a[i]);
	while (s.size()>1)
	{
		int t=*s.begin();s.erase(s.begin());
		int p=lowbit(t),cnt=count(t);
		int x=(((1<<cnt)-1)^t)/p*p+p;
		if (s.find(x)!=s.end()) s.erase(s.find(x)),ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> height(n);
	for (int i = 0; i < n; i++) {
		cin >> height.at(i);
	}
	int count = 1;
	int max = height.at(0);
	for (int i = 1; i < n; i++) {
		if (max <= height.at(i)) {
			count++;
			max = height.at(i);
		}
	}
	cout << count << endl;
}

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

int main(){
  int si,ti;
  int S,T;
  string s,t;
  cin >> s >> t;
  int m[3001][3001];
  S = s.size();
  T = t.size();
  for(si=1;si<=S;si++)
    for(ti=1;ti<=T;ti++){
      if (s[si-1] == t[ti-1])
        m[si][ti] = m[si-1][ti-1] +1; 
      else
        m[si][ti] = max(m[si-1][ti],m[si][ti-1]);
    }
  
  string res = "";
  si=S;
  ti=T;
  while(si>0 && ti>0)
    if (s[si-1] == t[ti-1]){
      res += s[si-1];
      si--;
      ti--;
    }
  	else {
      if (m[si-1][ti] > m[si][ti-1])
        si--;
      else
        ti--;
    }
  
  reverse(res.begin(),res.end());
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 38736
#include<iostream>
#include<vector>
#include<string>

using namespace std;

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


	int s1;

	cin >> s1;

	int cnt = 0;

	if (s1 == 111)
		cnt = 3;
	if (s1 == 1)
		cnt = 1;
	if (s1 == 11)
		cnt = 2;
	if (s1 == 101)
		cnt = 2;
	if (s1 == 100)
		cnt = 1;
	if (s1 == 10)
		cnt = 1;
	if (s1 == 110)
		cnt = 2;
	if (s1 == 0)
		cnt = 0;


	cout << cnt;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>

int main(){
    char s[202], t[101], p[101];
    
    scanf("%s %s", s, p);
    strcpy(t, s);
    strcat(s, t);
    if(strstr(s,p) == NULL) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    vector<P> ab(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[i] = P(a, b);
    }
    sort(all(ab));
    ll ans = 0;
    rep(i, n) {
        P p = ab[i];
        ans += 1LL * min(m, p.se) * p.fi;
        m -= min(m, p.se);
        if (m == 0) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3956
#include <stdio.h>
#include <stdbool.h>

bool is_leap_year(int y);
int  get_leap_years(int list[], int begin, int end);

int main(void)
{
    int i;

    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }

        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }

    }

    return 0;
}

int get_leap_years(int list[], int begin, int end)
{
    int cnt = 0;
    int year;
    for (year = begin; year <= end; year++) {
        if (is_leap_year(year)) {
            list[cnt] = year;
            cnt++;
        }
    }

    return cnt;
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true;
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

Measured memory_bytes: 616
import collections
 
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
all_ans=0

for i,j in c.items():
    all_ans+=(j*(j-1))//2

for k in a:
    print(all_ans-((c[k]*(c[k]-1))//2)+(((c[k]-1)*(c[k]-2))//2))
    


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    char A, B;
    cin >> A >> B;

    if(A<B){
        cout << "<" << endl;
    }
    else if(A==B){
        cout << "=" << endl;
    }
    else{
        cout << ">" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::{Read, Write, stdin, stdout};
use std::cmp::max;

fn solve<R: Read, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_to_string(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let k: u64 = split.next().unwrap().parse().unwrap();
    let s: u64 = split.next().unwrap().parse().unwrap();
    let redundant = k * 3 - s;
    let mut sum: u64 = 0;
    for x in 0..redundant / 3 + 1 {
        for y in x..max((redundant - x) / 2, k) + 1 {
            if x + 2 * y > redundant {
                continue;
            }
            let z = redundant - x - y;
            if z > k {
                continue;
            }
            match (x, y, z) {
                _ if x == y && y == z => sum += 1,
                _ if x == y || y == z || x == z => sum += 3,
                _ => sum += 6,
            }
        }
    }
    writeln!(output, "{}", sum).unwrap();
}

fn main() {
    solve(stdin(), stdout());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("2 2\n", "6\n");
    }
    #[test]
    fn case2() {
        test("5 15\n", "1\n");
    }
}

Measured memory_bytes: 380
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

int main()
{
    int r;
    cin >> r;
    cout << 3 * r * r;

    return 0;
}


Measured memory_bytes: 764
import java.io.PrintWriter
import kotlin.math.PI
import kotlin.math.max

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val (n, m) = readIntegerList()
    val aSum = readIntegerList().sum()
    println(max(-1, n - aSum))
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 40096
import sys
rl = sys.stdin.readline
def a():
    N, W = map(int, rl().split())
    dp = [-1]*(W+1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, rl().split())
        for i in range(W-w, -1, -1):
            dpi = dp[i]
            if dpi == -1:
                continue
            if dp[i+w] < dpi + v:
                dp[i+w] = dpi + v
    print(max(dp))
a()



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

int main(void){
	int K,T;
	cin >> K >> T;
	vector<int> a(T);
	for(int i=0;i<T;i++){
		cin >> a[i];
	}

	sort(a.begin(),a.end(),greater<int>());
	int rem = K - a[0];

	cout << max(0,a[0] - 1 - rem) << endl;

	return 0;
}

Measured memory_bytes: 384
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] > h[b]:
        l[b] = False
    elif h[a] < h[b]:
        l[a] = False
    else:
        l[a] = False
        l[b] = False

print(l.count(True))


Measured memory_bytes: 20116
import java.util.Scanner;

public class Main {

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

		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int val = (a + b + c) / 2;

		int ans = (int) Math.sqrt(val * (val - a) * (val - b) * (val - c));

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 23892
def main():
    N = int(input())
    P = list(map(int, input().split(" ")))
    order = 0
    for i in range(N):
        if P[i] != i + 1:
            order += 1
    if order == 2 or order == 0:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
if n%2:
    mx = n//2 + 1
else:
    mx = n//2
    
print('YES') if k <= mx else print('NO')

Measured memory_bytes: 3064
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let answer = 0;
    
    if(N <= K) {
        answer = 1;
    } else {
        answer = Math.ceil((N - K) / (K - 1)) + 1;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 16716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/

vector<int> ar; //Bit Array
vector<int> a;
int la[500001];

ll n;
struct node
{
    int l, r, in;
};
vector<node> qu;
int comp(node &a, node &b){
    return a.r<b.r;
}
void update(ll x, ll v){
    //cout<<x<<endl;
    //x += 1;
    while(x<=(n)){
        //cout<<x<<endl;
        ar[x]+=v;
        x += (x & (-x));
    }
}
ll query(ll x){
    //x+=1;
    ll an = 0;
    while(x>0){
        an += ar[x];
        x = x&(x-1);
    }
    return an;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    ll q;
    cin>>n>>q;
    a.resize(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    memset(la, -1, sizeof(la));
    ar.assign(n+1, 0);
    for(int i=0;i<q;i++){
        int l, r;
        cin>>l>>r;
        qu.push_back({l, r, i});
    }
    sort(qu.begin(), qu.end(), comp);
    ll j=0;
    /*for(ll i=0;i<q;i++)
        cout<<qu[i].l<<" "<<qu[i].r<<" "<<qu[i].in<<endl;*/
    vector<int> an(q);
    for(int i=0;i<n;i++){
        //cout<<a[i]<<" "<<la[a[i]]<<endl;
        if(la[a[i]]==-1){
            la[a[i]]=i+1;
            update(la[a[i]], 1);
        }
        else{
            update(la[a[i]], -1);
            la[a[i]]=i+1;
            update(la[a[i]], 1);
        }
        while(j<q && qu[j].r==(i+1)){
            int l = qu[j].l, r = qu[j].r, in = qu[j].in;
            //cout<<in<<" "<<query(r)<<" "<<query(l-1)<<endl;
            an[in] = query(r) - query(l-1);
            j++;
        }
    }
    for(ll i=0;i<q;i++)
        cout<<an[i]<<endl;
    return 0;
}


Measured memory_bytes: 17384
using System;

class Code_01
{
    
    public static void Main()
    {
        string Colors = Console.ReadLine();
        string Nums = Console.ReadLine();
        string Selected = Console.ReadLine();
        string FirstColor = Colors.Split(' ')[0];
        string SecondColor = Colors.Split(' ')[1];
        int FirstNum = int.Parse(Nums.Split(' ')[0]);
        int SecondoNum = int.Parse(Nums.Split(' ')[1]);
        if (Selected == FirstColor)
        {
            FirstNum--;
        }
        else if (Selected ==SecondColor)
        {
            SecondoNum--;
        }
        Console.WriteLine(FirstNum + " " + SecondoNum);



    }
}


Measured memory_bytes: 13140
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::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
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 10005;
#define endl '\n'
//#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()


int32_t main()
{ 
  IOS
  
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i = 0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  sort(all(a));
  sort(all(b));
  if(n%2){
    cout<<(b[n/2] - a[n/2] + 1)<<endl;
  }
  else{
    cout<<(b[(n+1)/2] + b[(n-1)/2] - a[(n+1)/2] - a[(n-1)/2] +1 );
  }
}
 

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  int cnt = 1;
  for(int i=0; i<n-1; ++i){
    if(s[i] == s[i+1]) ++cnt;
    else break;
  }
  if(cnt == n){
    cout << (ll)n*k/2 << endl;
    return 0;
  }
  ll ans = 0;
  for(int i=0; i<n-1; ++i){
    if(s[i] == s[i+1]){
      ++ans;
      s[i+1] = '.';
    }
  }
  ans *= k;
  if(s[0] == s[n-1] && cnt%2 == 1) ans += k-1;
  cout << ans << endl;
}

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

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  if(b-a+1 <= 2*k){
    for(int i = a; i<=b ; i++){
      cout << i << endl;
    }
  }
  else {
    for(int i = a ; i<a+k;i++){
      cout << i << endl;
    }
    for(int i= b-k+1; i<=b ;i++){
      cout << i << endl;
    }
  }
}

  


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  if(N == K){
    cout << 1 << endl;
    return(0);
  }
  int x = ceil((N-K)*1.0/(K-1));
  cout << x + 1 << endl;
  
  return(0);
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  int s;
  cin >> s;
  vector<int> v;
  v.push_back(0);
  v.push_back(s);
  map<int, int> mp;
  mp[s] = 1;

  int i = 2;
  while(true) {
    if(v[i-1] % 2 == 0) v.push_back(v[i-1] / 2);
    else v.push_back(v[i-1] * 3 + 1);
    if(mp[v[int(v.size()-1)]] == 1) break;
    mp[v[int(v.size()-1)]]=1;
    i++;
  }

  cout << i << endl;

}


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

int main(){
  int R,G,B,N;
  int res;
  cin >> R >> G >> B >> N;
  
  int k;
  for (int i = 0; i <= N / R; ++i){
  	for (int j = 0; j <= N / G; ++j){
    	k = ( N - i*R - j*G ) / B;
      	if ( k >= 0 && (i*R + j*G + k*B == N) ){
        	res ++;
        }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
const int MAX = 10000001; 
  
ll factor[MAX] = { 0 }; 
  
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
   for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    for (int i = 3; i * i < MAX; i++) { 
        if (factor[i] == i) { 
            for (int j = i * i; j < MAX; j += i) { 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
// function to calculate number of factors 
ll calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    ll ans = 1; 
  
    ll dup = factor[n]; 
  
    ll c = 1; 
  
    ll j = n / factor[n]; 
  
    while (j != 1) { 
        if (factor[j] == dup) 
            c += 1; 
  
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        j = j / factor[j]; 
    } 
  
    ans = ans * (c + 1); 
  
    return ans; 
} 
  
int main() 
{ 
    ll n;
    cin>>n;
    ll ans=0;
     generatePrimeFactors(); 
    fo(1,n+1)
    {
    ans+=(i*calculateNoOFactors(i)); 
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 81752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,x;cin>>N>>x;
	long A[N];long cnt=0;
	rep(i,0,N){
		cin>>A[i];
		if(A[i]>x){ cnt+=A[i]-x; A[i]=x; }
	}
	rep(i,1,N){
		if(A[i-1]+A[i]>x){
			cnt+=A[i-1]+A[i]-x;
			A[i]=x-A[i-1];
		}
	}cout<<cnt<<endl;  
}

Measured memory_bytes: 1024
// C - GeT AC
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,Q; string S; cin>>N>>Q>>S;

	vector<int> P(N+1), I(N+1);
	for(int i=1; i<=N; ++i){
		P[i] = P[i-1];
		I[i] = I[i-1];
		if(S[i-1]=='A' && S[i]=='C'){
			P[i]++;
			I[i] = i;
		}
	}

	for(int i=0; i<Q; ++i){
		int l,r; cin>>l>>r;
		int c = P[I[r]] - P[I[l]] + 1;
		if(l!=I[l]) --c;
		if(r==I[r]) --c;
		cout<< c <<endl;
	}

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N, K;
    cin >> N >> K;
    cout << 1LL * K * (ll)pow(K - 1, N - 1) << endl;

    return 0;
}

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

int main()
{
  int N, tmp, L[100], max = 0;

  cin >> N;
  for(int i = 0; i < N; i++)
    cin >> L[i];

  for(int i = 0; i < N; i++){
    if(max < L[i]){
      max = L[i];
      tmp = i;
    }
  }
  
  int sum = 0;
  for(int i = 0; i < N; i++){
    if(i != tmp)
      sum += L[i];
  }

  if(sum > max)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
 
int main() {
  int Tc;
  cin >> Tc;
  cin.ignore();
  for(int tc = 0; tc < Tc; ++tc) {
    string text;
    int M;
    int cursor = 0;

    getline(cin, text);
    cin >> M;
    cin.ignore();

    while(M--) {

      string a, b;
      {
        string line;
        getline(cin, line);
        for(int i = 0; i < line.size(); ++i) {
          if(line[i] == ' ') {
            a = line.substr(0, i);
            b = line.substr(i+1);
            break;
          }
        }
      }

      int N = text.size();
      if(0) {

      } else if(a == "forward" && b == "char") {

        cursor = min(cursor+1, N);

      } else if(a == "forward" && b == "word") {

        for(; cursor < N && text[cursor] == ' '; ++cursor);
        for(; cursor < N && text[cursor] != ' '; ++cursor);

      } else if(a == "backward" && b == "char") {

        cursor = max(cursor-1, 0);

      } else if(a == "backward" && b == "word") {

        for(; cursor > 0 && text[cursor-1] == ' '; --cursor);
        for(; cursor > 0 && text[cursor-1] != ' '; --cursor);

      } else if(a == "insert") {

        b = b.substr(1, b.size()-2);
        text.insert(cursor, b);
        cursor += b.size();

      } else if(a == "delete" && b == "char") {

        if(cursor < N) text.erase(cursor, 1);

      } else if(a == "delete" && b == "word") {

        int begin = cursor;
        int end = cursor;
        for(; end < N && text[end] == ' '; ++end);
        if(end == N) continue;
        for(; end < N && text[end] != ' '; ++end);
        if(begin < N && end-begin > 0) text.erase(begin, end-begin);

      }

    }

    text.insert(cursor, "^");
    cout << text << endl;

  }
  return 0;
}

Measured memory_bytes: 1240
using System;
using System.Linq;
namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = parseIntList(Console.ReadLine().TrimEnd());
            var A_turn = Math.Ceiling( (float)list[2]/(float)list[1]);
            var B_turn = Math.Ceiling( (float)list[0]/(float)list[3]);
            Console.WriteLine(A_turn <= B_turn ? "Yes" : "No");
            Console.ReadLine();
        }
        static int[] parseIntList(string obj){
            return (int[])obj.Split(" ").Select(x=> int.Parse(x)).ToArray();
        }

    }
}


Measured memory_bytes: 19040
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A, K));

        sc.close();
    }

    static int solve(int[] A, int K) {
        Map<Integer, Integer> valueToCount = new HashMap<>();
        for (int value : A) {
            valueToCount.put(value, valueToCount.getOrDefault(value, 0) + 1);
        }

        return A.length
                - valueToCount.values().stream().sorted(Collections.reverseOrder()).limit(K).mapToInt(x -> x).sum();
    }
}

Measured memory_bytes: 92160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007

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

    ll ans = 0;
    ll sum = 0;
    for (int i = 1; i < n; i++)
    {
        sum += a[i];  
    }


    int i = 1;
    for(int j = 0; j < n - 1; j++) {
        b[j] = sum;
        sum -= a[i++];
    }

    for(int i = 0; i < n - 1; i++) {
        ans += (b[i]%mod)*(a[i]%mod);
        ans %= mod;
    }



    cout << ans << endl;

}

Measured memory_bytes: 6416
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim S As String = NextString()
        WriteLine(New String() {"WA", "AC"}(B2I(Judge(S))))
    End Sub

    Function Judge(S As String) As Boolean
        Dim flg As Boolean


        For i As Integer = 0 To S.Length - 1
            If i = 0 Then
                If S(i) <> "A"c Then Return False
            ElseIf 2 <= i And i < S.Length - 1 And S(i) = "C"c And Not flg Then
                flg = True
            ElseIf S(i) <> StrConv(S(i), vbLowerCase) Then
                Return False
            End If
        Next
        If Not flg Then Return False
        Return True
    End Function

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int M = (int) 1e5 + 100;
		bool[] isPrime = new bool[M];
		for(int i=2;i<M;i++) isPrime[i] = true;
		for(int i=2;i<M;i++){
			if(isPrime[i]){
				for(int j=i+i;j<M;j+=i) isPrime[j] = false;
			}
		}
		
		int[] sum = new int[M+1];
		for(int i=0;i<M;i++) sum[i+1] = sum[i] + ((isPrime[i] && isPrime[(i + 1) / 2]) ? 1 : 0);
		
		int[] ans = new int[Q];
		for(int i=0;i<Q;i++){
			ans[i] = sum[R[i] + 1] - sum[L[i]];
		}
		Console.WriteLine(String.Join("\n",ans));
		
	}
	int Q;
	int[] L,R;
	public Sol(){
		Q = ri();
		L = new int[Q];
		R = new int[Q];
		for(int i=0;i<Q;i++){
			var d = ria();
			L[i] = d[0]; R[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 19264
#include<bits/stdc++.h>
#define range(i,a,b) for(long long i = (a); i < (b); i++)
#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

long long gcd(long long x, long long y) {
	long long r;
	if(x < y) swap(x, y);

	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

long long lcm( long long m, long long n ) {
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) ) return 0;
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main(){
	long long n, m;
	string s,t ;
	cin >> n >> m >> s >> t;

	if(s.front() != t.front()){
		cout << -1 << endl;
		return 0;
	}

	long long l = lcm(n, m);
	long long g = gcd(n, m);


	if([&]() -> bool{
		for(int i = 0, j = 0; i < n or j < m; i += n / g, j += m / g){
			if(s[i] != t[j]) return false;
		}
		return true;
		}()) cout << l << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))

border = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]

ret = 0
for i in range(len(border) - 1):
    if len(list(filter(lambda n: border[i] <= n < border[i + 1], A))) > 0:
        ret += 1
print(max(1, ret), ret + len(list(filter(lambda n: 3200 <= n, A))))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//
int main(){
    int N;
    cin >> N;

    vector <int> a(N);
    REP(i,N)
    {
        cin >> a.at(i);
    }


    REP(i,N)
    {
        cout << a.at(N-1-i);
        if(i != N-1)
        {
            cout << " ";
        }
    }

    cout << endl;

    return 0;    

}




Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int n,m;
char s[1005][1005];
int dp[1005][1005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(s[i+1][j]!='#')dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			if(s[i][j+1]!='#')dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
		}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;



int main() {
	ll n;
	ll in;
	vector <ll> a;
	cin >> n;
	REP(i, n) {
		cin >> in;
		a.push_back(in - i - 1);
	}
	sort(a.begin(), a. end());
	ll min = -1;
	ll total=0;
	ll kijun;

	if (n % 2 == 0) {
		kijun = (a[n / 2] + a[n / 2 - 1]) / 2;
	}
	else {
		kijun = a[n / 2];
	}
	/*int flag;
	REP(i, n) {
		flag = 0;
		total = 0;
		kijun = a[i];
		//cout << kijun << endl;
		REP(j, n) {
			if (i != 0) {
				
				if (a[i] == a[i - 1]) {
					//cout << "!!!" << endl;
					flag = 1;
					break;
				}
			}
			total += abs(a[j] - kijun);
		}
		if ((min > total || min<0)&&flag==0) {
			min = total;
		}
		//cout << total << endl;
	}*/
	REP(i, n) {
		total += abs(kijun - a[i]);
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 2420