akhauriyash/Code-Regression huggingface dataset:
m,a,r,c,h = 0,0,0,0,0
for i in range(int(input())):
    s = input()
    if s[0] == 'M': m += 1
    if s[0] == 'A': a += 1
    if s[0] == 'R': r += 1
    if s[0] == 'C': c += 1
    if s[0] == 'H': h += 1

l = [m,a,r,c,h]
res = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            res += l[i] * l[j] * l[k]
print(res)


Measured memory_bytes: 3064
import java.util.Scanner;

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

        char[] input = scanner.next().toCharArray();

        if (input[1] == input[2]) {
            if (input[0] == input[1] || input[2] == input[3]) {
                result = "Yes";
            }
        }

        System.out.println(result);

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



int main() {
	string s;
	int a;
	cin >> s;
	a = s.size() / 2;
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(i, a) {
		if (s[i] != s[a - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
// using mP = pair<modint, modint>;

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




void solve() {
    ll X; cin >> X;
    ll i=0;
    ll a = 100;
    while(a < X){
        a += a/100;
        i++;
    }

    cout << i << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7748
#include<iostream>
#include<cmath>

#define ll long long

using namespace std;

int main()
{
  int n,w;
  cin>>n>>w;
  int weight[n];
  int value[n];
  for(int i=0;i<n;i++)
    cin>>weight[i]>>value[i];
  
  ll dp[n+1][w+1];
  for(int i=0;i<=n;i++)
    dp[i][0] = 0;
  for(int j=0;j<=w;j++)
    dp[0][j] = 0;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=w;j++)
    {
      if(weight[i-1]<=j)
        dp[i][j] = max( (value[i-1] + dp[i-1][j-weight[i-1]]) , dp[i-1][j]);
      else
        dp[i][j] = dp[i-1][j];
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}

Measured memory_bytes: 82340
#include <stdio.h>
#define MAX 100000

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);

  for(i=1;i<=H;i++){
     
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H)printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int n;
map<string,int>S;
main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int c;string s;cin>>c>>s;
    if(c==0)
    {
      int x;cin>>x;S[s]=x;
    }
    else cout<<S[s]<<endl;
  }
}



Measured memory_bytes: 27808
#include <stdio.h>

int main (void){
    int i,j; 
    int n,a,b; 
    
   
    scanf("%d %d %d",&n,&a,&b);
    if(n*a > b){
        printf("%d\n",b);
    }else{
        printf("%d\n",n*a);
    }
    

    
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int idx[100001] = {};
    int idx2[100001] = {};
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int tp;
        cin >> tp;
        if (i % 2 == 0)
            idx[tp]++;
        else
            idx2[tp]++;
    }

    vector<pair<int, int>> v1;
    vector<pair<int, int>> v2;
    for (int i = 1; i < 100000; i++)
    {
        v1.push_back(make_pair(idx[i], i));
        v2.push_back(make_pair(idx2[i], i));
    }
    sort(v1.begin(), v1.end(), greater<pair<int, int>>());
    sort(v2.begin(), v2.end(), greater<pair<int, int>>());
    /*
    for (int i = 0; i < 10; i++)
    {
        cout << v1[i].first << "," << v1[i].second << " ";
    }
    cout << endl;
    */
    auto itr1 = v1.begin();
    auto itr2 = v2.begin();
    while (1)
    {
        if (itr1->second != itr2->second)
        {
            // cout << itr1->first << "," << itr2->first << endl;
            cout << (n / 2 - itr1->first) + (n / 2 - itr2->first) << endl;
            break;
        }
        else
        {
            if ((itr1 + 1)->first > (itr2 + 1)->first)
            {
                itr1++;
            }
            else
            {
                itr2++;
            }
        }
    }
}


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

struct edge { long long to, cost;};
typedef pair<long long, long long> P_dij;

vector<long long> dijkstra(long long s, long long n, vector<edge> G[]){
    vector<long long> d = {};
    long long INF = 10000000000000000;
    d.resize(n);
    for(int i=0; i<n; i++){
        d[i] = INF;
    }
    priority_queue<P_dij, vector<P_dij>, greater<P_dij>> que;
    d[s] = 0;
    que.push(P_dij(0, s));
    while(!que.empty()){
        P_dij p = que.top();
        que.pop();
        long long v = p.second;
        if(d[v] < p.first)continue;
        for(int i=0;i<G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P_dij(d[e.to], e.to));
            }
        }
    }
    return d;
}

