akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

int main()
{
    int a,b;
    std::cin >> a >> b;
    int ans;
    if(a+b == 3)ans = 3;
    if(a+b == 5)ans = 1;
    if(a+b == 4)ans = 2;
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a[5][53];
    for(int i = 1; i<=4; i++) {
        for(int j = 1; j<=13; j++) {
            a[i][j] = 0;
        }
    }
    // spades, hearts, clubs and diamonds
    char c;
    int num;
    int n = 0;
    scanf("%d", &n);
    //printf("%d\n",n);
    for(int i = 0; i<n; i++){
        //getchar();
        scanf(" %c %d",&c,&num);
        //printf("%c %d\n",c,num);
        if(c=='S') a[1][num] = 1;
        else if(c=='H') a[2][num] = 1;
        else if(c=='C') a[3][num] = 1;
        else if(c=='D') a[4][num] = 1;
    }
    
    for(int i = 1; i<=4; i++) {
        for(int j = 1; j<=13; j++) {
            if(a[i][j] == 0){
                if(i == 1) printf("S %d\n",j);
                else if(i == 2) printf("H %d\n",j);
                else if(i == 3) printf("C %d\n",j);
                else if(i == 4) printf("D %d\n",j);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2748
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
vector<ll> v[100001];
ll comp[100001], in[100001], fr[100001], b[100001], num[100001];
void dfs(ll x, ll c) {
	b[x] = 1;
	comp[x] = c;
	for(auto u: v[x]) {
		if(!b[u]) {
			dfs(u, c);
		}
	}
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, k, i, v1, v2, c = 1;
    cin>>n>>m>>k;
    for(i=0; i<m; i++) {
    	cin>>v1>>v2;
    	in[v1]++;
    	in[v2]++;
    	v[v1].pb(v2);
    	v[v2].pb(v1);
    }
    for(i = 1; i <= n; i++) {
    	if(!b[i]) {
    		dfs(i, c++);
    	}
    }
    for(i = 1; i <= n; i++) {
    	num[comp[i]]++;
    }
    for(i = 1; i <= n; i++) {
    	fr[i] = num[comp[i]] - in[i] - 1;
    	// cout<<fr[i]<<" ";
    }
    while(k--) {
    	cin>>v1>>v2;
    	if(comp[v1] == comp[v2]) {
    		fr[v1]--;
    		fr[v2]--;
    	}
    }
    for(i = 1; i<=n; i++) {
    	cout<<fr[i]<<" ";
    }
    cout<<"\n";
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
#define SIZE 1005
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, m, k;
int main() {
	io(); cin >> n >> m;
	vector<double> a(n);
	double sum = 0;
	for (auto& i : a) cin >> i, sum += i;
	sum /= (4.0 * m);
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	rep(i, 0, (m - 1)) {
		if (a[i] < sum) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll A, B, C, D; cin >> A >> B >> C >> D;
	vector<vector<ll>> dp(C + 1, vector<ll>(D + 1));
	dp[A][B] = 1;
	for (ll i = A; i <= C; i++) {
		for (ll j = B; j <= D; j++) {
			if (i == A && j == B)continue;
			dp[i][j] = (i * dp[i][j - 1]) % DIV + (j * dp[i - 1][j]) % DIV
				- ((i - 1) * (j - 1) * dp[i - 1][j - 1]) % DIV;
			dp[i][j] += DIV;
			dp[i][j] %= DIV;
		}
	}

	/*
	for (ll i = A; i <= C; i++) {
		for (ll j = B; j <= D; j++) {
			printf("dp[%lld][%lld]=%lld ", i, j, dp[i][j]);
		}
		cout << endl;
	}
	*/
	cout << dp[C][D] << endl;
}


Measured memory_bytes: 73684
#include<iostream>
using namespace std;
int main(){
    int x,y,n;
    int c=0;
    cin >> n;
    int b[n];
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int flag=1;
    while(flag==1){
        flag=0;
        for(int j=0;j<n;j++){
            if(b[j]<b[j-1]){
                x=b[j];
                y=b[j-1];
                b[j]=y;
                b[j-1]=x;
                flag=1;
                c++;
            }
        }
        
    }for(int i=0;i<n;i++){
        cout << b[i];
        if(i!=n-1)cout <<" ";
    }cout<<endl << c <<endl;
}


Measured memory_bytes: 3104
N, *A = map(int, open(0).read().split())
s = set(A)
if max(s)-min(s)>1:
  print('No')
else:
  if len(s)==1:
    if A[0]==N-1:
      print('Yes')
    elif 2*A[0]<=N:
      print('Yes')
    else:
      print('No')
  elif len(s)==2:
    N -= A.count(min(s))
    u = max(s)-A.count(min(s))
    if u<=0:
      print('No')
    elif 2*u<=N:
      print('Yes')
    else:
      print('No')
  else:
    print('No')

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

int main(){
  string N;
  cin >> N;
  for(int i=0;i<N.size();i++){
    if(N.at(i)=='7'){
      cout << "Yes" << endl;
      break;
    }
    if(i==N.size()-1){
      cout << "No" << endl;
    }
  }
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main() {
  ll n;
  cin >> n;
  cout << a[n-1] << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()

n = len(s) - 1
sum = 0
for i in range(2**n):
    dig = bin(i)[2:].zfill(n)
    tp = "0"
    for i in range(n):
        tp += s[i]
        if (dig[i] == "1"):  # number
            sum += int(tp)
            tp = "0"
        #print(tp)
    #for i in range():
    #sum+=
    tp += s[-1]
    sum += int(tp)
print(sum)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int main(void){
    char a[100], b[100];
    scanf("%s%s", a, b);
    int a_keta = strlen(a), b_keta=strlen(b);
    if(a_keta>b_keta){
        puts("GREATER");
        return 0;
    }
    else if(b_keta>a_keta){
        puts("LESS");
        return 0;
    }
    for(int i=0; a[i]||b[i]!='\0'; i++){
        if(a[i]>b[i]){
            puts("GREATER");
            return 0;
        }
        else if(b[i]>a[i]){
            puts("LESS");
            return 0;
        }
    }
    puts("EQUAL");
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  ll Acnt=0;
  ll ans=0;
  for(ll i=0;i<(ll)s.length();i++){
    if(s[i]=='A'){
      Acnt++;
    }else if(i+1<(ll)s.length()&&s[i]=='B'&&s[i+1]=='C'){
      ans += Acnt;
      i++;
    }else{
      Acnt=0;
    }
    //debug(Acnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 720
s = input()
n = len(s) - 1

for i in range(2**n):
    S = s[0]
    for j in range(n):
        if ((i >> j) & 1):
            S += '+'
        else:
            S += '-'
        S += s[j+1]
        if len(S) == 7 and eval(S) == 7:
            print(S+'=7')
            exit()


Measured memory_bytes: 3060
let id x = x
let n = Scanf.scanf "%d\n" id
let a = Array.init n (fun _ -> (Scanf.scanf "%d " id))  
let h = Hashtbl.create 100000

let hash_add x =
  if Hashtbl.mem h x then Hashtbl.replace h x ((Hashtbl.find h x) + 1)
  else Hashtbl.add h x 1  

let rec add m = 
  if m = n then ()
  else
    let () = hash_add (a.(m)-1) in
    let () = hash_add (a.(m)) in
    let () = hash_add (a.(m)+1) in
    add (m+1)
      
let rec func m z =
  if m = n then z
  else
    let h = max (max (Hashtbl.find h (a.(m)-1)) (Hashtbl.find h (a.(m)))) (Hashtbl.find h (a.(m)+1)) in
    func (m+1) (max h z)
      
let () = add 0

let () =
  let ans = func 0 0 in
  Printf.printf "%d\n" ans

Measured memory_bytes: 11904
#include<cstdio>
#include<cstring>
#include<algorithm>
#define boynextdoor return puts("0"),0
using namespace std;
const int N=100005,mod=1000000007;
int n,x,ans=1,ring[N],to[N],f[N],e[N][2];
char ch[5000005],*p=ch;
bool vis[N];
inline int rd(){
	register int res=0;
	while(*p<'0'||*p>'9'){
		p++;
	}
	while(*p>='0'&&*p<='9'){
		res=res*10+*p-'0';
		p++;
	}
	return res;
}
int main(){
	fread(ch,5000000,1,stdin);
	n=rd();
	for(int i=1;i<=n;i++){
		to[i]=rd();
		if(!e[to[i]][0]){
			e[to[i]][0]=i;
		}else if(!e[to[i]][1]){
			e[to[i]][1]=i;
		}else{
			boynextdoor;
		}
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			int now=i,siz=0,last=0,prod=1;
			bool flag=false;
			while(!vis[now]){
				vis[now]=true;
				now=to[now];
			}
			int beg=now;
			do{
				siz++;
				if(e[to[now]][0]!=now){
					swap(e[to[now]][0],e[to[now]][1]);
				}
				now=to[now];
			}while(now!=beg);
			do{
				now=to[now];
				if(e[now][1]){
					flag=true;
					break;
				}
			}while(now!=beg);
			if(!flag){
				ring[siz]++;
				continue;
			}else{
				beg=now;
			}
			do{
				now=to[now];
				last++;
				if(e[now][1]){
					flag=true;
					int tmp=e[now][1],dep=0;
					while(tmp){
						dep++;
						vis[tmp]=true;
						if(e[tmp][1]){
							boynextdoor;
						}else{
							tmp=e[tmp][0];
						}
					}
					if(dep>last){
						boynextdoor;
					}else if(dep<last){
						prod=prod*2%mod;
					}
					last=0;
				}
			}while(now!=beg);
			ans=1LL*ans*prod%mod;
		}
	}
	for(int i=1;i<=n;i++){
		if(!ring[i]){
			continue;
		}
		int flag=(i&1)&&i!=1;
		f[0]=1,f[1]=flag+1;
		for(int j=2;j<=ring[i];j++){
			f[j]=(1LL*f[j-2]*(j-1)%mod*i+(f[j-1]<<flag))%mod;
		}
		ans=1LL*ans*f[ring[i]]%mod;
	}
	printf("%d\n",ans);
	return 0;
}

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

#define mod 1'000'000'007
typedef long long ll;

template<typename T>
void deb(initializer_list<T> l)
{
	for (auto &e : l)
		cout << e << ' ';
	cout << endl;
}

void solve()
{
	ll n;
	cin >> n;

	ll ans = n * n * (n + 1) / 2 - n * (n - 1) / 2 - (n - 1) * n * (2 * n - 1) / 6;
	for (ll i = n - 1; i--; )
	{
		ll u, v;
		cin >> u >> v;
		if (u > v)
			swap(u, v);

		ans -= u * (n - v + 1);
	}

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

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

	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;
}


Measured memory_bytes: 3608
import Control.Applicative
import Data.Fixed

main = do
    r <- (read :: String -> Double) <$> getLine
    putStrLn $ unwords $ show . toFixedE9 <$> [(pi*r^2), (2*pi*r)]

toFixedE9 :: Double -> Fixed E9
toFixedE9 r = realToFrac r :: Fixed E9


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

using namespace std ;

const int N=1e5+10 ;

char s[N] ;
int n ;

int main ()
{
	int i ;
	scanf(" %d %s ",&n,s+1);
	if ( n&1 ) return puts("No")*0;
	for ( i=1 ; 2*i<=n ; i++ )
		if ( s[i]!=s[i+n/2] ) return puts("No")*0;
	puts("Yes");
	return 0 ;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> S;
}
void solve() {
  int now = 0;
  if (S == "SUN") {
    now = 0;
  }
  if (S == "MON") {
    now = 1;
  }
  if (S == "TUE") {
    now = 2;
  }
  if (S == "WED") {
    now = 3;
  }
  if (S == "THU") {
    now = 4;
  }
  if (S == "FRI") {
    now = 5;
  }
  if (S == "SAT") {
    now = 6;
  }
  cout << 7 - now << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;
ll add(ll a, ll b)
{
    return (a + b) % MOD;
}
int main()
{
    string s;
    cin >> s;
    vector<vector<ll>> d(s.size()+1, vector<ll>(4));
    d[0][0] = 1;
    for(int i = 0; i < s.size(); i++)
    {
        char cand = s[i];
        for(int j = 0; j < 4; j++)
        {
            if(cand == '?')
            {
                d[i+1][j] = add(d[i+1][j], 3 * d[i][j]);
            }
            else
            {
                d[i+1][j] = add(d[i+1][j], d[i][j]);
            }
        }
        if(cand == '?' || cand == 'A') d[i+1][1] = add(d[i+1][1], d[i][0]);

        if(cand == '?' || cand == 'B') d[i+1][2] = add(d[i+1][2], d[i][1]);

        if(cand == '?' || cand == 'C') d[i+1][3] = add(d[i+1][3], d[i][2]);
    }
    cout << d[s.size()][3] << endl;
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
long long a[3],k;
int main()
{
	cin>>a[0]>>a[1]>>a[2]>>k;
	sort(a,a+3);
	cout<<(long long)(a[0]+a[1]+a[2]*pow(2,k))<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();
        
        if(A<=X && A+B>=X){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

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

using namespace std;

typedef pair<double, string> crop;

class lesser {
public:
    bool operator()(const crop r, const crop l) {
        if (r.first > l.first)
            return true;
        else if (r.first < l.first)
            return false;
        else
            return r.second < l.second;
    }
};

int main()
{
    for (;;) {
        int n;

        scanf("%d", &n);
        if (n == 0)
            break;

        vector<crop> l(n, make_pair(0, string(20, 0)));
        for (int i = 0; i < n; ++i) {
            int p, a, b, c, d, e, f, s, m;
            cin >> l[i].second;
            scanf("%d %d %d %d %d %d %d %d %d",
                    &p, &a, &b, &c, &d, &e, &f, &s, &m);
            l[i].first = double(f * s * m - p) / ((a + b + c) + (d + e) * m);
        }

        sort(l.begin(), l.end(), lesser());

        for (int i = 0; i < n; ++i)
            printf("%s\n", l[i].second.c_str());
        printf("#\n");
    }

    return 0;
}

Measured memory_bytes: 1252
import math

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
maxA = A[len(A)-1]
valid = [True] * maxA

for i in range(len(A)):
    if valid[A[i]-1] == False:
        continue
    if i != 0 and A[i-1] == A[i]:
        valid[A[i]-1] = False
    else:
        for j in range(A[i]*2, maxA+1, A[i]):
            valid[j-1] = False

count = 0
for i in range(len(A)):
    if valid[A[i]-1] == True:
        count += 1
print(count)

Measured memory_bytes: 32132
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
cnt = 0
cnt_l = []
(n-1).times do |i|
  if h[i] < h[i+1] then
    cnt_l << cnt
    cnt = 0
  else
    cnt += 1
  end
end
cnt_l << cnt
puts cnt_l.max


Measured memory_bytes: 10628
n=int(input())
a=[]
for i in range(n-1):
    x,y,z=map(int, input().split())
    a.append([x,y,z])
for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<=a[j][1] :t=a[j][1] + a[j][0]
        else:t=((t - a[j][1] + a[j][2]-1) // a[j][2]) * a[j][2] + a[j][1] + a[j][0]
    print(t)

Measured memory_bytes: 3188
c=[0]*26
while True:
    try:
        x1=input()
        x2=x1.lower()
        for i in x2:
            if 96<ord(i)<124:
                c[ord(i)-97]+=1
    except:
        break
    
for i in range(26):
    print(f'{chr(i+97)} : {c[i]}')



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


int main(){
	string S;
	cin >> S;
	bool ok = false;
	if(S[0]==S[1]&&S[2]==S[3]) ok = true;
	if(S[0]==S[2]&&S[1]==S[3]) ok = true;
	if(S[0]==S[3]&&S[2]==S[1]) ok = true;
	if(S[0]==S[1]&&S[1]==S[2]&&S[2]==S[3]) ok = false;
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}












Measured memory_bytes: 3628
import sys
from collections import Counter, defaultdict

n, m = list(map(int, input().split()))
aaa = list(map(int, input().split()))
cards = defaultdict(lambda: 0, Counter(aaa))
for line in sys.stdin:
    b, c = map(int, line.split())
    cards[c] += b
ans = 0
cnt = 0
for c in sorted(cards, reverse=True):
    b = cards[c]
    if cnt + b >= n:
        ans += c * (n - cnt)
        break
    ans += c * b
    cnt += b
print(ans)


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

double dist(double x,double y){
    return sqrt(pow(x,2)+pow(y,2));
}

int main(){
    long long N,D;
    cin>>N>>D;
    long long res=0;
    for(int i=0;i<N;i++){
        double p,q;cin>>p>>q;
        if(dist(p,q)<=D)res++;
    }
    cout<<res;
}    

Measured memory_bytes: 3784
#include <stdio.h>

int
main()
{
	int x, y;
	int k;

	int n, m, l;	
	long long int a[100][100] = {0};
	long long int b[100][100] = {0};
	long long int c[100][100] = {0};

	scanf("%d %d %d", &n, &m, &l);
	for (y = 0; y < n; y++)
	{
		for (x = 0; x < m; x++)
		{
			scanf("%lld", &a[y][x]);
		}
	}
	for (y = 0; y < m; y++)
	{
		for (x = 0; x < l; x++)
		{
			scanf("%lld", &b[y][x]);
		}
	}

	for (y = 0; y < n; y++)
	{
		for (x = 0; x < l; x++)
		{
			for (k = 0; k < m; k++)
			{
				c[y][x] += a[y][k] * b[k][x];
			}
		}
	}

	for (y = 0; y < n; y++) {
		for (x = 0; x < l; x++)
		{
			if (x != 0)
			{
				printf(" ");
			}
			printf("%lld", c[y][x]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 848
#include <iostream>
using namespace std;
int main () {
    string N;
    int x=0, y=0, z=0;
    cin >> N;
    x=(N[0]-48)*1000+(N[1]-48)*100+(N[2]-48)*10+(N[3]-48);
    y=(N[5]-48)*10+(N[6]-48);
    z=(N[8]-48)*10+(N[9]-48);
    if (x<2019)
        cout << "Heisei";
    else if (x==2019 && y<4)
        cout << "Heisei";
    else if (x==2019 && y==4 && z<=30)
        cout << "Heisei";
    else
        cout << "TBD";
    return 0;
}

Measured memory_bytes: 384
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(n) = in.readLine().split("\\s+").map(_.toInt)
    val as = in.readLine.split("\\s+").map(_.toInt)

    System.out.println(
      as.zipWithIndex.sortWith((a, b) => a._1 < b._1).map { case (a, i) => i + 1 }.mkString(" ")
    )
  }
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string t = "";
    for(int i = 0; i < n-1; ++i) if(s[i]!=s[i+1]) t.push_back(s[i]); 
    ll ans = t.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3708
/**
 * C - Traveling
 * https://atcoder.jp/contests/abc086/tasks/arc089_a
 **/
#include<iostream>
#include<vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> t(N+1,0), x(N+1,0), y(N+1, 0);
    for(int i=1; i<N+1; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    bool flag = true;
    for(int i=1; i<N+1; i++) {
        int judge = (t[i]-t[i-1])-abs(x[i]-x[i-1])-abs(y[i]-y[i-1]);
        if(!(judge>=0&(judge%2==0))) {
            flag = false;
            break;
        }
    }
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool f = false;
  if(s == "AKIHABARA") f = true;
  if(s == "KIHABARA") f = true;
  if(s == "AKIHBARA") f = true;
  if(s == "AKIHABRA") f = true;
  if(s == "AKIHABAR") f = true;
  if(s == "KIHBARA") f = true;
  if(s == "KIHABRA") f = true;
  if(s == "KIHABAR") f = true;
  if(s == "AKIHBRA") f = true;
  if(s == "AKIHBAR") f = true;
  if(s == "AKIHABR") f = true;
  if(s == "KIHBRA") f = true;
  if(s == "KIHBAR") f = true;
  if(s == "AKIHBR") f = true;
  if(s == "KIHABR") f = true;
  if(s == "KIHBR") f = true;
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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();
    int ans = 0;
    int prev = 0;
    int len = 1;
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      if (prev == a) {
        len++;
      } else {
        ans += len/2;
        len = 1;
      }
      prev = a;
    }
    ans += len/2;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
n = gets.to_i
 
1.upto(n) do |i|
  x = i
  if (x % 3 == 0)
    print " #{i}"
 
    next
  end
 
  while x > 0
    if x % 10 == 3
      print " #{i}"
      break
    end
    x /= 10
  end
end
puts

Measured memory_bytes: 8788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
    // Your code here!
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    vector<int> black(N);
    vector<int> white(N);
    
    for (int i = 0; i < N; i++){
        if (S[i] == '#') black[i] = 1;
        else white[i] = 1;
    }
    
    black.insert(black.begin(), 0);
    white.push_back(0);
    
    vector<int> black_ruisekiwa(N + 1);
    vector<int> white_ruisekiwa(N + 1);
    
    for (int i = 0; i < N; i++){
        black_ruisekiwa[i + 1] = black_ruisekiwa[i] + black[i + 1];
    }
    
    for (int i = N; i > 0; i--){
        white_ruisekiwa[i - 1] = white_ruisekiwa[i] + white[i - 1];
    }
    
    int ans = 99999999;
    for (int i = 0; i < N + 1; i++){
        ans = min(ans, black_ruisekiwa[i] + white_ruisekiwa[i]);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


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

ll sum_digit(ll n){
  ll value = 0;

  while(n!=0){
    value += n%10;
    n = n/10;
  }

  return value;
}


int main() {


ll n;
cin>>n;

ll value = sum_digit(n);

// cout<<"value => "<<value<<"\n";

if(n%value == 0){
  cout<<"Yes\n";
}
else{
  cout<<"No\n";
}


  
  return 0;
}


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


int main() {
    string S; cin >> S;
    int ans;
    if (S == "SAT") {
        ans = 1;
    } else if (S == "SUN") {
        ans = 7;
    } else if (S == "MON") {
        ans = 6;
    } else if (S == "TUE") {
        ans = 5;
    } else if (S == "WED") {
        ans = 4;
    } else if (S == "THU") {
        ans = 3;
    } else if (S == "FRI") {
        ans = 2;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

void call(int n) {
  int i = 1;

  while (++i <= n) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    }

    while (x) {
      if (x % 10 == 3) {
        cout << " " << i;
        break;
      }
      x /= 10;
    }
  }
  cout << endl;
}

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

  int n;
  cin >> n;
  call(n);
}



Measured memory_bytes: 3228
#include <iostream>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

constexpr int     MAX =       200'005;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int n, k;
    cin >> n >> k;
    COMinit();

    int64_t ans = 0;
    for(int i=0; i<=min(n, k); i++) {
        ans += COM(n, i) * COM(n-1, i);
        ans %=MOD;
    }

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


Measured memory_bytes: 4992
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    ans = 100000000
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans = min(ans, abs(a[i] - a[j]))
    print(ans)



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

int main(){

    int N;
    cin >> N;

    vector<int> ans(60001);
    for (int x = 1; x <= ceil(sqrt(N)); x++){
        for (int y = 1; y <= ceil(sqrt(N)); y++){
            for (int z = 1; z <= ceil(sqrt(N)); z++){
                int n = pow(x+y, 2)/2 + pow(y+z, 2)/2 + pow(z+x, 2)/2; 
                ans[n-1]++;
            }
        }
    }

    rep (i, N) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 3544
//Burn It Dowwwnnnnn.....................
#include<bits/stdc++.h>
#define pi acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l,a,b,c,d,q,s,n,m,o,t=1;
//    cin>>t;
    for(j=0; j<t; j++)
    {
        vector<long long int>vv;
        map<long long int,long long int>uu;
        cin>>n>>m;
        k=0;
        for(i=0; i<m; i++)
        {
            cin>>o;
            k+=o;
        }
        if(k>n)
        {
            cout<<-1<<endl;
        }
        else
        {
            cout<<n-k<<endl;
        }

    }
}



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

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main() {	
	ll n;
	cin>>n;
	ll sub = 0, tot, ans;
	for (ll i = 1; i <= n; i++) {
		if(i%3 == 0 || i%5 == 0)
			sub += i; 
	}
	tot = n*(n+1)/2;
	ans = tot - sub;
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3632
# 要求されるカルテットを条件ごとに求めて、その後要求されるペアを求めているが２つWA

from collections import Counter
w = ''
H,W = map(int,input().split())
for _ in range(H):
    w += input()
freq = Counter(list(w))
#print(freq)

quartet = 0
pair = 0
if H%2 == 0 and W%2 == 0:
    for v in freq.values():
        if v%4 != 0:
            print('No')
            exit()
    print('Yes')
    exit()

elif H%2 == 0 and W%2 != 0:

    for k,v in freq.items():
        #if freq[k] %4 ==0:
        if freq[k]>=4:
            quartet += v//4
            freq[k] -= 4*(v//4)
    if quartet < (H//2)*(W//2): # change slash //
        print('No')
        exit()
    else:
        pair += 2*(quartet-(H//2)*(W//2)) # 余分なカルテットをペアに分解

    for k,v in freq.items():
        if freq[k] >= 2:
            pair += v//2
            freq[k] -= 2*(v//2)
    if pair != H//2:
        print('No')
        exit()
    else:
        print('Yes')
        exit()


elif H%2 != 0 and W%2 == 0:
    for k, v in freq.items():
        #if freq[k] % 4 == 0:
        if freq[k] >= 4:
            quartet += v // 4
            freq[k] -= 4 * (v // 4)
    if quartet < (H // 2) * (W // 2):
        print('No')
        exit()
    else:
        pair += 2 * (quartet - (H // 2) * (W // 2))  # 余分なカルテットをペアに分解

    for k, v in freq.items():
        if freq[k] >= 2:
            pair += v // 2
            freq[k] -= 2 * (v // 2)
    if pair != W // 2:
        print('No')
        exit()
    else:
        print('Yes')
        exit()

else:
    for k, v in freq.items():
        if freq[k] >= 4:
            quartet += v // 4
            freq[k] -= 4 * (v // 4)
    if quartet < (H // 2) * (W // 2):
        print('No')
        exit()
    else:
        pair += 2 * (quartet - (H // 2) * (W // 2))  # 余分なカルテットをペアに分解

    for k, v in freq.items():
        #if freq[k] % 2 == 0:
        if freq[k] >=2:
            pair += v // 2
            freq[k] -= 2 * (v // 2)
    if pair != (W//2 + H//2):
        print('No')
        exit()
    else:
        print('Yes')
        exit()


Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,M;
 cin >> N >> M;
 vector<int> veca(M),vecb(M);
  for(int i = 0 ; i < M ; i++){
    cin >> veca.at(i) >> vecb.at(i);
  }
  
  for(int i = 0 ; i < N ; i++){
    int ans = 0;
    for(int j = 0 ; j < M ; j++){
      if(veca.at(j) == i + 1 || vecb.at(j) == i + 1){
      ans++;
    }
  }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			String [] s = new String[H];
			char[][]S = new char[H][W];
			MAP[][] map = new MAP[H][W];
			
			
			for(int i =0 ;i<H;i++) {
				s[i] = scan.next();
				S[i] = s[i].toCharArray();	
			}
			
			for(int i = 0;i<H;i++) {
				for(int j=0;j<W;j++) {
					map[i][j] = new MAP(i,j,S[i][j]);
				}
			}
			int max = 0;
			
			int []dy = {-1,0,1,0};
			int []dx = {0,1,0,-1};
			int starty =0;
			int startx =0;
			
			
			for(int i = 0;i<H;i++) {
				for(int j=0;j<W;j++) {
					if(map[i][j].type=='.') {
					 starty = i;
					 startx = j;
					}
					
					Deque<MAP> queue = new ArrayDeque<MAP>();
					queue.addFirst(map[starty][startx]);
					map[starty][startx].check=true;
					
					while(!queue.isEmpty()) {
						MAP p = queue.removeLast();
						
						for(int v=0;v<4;v++){//上下左右移動方向を調べる
							int x = p.X+dx[v];
							int y = p.Y+dy[v];
							
							if(0<=x&&x<W&&y>=0&&y<H){
								if(map[y][x].type=='.' && map[y][x].check==false){
									queue.addFirst(map[y][x]);
									map[y][x].count = p.count+1;
									map[y][x].check = true; //追加した座標を探索済みにする
									}
								}
							}		
						}
					
					int imax = 0;
					for(int z = 0;z<H;z++) {
						for(int w=0;w<W;w++) {
							if(imax<map[z][w].count)imax = map[z][w].count;
							map[z][w].count = 0;
							map[z][w].check = false;
						}
					}
					if(max<imax)max = imax;
					
					
					
				}	
			}
				
	
			
		System.out.println(max);
	
	
	
		}
	}
}



class MAP{
	int Y;
	int X;
	boolean check = false;
	char type;
	int count = 0;
	MAP(int y,int x,char t){
		Y = y;X = x;type = t;
	}
}


Measured memory_bytes: 24472
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


using ll=long long;

class mod_ll
{
public:
	ll m_v;
	static const ll m_m=1000000007; // prime value ex. 1000000009
	mod_ll(ll v=0) : m_v(v) {}
	mod_ll operator = (ll rhs)
	{
		m_v=rhs%m_m;
		return *this;
	}
	ll operator ()(){return m_v;}
	mod_ll operator = (mod_ll rhs)
	{
		m_v=rhs.m_v;
		return *this;
	}
	mod_ll operator += (ll rhs)
	{
		m_v=(m_v+rhs)%m_m;
		return *this;
	}
	mod_ll operator += (mod_ll rhs)
	{
		m_v=(m_v+rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator + (mod_ll rhs)
	{
		auto ret=*this;
		return ret+=rhs;
	}
	mod_ll operator -= (mod_ll rhs)
	{
		m_v=(m_v-rhs.m_v+m_m)%m_m;
		return *this;
	}
	mod_ll operator - (mod_ll rhs)
	{
		auto ret=*this;
		return ret-=rhs;
	}
	mod_ll operator *= (ll rhs)
	{
		m_v=(m_v*rhs)%m_m;
		return *this;
	}
	mod_ll operator *= (mod_ll rhs)
	{
		m_v=(m_v*rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator * (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret*=rhs;
	}
	mod_ll operator ^ (ll rhs)
	{
		mod_ll t=*this;
		mod_ll ret(1LL);

		for(;rhs>0;rhs>>=1)
		{
			if(rhs&1) ret*=t;
			t*=t;
		}
		return ret;
	}
	mod_ll operator /= (mod_ll rhs)
	{
		return *this*=(rhs^(m_m-2));
	}
	mod_ll operator /= (ll rhs)
	{
		mod_ll t(rhs);
		return *this/=t;
	}
	mod_ll operator / (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret/=rhs;
	}
};


mod_ll mod_fact(int n)
{
	static vector<mod_ll> memo(1);

	if(memo.size()<=n)
	{
		if(memo.size()==1)
		{
			memo[0]=1;
		}
		for(int i=memo.size();i<=n;i++)
		{
			memo.push_back(memo.back()*i);
		}
	}
	return memo[n];
}


mod_ll mod_nCr(int n, int r)
{
	mod_ll bunsi=mod_fact(n);
	mod_ll bunbo=mod_fact(n-r)*mod_fact(r);
	return bunsi/bunbo;
}


mod_ll mod_nPr(int n, int r)
{
	mod_ll ret(1);

	for(int i=0;i<r;i++)
	{
		ret*=(n-i);
	}
	return ret;
}


mod_ll g(int r, int c)
{
	return mod_fact(r+c+2)/(mod_fact(r+1)*mod_fact(c+1))-1;
}


int main(void)
{
	int r1, c1, r2, c2;
	while(scanf("%d%d%d%d", &r1, &c1, &r2, &c2)==4)
	{
		mod_ll ans=g(c2,r2)-g(c2,r1-1)-g(c1-1,r2)+g(c1-1,r1-1);
		printf("%lld\n", ans());
	}
	return 0;
}


Measured memory_bytes: 18536
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
print(a if a <= b else a-1)



Measured memory_bytes: 5780
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

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

/// template end ///



void solve()
{
	while (true)
	{
		READ(int, N,A,B,C,X);
		if (!N) { break; }
		auto Ys = read<int>(N);
		
		int f = 0, n = 0;
		REP(i, 10001)
		{
			if (X == Ys[n]) { n++; }
			if (n == N) { break; }
			X = (A * X + B) % C;
			f++;
		}

		write(f <= 10000 ? f : -1);
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

#define ll long long
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> x(N), y(N);

    rep(i, N)
    {
        cin >> x[i] >> y[i];
    }
    vector<int> v(N);
    rep(i, N)
    {
        v[i] = i;
    }

    double ans = 0.0;
    do
    {
        rep(j, N - 1)
        {
            ans += pow((pow(x.at(v[j]) - x.at(v[j + 1]), 2) +
                        pow(y.at(v[j]) - y.at(v[j + 1]), 2)),
                       0.5);
        }
    } while (next_permutation(all(v)));
    int Factorial = 1;
    for (int i = 2; i <= N; i++)
        Factorial *= i;
    cout << fixed << setprecision(10) << ans / Factorial << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;
 
const int N = 2e5 + 5;
 
int n, K;
int a[N], Q[N];
boolean ismx[N], ismi[N];
 
int main() {
    scanf("%d%d", &n, &K);
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
    }
    int st = 1, ed = 0;
    for (int i = n; i; i--) {
        while (st <= ed && Q[st] >= i + K)
            st++;
        while (st <= ed && a[Q[ed]] > a[i])
            ed--;
        Q[++ed] = i;
        ismi[i] = (st == ed);
    }
    st = 1, ed = 0;
    for (int i = 1; i <= n; i++) {
        while (st <= ed && Q[st] <= i - K)
            st++;
        while (st <= ed && a[Q[ed]] < a[i])
            ed--;
        Q[++ed] = i;
        ismx[i] = (st == ed);
    }
    int qaq = 0;
    for (int i = 1, j = 1; i <= n; i = j) {
        ++j;
        while (a[j] > a[j - 1])
            j++;
        qaq += (j - i >= K);
    }
    int ans = n - K + 1 - max(qaq - 1, 0);
    for (int i = K + 1; i <= n; i++) {
        ans -= ismi[i - K] && ismx[i];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc070.contest.atcoder.jp/tasks/arc070_b>
問題文============================================================
 シカのAtCoDeerくんは正整数が書かれたカードを N 枚持っています。i(1≦i≦N) 枚目に書かれている数は ai です。
 AtCoDeerくんは大きい数が好きなので、
 カードに書かれた数の総和が K 以上になるようなカードの部分集合をよい集合と呼びます。
 
 そして、各カード i に対して、そのカードが不必要かどうかを次のように判定します。
 
 「カード i を含む任意のよい集合に対して、その集合からカード i を除いたものもよい集合」ならカード i は不必要
 それ以外の場合は、不必要でない
 
 不必要なカードの枚数を求めてください。
 ただし、それぞれの判定は独立に行われ、不必要だからと言ってカードが途中で捨てられたりすることはありません。

 入力は全て整数
 1≦N≦5000
 1≦K≦5000
 1≦ai≦10^9(1≦i≦N)
=================================================================

解説=============================================================

================================================================
*/
ll N,K;
vector<ll> a;
ll solve(){
    ll res = 0;
    cin >> N >> K;
    a.resize(N); for(auto &in:a) cin >> in;
    sort(a.begin(),a.end()); reverse(a.begin(),a.end());
    ll ans = -1;
    for(int i = 0; i < N;i++){
        ll sum = 0;
        for(ll j = i; j < N;j++){
            if(sum + a[j] < K){ sum += a[j]; continue; }
            ans = max(ans,j);
        }
    }
    return res = N - ans - 1;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int n, k; cin >> n >> k;
    string s; cin >> s;

    vector<long> reward;
    vector<int> cost;

    long latest_reward = 0L; int latest_cost = 0;
    reward.push_back(latest_reward);
    cost.push_back(latest_cost);

    char prev = s[0]; int counter = 1;

    for(auto i = s.begin()+1;i!=s.end();++i) {
        if(prev != *i) {
            latest_reward += counter;
            if(prev=='0') {
                ++latest_cost;                
            }
            reward.push_back(latest_reward);
            cost.push_back(latest_cost);

            counter = 0;
        }
        ++counter;
        prev = *i;
    }

    latest_reward += counter;
    if(prev=='0') {
        ++latest_cost;                
    }
    reward.push_back(latest_reward);
    cost.push_back(latest_cost);

    int max_array = reward.size();
    int i, j, l;
    long max_reward;
    
    if(cost[1]==0) {
        i = 2;
        max_reward = reward[1];
    }
    else {
        i=1;
        max_reward = reward[0];
    }

    for(;i<max_array;++i) {
        if(cost[i-1]<cost[i]) {
            l = 0;
        } else {
            l = 1;
        }
        j = max(0, i-2*k-l);
        max_reward = max(max_reward, reward[i]-reward[j]);
    }

    cout << max_reward << endl;
    

    return 0;
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
int n;
using namespace std;
void solve(){
cin>>n; int cnt=0;
vector<int> v(n);
for(int& i:v)cin>>i;
sort(v.begin(),v.end());
for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n;k++){
                        if(v[k]>v[j]&&v[j]>v[i]&&(v[i]+v[j]>v[k]&&v[i]+v[k]>v[j]&&v[k]+v[j]>v[i])) cnt++;
                }
        }
}
cout<<cnt<<endl;
}
int main(){
solve();
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    T.pop_back();
    if(S == T)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

    
    return 0;
}


Measured memory_bytes: 3632
#import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop
import bisect

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

N = int(input())
A = list(map(int,input().split())) ## 横一列

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      print('DENIED')
      exit()
else:
  print('APPROVED')

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << "," << a.second << ")";return os;}

const int MAX_N = 200010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void init(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}


int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    init(200000);
    ll ans = pow_mod(2,n)-1,x = 1,y = 1;
    for (int i = 0;i < a;++i) (x *= n-i) %= mod;
    for (int i = 0;i < b;++i) (y *= n-i) %= mod;
    (ans -= x*fact_inv[a]%mod) %= mod;
    (ans -= y*fact_inv[b]%mod) %= mod;
    cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,temp1=0,temp2=0,temp3;
    cin>>n;
    int time[n];
    for(i=0;i<n;i++)
    {
        cin>>time[i];
        temp1+=time[i];
    }
    cin>>m;
    int drink[m][2];
    for(i=0;i<m;i++)
    {
        for(j=0;j<2;j++)
        {
            cin>>drink[i][j];
        }
        temp2=drink[i][0];
        temp2=drink[i][1]-time[temp2-1];
        if(temp2>0)
            temp3=temp1+temp2;
        else if(temp2==0)
            temp3=temp1;
        else
            temp3=temp1+temp2;
        cout<<temp3<<endl;
    }

    return 0;
}


Measured memory_bytes: 3628
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
C.count(0)>1 and S.each {|s|
  26.times {|i| if s[i]==0 && i!=(z||=i); s[z]<s[i] ? (s[z]=0; z=i) : (s[i]=0) end }
}
L,M,N = [-1]*27,6,3
def calc(d,n)
  s = S[d]
  t = (0..25).map {s[_1] > 0 ? C[_1]*(d-L[_1])+s[_1] : 0}
  i = (0..25).max_by(M){t[_1]}.max_by {|i|
    next t[i]  if n == 0 || d+1 >= D || t[i] == 0
    l,L[i] = L[i],d
    calc(d+1,n-1)[1].tap {L[i]=l}
  }
  [i, t[i]]
end
D.times { p 1 + i=calc(_1,N)[0]; L[i]=_1 }

Measured memory_bytes: 15196
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint i,n,a,b;cin>>n>>a>>b;
	n%=12;
	for(i=0;i<n;i++){
		if(i%2==0){a=a-b;}
		else{b=a+b;}
		
	}cout<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 3120
//ΔAGC024A
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
int main()
{
	LL a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k&1)
		cout<<b-a;
	else
		cout<<a-b;
	return 0;
}

Measured memory_bytes: 256