akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <cfloat>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <string>
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <cassert>
#include <random>
#include <queue>
#include <list>
#include <map>
#include <array>
#include <chrono>
 
using namespace std;

typedef long long ll;

int main() {

	int N;

	scanf("%d",&N);

	vector<int>a,b,ma(N),mb(N);

	int i,j,k;

	for(i=0;i<N;i++){
	int sa;
	scanf(" %d",&sa);
	a.push_back(sa);
	}
 
	for(i=0;i<N;i++){
	int sb;
	scanf(" %d",&sb);
	b.push_back(sb);
	}

	ll ans=0ll;

	for(k=0;k<=28;k++){
	ll t=pow(2,k);
	for(i=0;i<N;i++){
		ma[i]=(a[i]%(2*(int)t));
		mb[i]=(b[i]%(2*(int)t));
	}
	sort(mb.begin(),mb.end());

	ll cnt=0ll;

	for(i=0;i<N;i++){
	cnt+=lower_bound(mb.begin(), mb.end(), 2ll*t-(ll)ma[i])-lower_bound(mb.begin(), mb.end(), t-(ll)ma[i])+
		mb.end()-lower_bound(mb.begin(), mb.end(), 3ll*t-(ll)ma[i]);
	}
	if(cnt%2ll==1ll){ans+=t;}

	}
	printf("%lld\n",ans);

 return 0;
 
}

Measured memory_bytes: 4084
def main():
    input()
    *H, = map(int, input().split())
    ans = 0
    prev = int(1e9+7)
    cnt = -1
    for cur in H:
        if prev >= cur:
            cnt += 1
        else:
            if ans < cnt:
                ans = cnt
            cnt = 0
        prev = cur
    if ans < cnt:
        ans = cnt
    print(ans)
    return


main()


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

int64_t	modinv(int64_t a, int64_t mod)
{
	int64_t b = mod, u = 1, v = 0;
	while (b) {
		int64_t t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0)
		u += mod;
	return u;
}

int	main()
{
	int64_t	mod = 1e+9 + 7;
	int64_t N, K;
	cin >> N >> K;

	int64_t num1 = (N + 1) * (N + 2) / 2 % mod - K * (K - 1) / 2 % mod;
	num1 *= (N + 1);
	num1 %= mod;
	int64_t inv6 = modinv(6, mod);
	int64_t num2 = inv6 * (N + 1) % mod * (N + 2) % mod * (2 * N + 3) % mod;
	int64_t num3 = inv6 * (K - 1) % mod * K % mod * (2 * K - 1) % mod;
	int64_t	num4 = N - K + 2;
	int64_t num = num1 - (num2 - num3) + num4;
	num %= mod;
	if (num < 0) num += mod;
	cout << num << endl;
}


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

using namespace std;


const int N=1e3+10;

int n;
int a[N];

vector <int> keep,ans;
void solve(){
        long long sodd=0,seven=0;
        for(int i=1;i<=n;i+=2) sodd+=max(a[i],0);
        for(int i=2;i<=n;i+=2) seven+=max(a[i],0);
        int st=(sodd<seven)+1;
        for(int i=st;i<=n;i+=2) if (a[i]>0) keep.push_back(i);
        int n1=keep.size();
        
        cout<<max(sodd,seven)<<'\n';
        for(int i=n;i>keep[n1-1];i--) ans.push_back(i);
        for(int i=n1-2;i>=0;i--){
                int L=keep[i],R=keep[i+1];
                int mid=(L+R)/2;
                for(int i=mid;i>L;i--) ans.push_back(i);
        }
        for(int i=1;i<keep[0];i++) ans.push_back(1);
        cout<<ans.size()<<'\n';
        for(auto ch:ans) cout<<ch<<'\n';
}
int main(){
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        if (*max_element(a+1,a+n+1)<0){
                int idx=max_element(a+1,a+n+1)-a;
                cout<<a[idx]<<'\n'<<n-1<<'\n';
                for(int i=n;i>idx;i--) cout<<i<<'\n';
                for(int i=1;i<idx;i++) cout<<"1\n";
                return 0;
        }
        solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
int main()
{
	RI(n);
	int mn, mx;
	RD(mn);
	mx = mn;
	DO(n-1) {
		RI(a);
		if (a < mn)
			mn = a;
		else if (a > mx)
			mx = a;
	}
	PL(mx - mn);
}


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

int main() {
	cin.sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h[10], k[10];
	cin >> h[0] >> h[1];
	cin >> k[0] >> k[1];
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int hsco = 0, ksco = 0;
	hsco += h[0] * a + (h[0] / 10) * c + h[1] * b + (h[1] / 20) * d;
	ksco += k[0] * a + (k[0] / 10) * c + k[1] * b + (k[1] / 20) * d;
	if (hsco == ksco) {
		cout << "even" << endl;
	} else if (hsco > ksco) {
		cout << "hiroshi" << endl;
	} else {
		cout << "kenjiro" << endl;
	}
}


Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))
total_breaks = 0
position = 0
for i in range(1, n + 1):
    try:
        next_position = a.index(i, position)
        if next_position < position:
            total_breaks = total_breaks + n - position
            break
        total_breaks = total_breaks + next_position - position
        position = next_position + 1
    except ValueError:
        if position == 0:
            total_breaks = -1
            break
        else:
            total_breaks = total_breaks + n - position
            break