long long i, j, k;
vector<edge> edge_yen[200001];
vector<edge> edge_snu[200001];

int main(){
    long long n, m, s, t;
    cin >> n >> m >> s >> t;
    for(i=0; i<m; i++){
        long long u, v, a, b;
        cin >> u >> v >> a >> b;
        edge e1;
        e1.to = v, e1.cost = a;
        edge_yen[u].push_back(e1);
        edge e2;
        e2.to = u, e2.cost = a;
        edge_yen[v].push_back(e2);
        edge e3;
        e3.to = v, e3.cost = b;
        edge_snu[u].push_back(e3);
        edge e4;
        e4.to = u, e4.cost = b;
        edge_snu[v].push_back(e4);
    }

    vector<long long> dist_yen = dijkstra(s, n+1, edge_yen);
    vector<long long> dist_snu = dijkstra(t, n+1, edge_snu);

    long long ans[200001];
    long long Max = 0;
    long long FIRST = 1e15;
    for(i=n; i>=1; i--){
        long long val = FIRST - (dist_yen[i] + dist_snu[i]);
        Max = max(val, Max);
        ans[i] = Max;
    }
    for(i=1; i<=n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 25464
#include<stdio.h>
int T,S[4*200010],N[200010];
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
//????????¢??°?????????MIN???
int hyoka(int a,int b){return (a<0||b<0)?(a<0?b:a):N[a]<N[b]?a:b;}
//?????°??¨?????????n?????°???d??§?????????????§????
void sset(int n){
  int i;
  for(T=1;T<n;T*=2);
  for(i=0;i<T;i++)S[T+i]=i<n?i:-1;
  for(i=T-1;i;i--)S[i]=hyoka(S[i*2],S[i*2+1]);
}
//?????°??¨???update??¢??°
//i???????????°??????n????????´???????§????
void sud(int i,int n){for(N[i+=T]=n;i/=2;)S[i]=hyoka(S[i*2],S[i*2+1]);}
//?????°??¨???find??¢??°
//[a,b)????????????????????????sout(a,b,1,0,T);
int sout(int a,int b,int i,int l,int r){//printf("%d %d %d %d %d\n",a,b,i,l,r);
  if(r<=a||b<=l)return -1;
  if(a<=l&&r<=b)return S[i];
  return hyoka(sout(a,b,i*2,l,(l+r)/2),sout(a,b,i*2+1,(l+r)/2,r));
}
int ta[100010],to[100010],nt[100010],d[100010],r=0,fi[100010],ID[200010];
void ldfs(int s){
  int i;
  N[fi[s]=r]=d[s];
  ID[r++]=s;
  for(i=ta[s];i+1;i=nt[i]){
    if(d[to[i]])continue;
    d[to[i]]=d[s]+1;
    ldfs(to[i]);
    N[r]=d[s];
    ID[r++]=s;
  }
}
void slca(int p){
  d[p]=1;
  r=0;
  ldfs(p);
  sset(r);
}
int alca(int a,int b){return sout(MIN(fi[a],fi[b]),MAX(fi[a],fi[b])+1,1,0,T);}
int main(){
  int n,m,i,j,e=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)ta[i]=-1;
  for(i=0;i<n;i++){
    scanf("%d",&m);
    while(m--){
      scanf("%d",&j);
      nt[e]=ta[i];
      to[e]=j;
      ta[i]=e++;
    }
  }
  slca(0);
  scanf("%d",&n);
  while(n--){
    scanf("%d %d",&i,&j);
    printf("%d\n",ID[alca(i,j)]);
  }
  return 0;
}

Measured memory_bytes: 10360
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

#define MAX 100005

int where[MAX];

signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  
  for(int i=0; i<n; i++) cin>>where[i];
  
  int ans=0;
  for(int i=1; i<n; i++){
    int kyori=where[i]-where[i-1];
    ans+=kyori*a>b?b:kyori*a;
  }
  cout<<ans<<en;
}




Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
 char moji[1200];
 int out[1200];
 int i,j;
