akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int a, b;
string s;
int main() {
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H, W, M = map(int,readline().split())
h_cnt = [0]*(H+1)
w_cnt = [0]*(W+1)
bomb = []
 
for i in range(M):
    h,w = map(int,readline().split())
    bomb.append((h,w))
    h_cnt[h] += 1 
    w_cnt[w] += 1
    
maxh = max(h_cnt)
maxw = max(w_cnt)
maxhCnt = h_cnt.count(maxh)
maxwCnt = w_cnt.count(maxw)

total = maxhCnt*maxwCnt
ans = maxh+maxw
cnt = 0
for h,w in bomb:
    if h_cnt[h] == maxh and w_cnt[w] == maxw:
       cnt += 1

print(ans-1 if cnt == total else ans) 

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

int main(){
  long long int a,b,x;
  cin >> a >> b >> x;
  if(a==0 && b==0){
    cout << 1 << endl;
  }
  else if(a==0){
    cout << b/x + 1 << endl;
  }
  else{
    cout << b/x - (a-1)/x << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
int n,m;char a[503][503];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++){
	  for(int j=1;j<=m;j++)
		putchar(a[i][j]=='#'||( i&1)&&i>1&&i<n&&j>1&&j<m||j==1?'#':'.');
	  puts("");
	}
	puts("");
	for(int i=1;i<=n;i++){
	  for(int j=1;j<=m;j++)
		putchar(a[i][j]=='#'||(~i&1)&&i>1&&i<n&&j>1&&j<m||j==m?'#':'.');
	  puts("");
	}
	return 0;
}

Measured memory_bytes: 1884
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int n;
  cin>>n;
  int x[n],y[n];
  char d[n];
  for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>d[i];
  int INF=1LL<<55LL;
  map<P,int> m;
  for(int i=0;i<n;i++) m[P(x[i],y[i])]=i;
  vector<int> cx,cy;
  cx.push_back(INF);
  cx.push_back(-INF);
  cy.push_back(INF);
  cy.push_back(-INF);
  for(int i=0;i<n;i++){
    cx.push_back(x[i]);
    cy.push_back(y[i]);
  }
  sort(cx.begin(),cx.end());
  cx.erase(unique(cx.begin(),cx.end()),cx.end());
  sort(cy.begin(),cy.end());
  cy.erase(unique(cy.begin(),cy.end()),cy.end());
  map<int,int> rx,ry;
  for(int i=0;i<(int)cx.size();i++) rx[cx[i]]=i;
  for(int i=0;i<(int)cy.size();i++) ry[cy[i]]=i;
  vector<set<int> > tx(cx.size()),ty(cy.size());
  for(auto& s:tx){
    s.insert(ry[INF]);
    s.insert(ry[-INF]);
  }
  for(auto& s:ty){
    s.insert(rx[INF]);
    s.insert(rx[-INF]);
  }
  for(int i=0;i<n;i++){
    tx[rx[x[i]]].insert(ry[y[i]]);
    ty[ry[y[i]]].insert(rx[x[i]]);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    vector<set<int> > sx=tx,sy=ty;
    int px=rx[x[i]],py=ry[y[i]];
    char pd=d[i];
    int tmp=0;
    while(1){
      tmp++;
      int bx=px,by=py;
      auto latte=sx[px].find(py);
      auto malta=sy[py].find(px);
      if(pd=='>') ++malta;
      if(pd=='<') --malta;
      if(pd=='v') ++latte;
      if(pd=='^') --latte;
      px=*malta;
      py=*latte;
      pd=d[m[P(cx[px],cy[py])]];
      if(abs(cx[px])==INF||abs(cy[py])==INF) break;
      sx[bx].erase(by);
      sy[by].erase(bx);
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#include <cmath>
#include <regex>
#include <fstream>

#define ll long long

#define MOD 1000000007

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;

	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

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

        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            long T = sc.nextLong();
            long[] t = new long[N + 2];
            t[0] = 0;
            t[N + 1] = Long.MAX_VALUE;

            for (int i = 0; i < N; i++) {
                t[i + 1] = sc.nextLong();
            }

            long ans = 0;
            for (int i = 1; i < N + 2; i++) {
                long diff = t[i] - t[i - 1];
                long plus = diff > T ? T : diff;
                ans += plus;
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 63468
#include <stdio.h>
int main(void)
{
	int v, l,s,a;
	v = 0;
	l = 0;
	scanf("%d",&v);
	scanf("%d",&l);
	s = v * l;
	a =v+v+l+l;
	printf("%d %d\n", s, a);

	return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll L;
string S[100009];
ll ans=0;

int BS(int x, int y, int d){
    if(y-x<2) return x;
    int z=(x+y)/2;
    return S[z][d]=='0'?BS(z,y,d):BS(x,z,d);
}

void dfs(int x, int y, ll d){
    if(x==y){
        ll z=L-d;
        ans^=(z&-z);
        return;
    }
    if(x+1==y&&S[x].size()==d+1) return;
    int z=BS(x-1,y,d+1);
    dfs(x,z+1,d+1);
    dfs(z+1,y,d+1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>L;
    rep(i,N) cin>>S[i];
    sort(S,S+N);
    int z=BS(-1,N,0);
    dfs(0,z+1,0);
    dfs(z+1,N,0);
    cout1((ans?"Alice":"Bob"));
}

Measured memory_bytes: 4432
s = list(input())
t = list(input())
flag = True

lists = []
listt = []
lists.append(s.count("a"))
lists.append(s.count("b"))
lists.append(s.count("c"))
lists.append(s.count("d"))
lists.append(s.count("e"))
lists.append(s.count("f"))
lists.append(s.count("g"))
lists.append(s.count("h"))
lists.append(s.count("i"))
lists.append(s.count("j"))
lists.append(s.count("k"))
lists.append(s.count("l"))
lists.append(s.count("m"))
lists.append(s.count("n"))
lists.append(s.count("o"))
lists.append(s.count("p"))
lists.append(s.count("q"))
lists.append(s.count("r"))
lists.append(s.count("s"))
lists.append(s.count("t"))
lists.append(s.count("u"))
lists.append(s.count("v"))
lists.append(s.count("w"))
lists.append(s.count("x"))
lists.append(s.count("y"))
lists.append(s.count("z"))
listt.append(t.count("a"))
listt.append(t.count("b"))
listt.append(t.count("c"))
listt.append(t.count("d"))
listt.append(t.count("e"))
listt.append(t.count("f"))
listt.append(t.count("g"))
listt.append(t.count("h"))
listt.append(t.count("i"))
listt.append(t.count("j"))
listt.append(t.count("k"))
listt.append(t.count("l"))
listt.append(t.count("m"))
listt.append(t.count("n"))
listt.append(t.count("o"))
listt.append(t.count("p"))
listt.append(t.count("q"))
listt.append(t.count("r"))
listt.append(t.count("s"))
listt.append(t.count("t"))
listt.append(t.count("u"))
listt.append(t.count("v"))
listt.append(t.count("w"))
listt.append(t.count("x"))
listt.append(t.count("y"))
listt.append(t.count("z"))

for i in range(26):
    if max(lists) == max(listt):
        lists.remove(max(lists))
        listt.remove(max(listt))
    else:
        flag = False
        break

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

Measured memory_bytes: 6892
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var m = input[0];
        var a = input[1];
        var b = input[2];
        if (b <= m)
        {
            Console.WriteLine(0);
        }
        else if (b <= m + a)
        {
            Console.WriteLine(b - m);
        }
        else
        {
            Console.WriteLine("NA");
        }
    }
}


Measured memory_bytes: 18412
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var h = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            if (h == 0 && w == 0) break;
            var s = "";
            for (int i = 0; i < w; i++)
                s += "#";
            for (int i = 0; i < h; i++)
                Console.WriteLine(s);
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8876
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
const int mod=998244353;
//const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int d[100005];
map<int,int> sz;
map<int,int> vert;
map<int,int> par;
vi gra[100005];
pii dfs(int at) {
	pii ans={0,1};
	for(int i:gra[at]) {
		pii lol=dfs(i);
		ans.fi+=lol.fi;
		ans.se+=lol.se;
	}
	ans.fi+=ans.se;
	return ans;
}
void solve() {
	int n;
	cin>>n;
	fr(i,1,n) {
		cin>>d[i];
		vert[d[i]]=i;
		sz[d[i]]=1;
	}
	sort(d+1,d+n+1);
	for(int i=n; i>1; i--) {
		int tol=d[i]-n+2*sz[d[i]];
		if(tol>=d[i]||vert.find(tol)==vert.end()) {
			cout<<-1<<endl;
			return;
		}
		par[d[i]]=tol;
		sz[tol]+=sz[d[i]];
	}
	fr(i,2,n)
		gra[vert[par[d[i]]]].pb(vert[d[i]]);
	if(dfs(vert[d[1]]).fi!=n+d[1])
		cout<<-1<<endl;
	else
		fr(i,2,n)
			cout<<vert[d[i]]<<" "<<vert[par[d[i]]]<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


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

ll n;

int main() {
  vector<ll> v(4);
  rep (i, 4) {
    cin >> v[i];
  }
  cin >> n;
  n *= 4;
  vector<ll> want(4, 0);
  vector<P> vperL(4);
  rep (i, 4) {
    vperL[i] = make_pair(v[i] * 12 / pow(2, i), i);
  }
  ll ans = 0;
  sort(vperL.begin(), vperL.end());
  rep (i, 4) {
    ans += (n/(ll)pow(2, vperL[i].second)) * v[vperL[i].second];
    n %= (ll)pow(2, vperL[i].second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4108
N = int(input())
ls = list(map(int,input().split()))
    
Pls = [0] * (10**6+1)

for i in ls:
    Pls[i] += 1

ii = 0
for j in range(len(Pls)):
    if Pls[j] == 0:
        continue
    elif Pls[j] == 1:
        ii += 1
        t = 2*j
        while t <= 10**6:
            Pls[t] = 0
            t += j
    else:
        t = 2*j
        while t <= 10**6:
            Pls[t] = 0
            t += j

print(ii)


Measured memory_bytes: 32212
var
  a,b,c,i,j:longint;
  s,s2:string;
begin
  readln(s);
  j:=maxlongint;
  if length(s)<3 then begin val(s,b,c); writeln(abs(b-753)); halt; end;
  for i:=1 to length(s)-2 do
  begin
    s2:=copy(s,i,3);
    val(s2,b,c);
    if j>abs(b-753) then j:=abs(b-753);
  end;
  writeln(j);
end.

Measured memory_bytes: 128
#include <string>
#include <time.h>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN 228228
#define MOD 1000000007
ll x, y, n, m, k, R, C;
ll a[MAXN], rsz[MAXN], csz[MAXN];
vector<ll> g;
struct info {
    ll siz;
    ll type;
    ll row;
};

bool operator <(const info& x, const info &y) {
    return (std::tie(x.siz, x.type, x.row) < std::tie(y.siz, y.type, y.row));
}

struct shit {
    ll val;
    ll x;
    ll y;
};

bool operator <(const shit& x, const shit& y) {
    return x.val < y.val;
}

ll p[MAXN], s[MAXN], h[MAXN];

int dsu_get (int v) {
    return (v == p[v]) ? v : (p[v] = dsu_get (p[v]));
}

void dsu_unite (int a, int b) {
    a = dsu_get (a);
    b = dsu_get (b);
    if (rand() & 1)
        swap (a, b);
    if (a != b) {
        p[a] = b;
        s[b] += s[a];
        h[b] += h[a];
    }
}

vector<shit> f;
int main() {
    cin >> n >> R >> C;
    for (int i = 0; i < n; i++ ){
        ll x, y, z;
        cin >> x >> y >> z;
        f.push_back({z, x, y + R});
    }
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());
    for (int i = 1; i <= R+C; i++) {
        p[i] = i;
        s[i] = 1;
        h[i] = 1;
    }

    ll ans = 0;
    for (auto v : f) {
        ll x = dsu_get(v.x);
        ll y = dsu_get(v.y);
        ll val = v.val;
        if (x == y) {
            if (h[x] == s[x]) {
                h[x]++;
                ans += val;
            }
        } else {
            if (h[x] + h[y] <= s[x] + s[y] + 1) {
                dsu_unite(x, y);
                ans += val;
            }
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=a;i>n;i--)
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define MOD 1000000007

int main() 
{ 
	FAST;
	lli a,b,k;
	cin>>a>>b>>k;
	lli temp = 0;
	cout<<max(temp,a-k)<<"	"<<max(temp,min(b,a+b-k))<<endl;
    return 0;
}

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

int main(void){
	int x[110], y[110], h[110];
	int n, h0 = 0;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> x[i] >> y[i] >> h[i];
		if(h[i] == 0) h0++;
	}
	if(n == 1){
		cout << x[0] << " " << y[0] << " " << h[0] << endl;
		return 0;
	}
	for(int i = 0; i <= 100; ++i){
		for(int j = 0; j <= 100; ++j){
			int h_ = -1;
			int c = 0;
			for(int k = 0; k < n; ++k){
				if(h[k] == 0){
					continue;
				}
				if(h_ == -1){
					h_ = max(h[k] + abs(i - x[k]) + abs(j - y[k]), 0);
					c++;
					continue;
				}
				if(h_ == max(h[k] + abs(i - x[k]) + abs(j - y[k]), 0)) c++;
			}
			if(c == n - h0 && h_ >= 1){
				int flag = 1;
				for(int k = 0; k < n; ++k){
					if(h[k] == 0){
						if(h_ > abs(i - x[k]) + abs(j - y[k])){
							flag = 0;
							break;
						}
					}
				}
				if(flag == 1){
					cout << i << " " << j << " " << h_ << endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var numsS = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.ReadLine();
            var numsT = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = 0;

            for (int i = 0; i < numsT.Length; i++)
            {
                var right = numsS.Length;
                var left = 0;
                var mid = 0;

                while (left < right)
                {
                    mid = (left + right) / 2;
                    if (numsT[i] == numsS[mid])
                    {
                        ans++;
                        break;
                    }
                    else if (numsT[i] < numsS[mid])
                    {
                        right = mid;
                    }
                    else
                    {
                        left = mid + 1;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 18076
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll ans=0;
	for(int a=1;a<=n;a++)
	{
		if(a%3==0)
		continue;
		else if(a%5==0)
		continue;
		else 
		ans+=a;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3652
def check(num):
  if num == "":return False
  if num[0] == "0":return num == "0"
  return 0 <= int(num) <= 255
s = input()
ans = 0
for i in range(1, 4):
  for j in range(1, 4):
    for k in range(1, 4):
      n1 = s[:i]
      n2 = s[i:i+j]
      n3 = s[i+j:i+j+k]
      n4 = s[i+j+k:]
      if check(n1) and check(n2) and check(n3) and check(n4):ans += 1
print(ans)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,x,y,z;
  cin>>n>>x>>y>>z;
  vector<vector<int>> dp(n+1,vector<int>((1<<(x+y+z-1)),0));
  int mask=(1ll<<(x+y+z-1))-1;
  int ng=(1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));
  dp[0][0]=1;
  rep(i,n){
    rep(S,1<<(x+y+z-1)){
      if((S & ng)==ng) continue;
      FOR(j,1,11){
        int T=(S<<j) | (1<<(j-1));
        if((T & ng)==ng) continue;
        T&=mask;
        (dp[i+1][T]+=dp[i][S])%=mod;
      }
    }
  }
  ll ans=1;
  rep(i,n) (ans*=10)%=mod;
  rep(i,1<<(x+y+z-1)) (ans-=dp[n][i])%=mod;
  cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 11136
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

typedef deque<bool> db;
typedef deque<db> ddb;

#define INF 1e8

int n;
vvi board;
int cnt;

void manipulate(int i, int j) {
  cnt += 1;
  vi tmp = board[i];
  rep (k, n) {
    board[k][j] = tmp[k];
  }
}

int main() {
  scanf("%d", &n);
  board.assign(n, vi(n, 0));
  db exist_j(n, false);
  bool impossible = true;
  vi filled_i(n, 0);
  rep (i, n) {
    char tmp;
    rep (j, n) {
      scanf(" %c", &tmp);
      if (tmp == '#') {
        board[i][j] = 1;

        exist_j[j] = true;
        filled_i[i] += 1;

        impossible = false;
      }
    }
  }
  if (impossible) {
    printf("-1\n");
    return 0;
  }
  vi needed_to_fill(n, 0);
  rep (i, n) {
    if (filled_i[i] == n) {
      continue;
    }
    if (exist_j[i]) {
      needed_to_fill[i] = n - filled_i[i];
      continue;
    }
    needed_to_fill[i] = n - filled_i[i] + 1;
  }
  int min_row = 0;
  rep (i, n) {
    if (needed_to_fill[min_row] > needed_to_fill[i]) {
      min_row = i;
    }
  }

  cnt = 0;
  if (!exist_j[min_row]) {
    rep (i, n) {
      rep (j, n) {
        if (board[i][j] == 1) {
          manipulate(i, min_row);
          i = n;
          break;
        }
      }
    }
  }
  if (board[min_row][min_row] == 0) {
    int dup_from = 0;
    rep (i, n) {
      if (board[i][min_row] == 1) {
        dup_from = i;
        break;
      }
    }
    manipulate(dup_from, min_row);
  }
  rep (j, n) {
    if (board[min_row][j] == 0) {
      manipulate(min_row, j);
    }
  }
  rep (j, n) {
    rep (i, n) {
      if (board[i][j] == 1) {
        continue;
      }
      manipulate(min_row, j);
      break;
    }
  }
  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

const int MAX_N = 10000010;

bool isPrime[MAX_N];
void eratosthenes(int n){
    for(int i=0; i<=n; i++) isPrime[i] = true;
    isPrime[0] = false, isPrime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(isPrime[i]){
            for(int j=2; i*j<=n; j++){
                isPrime[i*j] = false;
            }
        }
    }
}

int main(){
    eratosthenes(10000000);

    while(1){
        int m, n; cin>>m>>n;
        if(m == 0) return 0;

        int cnt=0;
        for(int i=m; ; i++){
            int num = i;

            bool canCount = true;
            if(!isPrime[num]){ 
                for(int j=2; j*j<=num; j++){
                    if(num % j == 0){
                        if(m <= num / j){
                            canCount = false;
                        }

                        break;
                    }
                }
            }

            if(cnt < n && canCount){
                cnt++;
            }
            else if(cnt == n && canCount){
                cout << num << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 12836
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val n = f.readLine().toInt()
	val array = f.readLine().split(" ").map{it.toLong()}.toLongArray().sortedDescending()

	var answer = array[0]

	var i = 1
	while(i < n-1){
		answer += array[(i+1)/2]
		i++
	}

	println(answer)
}


Measured memory_bytes: 76500
import sys

n, x = map(int, input().split())

a = list(map(int, input().split()))

a.sort()

cnt_children = 0
for i in range(n):
    if x >= a[i]:
        cnt_children += 1
        x -= a[i]
    else:
        break

if x > 0 and cnt_children == n:
    cnt_children -= 1

print("{}".format(cnt_children))

# cnt_candy = 0
# cnt_children = 0
# for item in a:
#     if cnt_candy < x:
#         cnt_candy += item
#         cnt_children += 1

# if cnt_candy != x:
#     cnt_children -= 1

# print("{}".format(cnt_children))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long a;
    cin >> a;
    int b;
    b = a % 10;
    if (b == 2 || b == 4 || b == 5 || b == 7 || b == 9) {
        cout << "hon" << endl;
    } else if (b == 3) {
        cout << "bon" << endl;
    } else {
        cout << "pon" << endl;
    }
}

Measured memory_bytes: 3656
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

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

    vi v(61);
    for(int i=1;i<=60;++i)
        v[i]+=v[i-1]+i;

    int ans=0;
    for(int i=2;i*i<=n;++i)
    {
        int cnt=0;
        while(n%i==0)
        {
            n/=i;
            ++cnt;
        }

        //if(cnt)
        //    cout<<cnt<<" ";

        ans+=(--upper_bound(all(v),cnt))-begin(v);
    }

    if(n>1)
        ++ans;

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (d == 1)cout << 1 << endl;
	else cout << 0 << endl;
}

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

int main(void)
{
    int n;
    int w[100];
    int i, j, t1, t2;
    int Abs = 100;
    int tAbs;

    scanf("%d", &n);
    for(i=0;i<n;i++)
    {
        scanf("%d", &w[i]);
    }
    for(i=0,t1=0;i<n;i++)
    {
        t1+=w[i];
        for(j=i+1,t2=0;j<n;j++)
        {
            t2+=w[j];
        }
        tAbs=abs(t1-t2);
        Abs=tAbs<Abs?tAbs:Abs;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
double dp[3005][3005],p[3005];
void solve(){
    int n;
    cin>>n;
    rep1(i,n) cin>>p[i];
    dp[1][1]=p[1],dp[1][0]=1.0-p[1];
    fr(i,2,n){
        fr(j,0,i){
            if(j) dp[i][j]+=dp[i-1][j-1]*p[i];
            dp[i][j]+=dp[i-1][j]*(1.0-p[i]);
        }
    }
    double ans=0;
    fr(i,(n+1)/2,n) ans+=dp[n][i];
    printf("%.10f\n",ans);
}
int main(){
    //IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 49876
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll countBit(ll b) {  // bの立っているbitの数を返す
    ll res = 0;
    rep(i, 60) {
        if(b & 1LL<<i) {
            res++;
        }
    }
    return res;
}
 
int main() {
    ll n;
    cin >> n;

    vector<vector<P>> v(n);  // v[i][j] : 人iのj番目の証言
    rep(i, n) {
        ll a;
        cin >> a;
        rep(j, a) {
            ll x, y;
            cin >> x >> y;
            x--;
            v[i].pb(make_pair(x, y));
        }
    }

    ll ans = 0;
    rep(b, 1<<n) {  // bのiビット目が1のとき人iは正直
        vl w(n);
        rep(i, n) {
            if(b & 1<<i) {
                w[i] = 1;
            }
        }
        bool ok = true;
        rep(i, n) {
            if(w[i]) {
                for(auto p : v[i]) {
                    ll x = p.first;
                    ll y = p.second;
                    if(w[x] != y) {
                        ok = false;
                    }
                }
            }
        }
        if(ok) {
            chmax(ans, countBit(b));
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<set>
#include<iomanip>
#include<bitset>
typedef long long LL;

using namespace std;

/************************************************/

int main(void) {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = abs(tx - sx), dy = abs(ty - sy);
	string ans1;
	while (dy != 0) {
		ans1 += 'U';
		dy--;
	}
	while (dx != 0) {
		ans1 += 'R';
		dx--;
	}
	string ans2;
	for (int i = 0; i < ans1.size(); i++) {
		if (ans1[i] == 'R') {
			ans2 += 'L';
		}
		else {
			ans2 += 'D';
		}
	}
	string ans3;
	ans3 += "LU";
	ans3 += ans1;
	ans3 += "RD";
	string ans4;
	for (int i = 0; i < ans3.size(); i++) {
		if (ans3[i] == 'L') {
			ans4 += 'R';
		}
		else if (ans3[i] == 'U') {
			ans4 += 'D';
		}
		else if (ans3[i] == 'R') {
			ans4 += 'L';
		}
		else {
			ans4 += 'U';
		}
	}
	cout << ans1 << ans2 << ans3 << ans4;

	return 0;
}

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

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

int main()
{
	unsigned int ans = 0;
	unsigned int n, m;
	vector<unsigned long> h;
	vector<bool> good;
	unsigned long height;
	unsigned int a, b;
	typedef struct {
		unsigned int a;
		unsigned int b;
	} ROUTE;
	vector<ROUTE> rt;

	// input
	cin >> n >> m;
	for (unsigned int i = 0; i < n; i++) {
		cin >> height;
		h.push_back(height);
		good.push_back(true);
	}
	for (unsigned int i = 0; i < m; i++) {
		ROUTE r;
		cin >> a >> b;
		if (a < b) {
			r.a = a;
			r.b = b;
		}else {
			r.a = b;
			r.b = a;
		}
		rt.push_back(r);
	}

	// calc
	for (unsigned int i = 0; i < m; i++) {
		unsigned int aidx = rt[i].a - 1;
		unsigned int bidx = rt[i].b - 1;
		if (h[aidx] < h[bidx]) {
			good[aidx] = false;
		}
		else
		if (h[aidx] > h[bidx]) {
			good[bidx] = false;
		}
		else{
			good[aidx] = false;
			good[bidx] = false;
		}
	}
	for (unsigned int i = 0; i < n; i++) {
		if (good[i]) ans++;
	}

	// output
	cout << ans;
	cout << endl;

	return 0;
}


Measured memory_bytes: 5632
while True:
    n,x= map(int,raw_input().split())

    if n == x == 0:
        break

    count = 0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i + j + k == x:
                     count = count + 1
                     break
    print count

Measured memory_bytes: 6368
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    int n=s.size();
    bool f1=1,f2=0;
    if(n%2==1){
        cout<<"No";
        return 0;
    }
    rep(i,n){
        if(i%2==0 && s[i]=='h') continue;
        if(i%2==1 && s[i]=='i') continue;
        f1=0;
    }
    if(f1) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
        long long n, ans = 0, count = 5;
        scanf("%lld", &n);
        if (n % 2 == 1)
                ans = 0;
        else
                while (count <= n) {
                  ans += n/(count*2);
                        count=count*5;
                }
        printf("%lld", ans);
        return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, X, Y;
  int D, G;
  char s[101]={};
  char s_temp[101]={};
  char t[101]={};
  int len=0;
  int N, M;
  int A[20000]={};
  int B[20000]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=101;
  int cnt=0;
  int max=0;
  int ans=0;

//  long cnt =0;
  long long A_temp;
//    int k=0;

  scanf("%d", &a, &b);
//  printf("%d %d\n",D,G);

//  for(i=0;i<D;i++){
//    scanf("%d %d", &A[i], &B[i]);
//    printf("%d %d", A[i], B[i]);
//  }

  
    
  
   if(194<a) printf("5\n");
   else if(188<a) printf("4\n");
   else if(164<a) printf("3\n");
   else if(134<a) printf("2\n");
   else if(104<a) printf("1\n");
   else printf("0\n");
  
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 30000;

int main(){
    
    int n;
    string s;
    int cnt=0;
    int a[maxn];
    cin >> n>>s;
    rep(i,n)a[i]=(int)s[i]-48;
    
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=9;k++){
                bool key1=0,key2=0;
                rep(m,n){
                    if(!key1&&!key2&&a[m]==i){
                        key1=true;
                        continue;
                    }
                    if(key1&&!key2&&a[m]==j){
                        key2=true;
                        continue;
                    }
                    if(key1&&key2&&a[m]==k){
                        //cout << i<<j<<k<<endl;
                        cnt++;
                        break;
                    }
                }
            }
        }
    }
    cout << cnt<<endl;
    return 0;
}


Measured memory_bytes: 384
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(a,b,c) {
    if(a<b && b<c){
      console.log('Yes');
    }else{
      console.log('No');
    }
    //????????????????????????

  }(params[0],params[1],params[2])); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    ll n, d;
    cin >> n >> d;
    // output
    cout << (n + (2 * d)) / (2 * d + 1) << endl;
    return 0;
}

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

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

  long long n, ans = 0;
  cin >> n;
  vector<ll> l(n);
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  long long a, b;
  for(int i=0;i<n-2;i++){
    a = l[i];
    for(int j=i+1;j<n-1;j++){
      b = l[j];
      long long add = a+b; //abs(a-b) < c < add
      long long le = j, ri = n-1;
      if(l[j+1] < add){
        while(ri-le>1ll){
          long long mid = (ri+le)/2ll;
          if(l[mid] >= add){
            ri = mid;
          }else{
            le = mid;
          }
        }
        if(l[ri] >= add){
          ans += le-j;
        }else{
          ans += ri-j;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  map<char, ll> mci;
  rep (i, n) {
    string s;
    cin >> s;
    if (s[0] != 'M' && s[0] != 'A' && s[0] != 'R' && s[0] != 'C' && s[0] != 'H') {
      continue;
    }
    mci[s[0]]++;
  }

  if (mci.size() < 3) {
    cout << 0 << endl;
    return 0;
  } else if (mci.size() == 3) {
    ll res = 1;
    for (auto v : mci) {
      res *= v.second;
    }

    cout << res << endl;
    return 0;
  }


  vector<char> skip1;
  for (auto v : mci) skip1.push_back(v.first);

  vector<string> skip2;
  for (int i = 0; i < skip1.size() - 1; i++) {
    for (int j = i + 1; j < skip1.size(); j++) {
      string s = "";
      s += skip1[i];
      s += skip1[j];
      skip2.push_back(s);
    }
  }

  ll ans = 0;
  if (mci.size() == 4) {
    for (auto sk : skip1) {
      ll tmp = 1;
      for (auto v : mci) {
        if (v.first == sk) continue;
        tmp *= v.second;
      }
      ans += tmp;
    }
  } else if (mci.size() == 5) {
    for (auto sk : skip2) {
      ll tmp = 1;
      for (auto v : mci) {
        if (v.first == sk[0] || v.first == sk[1]) continue;
        tmp *= v.second;
      }
      ans += tmp;
    }
  }

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


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <set>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)

using Int = long long;
const Int N_MAX = 100002;
Int as[3 * N_MAX];
Int n;


void solve() {
    cin >> n;
    REP(i, 3*n) cin >> as[i];
    priority_queue<Int, vector<Int>, greater<Int>> s1;
    set<pair<Int,Int>> s2;
    set<pair<Int,Int>> remain;
    Int sum1 = 0, sum2 = 0;
    Int bestScore;
    for(int i = 0; i < n; i++) {
        s1.push(as[i]);
        sum1 += as[i];
    }
    for(Int i = n; i < 3*n; i++) {
        remain.insert({as[i], i});
    }
    REP(i, n){
        auto x = *remain.begin();
        remain.erase(remain.begin());
        s2.insert(x);
        sum2 += x.first;
    }
    bestScore = sum1 - sum2;
    for (Int i = n; i < 2*n; i++){
        {
            Int x = s1.top();
            if (x < as[i]) {
                s1.pop();
                s1.push(as[i]);
                sum1 += as[i] - x;
            }
        }
        {
            auto p = make_pair(as[i], i);
            auto ite = remain.find(p);
            if (ite != remain.end()) {
                remain.erase(ite);
            }
            else {
                s2.erase(p);
                auto x = *remain.begin();
                remain.erase(remain.begin());
                s2.insert(x);
                sum2 += x.first - as[i];
            }
            Int scr = sum1 - sum2;
            bestScore = max(bestScore, scr);
        }
    }
    
    cout << bestScore << endl;
    return;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  ll ans = 0;
  REPI(i, 1, N + 1) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    ans += i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <type_traits>
#include <limits>
#include <random>
#include <iomanip>

using namespace std;

using ll = long long;

typedef pair<ll, ll> P;

#define rep(i,N) for(long long i = 0;i < (long long)N; ++i)

static int mod = 1000000007;
static int large_int = 1000000000;
static ll large_ll = 1000000000000000000;

int dx[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int N, W;
int w[100], v[100];
int ans;
ll dp[101][100100];

int main() {
	cin >> N >> W;
	rep(i, N) {
		cin >> w[i] >> v[i];
	}
	for (int i = 0; i < 100; ++i) for (int j = 0; j <= 100100; ++j) dp[i][j] = large_ll;
	dp[0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 100100; ++j) {
			if (j < v[i]) dp[i + 1][j] = dp[i][j];
			else {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}
	ll rec = 0;
	for (int j = 0; j < 100100; j++) {
		if (dp[N][j] <= W) rec = j;
	}
	cout << rec << endl;
	return 0;
}

Measured memory_bytes: 79232
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))


def insertionSort(N,A,g):
    global cnt
    for i in range(g,N):
        v = A[i]
        j = i-g
        while A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return A    
      
def shellSort(N,A):
    global cnt
    cnt = 0
    m = 1
    G = [1]
    x = 1
    for i in range(N):
        x = 3*x + 1
        if x > N:
            break
        G.insert(0,x)
        m += 1
    
    for i in range(m):
        A = insertionSort(N,A,G[i])
    
    return cnt,A,m,G

cnt,A,m,G = shellSort(N,A)
print(m)
print(" ".join([str(g) for g in G]))
print(cnt)
for i in range(len(A)):
    print(A[i])
        
        
        


Measured memory_bytes: 45528