print(total_breaks)

Measured memory_bytes: 76364
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<bitset>
#include<functional>
#include<climits>
using namespace std;
typedef pair<int,int>pii;
const int INF=1e9;
const int dx[]={0,-1,0,1},dy[]={-1,0,1,0};


struct data{
    string str;
    data(string _str):str(_str){}
    data(){}
    bool operator<(const data &d)const{
        if(str.length()!=d.str.length()){
            return str.length()<d.str.length();
        }
        else return str<d.str;
    }
};
int main(){
    map<data,int>M;
    int n;
    scanf("%d",&n);
    while(n--){
        string str;int m;
        cin>>str>>m;
        M[data(str)]+=m;
    }
    map<data,int>::iterator it;
    for(it=M.begin();it!=M.end();it++){
        cout<<(it->first).str<<" "<<it->second<<endl;
    }
    return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))

void solve()
{
    ll N,K;
    cin >> N >> K;
    vector<ll> L(N);
    for1(i,N) {
        cin >> L[i];
    }
    sort(L.begin(),L.end(),greater<ll>());
    ll ans = 0;
    for1(i,K) {
        ans += L[i];
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
 
int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i <= s.size()-t.size(); i++){
        int cnt = 0;
        for(int j = 0; j < t.size() && i+j < s.size(); j++){
            if(s[i+j] == t[j]) cnt++;
        }
        ans = max(ans,cnt);
    }
    cout << t.size()-ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;

i64 ord(i64 x, int p)
{
	int ret = 0;
	while (x % p == 0) {
		x /= p;
		++ret;
	}
	return ret;
}

int two[202020], five[202020];
int stat[100][100], acc[100][100];
const int aux = 50;

int main()
{
	scanf("%d", &N);
	int self = 0;
	for (int i = 0; i < N; ++i) {
		char buf[50];
		scanf("%s", buf);
		i64 a = 0, b = 1;
		bool mc = false;
		for (int j = 0; buf[j]; ++j) {
			if (buf[j] == '.') {
				mc = true;
				continue;
			}
			if (mc) b *= 10;
			a = a * 10 + (buf[j] - '0');
		}
		two[i] = ord(a, 2) - ord(b, 2);
		five[i] = ord(a, 5) - ord(b, 5);
		++stat[two[i] + aux][five[i] + aux];
		++acc[two[i] + aux][five[i] + aux];
		if (two[i] >= 0 && five[i] >= 0) ++self;
	}
	for (int i = 99; i >= 0; --i) {
		for (int j = 98; j >= 0; --j) {
			acc[i][j] += acc[i][j + 1];
		}
	}
	for (int i = 98; i >= 0; --i) {
		for (int j = 99; j >= 0; --j) {
			acc[i][j] += acc[i + 1][j];
		}
	}
	i64 ret = 0;
	for (int i = 1; i < 100; ++i) {
		for (int j = 1; j < 100; ++j) {
			int ri = aux * 2 - i;
			int rj = aux * 2 - j;
			ret += (i64)stat[i][j] * acc[ri][rj];
		}
	}
	ret = (ret - self) / 2;
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 4828
//つらら

#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>

using namespace std;
#define LL long long

LL N, L;
LL a[100005] = {};
LL ans = 999999999999999999;
vector<pair<LL,LL>> ice;
LL sec[100003] = {};//sec[i]=i本目のつららが折れるまでの秒数


int main() {
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sec[i] += L - a[i];
		ice.push_back(make_pair(a[i], i));
	}
	sort(ice.begin(), ice.end());
	reverse(ice.begin(), ice.end());
	for (int i = 0; i < N; i++) {
		LL index = ice[i].second;
		if (index == 0) {
			if (a[0] < a[1]) sec[0] += sec[1];
		}
		else if (index == N - 1) {
			if (a[N - 1] < a[N - 2]) sec[N - 1] += sec[N - 2];
		}
		else {
			if (a[index] < a[index + 1] && a[index] < a[index - 1]) sec[index] += max(sec[index - 1], sec[index + 1]);
			else if (a[index] < a[index + 1]) sec[index] += sec[index + 1];
			else if (a[index] < a[index - 1]) sec[index] += sec[index - 1];
		}
	}
	sort(sec,sec+N);	reverse(sec,sec+N);
	cout << sec[0] << endl;


	return 0;
}


Measured memory_bytes: 6204
n, m = map(int,input().split())
K = [0]*m
S = [[] for _ in range(m)]    

for i in range(m):
    K[i], *S[i] = map(int, input().split())
P = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    s = list(map(int, list(bin(i)[2:].zfill(n))))
    for j in range(m):
        p = [_s for k,_s in enumerate(s) if k+1 in S[j]]
        if sum(p)%2!=P[j]:
            break
        else:
            if j==m-1:
                ans += 1
print(ans)

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

int a[100];
int main(){
	int n, m,k=0,p=0;
	double sum=0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++){
         scanf("%d", &a[i]);
        sum+=a[i];
	}
	sum = sum / (4 * m);
	for (int i = 0; i < n; i++){
		if (a[i] >= sum) k++;
		if (k == m) {
                p = 1; 
                break;
                 }
	}
	if (p == 1) printf("Yes\n");
	else printf("No\n");

}

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