while(scanf("%c", &moji)!=EOF){
//fgets(moji, sizeof moji, stdin);
 for(j=0;j<26;j++){
  for(i=0;i<=strlen(moji);i++){
   if(moji[i]== 65+j || moji[i]==97+j) {out[j]++;}
  }
 }
}
 for(i=0;i<26;i++){
  printf("%c : %d\n",97+i,out[i]);
 }

 return 0;
}


Measured memory_bytes: 2060
fun main(args: Array<String>){
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val h = IntArray(n){ readLine()!!.toInt() }.sorted()
    var min = Int.MAX_VALUE
    for (i in 0 until n - k + 1){
        min = Math.min(min, h[i + k - 1] - h[i])
    }
    println(min)
}

Measured memory_bytes: 42604
#!/usr/bin/env python3

def main(N, a):
    alis_score = sum(a[0::2])
    bob_score = sum(a[1::2])

    print(alis_score - bob_score)

if __name__ == '__main__':
    N = int(input())
    a = list(map(int, (input().split())))
    main(N, sorted(a, reverse=True))


Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
	int n;
	double v,y;
	while(scanf("%lf",&v) !=EOF)
	{
		y=(v/2.0)*(v/9.8);
		n=(y+5)/5;
		printf("%d\n",n+1);
	}
	return 0;
}

Measured memory_bytes: 1056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	class Vertex {
		int id;
		int[] vertices;
		int visited = -1;
		int completed = -1;
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Vertex[] vertices = new Vertex[n];
		for (int i = 0; i < n; i++) {
			vertices[i] = new Vertex();
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int id = Integer.parseInt(st.nextToken());
			vertices[i].id = id;
			int cnt = Integer.parseInt(st.nextToken());
			vertices[i].vertices = new int[cnt];
			for (int j = 0; j < cnt; j++) {
				vertices[i].vertices[j] = Integer.parseInt(st.nextToken());
			}
		}
		reader.close();
		
		DFS(vertices, n);
		
		for (int i = 0; i < n; i++) {
			Vertex vertex = vertices[i];
			System.out.println(vertex.id + " " + vertex.visited + " " + vertex.completed);
		}
	}

	private void DFS(Vertex[] vertices, int n) {
		int time = 0;
		for (int i = 0; i < n; i++) {
			Vertex vertex = vertices[i];
			Stack<Integer> stack = new Stack<Integer>();
			if (vertex.visited == -1) {
				stack.push(vertex.id);
			}
			while (!stack.isEmpty()) {
				vertex = vertices[stack.peek()-1];
				if (vertex.visited == -1) {
					vertex.visited = ++time;
				}
				boolean allVisited = true;;
				for (int j = 0; j < vertex.vertices.length ; j++) {
					int childId = vertex.vertices[j];
					if (vertices[childId-1].visited == -1) {
						vertices[childId-1].visited = ++time;
						allVisited = false;
						stack.push(childId);
						break;
					}
				}
				if (allVisited) {
					vertex.completed = ++time;
					stack.pop();
				}
			}
		}
	}
}



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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    string s;

    cin >> s;

    if(s=="ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }





    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if(b-a==c-b) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		}
}


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll n; cin >> n;
    string s; cin >> s;
    ll r=0,g=0,b=0;

    if(n < 3){
        cout << 0 << endl;
        return 0;
    }

    rep(i,n){
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else if(s[i]=='B') b++;
        else cout << "Error" << endl;
    }

    ll ans = r*g*b;

    rep(i,n-2){
        rep2(j,i+1,n-1){
            ll k = j + (j - i);
            if(k >= n) break;
            if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]) ans--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
# 11-Array-Finding_Missing_Cards.py

