akhauriyash/Code-Regression huggingface dataset:
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
    double w;
   cin>>n>>m;
   p=m*(n+n-m+1)/2;
   q=m*(m-1)/2;;
   rep(i,m,n+2){
       ans=(ans+p-q+1)%1000000007;
       
       p+=n-i;
       q+=i;
   }
   cout<<ans<<endl;
   
}


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

int main() {
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else if(s == "ARC") cout << "ABC" << endl;
  return 0;
}

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

int x,m,k,y,z,dp[10000000],ar[10000000];

int main() {
	scanf("%d%d",&x,&y);
	for (int a = 1; a <= x; a++) {
		scanf("%d",&ar[a]);
	}
	dp[1] = 0;
	for (int a = 2; a <= x; a++) {
		dp[a] = 1999999999;
		for (int b = 1; b <= y && a-b > 0; b++) {
			dp[a] = min(dp[a],dp[a-b]+abs(ar[a]-ar[a-b]));	
		}
	}
	cout << dp[x] << "\n";
	return 0;
} 

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

typedef long long ll;

int main(){
    int n; cin >> n;
    int arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];
    int dp[n+1];
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-2] + abs(arr[i] - arr[i-2]), dp[i-1] + abs(arr[i] - arr[i-1]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef long long ll;
ll a,n,b,c,d;
string s;
string bi(ll n){
    string u;
    for(int i=51;i>=0;i--){
        if((n>>i)&1)u+='1';
        else u+='0';
    }
    return u;
}
string Bi(ll n){
    string u;
    for(int i=11;i>=0;i--){
        if((n>>i)&1)u+='1';
        else u+='0';
    }
    return u;
}
int main(void){
    while(1){
    a=(1LL<<52);
    cin>>n>>s;
    c=0;
    if(n==0)return 0;
    for(int i=0;i<52;i++){
        if(s[i]=='1')a|=(1LL<<(51-i));
    }
    b=a;
    //高速な方法
    while(n>0&&b>0){
        ll tmp=min(n,((1LL<<53)-a+b-1)/b);
        a+=tmp*b;
        c+=(a>>53);
        while(a>=(1LL<<53)){
            b>>=1;
            a>>=1;
        }
        n-=tmp;
    }
    /*愚直な方法（間に合わない）
    for(int i=0;i<n;i++){
        a+=b;
        if(a>=(1LL<<53)){
            c+=(a>>53);
            b>>=1;
            a>>=1;
        }
    }*/
    cout<<Bi(c)<<bi(a)<<endl;
    }
}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

	static final long MOD = 1000000007;
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int D = scan.nextInt();

		while (true) {
			C -= B;
			if (C <= 0) {
				System.out.println("Yes");
				break;
			}
			A -= D;
			if (A <= 0) {
				System.out.println("No");
				break;
			}
		}
	}
}

Measured memory_bytes: 35708
n=97
p=print
r=range
def c(i,j,k):p('<',i,j,k)
def a(i,j,k=0):p('+',i,j,max(i,k))
def b(i):a(i,i,i+1)
def d(x,i,j):
	for t in r(30):
		b(j+t-1)
		a(j+t,n)
		for s in r(j+t,j+29):b(s)
		c(j+29,x,i+t)
		b(j+t-1)
		a(j+t,i+t)
p(3933)
a(0,1,n)
c(2,n,n)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):
	a(2,2)
	for s in r(t+1):
		if t-30<s<30:a(5+t-s,36+s,98);c(n,98,99);a(2,99)

