akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N; cin >> N; // ボタン数
  vector<int> A(N+1); // 各ボタンの押した先
  vector<int> B(N+1); // 既に押したボタン。押した先が、ここに在ったら－１。
  int R = 0; // 回数
  
  // ボタンの押した先の取り込み
  rep(i,N){
    cin >> A.at(i+1);
  }

  // ボタンの押した先判定
  int w = 1;  // 次に押すボタンの位置
  rep(i,N+1){
    // 面倒なので、カウンタは１からＮまで動かす
    if ( i == 0 ) { continue; }
    
    R +=1;       // 押した
    B.at(i) = w; // 押したボタンを、済みボタンに登録
    w = A.at(w); // ボタンの行先
    // cout << i << ":" << w << endl;
    
    // 終了判定
    if ( w == 2 ) {
      break;
//    } else {
//      rep(j,i){
//        if ( B.at(j+1) == w ) {
//          R = -1;
//          break;
//        }
//      }
//      if ( R == -1) { break;}
    }
  }

  // 最大、全ボタン数繰り返して、w != 2 なら、-1
  if ( w != 2 ) { R = -1; }
  cout << R << endl;  
  
}



Measured memory_bytes: 1024
h,w = map(int,input().split())
S = ['.'*(w+2)]+['.'+input()+'.' for i in range(h)]+['.'*(w+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if S[i][j]=='.':
            mine = 0
            for k in range(-1,2):
                for l in range(-1,2):
                    if S[i+k][j+l]=='#' and not k==l==0:
                        mine += 1
            S[i] = S[i][:j]+str(mine)+S[i][j+1:]
for s in range(1,h+1):
    print(S[s][1:w+1])


Measured memory_bytes: 40688
#include<stdio.h>
#include<stdlib.h>

int *CountingSort(int *,int *,int,int);

int main(){
  int *A,*B,n,max,i;

  scanf("%d",&n);

  A=(int *)malloc(n*sizeof(int));
  B=(int *)malloc(n*sizeof(int));

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(i==0||max<A[i]){
      max=A[i];
    }
  }

  B=CountingSort(A,B,max,n);

  for(i=0;i<n;i++){
    printf("%d",B[i]);
    if(i!=n-1){
      printf(" ");
  }
  }
  printf("\n");

  free(A);
  free(B);
  return 0;

}

  int *CountingSort(int *A,int *B,int max,int n){
    int *C,i,j,a,b;

  C=(int *)malloc(max*sizeof(int));

  for(i=0;i<=max;i++){
    C[i]=0;
    }
    
    for(j=0;j<n;j++){
      C[A[j]]++;
    }

    for(i=1;i<=max;i++){
      C[i]=C[i-1]+C[i];
    }

    for(j=n-1;j>=0;j--){
      a=A[j];
      b=C[a]-1;
      B[b]=A[j];
      C[a]--;
    }

    free(C);
    return B;
  }




Measured memory_bytes: 17172
#include<bits/stdc++.h>
using namespace std;
vector<int>v;

int main()
{
	int a, b, c, ok=0, i;
	cin>>a>>b>>c;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(),v.end());
	for(i=0; i<v.size()-1; i++)
	{
		if(v[i]!=v[i+1])ok++;
	}
	if(ok==1){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

b = []
(n-1).times do |i|
  b << a[i] - a[i+1]
end

ans = 0
tmp = 0
(n-1).times do |i|
  if b[i] >= 0
    tmp += 1
  else
    ans = tmp if ans < tmp
    tmp = 0
  end
end
ans = tmp if ans < tmp
puts ans.to_s


Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
#define all(v) ((v).begin()),((v).end())
#define clr(v,val) memset(v,val,sizeof v)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
void fast(){
	std::ios_base::sync_with_stdio(0); cin.tie(NULL);
}
const int N = 1e5 + 20;
/***You***Can***Do***It***/
int main()
{
	fast();

	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++){
		cin >> v[i];
	}
	sort(all(v));
	reverse(all(v));
	ll sum = v[0]/2;
	for (int i = 1; i < n; i++){
		sum += v[i];
	}
	cout << sum << endl;
}



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

const int maxn = 200010;

int fa1[maxn], fa2[maxn], r1[maxn], r2[maxn];

map<pair<int, int>, int> mp;

void kexin_init() {
	for (int i=1; i<=maxn; ++i) {fa1[i] = i; fa2[i] = i;}
	memset(r1, 0, sizeof r1);
	memset(r2, 0, sizeof r2);
}

int kexin_find_road(int x) {
	if (fa1[x] == x) return x;
	return fa1[x] = kexin_find_road(fa1[x]);
}
void kexin_Union_road(int x, int y) {
	x = kexin_find_road(x);
	y = kexin_find_road(y);
	if (x == y) return ;
	if (r1[x] < r1[y]) swap(x, y);
	fa1[y] = x;
	if (r1[x] == r1[y]) r1[x]++;
}

int kexin_find_railway(int x) {
	if (fa2[x] == x) return x;
	return fa2[x] = kexin_find_railway(fa2[x]);
}
void kexin_Union_railway(int x, int y) {
	x = kexin_find_railway(x);
	y = kexin_find_railway(y);
	if (x == y) return ;
	if (r2[x] < r2[y]) swap(x, y);
	fa2[y] = x;
	if (r2[x] == r2[y]) r2[x]++;
}
int main() {
	int n, k, l;
	scanf("%d%d%d", &n, &k, &l);
	
	kexin_init();
	for (int i=1; i<=k; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		kexin_Union_road(x, y);
	}
	for (int i=1; i<=l; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		kexin_Union_railway(x, y);
	}
	
	mp.clear();

	for (int i=1; i<=n; ++i) mp[make_pair(kexin_find_road(i), kexin_find_railway(i))]++;
	for (int i=1; i<n; ++i) printf("%d ", mp[make_pair(kexin_find_road(i), kexin_find_railway(i))]);
	printf("%d\n", mp[make_pair(kexin_find_road(n), kexin_find_railway(n))]);

	return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> p(n);
  REP(i, n) cin >> p[i], p[i]--;
  ll ans = 0;
  REP(i, n-1){
    if(p[i] == i){
      swap(p[i], p[i+1]);
      ans++;
    }
  }
  if(p[n-1] == n-1){
    swap(p[n-2], p[n-1]);
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;




int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll m=0,ans=0;
    rep(i,n){
        if(m<=a[i]){
            m=a[i];
        }else{
            ans+=m-a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4832
#include <algorithm>
#include <iostream>

int main()
{
    int n, k;
    std::cin >> n >> k;

    std::string s;
    std::cin >> s;

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            ans++;
        }
    }

    ans = std::min(ans + 2 * k, n - 1);
    std::cout << ans << std::endl;
}


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

map <int, int> c;
int ac[100005];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, p;
  int pen = 0, ans = 0;
  string s;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p >> s;
    if (ac[p] == 0){
      if (s == "AC") {
        ac[p] = 1;
        ans++;
        pen += c[p];
      }else c[p]++;
    }
  }
  cout << ans << " " << pen << '\n';
  return 0;
}

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

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

  ll a, b;
  cin >> a >> b;

  ll g = __gcd(a, b);

  ll ans = 1;

  for (ll i = 2; i * i <= g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) g /= i;
    }
  }
  if (g != 1) ans++;

  cout << ans << endl;

  return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  string sharp;
  vector<string> pic(h), flame(h + 2);
  for (int i = 0; i < h; i++) {
    cin >> pic.at(i);
  }
  for (int i = 0; i < w + 2; i++) {
    sharp += "#";
  }
  for (int i = 0; i < h + 2; i++) {
    if (i == 0 || i == h + 1) {
      flame.at(i) = sharp;
    }
    else {
      flame.at(i) = "#" + pic.at(i - 1) + "#";
    }
    cout << flame.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,pos[1000000];
int main()
{
    n=read();reg int i;
    for(i=1;i<=n;++i)pos[read()]=i;
    for(i=1;i<=n;++i)cout<<pos[i]<<" ";cout<<"\n";
	return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<math.h>
 
int main(){
    int i;
    double n, x[10000], y[10000], d1 = 0, d2 = 0, d3 = 0, dinf = 0, tmp = 0;
    scanf("%lf", &n);
    for(i = 0; i < n; i++) scanf("%lf", &x[i]);
    for(i = 0; i < n; i++) scanf("%lf", &y[i]);
 
    for(i = 0; i < n; i++) d1 += fabs(x[i] - y[i]);
    for(i = 0; i < n; i++) d2 += pow(x[i] - y[i], 2);
    d2 = sqrt(d2);
    for(i = 0; i < n; i++) d3 += pow(fabs(x[i] - y[i]), 3);
    d3 = cbrt(d3);
    tmp = fabs(x[0] - y[0]);
    for(i = 0; i < n; i++){
        if(tmp < fabs(x[i] - y[i])) tmp = fabs(x[i] - y[i]);
    }
    dinf = tmp;
    printf("%lf\n%lf\n%lf\n%lf\n", d1, d2, d3, dinf);
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.gir","r",stdin);freopen ("kmp.cik","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,a[N],b[N],sum,ar[N];

int main()
{
	fast;
	cin>>n;
	fs(a,n+1);
	fo(i,1,n+1)
	ar[i]=a[i];
	fs(b,n);
	fo(i,1,n+1)
	{
		ll x=min(a[i],b[i]);
		a[i]-=x;
		b[i]-=x;
		x=min(b[i],a[i+1]);
		a[i+1]-=x;
		sum+=ar[i]-a[i];
	}
	cout<<sum;





}



/*     cd onedrive\desktop\kod
cls


*/

Measured memory_bytes: 9216
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<ll,ll>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll x,y,a,b,c,p[100005]={},q[100005]={},r[100005]={},ans=0;
  cin >> x >> y >> a >> b >> c;
  vector<ll> v;
  for(int i=0; i<a; i++) {
    cin >> p[i];
  }
  for(int i=0; i<b; i++) {
    cin >> q[i];
  }
  sort(p,p+a,greater<ll>());
  sort(q,q+b,greater<ll>());
  for(int i=0; i<x; i++) {
    v.push_back(p[i]);
  }
  for(int i=0; i<y; i++) {
    v.push_back(q[i]);
  }
  for(int i=0; i<c; i++) {
    cin >> r[i];
    v.push_back(r[i]);
  }
  sort(v.begin(),v.end(),greater<ll>());
  for(int i=0; i<x+y; i++) {
    ans+=v[i];
  }
  cout << ans << endl;
}

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

int main()
{
    int n;  cin >> n;
    vector<int> a(100010);
    for (int i = 0; i < n; i++){
        int in;
        cin >> in;
        a[in]++;    //a[in]には数字inの個数が入っている
    }

    int ans = 0;
    for (int i = 0; i < 100000 - 2; i++){
        ans = max(ans, a[i] + a[i + 1] + a[i + 2]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int data;
	char cast;
	int ans=0;
	scanf("%d",&ans);
	while(1){
		scanf(" %c",&cast);
		if(cast=='='){
			printf("%d\n",ans);
			return 0;
		}
		scanf("%d",&data);
		switch(cast){
			case '+':
				ans=ans+data;
				break;
			case '-':
				ans=ans-data;
				break;
			case '*':
				ans=ans*data;
				break;
			case '/':
				ans=ans/data;
				break;
		}
	}
}

Measured memory_bytes: 596
#include <cstdio>

int main(){
//  freopen("in.in", "r", stdin);
//  freopen("out.out", "w", stdout);
  char ch;
  int r, rez = 0;
  r = 0;
  ch = fgetc(stdin);
  while(ch >= 'A' && ch <= 'Z'){
    if(ch == 'A' || ch == 'T' || ch == 'C' || ch == 'G'){
      r++;
    }
    else{
      if(r > rez)
        rez = r;
      r = 0;
    }
    ch = fgetc(stdin);
  }
  if(r > rez)
    rez = r;
  printf("%d", rez);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  int N;
  cin >> N;
  int N2 = 1 << N;
  vector<ll> S(N2);
  rep(i, N2) {
    cin >> S[i];
  }
  sort(all(S));
  reverse(all(S));  // Elements in S are sorted in decreasing order.

  vector<ll> s;
  s.push_back(S[0]);
  S[0] = -1;

  // O(N * 2**N) ~ O(MlogM) in M = 2**N (< 10 ** 6)
  rep(iter, N) {
    vector<ll> p = s;
    sort(all(p));

    for (int j = 0; p.size() > 0 && j < N2; ++j) { // Search the largest remaining value from S.
      if (S[j] == -1) { continue; }
      if (S[j] < p.back()) {
        p.pop_back();
        s.push_back(S[j]);
        S[j] = -1;
      }
    }

    if (p.size() > 0) {  // Invalid if elmens are remaining in p.
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 5484
n,k=map(int,input().split())
A=list(map(int,input().split()))
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

C=Counter(A)
Q=list(C.values())
Q=sorted(Q,reverse=1)
if len(Q)<k:
    print(0);exit()
print(n-sum(Q[:k]))


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

int main(){
  int n, count = 0;
  cin >> n;
  if(n < 10)
    cout << n << endl;
  else if(n < 100)
    cout << 9 << endl;
  else if(n < 1000)
    cout << 9 + n - 99 << endl;
  else if(n < 10000)
    cout << 909 << endl;
  else if (n < 100000)
    cout << 909 + n - 9999 << endl;
  else
    cout << 90909 << endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

def main():

    N = int(input())
    H = list(map(int, input().split()))

    count = 0
    listA = []

    for i in range(N - 1):
        if H[i] >= H[i+1]:
            count += 1

        else:
            listA.append(count)
            count = 0

    listA.append(count)

    ans = max(listA)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 20312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
typedef unsigned long long ull;
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define testcases ll t;cin>>t;while(t--)
#define dec(x) greater<x>()

/*** Define Values ***/
#define mx 200005
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 100005
const char nl = '\n';

#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))

/*** STLs ***/
typedef vector <ll> vll;
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll , ll> > vpll;

/*** Sorts ***/
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtGreat(v) sort(all(v), greater<ll>())
inline bool cmp(pll a, pll b) { if (a.ff == b.ff)return a.ss < b.ss; return a.ff > b.ff; }

#define en cout << '\n';
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": "

/*** Functions
ll BigMod(ll base, ll pow, ll modvalue){ if (pow == 0) return 1;  ll ans = BigMod(base, pow / 2, modvalue);ll total = ((ans % modvalue) * (ans % modvalue)) % modvalue;  if(pow % 2 == 0) return total; else{ return (total * (base % modvalue) ) % modvalue; } }
ll InverseMod(ll base, ll pow) { if(pow == 0) return 1; ll ans = InverseMod(base, pow / 2); ans = (ans * ans) % mod; if(pow & 1){ return (ans * base) % mod; } else{ return ans; } }
bool checkprime(ll num) { if(num < 2) return false; for(ll i = 2; i * i <= num; i++){ if(num % i == 0) return false; } return true; }
ll EularPHI(ll num) { double ans = num; for(ll i = 2; i * i <= num; i++){ if(num % i == 0){ while (num % i == 0) { num /= i; } ans *= (1.0 - (1.0 / (double)i)); } } if(num > 1) ans *= (1.0 - (1.0 / (double)num)); return (ll)ans; }
ll sumofdigit(long ll n){ll sum=0;while(n){sum=sum+n%10;n=n/10;}return sum;}
ll countDigit(ll n) { if (n == 0) return 0; return 1 + countDigit(n / 10); }
ll countDigit(ll n) { return floor(log10(n) + 1); } //only positive
 ***/

template <class T> inline T gcd(T a, T b) {if (b == 0)return a; return gcd(b, a % b);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd<T>(a, b);}
template <class T> inline T power(T b, T p) {ll ans = 1; while (p--) ans *= b; return ans;}

void solve()
{	
	ll n;cin>>n;
	ll a[n];
	loop(i,0,n)cin>>a[i];

	ll ans=0;
	ll maxn=INT_MIN;
	loop(i,0,n)
	{
		maxn=max(maxn,a[i]);

		if(a[i]<maxn)
		{
			ll z=abs(maxn-a[i]);
			ans+=z;
		}
	}
	cout<<ans;
}


int main()
{

#ifndef ONLINE_JUDGE
	freopen("C:/Users/91731/Documents/input.txt", "r", stdin);
	freopen("C:/Users/91731/Documents/output.txt", "w", stdout);
	freopen("C:/Users/91731/Documents/error.txt", "w", stderr);
#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	solve();
}


Measured memory_bytes: 5164
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e6 + 120;
 



int n ,sum ,x ,a[maxn] ,res;
int main(){FAST;
    cin >> n >> x;
    forp(i ,0 ,n)
        cin >> a[i] ,sum += a[i];
    x -= sum;
    sort(a ,a + n);
    res = n + (x /a[0]);
    out(res);
    
   return 0;
}
 












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

int main() {
    long long n, m, a, b, last = -1, ret = 0;
    std::cin >> n >> m;
    std::vector<std::deque<long long>> v(n);
    for (long long i = 0; i < m; i++) {
        std::cin >> a >> b;
        v[b - 1].push_back(a - 1);
    }

    for (long long i = 0; i < n; i++) {
        for (auto& el : v[i]) {
            if (el > last) {
                //std::cout << i << " " << el << " " << last << std::endl;
                last = i - 1;
                ret++;
                break;
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

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

#define bitGet(a, i) a & (1 << i)
#define bitOn(a, i) a != (1 << i)
#define bitOff(a, i) a &= ~(1 << i)
#define bitMake(a, i) a = (1 << N)
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define ull unsigned long long
#define ll long long
#define ld long double
#define pri(a) cout << a << " "
#define pril(a) cout << a << " "
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define pi pair<int, int>
#define oo INT_MAX
#define maxN

using namespace std;


int main() {
    #ifndef ONLINE_JUDGE
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    #endif // !ONLINE_JUDGE

    int x;
    cin >> x;
    if(x == 0) cout << 1;
    else cout << 0;
    
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>

using namespace std;
int main(int argc, char *argv[])
{

  int A;
  double inte;
  unsigned int S;//面積
  while(scanf("%d",&A)!=EOF){
    inte = A;
    S = 0;
    for(int i =inte;i <= 600-A; i+=inte){
      S += (i)*(i)*inte;
    }
    cout <<S<<endl;
  }

  return 0;
}

Measured memory_bytes: 1204
package main

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

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func main() {
	n, _ := strconv.Atoi(nextLine())
	x := nextIntArray()
	cx := make([]int, n)
	copy(cx, x)
	sort.Ints(cx)
	median := cx[n/2]

	for _, xi := range x {
		if xi < median {
			fmt.Println(median)
		} else {
			fmt.Println(cx[n/2-1])
		}
	}
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}


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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    vector<int>p,m;
    p.push_back(a[n-1]);
    m.push_back(a[0]);
    for(int i=1; i<n-1; ++i){
        if(a[i]<0)m.push_back(a[i]);
        else p.push_back(a[i]);
    }
    vector<P>ans;
    for(int i=1; i<p.size(); ++i){
        ans.push_back(P(m[0],p[i]));
        m[0]-=p[i];
    }
    for(int i=0; i<m.size(); ++i){
        ans.push_back(P(p[0],m[i]));
        p[0]-=m[i];
    }
    cout<<p[0]<<endl;
    rep(i,ans.size()){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}

Measured memory_bytes: 5408
#include <iostream>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int a;
	int b[101];
	cin >> a;
	
	int count=0;
	for (int i = 0; i < a; i++) {
		cin >> b[i];
	}
	for (int i = a-1; i >=0; i--) {

		cout<< b[i];
		if (i == 0) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
	return 0;
}




Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib> //abs　絶対値

using namespace std;

int main() {
	int n, ans;
	cin >> n;
	//vector <int> A(n);
	//for (int i = 0; i < n; i++) {
		//cin >> A[i];
	//}
	
	if (n == 1) { ans = 1; }
	else if (n == 2) { ans = 2; }
	else if (n < 4) { ans = 2; }
	else if (n < 8) { ans = 4; }
	else if (n < 16) { ans = 8; }
	else if (n < 32) { ans = 16; }
	else if (n < 64) { ans = 32; }
	else { ans = 64; }

	//sort(A.begin(), A.end());

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    if N<K:print(0)
    else:print(10)




if __name__ == "__main__":
    main()

Measured memory_bytes: 77312
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n;
    cin>>n;
    vl a(n+2);
    map<ll, ll> mp1;
    for(ll i=1; i<=n; i++)
    mp1[i]=0;
    for(ll i=2; i<=n+1; i++)
    {
        cin>>a[i];
        mp1[a[i]]++;
    }
    forr1(i, n)
    cout<<mp1[i]<<endl;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 17200
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

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

	vector<int> A(N);
	vector<int> B(N);

	rep(i, N)
	{
		cin >> A[i] >> B[i];
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	int ans;
	if (N % 2 != 0)
	{
		int l = A[(N-1)/2];
		int r = B[(N-1)/2];

		ans = r - l + 1;
	}
	else
	{
		int l = A[N/2] + A[N/2 - 1];
		int r = B[N/2] + B[N/2 - 1];

		ans = r - l + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4840
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
dp = [[0]*3 for i in range(N+1)]
for i in range(1,N+1):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k],dp[i-1][j]+A[i-1][k])
print(max(dp[-1]))

Measured memory_bytes: 47344
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			b[i] = a[i];
		}
		sc.close();
		Arrays.sort(b);
		int max = b[n - 1];
		int max2 = b[n - 2];
		int ans = max;
		for (int i = 0; i < n; ++i) {
			if (max != a[i])
				ans = max;
			else
				ans = max2;

			System.out.println(ans);
		}
	}
}


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

int main() {
  int N , A , min = 10000000,kaunto = 0;
  cin >> N ;
  for (int i = 0; i < N; i++){
    cin >> A;
    while (A % 2 == 0){
      kaunto++;
      A = A / 2;
    }
    if (min > kaunto){
      min = kaunto;
    }
    kaunto = 0;
  }
  cout << min << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 300010;
const int MAXM = 110;
const int MAXK = 510;

int n, k;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    ld res = 0;
    FOR(i,1,n)
        if (i < k) {
            ld prob = 1.0 / n;
            int g = i;
            while (g < k) {
                g *= 2;
                prob *= 0.5;
            }
            res += prob;
        }
        else res += 1.0 / n;
    cout << fixed << setprecision(9) << res;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int naive(int N, int K, vector<int> &P){
    set<vector<int>> st;
    for(int i=0; i<=N-K; i++){
        vector<int> v(K);
        for(int j=0; j<K; j++)
            v[j] = P[i+j];
        sort(v.begin(), v.end());

        vector<int> vv = P;
        for(int j=0; j<K; j++)
            vv[i+j] = v[j];

        st.insert(vv);
    }

    //for(auto x : st){
    //    for(auto y : x)
    //        cerr << y << " ";
    //    cerr << endl;
    //}

    return st.size();
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    for(int i=0; i<N; i++)
        cin >> P[i];

    //cerr << "NAIVE\n" << naive(N, K, P) << endl;

    bool flg = false;
    vector<bool> v(N);
    int cur = 0;
    for(int i=0; i<N-1; i++){
        if(P[i+1] > P[i]) cur++;
        else cur = 0;
        //cerr << cur << endl;
        if(cur >= K-1){
            v[i-K+2] = true;
            flg = true;
        }
    }

    //for(int i=0; i<N; i++)
    //    cerr << v[i] << " ";
    //cerr << endl;

    set<int> st;
    for(int i=0; i<K; i++)
        st.insert(P[i]);


    int ans = 1;
    for(int i=0; i<N-K; i++){
        st.insert(P[i+K]);

    //for(auto x : st)
    //    cerr << x << " ";
    //cerr << endl;
        int mn = *st.begin();
        int mx = *st.rbegin();
        st.erase(P[i]);

    //    cerr << i+1 << endl;
    //    cerr << mn << " " << mx << endl;
        if(P[i] == mn && P[i+K] == mx) continue;
        if(!v[i+1]){
    //        cerr << "ADD" << i+1 << endl;
            ans++;
        }
    }
    if(!v[0] && flg){
     //   cerr << "HOGE" << endl;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=3e3+5;
const int mod=1e9+7;
const ll oo=1e18+5;


int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int i=0;i<n;++i) cin>>h[i];
	sort(h.begin(),h.end());
	ll ans=0;
	for(int i=n-1;i>=0;--i){
		if(k>0){
			--k;
			continue;
		}
		ans+=h[i];
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

int main(){

	int N, M, tmp, A=INT_MIN, B=INT_MAX;	cin>>N>>M;

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

		cin>>tmp;

		A=max(A, tmp);

		cin>>tmp;

		B=min(B, tmp);

	}

	if(A>B)

		cout<<0;

	else

		cout<<min(B-A+1, N-A+1);

}

Measured memory_bytes: 256
#include <stdio.h>

typedef unsigned long long ull;

int main(){
	ull n;
	scanf("%llu", &n);
	ull ans = 0;
	for(ull i = 1; i <= n; ++i){
		for(ull j = 1; i * j <= n; ++j){
			ans += i * j;
		}
	}
	printf("%llu\n", ans);
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( ll i = 0;i < (ll) n;++i)
vector<ll> dx = {-1,0,1,0};
vector<ll> dy = {0,1,0,-1};


int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i,n) cin >> h.at(i);

  vector<vector<ll>> v(n);
  rep(i,m){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    v.at(a).push_back(b);
    v.at(b).push_back(a);
  }
  ll ans = 0;
  rep(i,n){
    if( v.at(i).size() == 0 ) ans++;
    rep(j,v.at(i).size()){
      if( h.at(v.at(i).at(j)) >= h.at(i) ) break;
      if( j == (ll)(v.at(i).size()-1) ){
        ans++;
        //cout << i << endl;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n,m,k;
	cin >> n >> m >> k;
	if(k == 0){
		cout << "Yes" << endl;
		return 0;
	}
	REP(i, m+1){
		REP(j, n+1){
			int now = n * i + (m - i * 2) * j;
			if(now == k){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
Wcum=[0]*(N+1)
Bcum=[0]*(N+1)
for i in range(N):
    Wcum[i+1]=Wcum[i]+(S[i]=='.')
    Bcum[i+1]=Bcum[i]+(S[i]=='#')
ans=N
for i in range(N+1):
    ans=min(ans,(i-Wcum[i])+(N-i-(Bcum[N]-Bcum[i])))
print(ans)

Measured memory_bytes: 24884
import sys
sys.setrecursionlimit(10**6)

def get_par(x):
  if x == par_list[x]:
    return x
  else:
    par_list[x] = get_par(par_list[x])
    return par_list[x]

N,M=map(int,input().split())
edge_list = []
for i in range(M):
  Ai,Bi=map(int,input().split())
  edge_list.append((Ai,Bi))
  
inconv = N*(N-1)//2
inconv_list_rev = [inconv]
par_list = list(range(N))
size_list = [1]*N
for Ai,Bi in reversed(edge_list):
  par_A = get_par(Ai-1)
  par_B = get_par(Bi-1)
  if par_A != par_B:
    size_A = size_list[par_A]
    size_B = size_list[par_B]
    par_list[par_B] = par_A
    size_list[par_A] += size_list[par_B]        
    inconv -= size_A*size_B
  inconv_list_rev.append(inconv)
    
for con in reversed(inconv_list_rev[:-1]):
  print(con)


Measured memory_bytes: 37908
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 2005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,m,q,v[N][N],xe[N][N],ye[N][N];
char s[N][N];
int main()
{
	re(n),re(m),re(q);
	for(int i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			v[i][j]=s[i][j]-'0'+v[i-1][j];
			xe[i][j]=(s[i][j]=='1'&&s[i-1][j]=='1')+xe[i-1][j];
			ye[i][j]=(s[i][j]=='1'&&s[i][j-1]=='1')+ye[i][j-1];
		}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			v[i][j]+=v[i][j-1];
			xe[i][j]+=xe[i][j-1];
			ye[i][j]+=ye[i-1][j];
		}
	for(int a,b,c,d;q--;)
	{
		re(a),re(b),re(c),re(d);
		int ans=v[c][d]+v[a-1][b-1]-v[a-1][d]-v[c][b-1];
		ans-=xe[c][d]-xe[a][d]-xe[c][b-1]+xe[a][b-1];
		ans-=ye[c][d]-ye[a-1][d]-ye[c][b]+ye[a-1][b];
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 52864
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int a,b,k;
    while(cin>>k>>a>>b)
    {
        double result = ceil(a/(double)k);
       // cout<<result<<endl;
        result=result*k;
        //cout<<result<<endl;
        if(result>=a && b>=result)
            cout<<"OK\n";
        else
            cout<<"NG\n";
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    for(ll i=0;i<s.length();i++)
    {
        s[i]=(char)((((s[i]-'A')+n)%26)+'A');
    }
    cout<<s;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            if l[i]+l[j] > l[k] and l[j]+l[k] > l[i] and l[k]+l[i] > l[j]:
                ans += 1
print(ans)

Measured memory_bytes: 9136
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
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
A, B = MAP()
 
if A >= 13:
  print(B)
  exit()
if A <= 5:
  print(0)
  exit()
print(B//2)

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

int hachTable[250000000];

int getNum(char c){
    switch (c) {
        case 'A':
            return 1;
        case 'C':
            return 2;
        case 'G':
            return 3;
        case 'T':
            return 4;
        default:
            return 0;
    }
}

int getKey(char *str) {
    int i,cou = 0;
    for(i = 0;i < strlen(str); i++) {
        cou *= 5;
        cou += getNum(str[i]);
    }
    return cou;
}

void insert(char *str){
    int key = getKey(str);
    hachTable[key] = 1;
}

int find(char *str){
    int key = getKey(str);
    return hachTable[key];
}

int main(){
    int n;
    scanf("%d",&n);
    int i;
    char cmd[10];
    char str[15];
    for(i = 0;i < n; i++) {
        scanf("%s%s", cmd, str);
        if(strcmp(cmd, "insert") == 0) {
            insert(str);
        }else if(strcmp(cmd, "find") == 0) {
            if(find(str))printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}



Measured memory_bytes: 18676
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string S;
  cin >> S;
  if(S.size() <4) {
    cout << "No" << endl;
    return 0;
  }
  if(S.substr(0,4) == "YAKI") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string S, T;
    cin >> S >> T;
    char to[26];
    for(int i = 0; i < 26; i++) to[i] = '-';

    for(int i = 0; i < S.size(); i++) {
        if(to[(int)S[i] - (int)'a'] != '-') {
            if(to[(int)S[i] - (int)'a'] != T[i]) {
                cout << "No\n";
                return 0;
            }
        }
        to[(int)S[i] - (int)'a'] = T[i];
    }
    sort(to, to + 26);
    for(int i = 25; i >= 1; i--) {
        if(to[i] == '-') break;
        if(to[i - 1] == to[i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 776
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		
		int count = 0;
		
		for(int i = 0 ; i <= A ; i++){
			for(int j = 0 ; j <= B ; j++ ){
				for(int k = 0 ; k <= C ; k++ ){
					int S = 500 * i + 100 * j + 50 * k ;
					if( S == X){
						count ++ ;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22224
import java.util.Scanner;

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

		String a=sc.next();

		int[] cmj=new int[26];

		for(int i=0; i<a.length(); i++) {
			cmj[a.charAt(i)-97]++;
		}

		for(int i=0; i<26; i++) {
			if(cmj[i]%2==1) {
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 22996
#include<iostream>

using namespace std;

int main() {
	int X;

	cin >> X;

	int kouka_500 = X / 500;
	int kouka_5 = (X - 500 * kouka_500) / 5;

	cout << kouka_500 * 1000 + kouka_5 * 5 << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define f(a,b) ((x[i]-x[(i+1)%3])*(b-y[i])-(y[i]-y[(i+1)%3])*(a-x[i]))
int main(){double x[4],y[4];while(cin>>x[0]>>y[0]){for(int i=1;i<4;i++) cin>>x[i]>>y[i];bool f=false;for(int i=0;i<3;i++){if(f(x[(i+2)%3],y[(i+2)%3])*f(x[3],y[3])<0){f = true;break;}}if(f) cout<<"NO\n";else cout<<"YES\n";}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
  int a[3];
  int ans = 0;
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  ans = a[2] - a[1];
  if ((a[2] - a[0] - ans) % 2 == 0)
    ans +=(a[2] - a[0] - ans) / 2;
  else
    ans +=(a[2] - a[0] - ans) / 2 + 2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
struct A
{
    int x,y,flag;

} a[110],b[110];
int cmp(A a,A b)
{
    if(a.x!=b.x)
    {
        return a.x<b.x;
    }
    return a.y<b.y;
}
int main()
{
    int n;
    ll sum=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].flag=0;
    }
    for(int i=0; i<n; i++)
    {
        cin>>b[i].x>>b[i].y;
    }
    sort(a,a+n,cmp);
    sort(b,b+n,cmp);
    for(int i=0; i<n; i++)
    {
        int flag=0,p=-1;
        for(int j=0;a[j].x<=b[i].x&&j<n; j++)
        {
            if(a[j].x<b[i].x&&a[j].y<b[i].y&&!a[j].flag)
            {
                if(!flag)
                {
                    p=j;
                }
                else if(a[j].y>a[p].y)
                {
                    p=j;
                }
                flag=1;
            }

        }
        if(flag)
        {
            sum++;
            a[p].flag=1;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static Map<Integer,Integer> map = new HashMap<Integer,Integer>();
	public static int max = 0;

    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			int in1 = Integer.parseInt(br.readLine());
			String[] in2 = br.readLine().split(" ");

			for(String str :in2){
				int key = Integer.parseInt(str);
				setMap(key,0);
				setMap(key,+1);
				setMap(key,-1);
			}

			System.out.println(max);

		} catch (Exception e) {
			System.exit(0);
		}
    }

    public static void setMap(int key, int num){
		int key2 = key+num;
		int val = 0;
		if(map.containsKey(key2)){
			val = map.get(key2);
		}
		val += 1;
		map.put(key2, val);
		if(val > max){
			max = val;
		}
    }
}


Measured memory_bytes: 47244
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int_;
inline int readint() {
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0' or c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c and c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}
void writeint(int_ x){
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) writeint(x/10);
	putchar((x%10)^48);
}
# define MB template < typename T >
MB void getMax(T &a,const T &b){ if(a < b) a = b; }
MB void getMin(T &a,const T &b){ if(b < a) a = b; }
# define FOR(i,n) for(int i=0; i<(n); ++i)

struct Edge{
	int to, nxt;
	Edge(){}
	Edge(int T,int N):to(T),nxt(N){}
};

const int MaxN = 200005, infty = (1<<30)-1;
int a[MaxN], head[MaxN], n;
Edge edge[MaxN<<1];

int cntEdge;
void addEdge(int x,int b){
	edge[cntEdge] = Edge(b,head[x]);
	head[x] = cntEdge ++;
	edge[cntEdge] = Edge(x,head[b]);
	head[b] = cntEdge ++;
}

int g[MaxN], ans[MaxN], sxy[MaxN];
void dfs(int x,int pre){
	ans[x] = lower_bound(g+1,g+n+1,a[x])-g;
	int origin = g[ans[x]];
	g[ans[x]] = a[x];
	sxy[x] = max(sxy[pre],ans[x]);
	for(int i=head[x]; ~i; i=edge[i].nxt)
		if(edge[i].to != pre)
			dfs(edge[i].to,x);
	g[ans[x]] = origin;
}

int main(){
	n = readint();
	for(int i=1; i<=n; ++i){
		a[i] = readint();
		head[i] = -1, g[i] = infty;
	}
	for(int i=1; i<n; ++i)
		addEdge(readint(),readint());
	dfs(1,0);
	for(int i=1; i<=n; ++i)
		printf("%d\n",sxy[i]);
	return 0;
}

Measured memory_bytes: 25156