#define MAX 500000

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

void marge(int left, int mid, int right){

  int end1 = mid - left;
  int end2 = right - mid;
  
  //cout << "left";
  for(int i = 0; i < end1; i++){
    L[i] = arr[left+i];
    // cout << arr[left+i] << " ";
  }
  //cout << " right";
  for(int i = 0; i < end2; i++){
    R[i] = arr[mid+i];
    //    cout  << arr[mid+i] << " ";
  }
  L[end1] = R[end2] = INT_MAX;
  int s = 0, l = 0;

  for(int i = left; i < right; i++){
    cnt++;
    if(L[s] <= R[l]){
      arr[i] = L[s];
      s++;
    }else{
      arr[i] = R[l];
      l++;
    }
    // cout << L[s] << " " << R[l] << endl;
  }


}


void margesort(int left, int right){

  if(left+1 < right){
    int mid = (left+right)/2;
    margesort(left,mid);
    margesort(mid,right);
    marge(left,mid,right);
  }


}

int main(){

  cin >> n;

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

  margesort(0,n);

  for(int i = 0; i < n; i++){
    if(i != n-1)    cout << arr[i] << " ";
    else cout << arr[i] << endl << cnt << endl;
  }



}

Measured memory_bytes: 5064
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
 
int main()
{
    priority_queue< int,vector<int>,less<int> > que;
    int in;
 
    for(int i = 0; i < 10; i++){
        cin >> in;
        que.push(in);
    }
 
 
    for(int j = 0; j < 3; j++){
        cout << que.top() << '\n';
        que.pop();
    }
 
    return 0;
}

Measured memory_bytes: 1212
M=998244353
n,m,k=map(int,input().split())
a=0
c=1
for i in range(k+1):
  a+=c*m*pow(m-1,n-i-1,M)
  c=c*(n-i-1)*pow(i+1,M-2,M)%M
print(a%M)

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

int main() {
	string s;
	int k;
	cin >> s >> k;
	string topK[5];
	for(int i=0;i<k;i++) topK[i] = "";
	for(int i=0;i<s.length();i++) {
		string tmp[5];
		int tmp_ind = 0;
		int topK_ind = 0;
		int l = 1;
		while(tmp_ind < k) {
			bool topK_empty = topK_ind >= k || topK[topK_ind].empty();
			bool substr_empty = l > s.length() - i;
			if(topK_empty && substr_empty) break;
			if(substr_empty) {
				tmp[tmp_ind++] = topK[topK_ind++];
				continue;
			}
			if(topK_empty) {
				tmp[tmp_ind++] = s.substr(i, l++);
				continue;
			}
			if(topK[topK_ind] == s.substr(i, l)) {
				tmp[tmp_ind++] = topK[topK_ind];
				topK_ind++;
				l++;
			} else if(topK[topK_ind] < s.substr(i, l)){
				tmp[tmp_ind++] = topK[topK_ind++];
			} else {
				tmp[tmp_ind++] = s.substr(i, l++);
			}
		}
		for(int j=0;j<tmp_ind;j++) topK[j] = tmp[j];
	}
	cout << topK[k-1] << endl;
	return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input.split('\n')
  input[0] = input[0].split(' ')
  const n = ~~input[0][0]
  const k = ~~input[0][1]

  const tree = input
    .slice(1, -1)
    .map(v => ~~v)
    .sort((a, b) => a - b)

  // i-1+k本の差を収納
  const diff = Array.apply(null, { length: n - (k - 1) }).fill(-1)
  let min = Number.MAX_SAFE_INTEGER
  let tmp = 0
  for (let i = 0; i < diff.length; i++) {
    // diff.push()
    tmp = tree[i + k - 1] - tree[i]
    min = min > tmp ? tmp : min
  }
  console.log(min)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29388
#include<stdio.h>
int main(){
	int A[3];
	scanf("%d %d %d",&A[0],&A[1],&A[2]);

	int i,j,k;
	for(i=0;i<2;i++){
		for(j=2;j>i;j--){
			if(A[j-1]>A[j]){
				k=A[j-1];
				A[j-1]=A[j];
				A[j]=k;
			}
		}
	}

	int cost=0;
	cost = (A[1]-A[0]) + (A[2]-A[1]);

	printf("%d\n",cost);


	return 0;
}

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

int N;
vector<int> country_time_differences{0};
vector<int> country_times;

int choose(int now){
    if(now == N + 1){
        vector<int> country_times_sorted = country_times;
        sort(country_times_sorted.begin(), country_times_sorted.end());
        int ans = country_times_sorted[0] - country_times_sorted[N] + 24;
        for(int i = 0; i < N; i++){
            ans = min(ans, country_times_sorted[i + 1] - country_times_sorted[i]);
        }
        return ans;
    }else if(country_time_differences[now] % 12 == 0){
        country_times.push_back(country_time_differences[now]);
        int ans = choose(now + 1);
        country_times.pop_back();
        return ans;
    }else{
        country_times.push_back(country_time_differences[now]);
        int ans = choose(now + 1);
        country_times.back() = 24 - country_time_differences[now];
        ans = max(ans, choose(now + 1));
        country_times.pop_back();
        return ans;
    }
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int input;
        cin >> input;
        country_time_differences.push_back(input);
    }
    if(N >= 24){
        cout << 0 << endl;
        return 0;
    }
    cout << choose(0) << endl;
}


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