Measured memory_bytes: 9220
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A[222222];

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> A[i];

  std::sort(A, A + N, std::greater<int>());

  std::multiset<int> set;

  set.insert(- A[0]);

  long long C = 0;

  for (int i = 1; i < N; i ++) {
    auto it = std::begin(set);
    
    C += - *it;

    set.erase(it);

    set.insert(- A[i]);
    set.insert(- A[i]);
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 13808
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    long long x;
    cin >> x;
    long long ans = (x / 500) * 1000LL;
    ans += ((x % 500) / 5) * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'
const main = input => {
  const n = parseInt(input[0], 10)
  input.shift();
  const a = input.map(val => parseInt(val, 10));
  a.pop();
  // console.log(n, a);
  const arr = [...a];
  a.sort((x,y) => y-x);
  // console.log(a);
  for(let i=0; i<n; i++) {
    console.log(arr[i]==a[0]?a[1]:a[0]);
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

#include <string>

int main()
{
    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
        
    }
    return 0;
}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string s; cin >> s;
  int ans=0;
  for(auto c:s){
    if(c=='+')ans++;
      else ans--;
  }
  cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

long steps[100001];

long count_steps(const vector<int>& as, int n) {
  int j = 0;
  steps[0] = 1;
  steps[1] = 1;
  for (int i = 1; i <= n; ++i) {
    if (j < as.size() && i == as[j]) {
      steps[i] = 0;
      ++j;
      continue;
    }
    if (i == 1) {
      continue;
    }
    steps[i] = (steps[i - 1] + steps[i - 2]) % 1000000007;
  }
  return steps[n];
}

int main(int argc, char* argv[]) {
  int n, m;
  cin >> n >> m;
  std::vector<int> as(m);
  for (int i = 0; i < m; ++i) {
    cin >> as[i];
  }
  cout << count_steps(as, n);
  return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;

typedef complex<double> P;

double dot(const P& a, const P& b)
{
	return real(conj(a)*b);
}
double cross(const P& a, const P& b)
{
	return imag(conj(a)*b);
}

struct L : public vector<P>
{
	L(){}
	L(const P& a, const P& b)
	{
		push_back(a); push_back(b);
	}
};

P crosspoint(const L& l, const L& m)
{
	double A=cross(l[1]-l[0], m[1]-m[0]);
	double B=cross(l[1]-l[0], l[1]-m[0]);
	
	return m[0]+B / A*(m[1]-m[0]);
}

double Area(P a, P b, P c, P d)
{
	b-=a; c-=a; d-=a;
	
	return (fabs(cross(b,c)) + fabs(cross(c,d)))/2;
}

int main()
{
	int N;
	while(scanf("%d", &N), N)
	{
		vector<double> A(N),B(N),C(N),D(N);
		for(int i=0; i<N; i++)
		{
			double x;
			scanf("%lf", &x);
			A[i]=x;
		}
		for(int i=0; i<N; i++)
		{
			double x;
			scanf("%lf", &x);
			B[i]=x;
		}
		for(int i=0; i<N; i++)
		{
			double y;
			scanf("%lf", &y);
			C[i]=y;
		}
		for(int i=0; i<N; i++)
		{
			double y;
			scanf("%lf", &y);
			D[i]=y;
		}
		
		vector<L> row(N+2), col(N+2);
		
		row[0]=L(P(0,0), P(0,1));
		row[N+1]=L(P(1,0),P(1,1));

		col[0]=L(P(0,0),P(1,0));	
		col[N+1]=L(P(0,1),P(1,1));

		
		for(int i=0; i<N; i++)
		{
			row[i+1]=L(P(A[i], 0), P(B[i], 1));
			col[i+1]=L(P(0, C[i]), P(1, D[i]));
		}
		
		double ans=0;
		
		for(int i=0; i<N+1; i++)		
		for(int j=0; j<N+1; j++)
		{
			P LT=crosspoint(col[j+1], row[i]);
			P LB=crosspoint(col[j], row[i]);
			P RT=crosspoint(col[j+1], row[i+1]);
			P RB=crosspoint(col[j], row[i+1]);
			
			ans=max(ans, Area(LT,LB,RB,RT));
		}
		
		printf("%.6lf\n", ans);
	}
}

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

// definitions
#define __Imperial_Lord__ ONLINE_JUDGE
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define exec cerr<<"Time taken : "<<(ld)(clock())/_cps<<"s"<<endl
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF=1e18;

// cin and cout overloaded for vectors and sets
template<typename T>    istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v) 
        is >> i;        
    return is;
}
template<typename T>             
ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v) 
        os << i << ' '; 
        return os;
}

// code beigns in main
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
    	ll cnt=0;
    	string s,t;
    	cin >> s >>t;
    	ll n=s.length();
    	rep(i,0,n)
    	{
    		if(s[i]!=t[i]) cnt++;
    	}
    	p1(cnt);
    }
    exec;
}

Measured memory_bytes: 3972
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(){
	int n,a,b,c;
	int m=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a[3];
		for(int j=0;j<3;j++)scanf("%d",&a[j]);
		std::sort(a,a+3);
		
		m=max(m,a[2]);
		
		if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2])puts("YES");
		else{
			if(m<15)puts("NO");
			else puts("YES");
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  char S[N];
  bool flag = false;
  for(int i = 0; i < N; ++i){
    cin >> S[i];
    if(S[i] == 'Y') flag = true;
  }
  if(flag) cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <regex>
#include <list>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define FORi(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FOR(i,n) FORi(i,1,n)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mt make_tuple
#define pb push_back
#define sz size()
#define SET(__set, val) memset(__set, val, sizeof(__set))

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
using pdd=pair<double, double>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto& p: c) os << p << " ";
	return os<<']';
}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}


