akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    aI,aO,aT,aJ,aL,aS,aZ=map(int,input().split())
    ans=aO

    if(aI>=1 and aJ>=1 and aL>=1 and (aI%2+aJ%2+aL%2)==2):
        ans+=3
        aI-=1; aJ-=1; aL-=1

    ans+=(aI//2)*2
    ans+=(aJ//2)*2
    ans+=(aL//2)*2
    if(aI&1 and aJ&1 and aL&1):
        ans+=3

    print(ans)
resolve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
#define ll long long

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

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

    string oriS = S;
    transform(S.begin(), S.end(), S.begin(), ::tolower);

    oriS[K-1] = S[K-1];

    cout << oriS << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define modulo 998244353
#define endl '\n'
#define pb push_back
using namespace std;
vector <int> adj[100001];
ll fxp(ll a, ll b)
{
    if(b == 0)return 1;
	if(b%2 == 0){
		ll c = fxp(a,b/2);
		return (c*c)%1000000007;
	}
	return (a*fxp(a,b-1))%1000000007;
}
int lcm(int c,int d)
{
    int a=c;
    int b=d;
    int ans;
    if(a>=b)
    {
        while(b!=0)
        { 
            int x=b;
            b=a%b;
            a=x;
        }
        ans = ( c*d)/a;
    }
    else
    {
        while(a!=0)
        {
            int x=a;
            a=b%a;
            b=x;
        }
        ans = ( c*d)/b;  
    }
    return ans;
}
int root_find()
{
    ll x;
    for(int i=1;i<100001;i++)
    {
        if(adj[i].size()==1)
        {
            x = i;
            break;
        }
    }
    return x;
}
void dfs(int s,int y)
{
    for(int i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]==y)
        continue;
        dfs(adj[s][i],s);
    }
}
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return n/2; 
  
    // iterate from 3 to sqrt(n) 
    for (int i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return n/i; 
    } 
  
    return n; 
}  
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll p[n];
    for(int i=0;i<n;i++)
    cin>>p[i];
    sort(p,p+n);
    ll sum=0;
    for(int i=0;i<k;i++)
    sum=sum+p[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 6020
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<int>> res(h+2, vector<int>(w+2, 0)); // マージンをとる

    char v;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){

            cin >> v;

            if(v=='#'){
                // res[i+1][j+1] 現在地
                res[i+1][j+1] = -100;
                res[i][j] += 1;
                res[i][j+1] += 1;
                res[i][j+2] += 1;
                res[i+1][j] += 1;
                res[i+1][j+2] += 1;
                res[i+2][j] += 1;
                res[i+2][j+1] += 1;
                res[i+2][j+2] += 1;
            }
        }

    }


    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){

            if(res[i][j] < 0){
                cout << '#';
            }
            else {
                cout << res[i][j];
            }
        }

        cout << endl;
    }







}

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

using namespace std;

int n, sum, a[22], b[22], c[22];

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= n; i++)
    cin >> b[i];
  for (int i = 1; i < n; i++)
    cin >> c[i];
  for (int i = 1; i <= n; i++) {
    if (a[i] + 1 == a[i + 1])
      sum += c[a[i]];
    sum += b[i];
  }
  cout << sum;
  return 0;
}


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

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long MX = sqrt(N);
const long long H = 17;
const long long MAGIC = 1000;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int m;
int a;
int b;

