akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] sums = new long[n];
		long prev = 0;
		for (int i = 0; i < n; i++) {
			long a = sc.nextInt();
			sums[i] = a + prev;
			prev = sums[i];
		}
		long min = Long.MAX_VALUE;
		int idx1 = 0;
		int idx3 = 2;
		for (int idx2 = 1; idx2 < n - 1; idx2++) {
			while (sums[idx1] < sums[idx2] - sums[idx1] && idx2 - idx1 > 1) {
				if (Math.abs(sums[idx1] - (sums[idx2] - sums[idx1])) < Math.abs(sums[idx1 + 1] - (sums[idx2] - sums[idx1 + 1]))) {
					break;
				}
				idx1++;
			}
			if (idx2 >= idx3) {
				idx3 = idx2 + 1;
			}
			while (sums[idx3] - sums[idx2] < sums[n - 1] - sums[idx3] && n - idx3 > 2) {
				if (Math.abs((sums[idx3] - sums[idx2]) - (sums[n - 1] - sums[idx3])) < Math.abs((sums[idx3 + 1] - sums[idx2]) - (sums[n - 1] - sums[idx3 + 1]))) {
					break;
				}
				idx3++;
			}
			long ans = getAns(sums[idx1], sums[idx2], sums[idx3], sums[n - 1]);
			min = Math.min(min, ans);
		}
		System.out.println(min);
	}
	
	static long getAns(long a, long b, long c, long d) {
		return Math.max(Math.max(a, b - a), Math.max(c - b, d - c)) - Math.min(Math.min(a, b - a), Math.min(c - b, d - c));
	}
}


Measured memory_bytes: 83964
n,k = map(int,input().split())
ls = list(map(int,input().split()))
fi = [-1]*(n+1)
fi[1] = 0
a = 0
aa = 0
for i in range(k):
    if fi[ls[a]] == -1:
        fi[ls[a]] = i + 1
        aa = a
        a = ls[a] - 1
    else:
        ind = fi[ls[a]]
        t = (k - ind) % (max(fi) + 1 - ind)
        t += ind
        print(fi.index(t))
        break
else:
    print(ls[aa])

Measured memory_bytes: 32260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
using namespace std;