template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

constexpr int INF=1e9;
constexpr int MOD=1000000007;
constexpr double EPS=1e-9;
constexpr int maxw=31;
constexpr int maxn=100001;

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

	int a, b;
	while(cin>>a) {
		cin>>b;
		cout << b*2 - a <<endl;
	}
	return 0;
}


Measured memory_bytes: 256
(defparameter *n* (read))
(when (= *n* 2)
  (defparameter *a* (read))
  (defparameter *b* (read)))
(when (= *n* 1)
  (defparameter *a* nil)
  (defparameter *b* nil))

(defun f (n a b)
  (if (= n 1)
      "Hello World"
      (+ a b)))

(princ (f *n* *a* *b*))

Measured memory_bytes: 9952
#include <stdio.h>
int main(){
  int n, i, k, j, count;
  int point[200][3], sum[200];
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    for(k = 0; k < 3;k++){
      scanf("%d", &point[i][k]);
    }
  sum[i] = 0;
  }
  for(i = 0;i < n;i++){
    for(k = 0;k < 3;k++){
      count = 0;
      for(j = 0;j < n;j++){
        if(point[i][k] == point[j][k]){
          count += 1;
        }
      }
      if(count == 1){
        sum[i] += point[i][k];
      }
    }
  printf("%d\n", sum[i]);
  }
  return 0;
}

Measured memory_bytes: 596
import sys
from pprint import pprint

def solve(a, b, c):
    if a == b == c:
        return "Yes"
    else:
        return "No"

if __name__ == '__main__':

    a, b, c = sys.stdin.readline().strip().split(" ")
    ans = solve(int(a), int(b), int(c))
    print ans

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll flag = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++){
        flag = max(flag, a[i]);
        ans += (flag - a[i]);
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int v[n], c[n];
    float r[n];
    for(int i=0; i<n; ++i){
        cin >> v[i];
    }
    for(int i=0; i<n; ++i){
        cin >> c[i];
        r[i] = v[i]/c[i];
    }
    for(int i=0; i<n-1; ++i){
        for(int j=i+1; j<n; ++j){
            if(r[i] < r[j]){
                swap(r[i], r[j]);
                swap(v[i], v[j]);
                swap(c[i], c[j]);
            }
        }
    }
    int c1=0, c2=0, c3, ans = 0, temp;
    for(int i=0; i<n; ++i){
        c1 += v[i];
        c2 += c[i];
        temp = c1 - c2;
        ans = max(ans, temp) ;
    }
    cout << ans << "\n"    ;
}


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

using namespace std;
typedef long long ll;
const ll MAX_N = 100000 + 1;
ll h[MAX_N];

int main() {

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

  ll N;
  cin >> N;
  for(ll i = 1; i <= N; i++) cin >> h[i];

  ll dp[N + 1];
  dp[1] = 0;
  for(ll i = 2; i <= N; i++) {
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
  }
  cout << dp[N] << endl;
  return 0;
}


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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int n,t=1,ans=0;
    cin>>n;
    Vi a(n);
    REP(i,0,n) cin>>a[i];
    
    REP(i,1,n){
        if(a[i-1]==a[i]) t++;
        else{
            ans += (t/2);
            t=1;
        }
    }
    ans+=(t/2);
    cout<<ans<<ENT;
    return 0;
}


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


Measured memory_bytes: 256
import itertools
a=[list(map(int,input().split())) for i in range(3)]
a=list(itertools.chain.from_iterable(a))
n=int(input())
b=[]

for i in range(n):
  b.append(int(input()))

ans=['-']*9

for i in a:
  if i in b:
    ans[a.index(i)]='+'

if ans[0]==ans[1]==ans[2]=='+' or ans[3]==ans[4]==ans[5]=='+' or ans[6]==ans[7]==ans[8]=='+'\
   or ans[0]==ans[3]==ans[6]=='+' or ans[1]==ans[4]==ans[7]=='+' or ans[2]==ans[5]==ans[8]=='+'\
   or ans[0]==ans[4]==ans[8]=='+' or ans[2]==ans[4]==ans[6]=='+':
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9248
import java.util.*;
import java.util.function.*;
import java.lang.*;