void solve()
{
        cin >> n >> m >> a >> b;
        if(n % a == 0 && m % b == 0){
                cout << "No" << "\n";
        }
        else{
                cout << "Yes" << "\n";
                if(n % a){
                        for(int i = 0; i < n; i++){
                                for(int j = 0; j < m; j++){
                                        cout << (i % a == 0 ? 1000 * (a - 1) - 1 : -1000) << " \n"[j == m - 1];
                                }
                        }
                }
                else{
                        for(int i = 0; i < n; i++){
                                for(int j = 0; j < m; j++){
                                        cout << (j % b == 0 ? 1000 * (b - 1) - 1 : -1000) << " \n"[j == m - 1];
                                }
                        }
                }
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("landscape.in");
        //fout("landscape.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}



void Main()
{
	ld a,b,h,m; ld res=0;
	string s,t,u; string sres="No or NO";
	ll k;
	cin>>a>>b>>h>>m;

	ld xa,ya,xb,yb;
	ld thb=-(M_PI*2.0*m/60.0);
	ld addtha=(M_PI*2.0/12.0)*m/60.0;
	ld tha=-(M_PI*2.0*h/12.0)-addtha;

	xa=a*cos(tha);
	ya=a*sin(tha);
	xb=b*cos(thb);
	yb=b*sin(thb);

	res=hypot(xa-xb,ya-yb);
	cout << res << "\n";
	return;
}

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


Measured memory_bytes: 4212
def main():
    N = int(input())
    S = input()

    ans = 0

    for i in range(N - 2):
        if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9040
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NMK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            int N = (int)NMK[0], M = (int)NMK[1];
            long K = NMK[2];

            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var B = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long[] da = new long[N + 1];
            long[] db = new long[M + 1];
            for (int i = 0; i < N; i++)
            {
                da[i + 1] = da[i] + A[i];
            }
            for (int i = 0; i < M; i++)
            {
                db[i + 1] = db[i] + B[i];
            }

            int maxcount = 0;
            for (int i = 0; i <= N; i++)
            {
                long sum = da[i];

                int lb = -1, ub = M+1;
                while (ub - lb > 1)
                {
                    int mid = (lb + ub) / 2;
                    if (sum + db[mid] <= K) lb = mid;
                    else ub = mid;
                }
                if (lb == -1) continue;
                maxcount = Math.Max(maxcount, i + lb);
            }

            Console.WriteLine(maxcount);
        }
    }
}