int main(){
    int n,x;
    cin>>n>>x;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    int ans=1;
    rep(i,n){
        x-=l[i];
        if(x<0) break;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder(br.readLine());
        int q=Integer.parseInt(br.readLine());
        String[] op;
        int op1,op2;
		for(int i=0;i<q;i++){
	        op=br.readLine().split(" ");
			op1=Integer.parseInt(op[1]);
			op2=Integer.parseInt(op[2]);
			if(op[0].equals("print")){
				System.out.println(sb.substring(op1,op2+1));
			}else if(op[0].equals("reverse")){
				sb=sb.replace(op1,op2+1,new StringBuilder(sb.substring(op1,op2+1)).reverse().toString());
			}else if(op[0].equals("replace")){
				sb=sb.replace(op1,op2+1,op[3]);
			}
		}
	}
}

Measured memory_bytes: 24724
"""
N=int(input())
L=[int(x) for x in input().split()]
L.sort()
count=0


for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[k]>=L[i]+L[j]:
                break
            count+=1
            
print(count)
"""
N=int(input())
S=input()
result=N
for i in range(N):
    if i+1==N:
        break
    
    if S[i]==S[i+1]:
        result-=1

print(result)


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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int cnt[52];

int main(void){
  rep(i,10)rep(j,10)rep(k,10)rep(l,10)cnt[i+j+k+l]++;

  int x;
  while(cin>>x){
    cout<<cnt[x]<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int sLength = s.length();
		int count = 0;
		
		for(int i = 0; i < sLength; i++) {			
			//偶数番目の時'0'と一致
			boolean check1 = i % 2 == 0 && s.charAt(i) == '0';
			//奇数番目の時'1'と一致
			boolean check2 = i % 2 == 1 && s.charAt(i) == '1';

			// 0101...と一致する個数（1010...と一致しない個数）をカウント
			if(check1 || check2) {
				count++;
			}			
		}
		
		System.out.print(Math.min(count, sLength - count));
	}	
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int S = (a + b) * h / 2;

        PrintWriter out = new PrintWriter(System.out);
        out.println(S);
        out.flush();
        sc.close();
    }
}

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

using namespace std;

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

int data[100];
inline int root(int x) {
  return data[x] < 0 ? x : data[x] = root(data[x]);
}
typedef pair<int, pair<int, int> > edges;

int const INF = 1<<29;

int main() {
  
  int N, M;
  while(cin >> N >> M && (N|M)) {
    edges es[M];
    rep(i, M) {
      int a, b, c;
      scanf("%d %d %d", &a, &b, &c); a--, b--;
      es[i] = make_pair(c, make_pair(a, b));
    }
    sort(es, es+M);
    int ret = INF;
    
    int st = 0;
    for(; M-st >= N-1; st++) {
      memset(data, -1, sizeof data);
      int last = -1;
      int s = 0;
      REP(i, st, M) {
	int u = root(es[i].second.first), v = root(es[i].second.second);
	if(u != v) {
	  data[u] += data[v]; data[v] = u;
	  last = i;
	  s++;
	  if(s == N-1) {
	    ret = min(ret, es[last].first-es[st].first);
	    goto next;
	  }
	}
      }
      break;
    next:;
    }
    printf("%d\n", ret < INF ? ret : -1);
  }
  
  return 0;
}