public class Main {
    static int countBlack(String s){
        int N = s.length();
        int ans=0;
        for(int n=0; n<N; n++) if(s.charAt(n)=='#') ans++;
        return ans;
    }
    static int countWhite(String s){
        return s.length()-countBlack(s);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        //make it "....####"

        int ans = countWhite(S); //all-black is a possible solution
        int cur = ans;
        for(int n=0; n<N; n++){
            if(S.charAt(n)=='.') cur--;
            else cur++;

            ans = Math.min(ans,cur);
        }

        System.out.println(ans);


    }
}

Measured memory_bytes: 28664
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  vector<string> s(3);
  vector<int>used(3,0);
  rep(i,3) cin >> s[i];
  int now=0;
  while(true){
    if(s[now].size() > used[now]){
      used[now]++;
      now = s[now][used[now]-1]-'a';
    }
    else{
      cout << char('A'+now) << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N, M, X = (int(v) for v in input().split())
books = []

for i in range(N): 
    items = [int(v) for v in input().split()]
    books.append((items[0], items[1:]))

books = sorted(books)


def check(skill): 
    for item in skill: 
        if item < X:
            return False
    return True

queue = []

def buy_book(i, cost, input_skill):
    if i == N:
        if check(input_skill):
            queue.append(cost)
        return

    # 買わない
    buy_book (i+1, cost, input_skill)

    updated_cost = cost + books[i][0]
    updated_skill = [input_skill[i] for i in range(len(input_skill))] 
    for j in range(M): 
        updated_skill[j] = updated_skill[j] + books[i][1][j]
    buy_book (i+1, updated_cost, updated_skill)
 

buy_book(0, 0, [0 for i in range(M)])

if len(queue) == 0:
    print(-1) 
else: 
    print(min(queue))

Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl b(n),c(n);
  vector<string> a(n);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  rep(i,n){
    ll cnt=0;
    rep(j,n){
      if(a[i]>a[j]||(a[i]==a[j]&&b[i]<b[j])){
        cnt++;
      }
    }
    c[i]=cnt;
  }
  rep(i,n){
    rep(j,n){
      if(c[j]==i){
        cout << j+1 << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s){
        cout << a-1 << ' ' << b << endl;
    }else{
        cout << a << ' ' << b-1 << endl;
    }
    return 0;
}

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  // 机Aにある本を読む数で場合分け、二分探索
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> b(m);
  rep(i, m) cin >> b[i];
  int ans = 0;
  rep(i, n-1) a[i+1] += a[i]; // 累積和
  rep(i, m-1) b[i+1] += b[i];
  auto index = upper_bound(b.begin(), b.end(), k) - b.begin();
  index;
  ans = index;
  rep(i, n) {
    if (a[i] > k) break;
    auto index = upper_bound(b.begin(), b.end(), k-a[i]) - b.begin();
    index;
    int temp = i + 1 + index;
    ans = max(ans, temp);
  }
  cout << ans << '\n'; 
  
  return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 1e5 + 5;
int A[N], B[N], C[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i];
	for(int i = 0; i < n; i++)
		cin >> B[i];
	for(int i = 0; i < n; i++)
		cin >> C[i];
	sort(A, A + n);
	sort(B, B + n);
	sort(C, C + n);
	ll ans = 0;
	for(int i = 0; i < n; i++)
	{
		auto it1 = lower_bound(A, A + n, B[i]);
		auto it2 = upper_bound(C, C + n, B[i]);
		ans += (1ll * (it1 - A) * (n - (it2 - C)));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>]

int main(void){

	int a[4],b[4];
	int hit,blow;
	int i,j;

	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF){

		hit = 0, blow = 0;

		for(i=0;i<4;i++)
			scanf("%d",&b[i]);

		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(b[i] == a[j]){
					if(i == j)
						hit++;
					else
						blow++;
				}
			}
		}

		printf("%d %d\n",hit,blow);
	}

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  string T;
  cin >> S >> T;
  int ans = 0;
  REP(i,S.size()){
      if(S[i]==T[i])ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

const int N = 1e5 + 5 , MOD = 998244353;
int cnt[N];

int mul(int a , int b) {
    return a * 1ll * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = r * r % MOD;
    if (b&1) return r * a % MOD;
    return r;
}

int main() {
    int n , x , mx = 0;
    scanf("%d" , &n);
    for (int i = 0 ;i < n ;i++) {
        scanf("%d" , &x);
        if (i == 0 && x != 0) {
            puts("0");
            return 0;
        }
        cnt[x]++;
        mx = max(mx , x);
    }

    if (cnt[0] != 1) {
        puts("0");
        return 0;
    }

    int ans = 1;
    for (int i = 1 ;i <= mx ;i++)
        ans = mul(ans , power(cnt[i - 1] , cnt[i]));

    printf("%d" , ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)


int main(void){
	int h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	if(m2<m1){
		h2--;
		m2 += 60;
	}
	if(h2<h1) h2 += 24;
	printf("%d",max(0,(h2-h1)*60+(m2-m1)-k));
	return 0;
}


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

vector<long long> divisors(long long x) {
    vector<long long> a;
    a.push_back(x);
    for (int i = 2; i <= x / i; ++i) {
        if (x % i == 0) {
            a.push_back(i);
            if (x / i != i) {
                a.push_back(x / i);
            }
        }
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin >> n;
    if (n == 2) {
        cout << "1\n";
        return 0;
    }
    set<long long> ans;
    vector<long long> tmp;
    tmp = divisors(n - 1);
    for (auto i: tmp) {
        ans.insert(i);
    }
    tmp = divisors(n);
    for (auto i: tmp) {
        long long x = n;
        while (x % i == 0) {
            x /= i;
        }
        if (x % i == 1) {
            ans.insert(i);
        }
    }
    cout << ans.size() << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int n, k;
  int i;
  int value;
  double p = 1;
  double psum = 0;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; i++) {
    value = i;
    p = (double)1 * 1 / n;
    while (value < k) {
        p *= (double)1 / 2;
        value *= 2;
    }
    psum += p;
  }

  printf("%.9lf\n", psum);
  return 0;
}


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

const int INF = LONG_LONG_MAX;

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

  int n,k;
  cin >> n >> k;

  vector<int> p(n + 1);
  vector<int> c(n + 1);

  int MAXV = -INF;

  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    MAXV = max(MAXV, c[i]);
  }

  vector<vector<int>> route;

  vector<int> visited(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if(visited[p[i]]) continue;

    vector<int> path;
    path.push_back(c[i]);
    visited[p[i]] = 1;

    int cur = p[i];
    while(true) {
      if(visited[p[cur]]) break;
      visited[p[cur]] = 1;
      path.push_back(c[cur]);
      cur = p[cur];
    }
    route.push_back(path);
  }

  int answer = MAXV;

  for (auto path : route) {
    int m = path.size();

    for (int i = 0; i < m; i++) {
      int loop_sum = 0;

      for (int j = 0; j < min(k, m); j++) {
        loop_sum += path[(i + j) % m];
        answer = max(answer, loop_sum);
      }

      if(k <= m || loop_sum < 0) continue;

      int cycle = k / m;
      int tmp = (cycle - 1) * loop_sum;
      answer = max(answer, tmp);

      int mod = k % m + m;
      for (int j = 0; j < mod; j++) {
        tmp += path[(i + j) % m];
        answer = max(answer, tmp);
      }

    }
  }
  cout << answer << '\n';
}

Measured memory_bytes: 3812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int kosu = sc.nextInt();
		int kaz = 0;
		int evenum = 0;
		int addnum = 0;
		int yonbai = 0;

		for(int i=0; i< kosu;i++){
			kaz = sc.nextInt();
			if (kaz%2 != 0){
				evenum++;
			}else
				addnum++;{
				if(kaz%4 == 0){
					yonbai++;
				};
			}
		}

		if(evenum == 0){
			System.out.println("Yes");
		}else{
			if( (evenum -1) < yonbai){
				System.out.println("Yes");
			}else if ((evenum -1) == yonbai && (evenum + addnum)%2 != 0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}

		sc.close();
	}


}