# ????¶???????????????????????????????
# ???????????±?????¨?????????????????????????????????????????¨????????¨?????????52?????????????????????????????? n ????????????????????????????????????????????????
# ???????????? n ????????????????????\?????¨??????????¶??????????????????????????????????????????°?????????????????????????????????
# ???????????????????????£?????????????????????????????§??????????????????52?????????????????§??????

# 52???????????????????????????????????????????????????????????????????????????????????????????????????????????????
# ???????????????13??????????????????????????????

# Input
# ?????????????????????????????£??????????????????????????° n (n ??? 52)????????????????????????
# ?¶??????? n ????????????????????????????????????????????????????????????
# ??????????????????????????§???????????????????????¨??´??°??§??????
# ????????????????????????????????¨?????????????????????'S'???????????????'H'???????????????'C'???????????????'D'??§??¨?????????????????????
# ??´??°??????????????????????????????(1 ??? 13)?????¨??????????????????

# Output
# ?¶??????????????????????????????????1??????????????????????????????
# ?????????????????\?????¨????§?????????????????????§???????????????????????¨??´??°??§??????
# ???????????????????????????????????\????????¨????????¨????????????

# ????????????????????????????????????????????????????????????????????§???????????????????????????
# ?????????????????´??????????????????????°????????????????????????????
# Sample Input
# 47
# S 10
# S 11
# S 12
# S 13
# H 1
# H 2
# S 6
# S 7
# S 8
# S 9
# H 6
# H 8
# H 9
# H 10
# H 11
# H 4
# H 5
# S 2
# S 3
# S 4
# S 5
# H 12
# H 13
# C 1
# C 2
# D 1
# D 2
# D 3
# D 4
# D 5
# D 6
# D 7
# C 3
# C 4
# C 5
# C 6
# C 7
# C 8
# C 9
# C 10
# C 11
# C 13
# D 9
# D 10
# D 11
# D 12
# D 13
# Sample Output
# S 1
# H 3
# H 7
# C 12
# D 8

pair= []
no_cards= []

hand= int( input() )

for i in range( hand ):
	pair.append( input().split() )

#????????§????¶??????????????????????????????????????????????????????????
for i in ['S', 'H', 'C', 'D']:
	for j in range(13):
		if [i, str(j+1)] not in pair:
			 no_cards.append( [i, str(j+1)] ) 

for i in range( len(no_cards) ):
	print('{0} {1}'.format(no_cards[i][0], no_cards[i][1]))

Measured memory_bytes: 7628
#include <stdio.h>
#define N 100000

 struct Node{
  int left,right,p;
};

struct Node node[N];
int D[N],n;

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",node[u].p);
  printf("depth = %d, ",D[u]);

  if(node[u].p == -1)
    printf("root, ");
  else if(node[u].left == -1){
    printf("leaf, ");
  }
  else {
    printf("internal node, ");
  }

  printf("[");
  for(i=0, c=node[u].left; c != -1; i++,c=node[c].right){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int depth(int i,int p){
  D[i] = p;
  if(node[i].right != -1) depth(node[i].right,p);
  if(node[i].left != -1) depth(node[i].left, p+1);
  return 0;
}

int main(){
  int i,j,c,d,v,left,right;

  scanf("%d",&n);
  for(i=0; i<n; i++)
    node[i].p = node[i].left = node[i].right = -1;

  for(i=0; i<n; i++){
    scanf("%d",&v);
    scanf("%d",&d);

    for(j=0; j<d; j++){
      scanf("%d",&c);
      if(j==0) node[v].left = c;
      else node[left].right = c;
      left = c;
      node[c].p = v;

    }
  }

  for(i=0; i<n; i++){
    if(node[i].p == -1) right = i;
  }

  depth(right,0);

  for(i=0; i<n; i++)/*{
    printf("node %d: ",i);
    printf("parent = %d, ",node[i].p);
    printf("depth = %d, ",D[i]);

    if(node[i].p == -1)
      printf("root, ");
    else if(node[i].left == -1){
      printf("leaf, ");
    }
    else {
      printf("internal node, ");
    }

    printf("[");
    for(i=0, c=node[i].left; c != -1; i++,c=node[c].right){
      if(i)printf(", ");
      printf("%d",c);
    }
    printf("]\n");

  }
  */
  print(i);
  return 0;
}



Measured memory_bytes: 6448
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int a[7400000];
int main(){
  while(1){
    int m,n;
    cin>>m>>n;
    if(m==0 &&n==0) break;
    lp(i,7400000){
      a[i]=0;
    }
    int i=m;
    while(n>=0){
      if(a[i]==0){
	for(int j=i;j<7400000;j+=i){
	  a[j]=1;
	}
	n--;
      }
      i++;
    }
    cout<<i-1<<endl;
  }
  return 0;
}



Measured memory_bytes: 31888
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b) << endl;
}

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