Measured memory_bytes: 73004
/**
 * @author torith
 * @date 2018-11-02
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    string s; cin >> s;
    char bef = s[0];
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(bef != s[i]) ans++;
        bef = s[i];
    }

    cout << ans << "\n";


    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<int> L(2*N);
	rep(i,2*N)cin>>L[i];
	sort(all(L));
	int ans;
	rep(i,N)ans+=L[2*i];
	cout<<ans<<endl;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

vector<double> dp;
int main()
{
	ll n;
	cin >> n;
	vector<double> p(n);
	rep(i,n) cin >> p[i];
	dp.assign(n+1,0);
	dp[0] = 1;

	rep(i,n){
		for(int j = n; j >= 0; j--){
			if(j==0) dp[j] = dp[j] * (1-p[i]);
			else dp[j] = dp[j-1] * p[i] + dp[j] * (1-p[i]);
		}
	}
	double ans = 0;
	for(int i = n; i >= (n/2+1); i--){
		ans += dp[i];
	}
	cout << setprecision(15);
	cout << ans << endl;
}


Measured memory_bytes: 256
program main
    implicit none
    logical::isPrime(55555)
    integer::arr(55555)
    integer::i,j,k,t,N
    do i=1,size(isPrime)
        isPrime(i)=.true.
    end do
    isPrime(1)=.false.
    do i=2,size(isPrime)
        if(isPrime(i))then
            do j=2*i,size(isPrime),i
                isPrime(j)=.false.
            end do
        end if
    end do
    t=1
    do i=2,size(isPrime)
        if(isPrime(i).and.mod(i,5)==1)then
            arr(t)=i
            t=t+1
        end if
    end do
    read*,N
    print*,(arr(i),i=1,N)


end program


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

int main(){
	string s;
	int x,y;
	cin >> s >> x >> y;
	
	vector<int> a;
	int c=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='F')c++;
		else {
			a.push_back(c);
			c=0;
		}
	}
	a.push_back(c);
	
	vector<int> LR;
	vector<int> UD;
	for(int i=0;i<a.size();i++){
		if(i==0)continue;
		if(i%2==0)LR.push_back(a[i]);
		else UD.push_back(a[i]);
	}
	int X=(int)LR.size(),Y=(int)UD.size();
	
	bool dp1[20000][X+1];
	for(int i=0;i<20000;i++)for(int j=0;j<X+1;j++)dp1[i][j]=false;
	dp1[10000+a[0]][0]=true;
	for(int j=0;j<X;j++){
		for(int i=0;i<20000;i++){
			if(i-LR[j]>=0)dp1[i][j+1]|=dp1[i-LR[j]][j];
			if(i+LR[j]<20000)dp1[i][j+1]|=dp1[i+LR[j]][j];
		}
	}
	
	bool dp2[20000][Y+1];
	for(int i=0;i<20000;i++)for(int j=0;j<Y+1;j++)dp2[i][j]=false;
	dp2[10000][0]=true;
	for(int j=0;j<Y;j++){
		for(int i=0;i<20000;i++){
			if(i-UD[j]>=0)dp2[i][j+1]|=dp2[i-UD[j]][j];
			if(i+UD[j]<20000)dp2[i][j+1]|=dp2[i+UD[j]][j];
		}
	}
	if(dp1[10000+x][X] && dp2[10000+y][Y])cout << "Yes" << endl;
	else cout << " No" << endl;
	return 0;
}

Measured memory_bytes: 155264
program main;
var 
    a, i : integer;
    b : string;
begin
    readln(a);
    readln(b);
    if ( a >= length(b) ) then
        writeln(b)
    else 
        begin 
            for i := 1 to a do 
                write(b[i]);
            write('...');
        end;
end.

Measured memory_bytes: 1380
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 51
ll dp[MAXN][MAXN][2501]; 
int main() {
    int n, a;
    cin >> n >> a;
    int x[n + 1];
    // i番目まででj枚取った時にkに 何通り
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i <= n - 1; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= 2500; k++) {
                if (dp[i][j][k]) dp[i + 1][j + 1][k + x[i + 1]] += dp[i][j][k];
                dp[i + 1][j][k] += dp[i][j][k];
            }
        }
    }
    ll ret = 0;
    ll p = min(2500 / a, n);
    for (int i = 1; i <= p; i++) {
        ret += dp[n][i][i * a];
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 54448
#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>;

ll nextLunLun(ll n)
{
    if (n <= 9) return n + 1;
    ll d1 = n % 10;
    ll d2 = (n / 10) % 10;
    ll ans;
    if (d1 == 9 || d1 + 1 - d2 > 1) {
        ll m = nextLunLun(n / 10);
        ans = m * 10 + (m % 10) + (m % 10 == 0 ? 0 : -1);
    } else {
        ans = (n / 10) * 10 + d1 + 1;
    }
    return ans;
}

int main()
{
    ll k;
    cin >> k;
    ll ans = 1;
    rep(i, k - 1) {
        ans = nextLunLun(ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMixJuice solver = new BMixJuice();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMixJuice {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            int k = s.nextInt();
            int[] arr = s.nextIntArray(n);
            Arrays.sort(arr);
            int sum = 0;
            for (int i = 0; i < k; i++) {
                sum += arr[i];
            }

            out.println(sum);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; ++i) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25532
import sys

N=int(input())
if N==1:
	print(0)
	sys.exit()

def factorization(n):
	arr=[]
	temp=n
	for i in range(2,int(n**0.5)+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp//=i
			arr.append([i,cnt])
	if temp!=1:
		arr.append([temp,1])
	if arr==[]:
		arr.append([n,1])
	return arr

a=factorization(N)
ans=0
for i in range(len(a)):
	if a[i][1]!=0:
		cnt=1
		while a[i][1]-cnt>=0:
			a[i][1]-=cnt
			ans+=1
			cnt+=1
print(ans)

Measured memory_bytes: 9504
#include <stdio.h>

int main(void)
{
	int x, sum;

	sum = 1;
	while(sum != 0)
	{
		sum = 0;
		while((x = getchar()) != '\n')
			sum += x - '0';
		if(sum == 0)
			break;
		printf("%d\n", sum);
	}

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

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

    ll N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<ll> cnt(N, 0);
    REP(i, N-1){
    	if(S[i] == 'A' && S[i+1] == 'C') cnt[i+1] = 1;
    }
    vector<ll> sum(N+1, 0);
    REP(i, N) sum[i+1] = sum[i] + cnt[i];

    REP(i, Q){
    	ll l, r;
    	cin >> l >> r;
    	cout << sum[r] - sum[l] << endl;
    }
    return 0;
}

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

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

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

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

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for (i = 0; i < n; i++) cin >> A[i];

  mergeSort(A, n, 0, n);

  for (i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 6968
import collections

result = 0
n,k = map(int,input().split())
input_list = input().split()
counter_list = collections.Counter(input_list)
if k < len(counter_list):
  length = len(counter_list)-k
  sort_list = sorted(counter_list.values())
  for i in range(length):
    result += sort_list[i]
print(result)


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, k; std::cin >> n >> k;
  vi h(n); rep(i, n) std::cin >> h[i];
  sort(rng(h));
  int ans = inf;
  srep(i, k-1, n) {
    chmin(ans, h[i] - h[i-k+1]);
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    lint a,b;std::cin>>a>>b;
    std::cout<<(a==1||b==1?1:(a*b+1)/2)<<'\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;

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

    vector<char> sv, tv;
    for (char c : s) {
        sv.push_back(c);
    }
    for (char c : t) {
        tv.push_back(c);
    }
    sort(sv.begin(), sv.end());
    sort(tv.rbegin(), tv.rend());

    string s_ = "", t_ = "";
    for (char c : sv) {
        s_ += c;
    }
    for (char c : tv) {
        t_ += c;
    }
    if (s_ < t_) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 760
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int N_MAX = 100000;
const int A_I_MAX = 100000;

int N;
int A[N_MAX];

void solve() {
  sort(A, A + N);
  int ans = unique(A, A + N) - A;
  if (ans % 2 == 0) ans--;
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 512
// Problem Title : Welcome to AtCoder
// Link : https://atcoder.jp/contests/abc151/tasks/abc151_c
// Date : 03-08-2020 23:58:23

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	vector<bool> acc(n+1, false);
	vector<int> wa(n+1, false);

	for(int i = 0; i < m; i++) {
		int p;
		string ver;
		cin >> p >> ver;
		if(acc[p]) {
			continue;
		} else {
			if(ver == "AC") {
				acc[p] = true;
			} else {
				wa[p]++;
			}
		}
	}

	int solved = 0, pen = 0;
	for(int i = 1; i <= n; i++) {
		if(acc[i]) {
			solved++;
			pen += wa[i];
		}
	}

	cout << solved << ' ' << pen << '\n';
	
	return 0;
}

Measured memory_bytes: 640
local R,G,B,N = io.read("n", "n", "n", "n")

local cnt = 0
for r=0,N do
    local lim = (N - R*r) / G
    --print(lim)
    for g=0,lim do
        local b = (N - R*r - G*g) / B
        if b >= 0 and b == math.floor(b) then
            cnt = cnt + 1
            --print(r,g,b)
        end
    end
end
print(cnt)

Measured memory_bytes: 760
#include<stdio.h>
using namespace std;

int main(){
    long n,ai;
    scanf("%ld",&n);
    long a[n], b[n];


    for(long i=0; i<n; i++){
        scanf("%ld",&ai);
        a[i] = ai;
    }


    if( n%2==1 ){
        for(long i=n-1; i>=0; i=i-2){
            if( i!=n-1 ) printf(" ");
            printf("%ld", a[i]);
        }
        for(long i=1; i<=n-2; i=i+2){
            printf(" ");
            printf("%ld", a[i]);
        }
        printf("\n");
    }else{
        for(long i=n-1; i>=1; i=i-2){
            if( i!=n-1 ) printf(" ");
            printf("%ld", a[i]);
        }
        for(long i=0; i<=n-2; i=i+2){
            printf(" ");
            printf("%ld", a[i]);
        }
        printf("\n");        
    }


    return 0;
}

Measured memory_bytes: 3712
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!(usize; n);

    let mut count = 0;
    let mut p = 1;
    for e in a {
        if e > p {
            count += (e-1)/p;
            p = max!(2,p);
        } else {
            p = max!(p,e+1);
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 8572
import numpy as np

n = int(input())
a = np.array(list((map(int, input().split()))))

mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
    one = np.count_nonzero(a & 1)
    a = a >> 1
    ans = (ans + (one*(n-one))*two) % mod
    two = (two * 2) % mod
print(ans)

Measured memory_bytes: 68892
from collections import deque

S = input()
q = int(input())
res = deque([S])
reverseFlag = False
for i in range(q):
  tmp = input()
  t = tmp[0]
  if t == "1":
    reverseFlag ^= True # ひっくり返す
  else:
    f,c = tmp[2:].split()
    if f == "1" and reverseFlag == False or f == "2" and reverseFlag == True:
      res.appendleft(c)
    else:
      res.append(c)
if reverseFlag:
  ans = "".join(res)[::-1]
else:
  ans = "".join(res)

print(ans)
    
    
  	

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

using namespace std;

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  for (int i = 0; i < a + b; i++) {
    if (i == a) {
      if (s[i] != '-') {
        cout << "No\n";
        return 0;
      }
    } else {
      if (s[i] == '-') {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdint>
#include<map>

int const MAXN = 2e5;
int const MAXNN = 1<<18;

std::pair<int, int> mon[MAXN];
int N, D, A, NN;

int dat_[MAXNN*2-1];
int laz_[MAXNN*2-1];

void init() {
  for(NN = 2; NN < N; NN<<=1);
  std::fill_n(dat_, NN*2-1, 0);
  std::fill_n(laz_, NN*2-1, 0);
}

void eval(int k) {
  if(laz_[k] == 0) return;
  if(k*2+1 < NN*2-1) {
    laz_[2*k+1] += laz_[k];
    laz_[2*k+2] += laz_[k];
  }
  dat_[k] += laz_[k];
  laz_[k] = 0;
}

int add(int a, int b, int x, int k, int l, int r) {
  if(b <= l || r <= a) {
    eval(k);
    return dat_[k];
  }
  if(a <= l && r <= b) {
    laz_[k] += x;
    return dat_[k] + laz_[k];
  }
  eval(k);
  int m = (l+r)/2;
  return dat_[k] = std::max(add(a, b, x, k*2+1, l, m), add(a, b, x, k*2+2, m, r));
}

int query(int a, int b, int k, int l, int r) {
  if(b <= l || r <= a) return -1;
  eval(k);
  if(a <= l && r <= b) return dat_[k];
  int m = (l+r)/2;
  bool intLeft = !(m <= a || b <= l);
  bool intRight = !(r <= a || b <= m);
  if(intLeft&intRight) return std::max(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
  if(intLeft) return query(a, b, k*2+1, l, m);
  return query(a, b, k*2+2, m, r);
}

void add(int a, int b, int x){ add(a, b, x, 0, 0, NN); }
int query(int a, int b){ return query(a, b, 0, 0, NN); }

int main() {
  std::cin >> N >> D >> A; D += D;
  for(int i = 0; i < N; ++i) {
    int X, H; std::cin >> X >> H;
    mon[i] = std::make_pair(X, (H+A-1)/A);
  }
  std::sort(mon, mon+N);
  init();
  for(int i = 0; i < N; ++i) add(i, i+1, mon[i].second);
 
  int64_t ans = 0; 
  int e = 0;
  for(int i = 0; i < N; ++i) {
    int c = query(i, i+1);
    if(c <= 0) continue;
    while(e < N && mon[e].first <= mon[i].first+D) ++e;
    add(i, e, -c);
    ans += (int64_t)c;
  }
  std::cout << ans << std::endl;
  return 0;
}


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

int main() {
  vector<vector<int>> v(3, vector<int>(3));

 for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> v.at(i).at(j);
    }
  }
  
  int a;
  
  cin >> a;
  
  int b[a];
  
  for (int i = 0; i<a ; i++) {
    cin >> b[i];
  }
  
  int cnt = 0;
  for (int i = 0; i < 3 ; i++) {
    cnt = 0;
    for (int n = 0; n < a ; n++){
      if (b[n] == v[i][0]) cnt++;
      if (b[n] == v[i][1]) cnt++;
      if (b[n] == v[i][2]) cnt++;
    }
    if (cnt == 3) {
    	cout << "Yes" << endl;
    	return 0;
  	}
  }

  for (int i = 0; i < 3 ; i++) {
    cnt = 0;
    for (int n = 0; n < a ; n++){
      if (b[n] == v[0][i]) cnt++;
      if (b[n] == v[1][i]) cnt++;
      if (b[n] == v[2][i]) cnt++;
    }
      if (cnt == 3) {
        cout << "Yes" << endl;
        return 0;
      }
  }
  

  
  cnt = 0;
    for (int n = 0; n < a ; n++){
      if (b[n] == v[0][0]) cnt++;
      if (b[n] == v[1][1]) cnt++;
      if (b[n] == v[2][2]) cnt++;
    }
  
  if (cnt == 3) {
    cout << "Yes" << endl;
    return 0;
  }
  
  cnt = 0;
    for (int n = 0; n < a ; n++){
      if (b[n] == v[0][2]) cnt++;
      if (b[n] == v[1][1]) cnt++;
      if (b[n] == v[2][0]) cnt++;
    }
  
  if (cnt == 3) {
    cout << "Yes" << endl;
    return 0;
  }


    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//solved by *ALIKHAN*
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define ppb pop_back
#define mp make_pair
#define all(n) n.begin(), n.end()
#define timefaster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const int INF = (ll)1e18;

int main(){
	ll n;
	cin >> n;
		cout << pow(n,2);
}
// Aksay sila


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Sun Dec 22 21:00:17 JST 2019
 **/