Measured memory_bytes: 48372
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,k;
    cin >>a >> b >> c;
    cin >>k;
    for(int i=0;i<k;i++){
        if(b<=a) b*=2;
        else if(c<=b) c*=2;
        
        if(a<b&&b<c){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout << "No" <<endl;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,l,r) for(int i=(r-1);i>=(l);i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define range(i) i.begin(),i.end()
#define Yes(i) out(i?"Yes":"No");return 0
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
    int n,m;
    in(n,m);
    vector<ll> a(n+1);
    a[0]=0;
    rep(i,1,n+1){
        in(a[i]);
        a[i]+=a[i-1];
        a[i]%=m;
    }
    sort(a.begin(), a.end());
    ll start=0,ans=0;
    rep(i,1,n+1)if(a[start]-a[i]){
        ans+=(i-start)*(i-start-1)/2;
        start=i;
    }
    ans+=(n+1-start)*(n+1-start-1)/2;
    out(ans);
}








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

using namespace std;

using ull = unsigned long long;

int main() {
    int N, D, X[10][10], num = 0;
    cin >> N >> D;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < D; ++j) {
            cin >> X[i][j];
        }
    }
    for(int i = 0; i < N - 1; ++i) {
        for(int j = i + 1; j < N; ++j) {
            double norm = 0;
            for(int index = 0; index < D; ++index) {
                norm += pow(X[j][index] - X[i][index], 2.0);
            }
            if(static_cast<long>(norm) == pow < long > (static_cast<long>(round(sqrt(norm))), 2)) {
                num++;
            }
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var n, m int
	fmt.Scan(&n)

	ans := "No"
	for i:=0; i<=25; i++{
		m = n-4*i
		if m >= 0 {
			if m%7 == 0 {
				ans = "Yes"
			}
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100010],cnt[100010]={};
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i],cnt[a[i]]++;
  int c=0,ans=0;
  for(int i=0;i<=100000;i++){
    if(cnt[i]%2==1)ans++;
    else if(cnt[i])c++;
  }
  cout<<ans+c-c%2<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <sstream>
using namespace std;
 
stack<double> s;
 
double calc(string str){
    double x = s.top();
    s.pop();
    double y = s.top();
    s.pop();
     
    switch(str[0]){
        case '+':
            return x+y;
        case '-':
            return y-x;
        case '*':
            return x*y;
    }
    return y/x;
}
 
void judge(){
  string str,a;
     
  while(getline(cin,str)){
    stringstream ss(str);
    while(ss >> a){
      if(a == "+" || a == "-" || a == "*" || a == "/"){
            s.push(calc(a));
      }
      else{
	s.push(atof(a.c_str()));    
	  }
    }
    printf("%.6f\n" ,s.top());
  }
}


int main(){
    judge();
    return 0;
}

Measured memory_bytes: 1272
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[4];
for(int i=0;i<=3;i++)
cin>>a[i];
int x=0,y=0;
x=min(a[0],a[1]);
y=min(a[2],a[3]);
cout<<x+y;
system ("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int n;
	int d;

	std::cin >> n >> d;

	std::cout << ceil(n / (2.0 * d + 1)) << std::endl;
}

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

int main(){
  string s,c = "Yes";
  cin >> s;
  int a[26]={};
  for(int i=0;i<s.size();i++){
    a[s.at(i)-97]++;
  }
  for(int i=0;i<26;i++){
    if(a[i]%2!=0){
      c = "No";
      break;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#ARc080C

n=int(raw_input())
l=map(int,raw_input().split())
cnt1=cnt2=cnt4=0
for i in xrange(n):
 if l[i]%4==0:
  cnt4+=1
 elif l[i]%2==0:
  cnt2+=1
 else:
  cnt1+=1
if cnt4>=cnt1:
 print 'Yes'
elif cnt4==cnt1-1 and cnt2==0:
 print 'Yes'
else:
 print 'No'


Measured memory_bytes: 11296
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, a;
    cin >> n >> a;
    int x[n+1];
    x[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    sort(x, x+n+1);
    int X = max(x[n], a);

    ll dp[n+1][n+1][n*X+1];

    rep(j, n+1) {
        rep(k, n+1) {
            rep(s, n*X+1) {
                if(j == 0 && k == 0 && s == 0) {
                    dp[j][k][s] = 1;
                }
                else if(j >= 1 && s < x[j]) {
                    dp[j][k][s] = dp[j-1][k][s];
                }
                else if(j >= 1 && k >= 1 && s >= x[j]) {
                    dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
                }
                else {
                    dp[j][k][s] = 0;
                }
            }
        }
    }

    ll ans = 0;
    for(int k = 1; k <= n; k++) {
        ans += dp[n][k][k*a];
    }

    cout << ans;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 51072
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-18 23:49:42
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    vector<pair<int, int>> memo(n+1);
    for (int i = 0; i <= n; i++)
        memo[i] = make_pair(0, i);

    for (int i = 0; i < n; i++)
        memo[a[i]].first++;

    sort(all(memo));

    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += memo[n-i].first;
    }

    cout << n - sum << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#define ll long long
#define mod 998244353
using namespace std;
ll add(ll x,ll y){x+=y;if(x>mod)x-=mod;return x;}
ll sub(ll x,ll y){x-=y;if(x<0)x+=mod;return x;}
ll mul(ll x,ll y){x%=mod;y%=mod;return x*y%mod;}
ll power(ll n,ll x){
    ll sp=1ll;
    while(x){
        if(x&1) sp=mul(sp,n);
        n=mul(n,n);x>>=1;
    }return sp;
}
ll inv2=(mod+1)>>1;
void FWT(ll *a,int n,int opt){
    for(int i=1;i<n;i<<=1)
    for(int j=0;j<n;j+=(i<<1))
    for(int k=0;k<i;k++){
        ll X=a[j+k],Y=a[i+j+k];
        a[j+k]=add(X,Y);a[i+j+k]=sub(X,Y);
        if(opt==-1) a[j+k]=mul(a[j+k],inv2),a[i+j+k]=mul(a[i+j+k],inv2);
    }
}
ll n,m;
ll a[300000],b[300000],p[300000],sum,inv;
int main(){
    scanf("%lld",&n);m=1<<n;
    for(int i=0;i<m;i++) scanf("%lld",&p[i]),sum=add(sum,p[i]);
    inv=power(sum,mod-2);
    for(int i=0;i<m;i++) a[i]=mul(p[i],inv);a[0]=sub(a[0],1);
    for(int i=1;i<m;i++) b[i]=mod-1;b[0]=m-1;
    FWT(a,m,1);FWT(b,m,1);
    for(int i=0;i<m;i++) b[i]=mul(b[i],power(a[i],mod-2));
    FWT(b,m,-1);
    for(int i=0;i<m;i++) printf("%lld\n",sub(b[i],b[0]));
    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=b;i!=0;i=i/10)
	{
		a=a*10;
	}
	if((int)sqrt((double)(a+b))*(int)sqrt((double)(a+b))==(a+b)) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007 
#define slld(x) scanf("%lld",&x)
ll t = 1 ;
void solve()
{
    ll n , ans = 0 ;
    cin >> n ; 
    vector<ll> v(n) , dp(n,0) ;
    rep(i,0,n){
        cin>>v[i];
    }
    for( ll i = n - 2 ; i >= 0 ; i-- ){
        if(v[i+1]<=v[i])
            dp[i]=dp[i+1]+1;
        else
            dp[i]=0;
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int Getnum(int n)
{
	int i,s=0;
	for(i=0;i<5;i++)
	{
		if((n>>i)&0x01==1)
			s++;	
	}
	return s;
}
int main()
{
	long long sum=0,t;
	int i,tmp,check=0,n,a[(1<<5)+1]={0};
	char sz[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",sz);
		switch(sz[0])
		{
			case 'M':
				check|=1<<4;
				a[1<<4]++;
				break;
			case 'A':
				check|=1<<3;
				a[1<<3]++;
				break;
			case 'R':
				check|=1<<2;
				a[1<<2]++;
				break;
			case 'C':
				check|=1<<1;
				a[1<<1]++;
				break;
			case 'H':
				check|=1<<0;
				a[1<<0]++;
				break;
		}
	}
	//printf("%d\n",check);
	for(i=0;i<(1<<5);i++)
	{
		if(Getnum(i)!=3||(check&i)!=i)
			continue;
		tmp=i;
		t=1;
		while(tmp)
		{
			t*=a[tmp&-tmp];
			tmp-=tmp&-tmp;
		}
		//printf("%d %d\n",i,t);
		sum+=t;
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		if (N % 2 == 0) {
			System.out.println(N/2 - 1);
		} else {
			System.out.println(N/2);
		}
	}
}

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

#define INF 1e9+5
int absolute(int n){
    return (n<0) ? -1*n : n ;
}
int main(){
    int n;
    cin>>n;
    int h[n]={0};
    for(int i=0;i<n;i++) cin>>h[i];
    int dp[n];
    for(int i=0;i<n;i++){
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=0;i<n-1;i++){
        dp[i+1]=min(dp[i+1],dp[i]+absolute(h[i+1]-h[i]));
        if(i+2<n) dp[i+2]=min(dp[i+2],dp[i]+absolute(h[i+2]-h[i]));
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int, int> pi;
typedef pair<int, pi> pip;

const int dx[4] = {  0,   1,  0,  -1 };
const int dy[4] = { -1,   0,  1,   0 };
const int max_hw = 1000;

int H, W, K;
int sx, sy;
vector<string> A;

int calcu_rest(pi pos) {
	int rest_x = min(pos.first, W - 1 - pos.first);
	int rest_y = min(pos.second, H - 1 - pos.second);
	int min_xy = min(rest_x, rest_y);
	return min_xy;
}

int get_rest(void) {
	queue<pip> que;
	pi stt = make_pair(sx, sy);
	que.push(make_pair(0, stt));
	int rest = max_hw;
	while (que.size()) {
		pip p = que.front(); que.pop();
		if ((p.second.first == 0 || p.second.first == W - 1)
				|| (p.second.second == 0 || p.second.second == H - 1)) {
			rest = 0;
			break;
		}
		if (p.first >= K) {
			int rest_xy = calcu_rest(p.second);
			if (rest_xy < rest)
				rest = rest_xy;
			continue;
		}
		for (int i = 0; i < 4; ++i) {
			int nx = p.second.first + dx[i];
			int ny = p.second.second + dy[i];
			if (A[ny][nx] == '.') {
				A[ny][nx] = '@';
				que.push(make_pair(p.first + 1, make_pair(nx, ny)));
			}
			else {
				int rest_xy = calcu_rest(p.second);
				if (rest_xy < rest)
					rest = rest_xy;
			}
		}
	}
	return rest;
}

int main(void) {
	cin >> H >> W >> K;
	A.resize(H);
	sx = -1;
	for (int j = 0; j < H; ++j) {
		cin >> A[j];
		if (sx >= 0)
			continue;
		for (int i = 0; i < W; ++i) {
			if (A[j][i] == 'S') {
				sx = i;	sy = j;
				break;
			}
		}
	}

	int ans = 1;
	int rest = get_rest();
	int t2 = rest / K;
	if (rest % K != 0)
		++t2;
	ans += t2;

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n,W; cin >> n >> W;
    vector<ll> w(n+1),v(n+1);
    for(int i = 1; i <= n; i++) cin >> w.at(i) >> v.at(i);
    int sum = accumulate(all(v),0);
    vector<vector<ll>> dp(n+1,vector<ll>(sum+1));
    rep(i,sum+1) dp.at(0).at(i) = 1e18;
    dp.at(0).at(0) = 0;

    for(int i = 1; i <= n; i++){
        rep(j,sum+1){
            ll now;
            if(j - v.at(i) >= 0){
                now = min(dp.at(i-1).at(j - v.at(i)) + w.at(i),dp.at(i-1).at(j));
            }
            else now = min(w.at(i),dp.at(i-1).at(j));
            dp.at(i).at(j) = now;
        }
    }
    /*rep(i,n+1){
        rep(j,sum+1){
            cout << dp.at(i).at(j) << " ";
        }
        cout << endl;
    } */
    auto itr = upper_bound(all(dp.at(n)),W);
    cout << itr - dp.at(n).begin() -1 << endl;
    return 0;   
}


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

using namespace std;

const int MAXN = 3010;
const int MOD  = 1e9+7;

int n;
char s[MAXN];

int f[MAXN][MAXN];

int main()
{
	scanf("%d%s",&n,s+1);
	f[1][1] = 1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=i;j++){
			if(s[i-1] == '>') f[i][j] = (f[i-1][i-1] - f[i-1][j-1] + MOD) % MOD;
			else f[i][j] = f[i-1][j-1];
			f[i][j] = (f[i][j] + f[i][j-1]) % MOD;
		}
	}
	printf("%d\n",f[n][n]);
	return 0;
}

Measured memory_bytes: 34304
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int a,b,ans=1;
int gcd(int a,int b)
{
	if(a<b) swap(a,b);
	if(b==0) return a;
	return gcd(b,a%b);
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>a>>b;
	int c=gcd(a,b);
	int oc=c;
	for (int i=2;i<=sqrt(oc);i++)
	{
		if (c%i==0&&i<=c)
		{
			ans++;
			while (c%i==0) c/=i;
		}
	}
	for (int i=sqrt(oc);i>=1;i--)
	{
		int ni=oc/i;
		if(c%ni==0)
		{
			if(ni<=1) continue;
			ans++;
			while(c%ni==0&&ni<=c) c/=ni;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256