using namespace std;
using ll = long long;

vector<int> num_of_divisors(int n) {
    vector<int> ret(n + 1, 1);
    
    for(int i = 2; i <= n; ++i)
        for(int j = i; j <= n; j += i)
            ret[j]++;
    
    return ret;
}

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

    int n;
    cin >> n;

    ll ans = 0;
    vector<int> d = num_of_divisors(n);

    for(int i = 1; i <= n; ++i) {
        ans += (ll)i * d[i];
    }

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

    return 0;
}

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

int main(){

  int n, k;
  cin >> n >> k;

  int m = 1;
  for (int i = 0; i < n; i++){
    if (m < k) m*= 2;
    else m += k;
  }
  cout << m << "\n";
  return 0;
}


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

int main()
{
    auto getNextIndex = [](const std::string& str, int pos, char c) {
        size_t size = str.find(c, pos);
        if (size == std::string::npos) return -1;
        return static_cast<int>(size);
    };

    long long int result = 0;
    int n;

    std::cin >> n;
    std::string str;
    std::cin >> str;

    int b_num = std::count(str.cbegin(), str.cend(), 'B');

    int r = getNextIndex(str, 0, 'R');
    while (r != -1 && r < n)
    {
        int g = getNextIndex(str, 0, 'G');
        while (g != -1 && g < n)
        {
            int exclude_num = 0;
            int min         = std::min(r, g);
            int max         = std::max(r, g);

            auto isB = [](const std::string& str, int index, int n) {
                if (index < 0 || index >= n) return false;
                return str[index] == 'B';
            };

            if (isB(str, 2 * min - max, n)) ++exclude_num;
            if ((max - min) % 2 == 0 && isB(str, (min + max) / 2, n)) ++exclude_num;
            if (isB(str, 2 * max - min, n)) ++exclude_num;
            result += (b_num - exclude_num);

            g = getNextIndex(str, g + 1, 'G');
        }
        r = getNextIndex(str, r + 1, 'R');
    }

    std::cout << result << std::endl;
}


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

typedef long long int ll;

int main(void) {
	ll x;
	cin >> x;

	ll ans = (x / 11) * 2;
	ll m = x % 11;
	ll d;
	if (m == 0)
		d = 0;
	else if (m <= 6)
		d = 1;
	else
		d = 2;

	cout << ans + d << '\n';
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {

            var X = ulong.Parse(Console.ReadLine());
            ulong val = 100;
            ulong count = 0;

            while ( val < X)
            {
                val = val + val / 100;
                count++;
                //Console.WriteLine(count + ", " + val);
            }

            Console.WriteLine(count);


#if DEBUG
            Console.ReadLine();
#endif
        }
    }
}


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