signed main() {
    Int a = in(), b = in();
    Int g = __gcd(a, b);
    cout << a * b / g << endl;
}


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

int A(int x){
  int y=0;
  while(x>0){
    y+=x%10;
    x/=10;
  }
  return y;
}

int main(){
  int N;
  cin >> N;
  if(N%A(N)==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
func readInt() -> Int {
    Int(readLine()!)!
}
 
func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}
 
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

func main() {
    let n = readInt()
    let s = readLine()!

    let nr = s.lazy.filter {
        $0 == "R"
    }.count

    let ans = s.lazy.prefix(nr).filter {
        $0 == "W"
    }.count

    print(ans)
}

main()

Measured memory_bytes: 7988
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, N: int, A: "List[int]"):
    return [NO, YES][sum(A) >= H]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(H, N, A)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 86660
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try ( Scanner sc = new Scanner ( System.in ) ){
            while( true ) {
                int n = sc.nextInt();
                if( n == 0 ){ break; }
                int[] scores = new int[n];
                for(int i=0;i<scores.length;i++) {
                    scores[i] = sc.nextInt();
                }
                double average = 0, variance = 0;

                for(int i=0;i<scores.length;i++) {
                    average += scores[i];
                }
                average /= scores.length;

                for(int i=0;i<scores.length;i++) {
                    variance += ( scores[i] - average )*( scores[i] - average );
                }
                variance /= scores.length;

                System.out.println(Math.sqrt(variance));
            }
        }
    }

}