Measured memory_bytes: 1288
//47
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n,w;cin>>n>>w,n|w;){
    int h[100]={};
    int m=0;
    while(n--){
      int v;
      cin>>v;
      m=max(m,v/w);
      h[v/w]++;
    }
    double k=0.01;
    for(int i=0;i<=m;i++){
      k+=(m-i)*1./m*h[i]/ *max_element(h,h+m+1);
    }
    cout<<fixed<<k<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)

#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long ll;
const int N = 1e5+1 , M = 5e5+1, OO = 0x3f3f3f3f,MOD = 1e9+7;
bool c=0;
deque<char>dq;
char str[N];  
int main()
{
  scanf("%s",str);
  int n=strlen(str);
  for(int i=0;i<n;++i) dq.push_back(str[i]);
  int q;
  scanf("%d",&q);
  while(q--)
  {
    int op;
    scanf("%d",&op);
    op--;
    if(!op) c^=1;
    else
    {
      int pos;
      char ch;
      scanf("%d",&pos);
      scanf(" %c",&ch);
      
      pos--;
      if(c) pos^=1;

      if(!pos) dq.push_front(ch);
      else     dq.push_back(ch);
    }
  }  
  while(!dq.empty())
  {
    if(!c) printf("%c",dq.front()),dq.pop_front();  
    else printf("%c",dq.back()),dq.pop_back();  
  }
  #ifdef _LOCAL_DEFINE  
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int ans=0;
	cin>>s;
	rep(i,LEN(s)){
		if(LEN(s)-i-1<=i)break;
		if(s.at(i)!=s.at(LEN(s)-i-1))ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int y,m,d;
  char a;
  scanf("%d %c",&y,&a);
  scanf("%d %c",&m,&a);
  scanf("%d",&d);
  if(y<=2019 && m<=4 && d<=30){
        printf("Heisei\n");
  }
  else printf("TBD\n");
  //printf("%d %d %d",y,m,d);
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

    ll n, k;cin >> n >> k;
    ll ans = 0;

    while(n){
        ans++;
        n /= k;
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N=int(input())
D = [list(map(int, input().split())) for i in range(N)]

isOK=False

for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
        isOK=True
        break

if isOK:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll a,b,c;
cin >> a >> b >> c;
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << "0" << endl;
else
    cout << min({a * b, b * c, c * a});
}


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

int main() {
	int K, A, B;
	cin >> K >> A >> B;

	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;


  char a_in = a.at(0);  
  char b_in = b.at(0);  
  char c_in = c.at(0); 
  
  cout <<  a_in <<  b_in << c_in<< endl;

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll H[100100];
int N;
ll A, B, C;

bool solve(ll n){
    ll m = n;
    for(int i = 0; i < N; i++) {
        ll h = H[i] - B*n;
        if(h <= 0) continue;
        m -= h/C + (h%C != 0);
        if(m < 0) return false;
    }
    return true;
}

int main(){
    cin >> N;
    cin >> A >> B;
    C = A-B;

    REP(i,N){
        ll h;
        cin >> h;
        H[i] = h;
    }
    sort(H, H+N, greater<ll>());

    ll left = 0;
    ll right = 1e10;

    while(left+1 < right){
        //cout << left << " " << right << endl;
        ll mid = (right+left)/2;
        bool ok = solve(mid);
        if(ok){
            right = mid;
        }
        else{
            left = mid;
        }
    }

    cout << right << endl;

    return 0;
}


Measured memory_bytes: 1152
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int n = sc.nextInt();
        _out.printf("ABC%03d%n", n);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

int main() {
  int n;
  cin >> n;
  map<string, int> m;
  while (n--) {
    string s;
    cin >> s;
    m[s]++;
  }

  for (auto e : {"AC", "WA", "TLE", "RE"}) cout << e << " x " << m[e] << endl;
}


Measured memory_bytes: 3628
//arc060_c.cpp
//Sat Jun 23 13:19:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int n,a,X;
int x[50];
ll dptable[51][51][3000];

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

	for (int j=0;j<=n;j++){
		for (int k=0;k<=n;k++){
			for (int s=0;s<=2500;s++){
				if (j==0 && k==0 && s==0){
					dptable[j][k][s] = 1;
				}else if (j>=1 && s<x[j]){
					dptable[j][k][s] = dptable[j-1][k][s];
				}else if (j>=1 && k>=1 && s>=x[j]){
					dptable[j][k][s] = dptable[j-1][k][s] + dptable[j-1][k-1][s-x[j]];
				}else {
					dptable[j][k][s] = 0;
				}
			}
		}
	}

	ll ans = 0;

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

	cout << ans << endl;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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;}

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=0;
  int y=0;
  while(a>0){a-=d;x++;}
  while(c>0){c-=b;y++;}
  cout<<(x>=y?"Yes":"No");
}


Measured memory_bytes: 3636
#include<iostream>
#include<stack>
#include<vector>
#include <map>
#include <queue>
#include<string.h>
using namespace std;
typedef pair<int,int> P;
int node[200][200];
int main()
{
  int n;
  cin>>n;
  memset(node,-1,sizeof(node));
  for(;n--;)
    {
      int k,t;
      cin>>k>>t;
      for(int i=0;i<t;i++)
	{
	  int tmp;
	  cin>>tmp;
	  node[k][tmp]=1;
	}
    }
  int p;
  cin>>p;
  for(;p--;)
    {
      int s,d,v;
      cin>>s>>d>>v;
      int ans=-1;

      queue<P> qu;
      int c[200];
      memset(c,-1,sizeof(c));
      for(int i=0;i<200;i++)
	{
	  if(v-1>0)
	    if(node[s][i]==1)
	      qu.push(P(i,v-1));
	}
      while(!qu.empty())
	{
	  P a = qu.front();
	  qu.pop();
	  //      cout<<a.first<<" "<<a.second<<endl;
	  if(a.first==d)
	    {
	      ans=v-a.second+1;
	      break;
	    }
	  for(int i=0;i<200;i++)
	    {
	      if(node[a.first][i]==1)
		{
		  if(a.second-1>0)
		    {
		      if(c[i]==-1)
			{
			  c[i]=a.second-1;
			  qu.push(P(i,a.second-1));	    
			}
		    }
		}
	    } 
	}
      
      
      if(ans==-1)
	cout<<"NA"<<endl;
      else
	cout<<ans<<endl;
      
    }
  
}

Measured memory_bytes: 1364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[][] A = new int[n][m];
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				A[i][j] = sc.nextInt();
			}
		}
		
		int[] b = new int[m];
		for(int i=0; i<m; i++){
			b[i] = sc.nextInt();
		}
		
		int[] c = new int[n];
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				c[i] += A[i][j] * b[j];
			}
			System.out.println(c[i]);
		}
	}

}