int main(){
    long a,b,c,d;
    cin >>a >>b >>c>>d;
    long aa,bb,cc,dd;
    aa = a*c;
    bb = b*c;
    dd = a*d;
    cc = b*d;
    cout << max(aa,max(bb,max(cc,dd)));
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007LL
#define REP(i, n) for(int i=0;i<(n);++i)
typedef long long ll;

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

	int n, x; cin >> n >> x;
	if(x == 1 or x == 2*n-1) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		if(n == 2){
			cout << 1 << endl << 2 << endl << 3 << endl;
		} else if(x == 2){
			int ans = n*2-(n-1);
			REP(i, n*2-1){
				cout << ans << endl;
				ans--;
				if(ans < 1) ans = n*2-1;
			}
		} else {
			vector<int> vec(n*2-1);
			queue<int> que;
			vec[n-2]=x-1, vec[n-1]=x, vec[n]=x+1, vec[n+1]=x-2;
			for(int i = 1; i <= n*2-1; i++){
				if(i<x-2 or x+1<i) que.push(i);
			}
			REP(i, n*2-1){
				if(i<n-2 or n+1<i){
					cout << que.front() << endl;
					que.pop();
				} else {
					cout << vec[i] << endl;
				}
			}
		}
	}

	return 0;
}


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

int main() {
   ll n, k, a=0, m=1e9+7;
   cin >> n >> k;
   while(k<=n+1){
      a=(a+(n-k+1)*k+1)%m;
      k++;
   }
   cout << a << endl;
   return 0;
}


Measured memory_bytes: 3672
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a < b)
    cout << "a < b" << endl;
  else if (a > b)
    cout << "a > b" << endl;
  else
    cout << "a == b" << endl;
  return 0;
}



Measured memory_bytes: 3076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int a=0, b=0;
		double c=0, C=0, S=0, L=0, h=0;
		String[] data = in.readLine().split(" ");
		a = Integer.parseInt(data[0]);
		b = Integer.parseInt(data[1]);
		C = Math.toRadians(Integer.parseInt(data[2]));
		c = Math.sqrt((Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(C)));
		L = a+b+c;
		h = b*Math.sin(C);
		S = (a * h) / 2;
		System.out.println(S);
		System.out.println(L);
		System.out.println(h);

	}
}

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

using namespace std;

long long tong,n;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0); cout.tie(0);
	cin>>n;
 	tong=(n)*(n-1)/2;
	cout<<tong;
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7FFFFFFF
const double EPS = 1e-10;





int x, y, e;
vector<vector<int>>G;//グラフの隣接リスト表現
vector<int>match;//マッチングのペア
vector<bool>used;//同一頂点を始点としたDFSを行わないようにする
//uとvを結ぶ辺をグラフに追加する