Measured memory_bytes: 31368
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t
#define fs first
#define sc second
inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

void solve()
{
	lli n,k,ctr=0,m=0,x,y,ans=100000000000000000;
	cin>>n;
	vector<pair<lli,lli> > v;
	for(lli i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			v.push_back({i,n/i});
		}
	}
	for(auto it:v)
	{
		ans=min(it.first-1+it.second-1,ans);
	}
	cout<<ans;
}

int main()
{
	fast();
	lli t;
	//cin>>t;
	t=1;
	while(t--)
	{
		solve();
	}
	
	
	return 0;
}

Measured memory_bytes: 384
// あえて入力と出力しかいじらない
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	sc.Scan()
	as := sc.Text()
	a, _ := strconv.Atoi(as)
	num := make([]int, a)
	for i := 0; i < a; i++ {
		sc.Scan()
		ns := sc.Text()
		n, _ := strconv.Atoi(ns)
		num[i] = n
	}
	sort.Ints(num)
	// fmt.Printf("a: %d\n", a)
	// fmt.Printf("num: %v\n", num)
	score := 0
	for i := 1; i <= a; i++ {
		if i%2 == 0 {
			// bob's turn
			score -= num[a-i]

		} else {
			// alise's turn
			score += num[a-i]
		}
	}
	fmt.Println(score)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 201