Measured memory_bytes: 40884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    int n, k;
    cin >> n >> k;
    int h[n+1]={};
    for (int i=1; i<=n; i++) {
        cin >> h[i];
    }
    int dp[n+1]={};
    for (int i=2; i<=n; i++) {
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        for (int j=2; j<=min(k, i-1); j++) {
            dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n] << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>

#define ll long long

using namespace std;
int main(void)
{
  int n;
  cin >> n;
  vector<pair<ll, int>> a = vector<pair<ll, int>>(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }

  sort(a.begin(), a.end(), greater<pair<ll, int>>());
  vector<vector<ll>> dp = vector<vector<ll>>(n + 1, vector<ll>(n + 1, 0));

  for (int i = 0; i < n; i++) {
    ll ai = a[i].first;
    int idx = a[i].second;
    
    for (int j = 0; j <= i; j++) {
      dp[j + 1][i - j] = max(dp[j + 1][i - j], dp[j][i - j] + ai * (idx - j));
      dp[j][i - j + 1] = max(dp[j][i - j + 1], dp[j][i - j] + ai * (n - (i - j + 1) - idx));
    }
  }

  ll m = 0;
  for (int i = 0; i <= n; i++) {
    m = max(m, dp[i][n - i]);
  }
  
  cout << m << endl;
  
  
  return 0;
}


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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int h,w;
		char c;
		cin >> h >> w;
		for(int i=1;i<=w+2;i++) cout << "#";
		cout << endl;
		for(int i=1;i<=h;i++){
			cout << "#";
			for(int j=1;j<=w;j++){
				cin >> c;
				cout << c;
			}
			cout << "#\n";
		}
		for(int i=1;i<=w+2;i++) cout << "#";
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[][] nums = new int[4][4];
		for (int rIdx = 1; rIdx <= 3; rIdx++) {
			String[] inputs = scanner.nextLine().split(" ");
			for (int cIdx = 1; cIdx <=3; cIdx++) nums[rIdx][cIdx] = Integer.parseInt(inputs[cIdx - 1]);
		}

		boolean isRightInfo = true;
		for (int idx = 2; idx <= 3; idx++) {
			int diff = nums[idx][1] - nums[1][1];
			if (diff != nums[idx][2] - nums[1][2] || diff != nums[idx][3] - nums[1][3]) isRightInfo = false;

			diff = nums[1][idx] - nums[1][1];
			if (diff != nums[2][idx] - nums[2][1] || diff != nums[3][idx] - nums[3][1]) isRightInfo = false;
		}

		if (isRightInfo) System.out.println("Yes");
		else System.out.println("No");
	}
}


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