void add_edge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}
//増加パスをDFSで探す
bool bi_dfs(int v) {
	used[v] = true;
	for (int i = 0; i<(int)G[v].size(); i++) {
		int u = G[v][i], w = match[u];
		if (w < 0) {
			match[v] = u;
			match[u] = v;
			return true;
		}
		else if (used[w] == false) {
			if (bi_dfs(w)) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
	}
	return false;
}
//二部グラフの最大マッチングを求める
int bipartitea_matching() {
	int res = 0;
	fill(match.begin(), match.end(), -1);
	for (int v = 0; v<x+y; v++) {
		if (match[v]<0) {//頂点vのマッチングのペアが現時点でない場合
			fill(used.begin(), used.end(), false);
			if (bi_dfs(v)) {
				res++;
			}
		}
	}
	return res;
}

signed main() {
  int n;
  cin >> n;
  vector<int> a,b;
  x=n;
  y=n;
  
	G.resize(x + y);
	match.resize(x + y);
	used.resize(x + y);

  for(int i=0;i<2*n;i++){
    int u, v;
		cin >> u >> v;
    a.push_back(u);
    b.push_back(v);
  }

  for(int i=0;i<n;i++){
    for(int j=n;j<2*n;j++){
      if(a[i]<a[j]&&b[i]<b[j]){
        add_edge(i, j);
      }
    }
  }

	cout << bipartitea_matching() << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
const int maxn = 2e6 + 5;
long long a[maxn];
int main(){
	int n ;
	long long m ;
	scanf("%d%lld",&n,&m);
	for(int i = 1;i <= n;i++){
		scanf("%lld",&a[i]);
		}
	long long sum = m;
	for(int i = n;i > 1;i--){
		if(a[i] - a[i - 1] >= m)sum += m;
		else sum += a[i] - a[i - 1];
		}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll fact[100005],inv[100005];
ll ncr(ll n , ll r){
	if(n<r)return 0 ;
	ll ans = (fact[n]%mod*inv[n-r]%mod*inv[r]%mod)%mod;
	return ans ;
}
ll power(ll x , ll y){
	if(y==0)return 1;
	ll ps = power(x , y/2)%mod;
	ll ss=(ps%mod*ps%mod)%mod;
	if(y&1)ss=(ss%mod*x%mod)%mod;
	return ss;
}
void pre(){
	fact[0]=1;
	inv[0]=1;
	for(ll i=1;i<=100000 ; i++){
		fact[i]=(fact[i-1]%mod*i%mod)%mod;
		inv[i]=(inv[i-1]%mod*power(i , mod-2 )%mod)%mod;
	}
}
int main(){
	//mahakal();fast;
	pre();
	ll n , k ;
	cin>>n>>k ;
	ll arr[n];
	for(ll i=0;i<n;i++)cin>>arr[i];
	ll ans = 0 ;
	sort(arr , arr+n);
	for(ll i=0;i<n;i++){
		ans += (arr[i]%mod*(ncr(i,k-1)-ncr(n-i-1,k-1))%mod);
		ans = (ans%mod+mod) % mod;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define dump(a) cout << #a << "=" << a << endl
using namespace std;

char left_key[15] = {
	'q','w','e','r','t', 
	'a','s','d','f','g',
	'z','x','c','v','b'
};
char right_key[11] = {
	'y','u','i','o','p',
	'h','j','k','l',
	'n','m'
};

bool is_word(string word) {
	return false;
}

int main() {
	string word;
	while(cin >> word) {
		if (word[0] == '#') { break; }

		int back = 0;
		int now = 0;
		int cnt=0;
		for(int i = 0; i < word.size(); i++) {
			//cout << word[i] << endl;
			for(int j = 0; j < 15; j++) {
				if (left_key[j] == word[i]) {
					now = 1;
				}
			}
			for(int j = 0; j < 11; j++) {
				if (right_key[j] == word[i]) {
					now = 2;
				}
			}
			//cout << "now: " << now << endl;
			if (now != back) { cnt++; }
			back = now;
		}
		cout << (cnt-1) << endl;

	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1184
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    H, A = read_int_list()
    res = 0
    for i in range(10001):
      H = H - A
      res += 1
      if H <= 0:
        break
    print(res)


main()


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> P){
  vector<pll> p;
  REP(N)p.push_back(pll(P[i],i));
  sort(p.begin(),p.end(),greater<pll>());
  ll ans=0;
  set<ll> pos;
  REP(N){
    ll cnt=0;
    vector<ll> x(4);
    auto r=pos.upper_bound(p[i].second);
    if(r!=pos.end()){
      x[2]=*r-p[i].second;
      if(next(r)!=pos.end()){
        x[3]=*next(r)-*r;
      }else{
        x[3]=N-*r;
      }
    }else{
      x[2]=N-p[i].second;
    }
    if(r!=pos.begin()){
      x[1]=p[i].second-*prev(r);
      if(prev(r)!=pos.begin()){
        x[0]=*prev(r)-*prev(r,2);
      }else{
        x[0]=*prev(r)+1;
      }
    }else{
      x[1]=p[i].second+1;
    }
    //dump(p[i].first);
    //dump(x);
    cnt=x[1]*x[3];
    cnt+=x[0]*x[2];
    ans+=cnt*p[i].first;
    pos.insert(p[i].second);
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 7280
#include <iostream>
using namespace std;
int H[100005];
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i=0; i<N; i++) cin >> H[i];
  for (int i=N-1; i>0; i--) {
    if (H[i-1] > H[i]) H[i-1]--;
    if (H[i-1] > H[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
mantion = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]


n = int(input())

for i in range(n):
    i, j, k, v = map(int, input().split())
    mantion[i - 1][j - 1][k - 1] += v

for a in range(4):
    for b in range(3):
        print('',*mantion[a][b])
    if a != 3:
       print('#'*20)



Measured memory_bytes: 5620
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    s = S()

    print(yn[s[2] == s[3] and s[4] == s[5]])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38724
// atcoder/abc172/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  const lli N = 1e7 + 5;
  static lli x[N];
  fill(x, x + N, 0);
  for (lli i = 1; i < N; ++i) {
    for (int j = i; j < N; j += i) {
      ++x[j];
    }
  }

  lli n;
  while (cin >> n) {
    lli y = 0;
    for (lli i = 1; i <= n; ++i) {
      y += i * x[i];
    }
    cout << y << endl;
  }

  return 0;
}


Measured memory_bytes: 81776
N = int(input())
L = list(map(int,input().split()))

L.sort()

s = 0

ma = L[N-1]
for j in range(N-2):
    ja = L[j]
    for k in range(j+1,N-1):
        ka = L[k]
        # L[i] < L[j]+L[k] となる L[i]の数を求める
        key = ja + ka
        l = k + 1
        r = N - 1
        while r - l > 1:
            m = l + (r - l) // 2
            if L[m] < key:
                l = m
            else:
                r = m
        kka = L[k+1]
        if kka < key <= ma:
            s += l-k
        elif key <= kka:
            s += 0
        else:
            s += N-k-1

print(s)


Measured memory_bytes: 44764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 2e5 + 7, MOD = 1e9 + 7;

int binpow(int x, int deg) {
    int val = 1;
    while (deg) {
        if (deg & 1)
            val = val * x % MOD;
        x = x * x % MOD;
        deg >>= 1;
    }
    return val;
}

vector <int> g[N];
int ans, rev2, sz[N];

void dfs(int v, int p, int n) {
    sz[v] = 1;
    int mns = 0;
    for (int u : g[v])
        if (u != p) {
            dfs(u, v, n);
            sz[v] += sz[u];
            mns = (mns + binpow(2, sz[u]) - 1) % MOD;
        }
    mns = (mns + binpow(2, n - sz[v])) * 2 % MOD;
    ans = (ans + (binpow(2, n) - mns + MOD) % MOD * binpow (rev2, n + 1)) % MOD;
}

void solve() {
    rev2 = binpow(2, MOD - 2);
    int n; cin >> n;
    loop(i, n - 1) {
        int u, v;
        cin >> u >> v;
        g[v].pb(u);
        g[u].pb(v);
    }
    dfs(1, 1, n);
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 27476
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------
int n;
void dfs(string s,char mx){
  if(s.size() == n){
    cout << s << endl;
    return;
  }
  for(char c = 'a' ; c <= mx+1; c++){
    string t = s;
    t += c;
    dfs(t,max(mx,c));
  }
}

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

  cin >> n;
  dfs("", 'a'-1);
  return 0;
}


Measured memory_bytes: 1536
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

use std::collections::BTreeSet;

fn main() {
    input! {
        n:usize,
        p:[usize;n]
    }
    let mut set = BTreeSet::new();
    let mut idx = vec![0; n + 1];
    for (i, &x) in p.iter().enumerate() {
        idx[x] = i;
    }
    let mut ans = 0_isize;
    for i in (1..=n).rev() {
        set.insert(idx[i] as isize);
        let mut left = set.range(0..idx[i] as isize);
        let mut right = set.range(idx[i] as isize + 1..);

        if let Some(t) = left.next_back() {
            let f = *left.next_back().unwrap_or(&-1);
            let k = *right.next().unwrap_or(&(n as isize));
            ans += i as isize * (*t - f) * (k - idx[i] as isize);
        }

        let mut left = set.range(0..idx[i] as isize);
        let mut right = set.range(idx[i] as isize + 1..);

        if let Some(f) = right.next() {
            let t = *right.next().unwrap_or(&(n as isize));
            let k = *left.next_back().unwrap_or(&-1);
            ans += i as isize * (t - *f) * (idx[i] as isize - k);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 7120
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(a);
        int ans = 0;
        for(int i=0; i<n-1; i++){
            if(x >= a[i]){
                x -= a[i];
                ans++;
            }
        }
        if(x == a[n-1]) ans++;
        System.out.println(ans);
    }
}

Measured memory_bytes: 22732