#define MOD 1000000007
#define INF 1000000000000000000
#define lim 20

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}




void solve(){
    ll n, m;
    cin >> n  >> m;
    if(n > m) swap(n, m);
    string s;
    for(ll i = 0; i < m; i++){
        s += n+'0';
    }cout << s;

}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


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

using namespace std;

int a,b,c;

int main(){
	cin >> a >> b >> c;
	if (a > b) swap(a,b);
	if (b > c) swap(b,c);
	if (a > b) swap(a,b);
	if (a == 5 && b == 5 && c == 7) cout << "YES\n";
	else cout << "NO\n";


	return 0;
}

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

int main()
{
	int i, j, n, m, x, ans=0;
	cin >> n >> m;
	int a[n], p[m], flag[m], k[m], count;
	int t1=pow(2,n), t2, t3;
	vector< vector<int> > v(m);

	for(i=0; i<m; i+=1)
	{
		cin >> k[i];
		for(j=0; j<k[i]; j+=1)
		{
			cin >> x;
			v[i].push_back(x-1);
		}
	}
	for(i=0; i<m; i+=1)
		cin >> p[i];

	for(i=0; i<t1; i+=1)
	{
		memset(a, 0, sizeof(a));
		memset(flag, 0, sizeof(flag));
		x=i;
		t2=0;
		while(x!=0)
		{
			a[t2]=x%2;
			x/=2;
			t2+=1;
		}
		for(j=0; j<m; j+=1)
		{
			count=0;
			for(t3=0; t3<k[j]; t3+=1)
				if(a[v[j][t3]]==1)
					count+=1;
			if(count%2==p[j])
				flag[j]=1;
		}
		for(j=0; j<m; j+=1)
		{
			if(flag[j]==0)
			{
				ans-=1;
				break;
			}
		}
		ans+=1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int N, K;

int main() {
  cin >> N >> K;
  long ans = 0;
  if (K==0) {
    cout << (long)N*(long)N << endl;
    return 0;
  }
  for (int b=K+1; b<=N; b++) {
    ans += (long)(N/b)*(long)(b-K);
    if (N%b >= K) {
      ans += N%b-K+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#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(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll solve(ll N, ll l, ll r) { // [l, r)で条件を満たす数を求める
	ll d = N / l;
	
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (N % m >= d) l = m;
		else r = m;
	}
	
	if (N % l == N / l) return l;
	else return 0;
}

int main() {
	ll N;
	cin >> N;
	
	ll sqr = 1;
	while (sqr * sqr <= N) sqr++;
	sqr--;
	
	ll ans = 0;
	FOR(i, 1, sqr + 1) {
		ll l = N / (i + 1) + 1;
		ll r = N / i + 1;
		ans += solve(N, l, r);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools
A = int(input())
B = int(input())
C = int(input())
X = int(input())
AL = [500*i for i in range(A+1)]
BL = [100*i for i in range(B+1)]
CL = [50*i for i in range(C+1)]
num = 0

for comb in itertools.product(AL,BL,CL):
  x,y,z = comb
  if x + y + z == X:
    num += 1
print(num)

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

const int limit = 50;
int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < n; ++v2) {
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}

int main(void){
  cin >> n >> m;

  for(int i=0; i<m; ++i){
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }


  int ans = 0;

  for(int i=0; i<m; ++i){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

    for(int j=0; j<n; ++j){
      visited[j] = false;
    }


    dfs(0);

    bool bridge = false;

    for(int j=0; j<n; ++j){
      if(visited[j] == false){
        bridge = true;
      }
    }
    if(bridge){
      ans += 1;
    }
      graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

  }

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


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

int main(void)
{
	int n;
	int i;
	int x[100];
	int y[100];
	int z[100];
	double L_1 = 0, L_2 = 0, L_3 = 0, L_inf;
	
	scanf("%d\n", &n);
	for(i = 0; i<n; i++)
		scanf("%d", &x[i]);
	for(i = 0; i<n; i++)
		scanf("%d", &y[i]);
	for(i = 0; i<n; i++) {
		z[i] = (x[i] - y[i]>0)? x[i] - y[i]: y[i] - x[i];
		if(i == 0) L_inf = z[0];
		else {
			if(z[i] > L_inf) L_inf = z[i];
		}
	}
	
	for(i=0; i<n; i++) {
		L_1 += z[i];
		L_2 += z[i] * z[i];
		L_3 += z[i] * z[i] * z[i];
	}
	
	L_2=pow(L_2, 1.0/2);
	L_3=pow(L_3, 1.0/3);
	
	printf("%f\n%f\n%f\n%f\n", L_1, L_2, L_3, L_inf);
	
	return 0;
}



Measured memory_bytes: 2144
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  cout<<((a*b)%2==0 ? "No" : "Yes");
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int limit = 50;

bool graph[limit][limit];
bool isvisit[limit];

int N,M;

void DFS(int v){
    isvisit[v] = true;
    for(int i = 0; i < N; i++){
        if(graph[v][i] && !isvisit[i]) DFS(i);
    }
}

bool judge(int v){
    for(int i = 0; i < N; i++){
        isvisit[i] = false;
    }
    DFS(v);
    for(int i = 0; i < N; i++){
        if(isvisit[i] == false) 
            return false;
    }
    return true;
}

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

    vector<int> a(M), b(M);
    int inp0, inp1;
    for(int i=0; i < M; i++){
        cin >> inp0 >> inp1;
        inp0--;
        inp1--;
        a[i] = inp0;
        b[i] = inp1;
        graph[inp0][inp1] = true;
        graph[inp1][inp0] = true;
    }

    int num = 0;
    for(int e = 0; e < M; e++){
        graph[a[e]][b[e]] = false;
        graph[b[e]][a[e]] = false;
        if(judge(0) == false) num++;
        graph[a[e]][b[e]] = true;
        graph[b[e]][a[e]] = true;
    }
    cout << num << endl;
    return 0;
}


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

int main() {
    char a, b;
    bool ab, bb;
    cin >> a >> b;

    ab = (a == 'H');
    bb = (b == 'H');

    if (!(ab^bb)) {
        cout << 'H' << endl;
    } else {
        cout << 'D' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n;
double a[100005],dp[3005][3005];
double solve(long long i,long long k)
{
    if(i==n+1)
    {
        if(k>n/2)
        return 1;
        else
        return 0;
    }
    if(dp[i][k]!=-1)
    return dp[i][k];
    dp[i][k]=a[i]*solve(i+1,k+1)+(1-a[i])*solve(i+1,k);
    return dp[i][k];
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        dp[i][j]=-1;
    }
    printf("%0.9lf",solve(1,0));
    return 0;
}

Measured memory_bytes: 70912