int main() {
    int n, a, cnt = 0;
    cin >> n;
    map<int, int> m;
    for (auto i = 0; i < n; i++) {
        cin >> a;
        m[a]++;
    }
    for (auto& elm : m)
        if (elm.second != 1) cnt += (elm.second - 1);
    if (cnt % 2 == 1) n -= 1;
    cout << n - cnt << endl;
    return 0;
}

Measured memory_bytes: 8140
num = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

sum = sum(b)

for i in range(len(a) -1):
  if a[i + 1] - a[i] == 1:
    sum += c[a[i] - 1]
    
print(sum)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main()
{
 
	char text[4];

	scanf("%s", text);
	if (strcmp(text, "SUN") == 0) {
		printf("7");
	}
	else if (strcmp(text, "MON") == 0) {
		printf("6");
	}
	else if (strcmp(text, "TUE") == 0) {
		printf("5");
	}
	else if (strcmp(text, "WED") == 0) {
		printf("4");
	}
	else if (strcmp(text, "THU") == 0) {
		printf("3");
	}
	else if (strcmp(text, "FRI") == 0) {
		printf("2");
	}
	else if (strcmp(text, "SAT") == 0) {
		printf("1");
	}
	else {
		printf("-");
	}

}


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

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

    vector<int> cnt(2019);
    
    cnt[0] =  1;
    long long int mul = 1;
int cur  =0;
     int temp;
    for(int i=str.size()-1;i>=0;i--)
    {
        cur  +=  mul* (str[i] - '0');
        cur%=2019;
        ++cnt[cur];
        mul  =  mul*10 %2019;
    }
    long long int ans = 0;
    for(long long int c:cnt)
    {
        ans += (long long int)(c*(c-1))/2;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(){
typedef long long ll;
 ll a[4][1001],m[4][1001],n,w,t,ans=0;
 vector<ll>b,c;
  cin>>n>>w;

  for(int i=0;i<4;i++)
    for(int j=0;j<n;j++)
      cin>>a[i][j];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      b.push_back(a[0][i]+a[1][j]);
      c.push_back(a[3][i]+a[2][j]);
    }
  }

  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  for(vector<ll>::iterator it=b.begin();it!=b.end();it++){
    ans+=upper_bound(c.begin(),c.end(),w-(*it))-lower_bound(c.begin(),c.end(),w-(*it));
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main(){
  long long K,sind,eind;
  int keta;
  cin >> K;
  vector<long long> lunlun;

  for(int i=0;i<10;i++){
    lunlun.push_back(i);
  }
  sind=1;eind=10;
  while(1){
    if(eind > K) break;
    for(int i=sind;i<eind;i++){
      keta=lunlun[i]%10;
      for(int j=-1;j<2;j++){
        if(keta+j>=0 && keta+j<10){
          lunlun.push_back(lunlun[i]*10+keta+j);
        }
      }
    }
    sind=eind;
    eind=lunlun.size();
  }

  // for(auto itr=lunlun.begin();itr!=lunlun.end();itr++){
  //   cout << *itr << endl;
  // }

  cout << lunlun[K] << endl;

  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K; cin >> N >> K;
  long long a[5011];
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
  }

  sort(a, a + N);

  long long sum = 0;
  int ans = N;
  for(int i = N-1; i >= 0; --i) {
    if(sum + a[i] < K) sum += a[i];
    else ans = min(ans, i);
  }
  cout << ans << endl;

  return 0;
}

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


 
int main(){
    int N;
    cin>>N;
    string W[N];
    for(int i=0;i<N;i++)cin>>W[i];

    bool s=true,t=true;

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(W[i]==W[j]){
                s=false;
                break;
            }
            if(!s)break;
        }
    }

    for(int i=0;i<N-1;i++){
        if(W[i][W[i].size()-1]!=W[i+1][0])t=false;
    }
    if(s&&t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  ll n;
  std::cin >> n;

  ll ans = (n-1)*n/2;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
m=10**9+7
n=int(input())
s=r=0
f=1
a=input().split()
for i in range(n):
 s+=pow(i+1,m-2,m)
 r+=int(a[i])*~-s+int(a[~i])*s
 f=f*-~i%m
print(r*f%m)

Measured memory_bytes: 11484
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>

int main() {
  size_t A, B, M;
  scanf("%zu %zu %zu", &A, &B, &M);

  std::vector<int> a(A), b(B);
  for (auto& ai: a) scanf("%d", &ai);
  for (auto& bi: b) scanf("%d", &bi);

  std::vector<int> x(M), y(M), c(M);
  for (size_t i = 0; i < M; ++i) {
    scanf("%d %d %d", &x[i], &y[i], &c[i]);
    --x[i], --y[i];
  }

  int res = *std::min_element(a.begin(), a.end()) + *std::min_element(b.begin(), b.end());

  for (size_t i = 0; i < M; ++i) {
    int cur = a[x[i]] + b[y[i]] - c[i];
    res = std::min(res, cur);
  }
  printf("%d\n", res);
}


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

int func(int i) {
  if (i < 10)
    return i;
  else
    return func(i / 10) + (i % 10);
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int temp = func(i);
    if (A <= temp && temp <= B)
      ans += i;
  }
  cout << ans << endl;
}

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