int main() {
  int N;
  cin>>N;
  
  int ans=0;
  
  if(N<=9)
    ans=N;
  else if(10<=N && N<=99)
    ans=9;
  else if(100<=N && N<=999)
    ans=9+(N-99);
  else if(1000<=N && N<=9999)
    ans=909;
  else if(10000<=N && N<=99999)
    ans=909+(N-9999);
  else if(N==100000)
    ans=90909;
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
int N,K,A[100005],id,Ans=2e9;
inline void read(int &Res){
	char ch=getchar();
	for (Res=0;!isdigit(ch);ch=getchar());
	for (;isdigit(ch);ch=getchar()) Res=(Res<<3)+(Res<<1)+ch-48;
}
int main(){
	read(N),read(K);
	for (int i=1;i<=N;++i){
		read(A[i]);
		if (A[i]==1) id=i;
	}
	for (int i=id;i<id+K&&i<=N;++i){
		Ans=min(Ans,(((i-K)>0)?(((i-K)-1)/(K-1)+1):0)+((i<N)?((N-i-1)/(K-1)+1):0));
	}
	printf("%d",++Ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#define LIMIT 51
using namespace std;

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

int main()
{
    int n, m;
    cin >> n >> m;
    int *a = (int*)malloc(LIMIT * sizeof(int));
    int *b = (int*)malloc(LIMIT * sizeof(int));
    bool **graph = (bool**)malloc(LIMIT * sizeof(bool*));
    for(int i = 0; i < LIMIT; ++i) {
        graph[i] = (bool*)malloc(LIMIT * sizeof(bool));
    }
    bool *visited = (bool*)malloc(LIMIT * sizeof(bool));

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

    int ans = 0;

    for(int i = 0; i < m; ++i) {
        //辺を切り離す
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

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

        dfs(0, n, graph, visited);

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

    cout << ans << endl;
    free(a); free(b); free(graph); free(visited);
    return 0;
}

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

using namespace std;

typedef pair<int, int> P;

int main() {

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

	long long int nn = 1 << 13;

	int ans = 0;

	for (long long int i = 0; i < nn; i++) {
		vector<int> flag(13, 0);
		for (long long int j = 0; j < 13; j++) {
			if ((i & (1 << j)) != 0) {
				flag[j] = 1;
			}
		}
		vector<int> d2 = d;
		for (int j = 0; j < n; j++) {
			if (flag[d[j]] == 1) {
				d2[j] = 24 - d[j];
				flag[d[j]] = 0;
			}
			else {
				d2[j] = d[j];
				flag[d[j]] = 1;
			}
		}

		int MIN = 100;

		for (int j = 0; j < n; j++) {
			for (int k = j+1; k < n; k++) {
				int diff = abs(d2[j] - d2[k]);
				diff = min(diff, 24 - diff);
				MIN = min(MIN, diff);
			}
		}

		for (int j = 0; j < n; j++) {
			int diff = d2[j];
			diff = min(diff, 24 - diff);
			MIN = min(MIN, diff);
		}

		ans = max(ans, MIN);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
class Node
  attr_reader :id
  attr_accessor :left, :right

  def initialize(id)
    @id = id
  end
end

def tree(pre_ids, in_ids)
  return nil if pre_ids.none?

  root_id = pre_ids.first
  root = Node.new(root_id)
  return root if pre_ids.one?

  inorder_root_position = in_ids.find_index(root_id)
  left_in_ids = in_ids[0 .. inorder_root_position - 1]
  right_in_ids = in_ids[inorder_root_position + 1 .. -1]

  left_ids_count = inorder_root_position
  inorder_right_begin_position = left_ids_count + 1
  left_pre_ids = pre_ids[1, left_ids_count]
  right_pre_ids = pre_ids[inorder_right_begin_position .. -1]

  root.left = tree(left_pre_ids, left_in_ids)
  root.right = tree(right_pre_ids, right_in_ids)
  root
end

class TreeWalker
  def self.enum_node_postorder(node, &block)
    enum_node_postorder(node.left, &block) if node.left
    enum_node_postorder(node.right, &block) if node.right
    yield node
  end

  def initialize(root)
    @root = root
  end

  def enum_postorder(&block)
    self.class.enum_node_postorder(@root, &block)
  end
end

_ = gets.to_i
pre_ids = gets.chomp.split(' ').map(&:to_i)
in_ids = gets.chomp.split(' ').map(&:to_i)

root = tree(pre_ids, in_ids)
walker = TreeWalker.new(root)
puts walker.to_enum(:enum_postorder).map(&:id).join(' ')



Measured memory_bytes: 6888
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);


  int N;cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N-1;i++){
    cin>>vec[i];
  }
  vector<int> vecA(N);
  int sum=0;
  sum=vec[0]+vec[N-2];
 // cout<<sum<<endl;
  for(int i=1;i<N-1;i++){
    vecA[i]=min(vec[i],vec[i-1]);
   
    sum+=vecA[i]; 
    //cout<<sum<<" ";
  }
  
    
cout<<sum<<endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b;
	char op;
	while(1)
	{
		scanf("%d %c %d",&a,&op,&b);

		if(op == 43)
		{
			printf("%d\n",a+b);
		}
		else if(op == 45)
		{
			printf("%d\n",a-b);
		}
		else if(op == 42)
		{
			printf("%d\n",a*b);
		}
		else if(op == 47)
		{
			printf("%d\n",a/b);
		}
		else if(op == 63)
		{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

const int Mod = 1000000007;
int S[201];
long long memo[201][100001], fact[100001], fact_inv[100001];

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

void merge_sort(int x[], int n)
{
	static int y[201] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

long long recursion(int k, int x)
{
	if (memo[k][x] != -1) return memo[k][x];
	else memo[k][x] = 0;
	
	int i, l, r, m, y;
	for (i = 0; i < k; i++) {
		l = 0;
		r = i;
		y = x % S[i];
		while (l < r) {
			m = (l + r) / 2;
			if (S[m] > y) r = m;
			else l = m + 1;
		}
		memo[k][x] = (memo[k][x] + recursion(l, y) * fact[k-1] % Mod * fact_inv[l]) % Mod;
	}
	return memo[k][x];
}

int main()
{
	int i, j, N, X;
	scanf("%d %d", &N, &X);
	for (i = 0; i < N; i++) scanf("%d", &(S[i]));
	merge_sort(S, N);
	
	for (i = 1, fact[0] = 1; i <= N; i++) fact[i] = fact[i-1] * i % Mod;
	for (i = N - 1, fact_inv[N] = div_mod(1, fact[N], Mod); i >= 0; i--) fact_inv[i] = fact_inv[i+1] * (i + 1) % Mod;
	for (j = 0; j <= X; j++) memo[0][j] = j;
	for (i = 1; i <= N; i++) for (j = 1, memo[i][0] = 0; j <= X; j++) memo[i][j] = -1;
	printf("%lld\n", recursion(N, X));
	fflush(stdout);
	return 0;
}

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

typedef long long ll;

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll v[3],k;
    while(cin >> v[0] >> v[1] >> v[2] >> k)
    {
        sort(v, v+3);
        while(k--)
            v[2] *= 2;
        cout << v[0] + v[1] + v[2] << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        if(n % 2 == 0){
            String a = s.substring(0, n / 2);
            String b = s.substring(n / 2, n);
            
            if(a.equals(b)){
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
        }else{
            System.out.println("No");
        }



    }
}


Measured memory_bytes: 21844
// tzl ak IOI! 

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define nrof(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}

template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }

template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }

template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }

template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }

#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif

//---------------------------head----------------------------

const int N = 2e5 + 100;

int n, m;
int par[N];
int deg[N];

int F(int u){ return u == par[u] ? u : par[u] = F(par[u]); }
void UN(int u, int v){ debug(u, '\t') debug(v, '\n') par[F(u)] = F(v); }

void TZL()
{
	scf(n, m);
	rep(i, n + n) par[i] = i;
	rep(i, m)
	{
		int u, v;
		scf(u, v);
		u--; v--;
		deg[u]++;
		deg[v]++;
		u <<= 1;
		v <<= 1;
		UN(u, v | 1);
		UN(u | 1, v);
	}
	return;
}

void RANK1()
{
	LL cnt0, cnt1, ans;
	cnt0 = cnt1 = 0;
	rep(i, n + n) if(deg[i >> 1] && F(i) == i)
	{
		if(F(i) == F(i ^ 1)) cnt1++;
		else cnt0++;
	}
	ans = cnt0 * cnt0 / 2 + cnt1 * cnt1 + cnt0 * cnt1;
	debug(ans, '\n')
	ans += 1ll * n * n;
	for(int i = n - 1; i >= 0; --i) if(!deg[i]) n--;
	ans -= 1ll * n * n;
	printf("%lld\n", ans);
	return;
}

#define tzl int
#define ak main
#define IOI ()
tzl ak IOI
{
#undef tzl
#undef ak
#undef IOI

	TZL();
	RANK1();

#define tzl return
#define caisi 0
#define myy ;
	tzl caisi myy
#undef tzl
#undef caisi
#undef myy
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

vector<ll> fac(3000001); //n!(mod M)
vector<ll> ifac(3000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int main() {
  int a,b;
  cin >> a >> b;
  if(a<=9&&b<=9) cout << a*b << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 50108
import Control.Monad
import Data.List
main=do
    a<-getLine
    b<-getLine
    c<-getLine
    putStrLn $ ta a b c

ta [] _ _ = "A"
ta (a:ar) b c
    | a=='a' = ta ar b c
    | a=='b' = tb ar b c
    | a=='c' = tc ar b c

tb _ [] _ = "B"
tb a (b:br) c
    | b=='a' = ta a br c
    | b=='b' = tb a br c
    | b=='c' = tc a br c

tc _ _ [] = "C"
tc a b (c:cr)
    | c=='a' = ta a b cr
    | c=='b' = tb a b cr
    | c=='c' = tc a b cr


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

vector<int64_t> divisor(int64_t n) {
	vector<int64_t> ret;
	for(int64_t i = 1; i * i <= n; ++i) {
		if(n % i == 0) {
			ret.emplace_back(i);
			if(i * i != n) ret.emplace_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	return ret;
}

int main() {
	int q; cin >> q;
	int64_t ans[100010] = {};
	for(int64_t i = 2; i < 100010; ++i) {
		ans[i] = ans[i - 1];
		int64_t tmp = 1;
		for(int64_t j : divisor(i)) {
			if(j == i) continue;
			tmp *= j;
			if(tmp >= 2 * i) {
			    ans[i]++;
			    break;
			}
		}
	}
	while(q--) {
		int n; cin >> n;
		cout << ans[n] << '\n';
	}
	return 0;
}



Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
  
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
 
typedef long long int64;
const int INF = 1 << 30;

string S;

int main(){

  cin >> S; S += '~';
  int pos = 0, ret = 0;
  while(pos < S.length() - 1){
    int J = 0, O = 0, I = 0; 
    while(S[pos] == 'J') ++J, ++pos;
    while(S[pos] == 'O') ++O, ++pos;
    while(S[pos] == 'I') ++I, ++pos;
    if(J >= O && O <= I) ret = max( ret, O);
  }                          
  cout << ret << endl;
}

Measured memory_bytes: 2052
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = {{typeid(int), "%d"},
                                                      {typeid(ll), "%lld"},
                                                      {typeid(double), "%lf"},
                                                      {typeid(char), "%c"}};

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
	auto b = scan('g');
	ll gCount = b.count();
	ll pCount = b.size() - gCount;

	if (gCount == pCount) {
		cout << "0\n";
		return 0;
	}

	if (pCount > gCount) {
		cout << (pCount - gCount) / 2 << "\n";
		return 0;
	}

	cout << (gCount - pCount) / 2 << "\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  auto tFormat = scanType[typeid(T)];
  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 512
def main():
    k = int(input())
    dp = [[1] * 10]
    count = 9
    while k > count:
        dp.append([])
        dp[-1].append(dp[-2][0] + dp[-2][1])
        for i in range(1, 9):
            dp[-1].append(dp[-2][i - 1] + dp[-2][i] + dp[-2][i + 1])
        dp[-1].append(dp[-2][8] + dp[-2][9])
        count += sum(dp[-1][1:])
    ans = []
    li = [count - sum(dp[-1][i:]) for i in range(11)]
    for i in range(1, 10):
        if li[i + 1] >= k:
            ans.append(i)
            c = li[i]
            break
    for li in reversed(dp[:-1]):
        for i in range(max(0, ans[-1] - 1), min(9, ans[-1] + 1) + 1):
            if c + li[i] >= k:
                ans.append(i)
                break
            c += li[i]

    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	k <- readInt
	print $ minimum $ map ( \t -> ( 2 ^ t ) + ( n - t ) * k ) [ 0 .. n ]


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

vi enum_div(int n) {
	vi ans;
	for (int i = 1; i*i <= n; ++i) {
		if (n%i == 0) {
			ans.push_back(i);
			if (i != 1 && i*i != n) {
				ans.push_back(n / i);
			}
		}
	}
	ans.push_back(n);
	return ans;
}

int main() {
	makei(n);
	makei(m);
	vi v = enum_div(m);
	sort(all(v));
	for (int x : v) {
		if (x >= n) {
			say(m / x);
			re;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
#define PI 3.1415926535897932384626433832795
#define coutfix(i) cout << fixed << setprecision(i)
using namespace std;

int main()
{
	int64 aa, bb;
	cin >> aa >> bb;
	int64 ans = max(aa, bb);
	ans += max(min(aa, bb), max(aa, bb) - 1);
	cout << ans << endl;
}


Measured memory_bytes: 3512
function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    const [ char ] = readMany(1)
    if (char == char.toLowerCase()) {
        console.log('a')
    } else {
        console.log('A')
    }
})()


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

int fact(int n) {
    if (n == 0)
        return 1;
    else {
        int tmp = 1;
        for (int i = 1; i <= n; i++) {
            tmp *= i;
        }
        return tmp;
    }
}

int main() {
    int n, tmp, suma{0}, sumb{0};
    cin >> n;
    bool bits[9]{};
    int count{0};
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        count = 0;
        for (int j = 1; j < tmp; j++) {
            if (!bits[j]) {
                ++count;
            }
        }
        suma += count * fact(n - i - 1);
        bits[tmp] = true;
    }

    for (int i = 0; i < n; i++) {
        bits[i] = false;
    }

    for (int i = 0; i < n; i++) {
        cin >> tmp;
        count = 0;
        for (int j = 1; j < tmp; j++) {
            if (!bits[j]) {
                ++count;
            }
        }
        sumb += count * fact(n - i - 1);
        bits[tmp] = true;
    }

    cout << abs(suma - sumb);

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, m int
	n = nextInt()
	m = nextInt()

	ma := map[int]int{}

	if m == 0 {
		if n == 1 {
			ma[0] = 0
		} else {
			ma[0] = 1
		}
	}

	for l := 0; l < m; l++ {
		var s, c int
		s = nextInt() - 1
		c = nextInt()
		_, ok := ma[s]
		if ok && ma[s] != c {
			fmt.Println(-1)
			return
		} else if n > 1 && s == 0 && c == 0 {
			fmt.Println(-1)
			return
		} else {
			ma[s] = c
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		_, ok := ma[i]
		if !ok {
			if i == 0 && n > 1 {
				ma[i] = 1
			} else {
				ma[i] = 0
			}
		}
		ans += ma[i] * int(math.Pow10(n-i-1))
	}
	fmt.Println(ans)

}


Measured memory_bytes: 640
# include "cstdio"
# include "iostream"
using namespace std;
int main()
{
	int n,x;
	cin>>n>>x;
	int ans=1,l=0;
	for(int i=1;i<=n;i++)
	{
		int now;
		cin>>now;
		l+=now;
		if(l<=x)
		ans++;
		else
		break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
Ss = gets.split.map(&:to_i)
INF = 10**9 + 5
M = 1 << N

def born?(xs, ss)
  i = 1
  ys = xs.dup
  xs.reverse_each do |x|
    if i = (i ... M).find{|j| ss[j] < x}
      ys << ss[i]
      ss[i] = INF
    else
      puts 'No'
      exit
    end
  end
  return true if ys.size == M
  born?(ys.sort, ss)
end

ss = Ss.sort.reverse
xs = ss[0, 1]
ss[0] = INF
puts born?(xs, ss) ? 'Yes' : 'No'

Measured memory_bytes: 39428
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(a: chars);

    puts!("{}\n", if a.iter().any(|&x| x == '7') { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

long gcd( int m, int n) {
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;
  while( m != n ) {
    if ( m > n ) m = m - n;
    else  n = n - m;
  }
  return m;
}//gcd

long lcm( int m, int n ) {
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;
  
  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main() {
  
  int N,M;
  cin >> N >> M;
  string S,T;
  cin >> S >> T;
  long na=lcm(N,M)/N,nb=lcm(N,M)/M;
  long sum=0;
  for(int i=0;i<gcd(N,M);i++) {
    if(S.at(i*nb)==T.at(i*na)) sum++;
  }
  if(sum==gcd(N,M)) cout << lcm(N,M) << endl;
  else cout << -1 << endl;
}


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

// rep(i, 3){cout << i << endl;}


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

    cout << A*B <<endl;

    return 0;
}

Measured memory_bytes: 3636
from functools import reduce

n, *a_l = map(int, open(0).read().split())

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def gcd_list(numbers):
    return reduce(gcd, numbers)

print(gcd_list(a_l))

Measured memory_bytes: 14652
<?php
/*
    Problem URL : http://abc058.contest.atcoder.jp/tasks/abc058_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%s", $O);
fscanf(STDIN, "%s", $E);

for ($i = 0; $i < strlen($O); $i++) {
    $ans .= $O[$i];
    $ans .= $E[$i];
}
echo $ans . PHP_EOL;


Measured memory_bytes: 5112
#include<stdio.h>

int min(int b,int c)
{
	int M;
	if(b!=0 && c!=0)
	{
	   M=b;
	   if(M>c) M=c;
	}
	else
	{
		if(b==0)
		{
			return c;
		}
		else
		{
			return b;
		}
	}
	return M;
}

int main(void)
{
	int i,j,n,m,s[21],dp[21][50001];
	
	scanf("%d%d",&n,&m);
	s[0]=0;
	for(i=1;i<=m;i++)
	{
		scanf("%d",&s[i]);
	}
	for(i=0;i<=n;i++)
	{
		dp[0][i]=0;
	}
	for(i=1;i<=m;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(s[i]<=j)
			{
				dp[i][j]=min(dp[i][j-s[i]]+1,dp[i-1][j]);
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	printf("%d\n",dp[m][n]);
	return 0;
}

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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  int n, m, c, b[20], a[20][20];
  cin >> n >> m >> c;
  repi(m) cin >> b[i];
  repi(n) repj(m) cin >> a[i][j];
  int re = 0;
  repi(n) {
    int sum = c;
    repj(m) sum += a[i][j] * b[j];
    if (sum > 0) re++;
  }
  cout << re << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int dfs(int);
int N,M,x,y,r[100000],len[100000];
vector< vector<int> > g;

int main(){
	int maxLen=0;
	cin>>N>>M;
	g.resize(N);
	for(int i=0;i<M;i++){
		cin>>x>>y;
		x--;y--;
		g[x].push_back(y);
		r[y]++;
	}
	for(int i=0;i<N;i++){
		if(r[i]==0)maxLen=max(maxLen,dfs(i));
	}
	cout<<maxLen;
	
	return 0;
}

int dfs(int num){
	int maxL=0;
	if(len[num]!=0)return len[num];
	if(g[num].size()==0)return 0;
	for(int i=0;i<g[num].size();i++)maxL=max(maxL,dfs(g[num][i])+1);
	len[num]=maxL;
	return maxL;
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int[] array = new int[101];
        for (int i = a; i < b; i++) {
            array[i]++;
        }
        for (int i = c; i < d; i++) {
            array[i]++;
        }
        int ans = 0;
        for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
r, c = map(int, input().split())
MAP = [[] for _ in range(r)]
for i in range(r):
    MAP[i].extend(list(map(int, input().split())))
    MAP[i].append(sum(MAP[i]))
    print(*MAP[i])
li = []
for Z in zip(*MAP):
    li.append(sum(Z))
print(*li)


Measured memory_bytes: 5712
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(x!=i)ans++;
    }
    if(ans<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
#define MOD 1000000007ll 
using namespace __gnu_pbds;
using namespace std;

int n,a[200010],b[200010],pw[200010];
pair<int,int> val[200010];
map<pair<int,int>,int> mp,vis;

inline int gcd(int x,int y)
{
	if(y==0) return x;
	return gcd(y,x%y);
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	pw[0]=1ll;
	for(int i=1;i<=n;i++){
		pw[i]=(pw[i-1]*2ll)%MOD;
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		if(a[i]==0&&b[i]==0) continue;
		cnt++;
		int flag=1;
		if((a[i]<0&&b[i]>=0)||(b[i]<0&&a[i]>=0)) flag=-1;
		a[i]=abs(a[i]);b[i]=abs(b[i]);
		int g=gcd(a[i],b[i]);
		val[i]=make_pair(a[i]/g*flag,b[i]/g);
		mp[val[i]]++;
	}
	int ans=1ll;
	for(map<pair<int,int>,int>::iterator it=mp.begin();it!=mp.end();it++){
		pair<int,int> num=it->first;
		if(vis[num]) continue;
		pair<int,int> nxt=make_pair(num.second,-num.first);
		vis[num]=1;vis[nxt]=1;
		ans=(ans*((pw[it->second]+pw[mp[nxt]]-1ll+MOD)%MOD))%MOD;
	}
	ans+=n-cnt;
	cout<<(ans-1ll+MOD)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 61324
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; string S; cin>>N>>S;
  vector<bool>A(10,false);
  long long ans=0;
  for(int i=0;i<N-2;i++){
    if(A[S.at(i)-'0'])continue;
    A[S.at(i)-'0']=true;
    vector<bool>B(10,false);
    for(int j=i+1;j<N-1;j++){
      if(B[S.at(j)-'0'])continue;
      B[S.at(j)-'0']=true;
      vector<bool>C(10,false);
      for(int k=j+1;k<N;k++){
        if(C[S.at(k)-'0'])continue;
        C[S.at(k)-'0']=true;
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include<stdio.h>

int main(void)
{
  int x,y;
  scanf("%d %d", &x, &y);

  int flag=0;
  for(int i=0;i<=x;i++){
    if(i*2+(x-i)*4==y){
      flag = 1;
      break;
    }
  }

  if(flag) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 1632
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N;
	string S; 
	cin >> N>>S;
	for (int i = 0; i < S.size(); i++) {
		char h = (S[i] + N+'A')%26+'A';
		cout << h;
	}
	
}





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

template<typename ...> static inline int gc(void) { return getchar(); }
static inline void read(long long int &x){int k,m=0;x=0;for(;;){k=gc();if(k==45){m=1;break;}if(48<=k&&k<=57){x=k-48;break;}}for(;;){k=gc();if(k<48||k>57)break;x=x*10+k-48;}if(m)x=-x;}
static inline void uread(long long int &x){int k;x=0;for(;;){k=gc();if(48<=k&&k<=57){x=k-48;break;}}for(;;){k=gc();if(k<48||k>57)break;x=x*10+k-48;}}


long long int N, M;

static inline long long int fact(long long A){
    long long int a = 1;
    for(int i = 2; i <= A; ++i){
        a = (a * i) % 1000000007;
    }
    return a;
}

int main(){
    read(N);
    read(M);
    if(N == M){cout << (2 * fact(N) * fact(M)) % 1000000007 << endl;return 0;}
    if(N > M)swap(N, M);
    if(M == N + 1){cout << (fact(N) * fact(M)) % 1000000007 << endl;return 0;}
    puts("0");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

//-----------------------------------------------

//------------------------------------------------
int main(){
  int n,m,l,ans;
  cin>>n;
  vector<int> d(n);
  rep(i,0,n) cin>>d.at(i);
  sort(d.begin(),d.end());
  m=d.at(n/2-1);
  l=d.at(n/2);
  ans=l-m;
  cout<<ans<<endl;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver1 {
   Int n;
   std::vector<Int> ps, ns;
   Solver1(Int n_)
      : n(n_+1), ps(n, -1), ns(n, 1) {}
   void unite(Int x, Int y) {
      Int x2 = find(x);
      Int y2 = find(y);
      if( x2 == y2 ) return;
      if( not ( ns[x2] <= ns[y2] ) ) std::swap(x2, y2);
      ps[x2] = y2;
      ns[y2] += ns[x2];
   }
   bool same(Int x, Int y) {
      return find(x) == find(y);
   }
   Int find(Int x) {
      return ps[x] == -1 ? x : (ps[x] = find(ps[x]));
   }
   Int getSize(Int x) {
      return ns[find(x)];
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n, q; scan(n, q);
      Solver1 uf(n);
      for(Int i = 0; i < q; ++i) {
         Int a, b, c; scan(a, b, c);
         if( a == 0 ) {
            uf.unite(b, c);
         }
         if( a == 1 ) {
            puts(uf.same(b, c) ? "1" : "0");
         }
      }
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#define ALL(X) X.begin(), X.end()
#define SZ(A) int((A).size())
#define RALL(X) X.rbegin(), X.rend()
#define FOR(B) for (size_t i = 0; i < B; i++)
#define FOR2(B) for (size_t j = 0; j < B; j++)
#define FORE(B) for (size_t i = 1; i <= B-1; i++)
#define FORC(A, B) for (size_t i = A; i < B; i++)
#define PRINT(X) cout << X << endl
#define PRINTALL(E, X) { FOR(X) {cout << E[i] << endl; } }
#define PRINTSIDE(E, X) { FOR(X) {cout << E[i] << " ";} }
#define READALLI(V, N) FOR(N) {int x; cin >> x; V.push_back(x); }
#define READALL(V, N) FOR(N) {LL x; cin >> x; V.push_back(x); }
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXN 100000
#define SQRSIZE  317
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<LL>VL;
typedef vector<PII> VPII;
typedef map<int, int> MII;
typedef map<char, int>MCI;
typedef map<string, int> MSI;
typedef set<int> SI;
const int INF = (1 << 30);

int main() {

    int n = 0;
    cin >> n;
    if(n == 1){
        cout << "Hello World\n";
    }else{
        int x  = 0, y = 0;
        cin >> x >> y;
        cout << x + y << endl;
    }

    return 0;
}






Measured memory_bytes: 764
#include<iostream>
#include<bits/stdc++.h>
#define optimize() ios_base::sync_with_stdio(0);cin.tie();cin.tie();
using namespace std;

int main()
{

    optimize();
    map<string,int>mp;
    int n;
    cin>>n;
    int a,b;
    string s;
    while(n-->0)
    {
        cin>>a;
        if(a==0)
        {
            cin>>s>>b;
            mp[s]=b;
        }
        else if(a==1)
        {
            cin>>s;
            if(mp.find(s)==mp.end())

                cout<<0<<"\n";
            else
                cout<<mp[s]<<"\n";


        }
        else if(a==2)
        {
            cin>>s;
            mp.erase(s);
        }
        else
        {

            string x,y;
            cin>>x>>y;

            /*auto low = mp.lower_bound( x );
            auto upper = mp.upper_bound(y);

            for(auto it = low; it!=upper; it++)
                cout<<it->first<<" "<<it->second<<"\n";*/
                map<string,int>::iterator low,upper,it;
                low = mp.lower_bound(x);
                upper = mp.upper_bound(y);

            for( it = low; it!=upper; it++)
                cout<<it->first<<" "<<it->second<<"\n";
        }
    }

    return 0;
}



Measured memory_bytes: 25952
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

ll gcd(ll a, ll b){
	while(b){
		a %= b;
		swap(a, b);
	}
	return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n); cin >> as;
    sort(as.rbegin(), as.rend());
    int g = as[0];
    for(auto a : as){
        g = gcd(g, a);
    }
    for(auto& a : as){
        a /= g;
    }
    int g2 = as[0];
    if(g2 == 1){
        cout << g << '\n';
        return 0;
    }
    int cnt = 0;
    for(auto& a : as){
        if(!cnt && gcd(g2, a) == 1){
            swap(a, as[0]);
            cnt++;
        }else{
            g2 = gcd(g2, a);
        }
    }
    int g3 = as[0];
    cnt = 0;
    for(auto& a : as){
        if(!cnt && gcd(g3, a) == 1){
            cnt++;
        }else{
            g3 = gcd(g3, a);
        }
    }
    cout << g * max(g2, g3) << '\n';
}


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

using namespace std;

const int MAXN = 100000;
int a[MAXN], n;
bool p[MAXN];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n);
	long long int s = 0;
	for(int i = 0; i < n; i++) {
		p[i] = a[i] <= (s << 1);
		s += a[i];
	}
	int sol = 1;
	for(int i = n - 1; i >= 0 && p[i]; i--)
		sol++;
	printf("%d\n", sol);
	return 0;
}


Measured memory_bytes: 640