int main() {
  int A, B, dig, sum;
  cin >> A >> B;
  dig = A;
  sum = 0;
  
  rep(i, B-A+1) {
    if (dig/10000 != dig%10) {
      dig++;
      continue;
    }
    
    else if ((dig/1000) % 10 != (dig/10) % 10) {
      dig++;
      continue;
    }
    else {
      sum += 1;
    }
    dig++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let nr = lines.next().unwrap().unwrap();
    let mut nr = nr.split_whitespace();
    let n: i32 = nr.next().unwrap().parse().unwrap();
    let r: i32 = nr.next().unwrap().parse().unwrap();

    let ans = if n >= 10 { r } else { r + 100 * (10 - n) };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>

using namespace std;

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

    if(n % 2 == 0) cout << n << endl;
    else cout << (n * 2) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		List<Long> alist = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			alist.add(sc.nextLong());
		}

		long cntOdd = 0;
		long cntEvn = 0;
		long sum = 0;

		for (int i = 0; i < n; i++) {

			sum += alist.get(i);

			//iが偶数のとき正
			if(i%2 == 0) {
				if(sum > 0) {
					continue;
				} else {
					long diff = 1-sum;
					cntEvn += 1-sum;
					sum += diff;
				}
			} else {
				if(sum < 0) {
					continue;
				} else {
					long diff = 1+sum;
					cntEvn += 1+sum;
					sum -= diff;
				}
			}
		}

		sum =0;

		for (int i = 0; i < n; i++) {

			sum += alist.get(i);

			//iが偶数のとき負
			if (i%2 == 0) {
				if(sum < 0) {
					continue;
				} else {
					long diff = 1+sum;
					cntOdd += 1+sum;
					sum -= diff;
				}
			} else {
				if(sum > 0) {
					continue;
				} else {
					long diff = 1-sum;
					cntOdd += 1-sum;
					sum += diff;
				}
			}
		}
		if(cntOdd <= cntEvn) {
			System.out.println(cntOdd);
		} else {
			System.out.println(cntEvn);
		}
	}
}


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

int main( void )
{
    int a,b,c;
    cin >> a >> b >> c;
    
    if ( a + b == c || a + c == b || b + c == a )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
@a = sort { $a <=> $b } @a;
my @t;
$t[0] = $a[0];
for my $i (1..($n-1)) {
  $t[$i] = $a[$i] + $t[$i-1];
}
my $ans = 1;
for my $i (1..$n-1) {
  if ($a[$n-$i] <= 2*$t[$n-$i-1]) {
    $ans++;
  } else {
    last;
  }
}
say $ans;

Measured memory_bytes: 19236
n=int(input())
ans="Yes"
w=[input() for _ in range(n)]
for  i in range(n):
    a=w[max(0,i-1)]
    b=w[max(1,i)]
    if a[len(a)-1]!=b[0]:
        ans="No"
if len(set(w))!=len(w):
    ans="No"
print(ans)

Measured memory_bytes: 3060
<?php
// C
fscanf(STDIN, '%d', $n);
if (!$n) exit('0');
$b = '';
while ($n) {
    if ($n % 2) {
        $b .= '1';
        $n--;
    } else {
        $b .= '0';
    }
    $n /= -2;
}
echo strrev($b);

Measured memory_bytes: 4604
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

// numよりも大きい最小の値のindexを返したい
int binarySearch(int num, vector<int> &L) {
	int left = -1;
	int right = L.size();
	int mid = (right + left) / 2;
	while (right - left > 1) {
		mid = (right + left) / 2;
		if (L[mid] > num)right = mid;
		else left = mid;
	}
	return L[right];

}

int main() {
	string s, t; cin >> s >> t;
	map<char, vector<int>> mp;
	rep(i, s.size()) {
		mp[s[i]].push_back(i + 1);
	}

	long long ans = 0;
	int place = 0;
	rep(i, t.size()) {
		if (mp[t[i]].size() == 0) {
			cout << -1;
			return 0;
		}
		if (mp[t[i]][mp[t[i]].size() - 1] <= place) {
			ans += s.size();
			place = mp[t[i]][0];
		}
		else {
			int num = binarySearch(place, mp[t[i]]);
			//cout << "binary: " << num << endl;
			place = num;
		}
		//cout << place << endl;
		//cout << ans << endl;
	}
	cout << ans + (long long)place;
}

Measured memory_bytes: 1216