akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

ll cnt[10][10];

int main(){

    ll N;
    cin >> N;
    rep1(i, N){
        ll a = i % 10;
        ll b = i;
        while(b >= 10)b/=10;
        cnt[a][b]++;
    }
    ll ans = 0;
    rep(i, 10)rep(j, 10){
        ans += cnt[i][j] * cnt[j][i];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;
long long n;
int cnt = 0;

void check(long long x) {
    bool ok[3] = { false,false,false };

    if (x > n)return;
    int amari;
    while (x > 0) {
        amari = x % 10;
        if (amari == 3 ) {
            ok[0] = true;
        }
        else if (amari == 5) {
            ok[1] = true;
        }
        else if (amari == 7) {
            ok[2] = true;
        }

        x /= 10;
    }

    if (ok[0] == true && ok[1] == true && ok[2] == true) {
        cnt++;
        return;
    }
    else {
        return;
    }
}

void dfs(long long x) {
    check(x);
    if (x <= 1000000000) {
        dfs(10 * x + 3);
        dfs(10 * x + 5);
        dfs(10 * x + 7);
    }
}

int main()
{
 

    cin >> n;

    dfs(0);

    cout << cnt << endl;
}



Measured memory_bytes: 3648
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int ma = -(Integer.MAX_VALUE >> 4);
		int mi = Integer.MAX_VALUE >> 4;
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			ma = Math.max(ma, a[i]);
			mi = Math.min(mi, a[i]);
		}
		int cnt_ma = 0, cnt_mi = 0;
		for (int i = 0; i < n; ++i) {
			if (ma == a[i]) {
				++cnt_ma;
			} else {
				++cnt_mi;
			}
		}
		if (ma - 1 != mi && ma != mi) {
			System.out.println("No");
			return;
		}
		if (ma == mi && ma == n - 1) {
			System.out.println("Yes");
			return;
		}
		int v = ma - (ma == mi ? 0 : cnt_mi);
		if (1 <= v && v <= cnt_ma / 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 51024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    string C; cin >> C;
    vector<ll> dp(N+1);

    set<int> Rs,Ws;
    for(int i = 0; i < N;i++){
        if(C[i] == 'R'){
            Rs.insert(i);
            //Rs.emplace_back(i);
        }else{
            Ws.insert(i);
            // Ws.emplace_back(i);
        }
    }
    int R = (int)count(C.begin(),C.end(),'R');
    int W = N - R;
    // cout << R << " " << W << endl;


    res = LINF;
    int T = 0;
    for(int i = 0; i < N;i++){
        res = min(res,(ll)T+(ll)Rs.size());
        
        if(C[i] == 'W'){
            if(Rs.size()){
                int id = *Rs.rbegin();
                C[id] = 'W';
                Rs.erase(id);
                T++;
            }
        }else{
            Rs.erase(i);
        }
    }
    res = min(res,(ll)T+(ll)Rs.size());

    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 14444
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(int i=1;i<n-1;i++){
		if((a[i]<a[i-1]&&a[i]>a[i+1])||(a[i]>a[i-1]&&a[i]<a[i+1])){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int moji[40];
  string ret = "Yes";
  for(int i = 0; 40 > i; i++)moji[i] = 0;
  for(int i = 0; s.size() > i;i++)moji[s[i] - 90]++;
  for(int i = 0; 40 > i; i++){
    if(moji[i] % 2 == 1) ret = "No";
  }
  cout << ret << endl;
}

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

int main() {
    int K, S;
    cin>>K>>S;

    vector<int> k(K+1);
    for(int i=0; i<K+1; i++) k.at(i)=i;

    int cnt=0;

    for(int i=0; i<K+1; i++){
        for(int j=0; j<K+1; j++){
            if(binary_search(k.begin(), k.end(), S-i-j)) cnt++;
        }
    }

    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,n,a;
    cin>>h>>w>>n;
    int ma[h][w];
    pair<int,int> pa;
    vector<pair<int,int> > v;
    for(int i=1;i<=n;i++){
        cin>>a;
        pa=make_pair(a,i);
        v.push_back(pa);
    }
    int r=0,c=0;
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());


    for( int i=0;i<n;i++){
        while(v[i].first--){
            ma[r][c]=v[i].second;
            if(r&1) {
                if(c==0) {
                        r++;
                continue;
                }
                c--;
            }
            else {
                if(c==w-1) {
                        r++;
                continue;
                }
                c++;
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cout<<ma[i][j]<<" ";
        cout<<endl;
    }
return 0;
}


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

using namespace std;

int checker(std::vector<string> str, int x, int y, int n){
	for (size_t i = 0; i < n; i++) {
		/* code */
		for (size_t j = i; j < n; j++) {
			/* code */
			if (str[i + x][j + y] != str[j + x][i + y]) {
				/* code */
				return 0;
			}
		}
	}
	return 1;
}

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<string> str(n);
	for (size_t i = 0; i < n; i++) {
		std::cin >> str[i];
		str[i] += str[i];
	}
	for (size_t i = 0; i < n; i++) {
		str.push_back(str[i]);
	}
	int ans = 0;
	for (size_t i = 0; i < n; i++) {
		/* code */
		ans += checker(str, i, 0, n);
	}

	std::cout << ans * n << '\n';
	return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main() {
    int a,b,c,d,i;
    cin >> a >> b >> c >> d;
    
    for (i=0;i<150;i++)
    {
        if (c <= 0)
        {
            cout << "Yes";
            break;
        }
        else {
            c = c - b;
        }
        if (a <= 0)
        {
            cout << "No";
            break;
        }
        else{
            a = a - d;
        }
    }
    
}

Measured memory_bytes: 3588
s = input()
n = len(s)
s1 = s[0:(n - 1) // 2]
s2 = s[(n + 3) // 2 - 1:]
if s == s[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9072
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int N = in.nextInt();

        
        int prime_number[] = {11, 31, 41, 61, 71,
        		101,131,151,181,191,
        		211,241,251,271,281,
        		311,331,401,431,461,
        		491,521,541,571,601,
        		631,641,661,691,701,
        		751,761,811,821,881,
        		911,941,971,991,1021,
        		54941, 55021, 55051, 55061, 55171, 
        		55201, 55291, 55331, 55351, 55381, 
        		55411, 55441, 55501, 55511, 55541};
        
        
        
        
        	System.out.print("2");
        
        for(int i=0;i<N-1;i++)
        	System.out.print(" "+prime_number[54-i]);
        

     
    }

}


Measured memory_bytes: 23892
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in= new Scanner(System.in);
        int h,m,s,sec;
        sec=in.nextInt();
        h=sec/3600;
        m=(sec%3600)/60;
        s=((sec%3600)%60);
        System.out.println(h+":"+m+":"+s);
    }
}


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

typedef long long ll;

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

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

    int n = 0;
    cin >> n;
    vector<int> v(n, 0);
    vector<int> cnt(1e6 + 5, 0); 
    int mx = -1;

    for(int i = 0; i < n; i++) {
        cin >> v[i];
        mx = max(mx, v[i]);
        cnt[v[i]]++;
    }

    vector<int> dp(mx + 1, 0);

    int ans = 0;
    for(int i = 0; i < n; i++) {
        ll temp = v[i];
        while(temp + v[i] <= mx) {
            temp = temp + v[i];
            dp[temp] = 1;
        }
    }

    for(int i = 0; i < n; i++) {
        if(dp[v[i]] == 0 && cnt[v[i]] == 1) ans++; 
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 11904
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn divisor(n: i64) -> Vec<i64> {
    let mut v = Vec::new();
    let mut i = 1;
    while i * i <= n {
        if n % i == 0 {
            v.push(i);
            if i * i != n {
                v.push(n / i);
            }
        }
        i += 1;
    }

    v.sort();
    v
}

fn main() {
    input! {
        n: i64
    }


    let v = divisor(n);
    let mut ans: i64 = v.into_iter().map(|x| x as i64 -1).filter(|&x| x > 0 && n/x == n%x).sum();

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


Measured memory_bytes: 4352
#include<iostream>

#define MAXN 100000
#define MAXQ 50000

using namespace std;

int n,q;
int S[MAXN+1],T[MAXQ+1];
int cnt=0;

bool binarySearch( int num )
{
	int lo,mi,hi;
	bool res=false;
	lo=0;
	mi=hi=n-1;
	while( lo <= hi ) {
		mi=(lo+hi)/2;
		if( num < S[mi] ) {
			hi=mi-1;
		} else if( S[mi] < num ) {
			lo=mi+1;
		} else {
			res=true;
			break;
		}
	}
	

	return res;
}

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

	cin>>q;
	for( int i=0; i<q; i++ ) {
		cin>>T[i];
		cnt += binarySearch( T[i] );
	}
	cout<<cnt<<endl;
	
    return 0;
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
  ll N;
  string S;
  cin>>N>>S;

ll ans=0;
  for(char i='0';i<='9';i++){
  for(char j='0';j<='9';j++){
  for(char k='0';k<='9';k++){
    ll cou=0;
    for(ll t=0;t<S.size();t++){
      if(cou==0){
        if(S[t]==i){
          cou++;
        }
      }
      else if(cou==1){
        if(S[t]==j){
          cou++;
        }
      }
      else{
        if(S[t]==k){
          ans++;
          break;
        }
      }
    }
  }
  }
  }

cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    vi V(3);
    for (int i = 0; i < 3; ++i) cin >> V[i];
    sort(V.begin(), V.end());
    if (V[0] == 5 && V[1] == 5 && V[2] == 7) {
        cout << "YES\n";
    } else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    (v).begin(), (v).end()
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    lint N = in;
    vector<lint> A(5);
    rep( i, 5 ) A[i] = in;
    sort( all(A) );
    cout << 5+(N-1)/A[0] << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
const int MOD = 1e9+7;
using namespace std;
int main()
{ ios_base::sync_with_stdio(false); cin.tie(0);
	int n,k;cin>>n>>k;
  ll dpp[k+1]={0};
  dpp[0]=1;
  for(int i=0;i<n;i++)
  { int curr_lim;cin>>curr_lim;
    ll dp[k+1]={0};
    for(int already=k;already>=0;--already)
    {
         int l=already+1;
         int r=already+min(k-already,curr_lim);
         if(l<=r)
            { dp[l]=(dp[l]+dpp[already]+MOD)%MOD;
               if(r+1<=k)
               { dp[r+1]=(dp[r+1]-dpp[already]+MOD)%MOD; }
            }
    }
          ll pre=0;
        for(int j=0;j<=k;j++)
        {
          pre=(pre+dp[j]+MOD)%MOD;
          dpp[j]=(dpp[j]+pre+MOD)%MOD;
        }
  }
   cout<<dpp[k];
  return 0;
}


Measured memory_bytes: 1792
#因数分解
#N=24ならばa=[2, 2, 2, 3]　のように素因数が昇順の配列で返される
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

#Nから1,2,3...とどこまで引けるか数える
#引けなくなったらその前でストップ
#引ける回数(=最大で引ける数)を返す
#N=5であれば、1,2まで引けて3は引けない(負になる)ので2を返す
def cn(n):
  i=1
  count=0
  while n >= i:
    n=n-i
    count+=1
    i+=1
  return count;

N=int(input())
#checkに素因数リストを格納
check=prime_factorize(N)

ans=0

while check:
  #最小の素因数を取得
  get=check[0]
  #getを数える、すなわちある素数が何乗か調べる
  num=check.count(get)
  #与えられた手順をある素数に対して何回行えるか
  ans+=cn(num)
  #使った素数はリストから消す
  del check[:num]
  
print(ans)

Measured memory_bytes: 9100
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll n;
cin>>n;
ll ans=-1;
ll t=10;
ll st=7%n;
for(ll i=0;i<=1e7;i++)
{
if(st==0)
{
ans=i+1;
break;
}
st=(st+(t*7)%n)%n;
t=(t*10)%n;
}
cout<<ans<<endl;
}




/*
 * ||||


 */

Measured memory_bytes: 3628
import numpy as np

N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
ans = 0

for _ in range(N):
    A = np.array([list(map(int, input().split()))])
    if np.dot(A, B) + C > 0:
        ans += 1

print(ans)

Measured memory_bytes: 12488
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
    long long n,k,tool,t=1,a[10000]={0};
    cin>>n>>k;
    if(n>k)
    {
        if(n%k==0)
            cout<<0;
        else
        {
            if(n%k>abs(k-n%k))
                cout<<abs(k-n%k);
            else
                cout<<n%k;
        }
    }
    else
    {
    long long flag=0,jilu=n;
    a[0]=jilu;
    while(!flag)
    {
        t++;
        n=abs(n-k);
        a[t-1]=n;
        if(n==jilu)
           break;
    }
    long long mi=a[0];
    for(int i=1;i<t;i++)
    {
        mi=min(mi,a[i]);
    }
    cout<<mi;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int A[1000000];
int n;

int search(int key){
  int left = 0;
  int right = n;
  int mid;
  while( left < right ){
    mid = (left + right ) /2;
    if ( key == A[mid] ) return 1;
    if ( key > A[mid] ) left = mid+1;
    else if ( key < A[mid] ) right = mid;
  }
  return 0;
}

main(){
  int i, q, k, sum = 0;

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

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ){
    scanf("%d", &k);
    if ( search( k ) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;

#define N 2000000

int n;
int A[N+1];

int parent(int i){
	return i/2;
}
int left(int i){
	return 2*i;
}
int right(int i){
	return 2*i+1;
}
int inside(int i){
	if(i>=1&&i<=n) return 1;
	else return 0;
}

void max_heapify(int x){
	int l = left(x);
	int r = right(x);
	int largest = x;
	if(inside(l)&&A[l]>A[largest]) largest = l;
	if(inside(r)&&A[r]>A[largest]) largest = r;
	if(largest!=x){
		int tmp = A[largest];
		A[largest] = A[x];
		A[x] = tmp;
		max_heapify(largest);
	}
}

void insert(int k){
	A[n+1] = k;
	n++;

	int x = n;
	while(inside(parent(x))){
		if(A[x]>A[parent(x)]){
			int tmp = A[x];
			A[x] = A[parent(x)];
			A[parent(x)] = tmp;
			x = parent(x);
		}else{
			break;
		}
	}
}

int extract(){
	int ret = A[1];
	A[1] = A[n];
	n--;
	max_heapify(1);
	return ret;
}

int main(){
	n = 0;
	for(;;){
		char s_[100];
		scanf("%s", s_);
		string s = s_;
		if(s=="end"){
			break;
		}else if(s=="insert"){
			int k;
			scanf("%d", &k);
			insert(k);
		}else if(s=="extract"){
			cout << extract() << endl;
		}

//		cout << n << endl;
		/*
		for(int i=1; i<=n; i++){
			cout << " " << A[i];
		}
		*/
	}
	/*
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> A[i];
	}
	*/
	/*
	for(int i=1; i<=n; i++){
		printf("node %d: ", i);
		printf("key = %d, ", A[i]);
		if(inside(parent(i))) printf("parent key = %d, ", A[parent(i)]);
		if(inside(left(i))) printf("left key = %d, ", A[left(i)]);
		if(inside(right(i))) printf("right key = %d, ", A[right(i)]);
		printf("\n");
	}
	*/
/*
	for(int i=n; i>=1; i--){
		max_heapify(i);
	}
	for(int i=1; i<=n; i++){
		cout << " " << A[i];
	}
	cout << endl;
*/
	return 0;
}

Measured memory_bytes: 5324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n;
    cin >> n;
    ll m = -INF;
    ll ans = 0;
    for (i = 0; i < n; i++) {
        ll a;
        cin >> a;
        if (m < a)
            m = a;
        else
            ans += m - a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  const ll INF = 1e18;
  vector<vector<vector<ll>>> dp(n + 1,
                                vector<vector<ll>>(2, vector<ll>(2, -INF)));
  dp[0][1][0] = 0;
  REP(i, n) {
    REP(j, 2) {
      REP(k, 2) if (dp[i][j][k] != -INF) {
        if (i % 2 == 1) {
          chmax(dp[i + 1][j][0], dp[i][j][k]);
        } else {
          chmax(dp[i + 1][0][0], dp[i][1][k]);
        }
        if (i % 2 == 1) {
          chmax(dp[i + 1][1][1], dp[i][0][0] + a[i]);
        } else {
          chmax(dp[i + 1][j][1], dp[i][j][0] + a[i]);
        }
      }
    }
  }
  int b = !(n % 2 == 1);
  cout << max(dp[n][b][0], dp[n][b][1]) << endl;
}

Measured memory_bytes: 34364
#include<cstdio>
#define MAXN 100005
#define LL long long
int n;
LL a[MAXN],b[MAXN],sum,cnt;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    LL tmp=1LL*n*(n+1)/2;
    if(sum%tmp)
    {
        printf("NO\n");
        return 0;
    }
    LL cnt=sum/tmp;
    b[n]=b[1]-a[n];
    b[n]=cnt-b[n];
    for(int i=1;i<n;i++)
    {
        b[i]=cnt-(a[i+1]-a[i]);
        if(b[i]<0||(b[i]%n))
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 1664
n,m = gets.split.map(&:to_i)
def C n,k
   if k==0 then
      return 1
   elsif n==k then
      return 1
   else
      return C(n-1,k-1)+C(n-1,k)
   end
end
a = n >= 2 ? C(n, 2) : 0
b = m >= 2 ? C(m, 2) : 0
puts a + b


Measured memory_bytes: 1788
import math

a=input().rstrip().split(" ")
n=int(a[0])
k=int(a[1])
t=1
_sum=0

if k == 0:
    t=0
for b in range(k+1,n+1):
    
    _sum = _sum + (b-k)*math.floor(n/b)+max(0,n%b-k+t)
print(_sum)


Measured memory_bytes: 3060
import java.util.*;
 
public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int A = sc.nextInt(),
                            B = sc.nextInt(),
                            C = sc.nextInt(),
                            D = sc.nextInt(),
                            P = sc.nextInt();
                        System.out.println(Math.min(A*P, Math.max(P-C,0)*D+B));
                }
        }
}

Measured memory_bytes: 26360
N = int(input())
A = [int(x) for x in input().split(" ")]

A.sort(reverse=True)
score = A[0]
count = 1
for a in A[1:]:
    if count == len(A) - 1:
        break
    if count == (len(A) - 2):
        score += a
        count += 1
        continue
    score += a * 2
    count += 2

print(score)


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

int main(){
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long h,c=0,i=0;
  cin>>h;
  
  while(h>0){
  	c=c+pow(2,i);
    h/=2;
    i++;
  }
  cout<<c;
return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	var hh, nn, ww int
	for h := 1; h <= 3500; h++ {
		for n := 1; n <= 3500; n++ {
          if 4*h*n-h*N-n*N <= 0 {
            continue
          }       		
          if (h*n*N)%(4*h*n-h*N-n*N) == 0 {
            hh = h
            nn = n
            ww = (h * n * N) / (4*h*n - h*N - n*N)

          }
		}
	}
	fmt.Printf("%d %d %d\n", hh, nn, ww)
}


Measured memory_bytes: 512
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

void main() {
    int N, M;
    bool input() {
        scanf("%d %d\n", &N, &M);
        if (N == 0 && M == 0) return false;
        return true;
    }
    void solve() {
        int[] step(in int[] xs) {
            auto ret = new int[xs.back >= 2 ? xs.length + 1 : xs.length];
            foreach (int i, x; xs) {
                ret[0] += x / 2;
                ret[i] += x % 2;
                if (x >= 2) {
                    ret[i + 1] += x / 2;
                }
            }
            return ret;
        }
        auto xs = [N];
        for (int i = 0; ; i++) {
            //writeln(xs);
            if (xs.length == M + 1) {
                writeln(i);
                break;
            }
            xs = step(xs);
        }
    }
    int T = 0;
    while (input) {
        writef("Case %d: ", ++T);
        solve;
    }
}

Measured memory_bytes: 2036
#include<iostream>
#include<stdio.h>
#include <bits/stdc++.h>
#include<string>
#include<vector>
#include<iterator>
#include<algorithm>

using namespace std;

int main()
{
    int n, m, i, a, sum=0;

    scanf("%d %d", &n, &m);

    for(i=1;i<=m;i++){
        scanf("%d", &a);
        sum=sum+a;
    }

    if(sum>n) printf("-1\n");
    else if(n>sum) printf("%d\n", n-sum);
    else printf("0\n");

    return 0;
}

Measured memory_bytes: 3816
h, w = map(int, input().split())
a = []
for i in range(h):
    ai = [j for j in input()]
    if set(ai) == {'.'}:
        continue
    a.append(ai)
len_a = len(a)
at = list(zip(*a))
at2 = []
for ati in at:
    if set(ati) != {'.'}:
        at2.append(ati)
att = list(zip(*at2))
for ai in att:
    print(*ai, sep='')

Measured memory_bytes: 4596
n = int(input())

for i in range(1, (n+1)):
	x = i
	
	if (x % 3) == 0:
		print(" {}".format(i), end = "")
	else:
		while True:
			if (x % 10) == 3:
				print(" {}".format(i), end = "")
				break
			x //= 10
			if x == 0:
				break

print("")
	

Measured memory_bytes: 7940
n = int(input())
X = []
for i in range(n):
  x, l = map(int, input().split())
  X.append([x-l, x+l])
X.sort()
temp = X[0][1]
count = n
for i in range(1,n):
  if temp>X[i][0]:
    count -= 1
    temp = min(temp, X[i][1])
  else:
    temp = X[i][1]
print(count)

Measured memory_bytes: 59224
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()

    week = ('MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN')
    if S == 'SUN':
        ans = 7
    else:
        ans = 6 - week.index(S)
    print(ans)


main()


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>
#include <climits>
#include <map>
#define rep(i, c) for (int i = 0; i < (int)c; i++) //atcoderの解説コードに利用されていたので，ある程度一般生があるかと思われる．

int main()
{
    int N, count = 1, flag;
    std::cin >> N;

    std::map<int, int> P_map;
    count = 0;
    for (int i = 0; i < N; i++)
    {
        int temp;
        std::cin >> temp;
        P_map[temp] = i;
        auto begin = P_map.begin();
        if (begin->second == i)
        {
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};
#define MHW 501

int H,W;
string a[MHW];
char red[MHW][MHW];
char blue[MHW][MHW];
int main(){
    ios::sync_with_stdio(false);
    cin >> H >> W;
    REP(i,H)REP(j,W) {
        if (i%2) {
            red[i][j]='#';
            blue[i][j]='.';
        }
        else {
            red[i][j]='.';
            blue[i][j]='#';
        }
    }
    
    REP(i,H) {
        red[i][0]='#';
        blue[i][0]='.';
        red[i][W-1]='.';
        blue[i][W-1]='#';
    }
    
    REP(i,H) {
        cin >> a[i];
        REP(j,W) {
            if (a[i][j]=='.') continue;
            red[i][j] = a[i][j];
            blue[i][j] = a[i][j];
        }
    }
    
    REP(i,H) {
        REP(j,W) {
            cout << red[i][j];
        }
        cout << endl;
    }
    
    cout << endl;
    
    REP(i,H) {
        REP(j,W) {
            cout << blue[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
template<class T>
vector<ll> Dijkstra(T g, int st) {
	priority_queue<pii, vector<pii>, greater<pii>> que;

	que.push({ 0, st });
	int kk = 0;
	vector<ll> res(g.vn, -1);
	while (kk < g.vn && que.size()) {
		pii cur = que.top();
		que.pop();
		if (res[cur.second] != -1)
			continue;
		res[cur.second] = cur.first;
		kk++;
		for (auto itr : g.g[cur.second]) {
			if (res[itr.first] == -1)
				que.push({ cur.first + itr.second,itr.first });
		}
	}
	return res;
}
signed main() {

	ll n;
	cin >> n;

	printf("50\n");

	ll base = n / 50 + 49;
	REP(j, 50 - n % 50) {
		printf("%lld ", base - n % 50);
	}
	REP(j, n % 50) {
		printf("%lld ", base + 50 - n % 50 + 1);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve(long long N, std::vector<long long> d){
    ll sum=0;
    for (ll i = 0; i < N; i++)
    {
        for (ll j = i + 1; j < N; j++)
        {
            sum+=d[i]*d[j];
        }
    }
    cout << sum << "\n";
}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    for(ll h = 1; h <= 3500; h++){
        for(ll n = 1; n <= 3500; n++){
            if(4 * n * h - n * N - N * h != 0){
                if(n * N * h % (4 * n * h - n * N - N * h) == 0){
                    ll w = n * N * h / (4 * n * h - n * N - N * h);
                    if(w > 0){
                        cout << h << ' ' << n << ' ' << w << endl;
                        return 0;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    unordered_map<int,int> d;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        d[a]++;
        d[b]++;
    }
    bool can=true;
    for(auto it:d){
        if(it.second%2==1)can=false;
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5010;
int f[1010][maxn], c[maxn], a[maxn], n, m;
int read() {
	int x = 0, f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar())if (c == '-')f = -1;
	for (; isdigit(c); c = getchar())x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

template<typename T>bool chkmin(T &a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	else return 0;
}

void solve() {
	//ios::sync_with_stdio(false);

	//cin>>n>>m;
	n = read(); m = read();
	//cerr << m << endl;
	for (int i = 1, x; i <= m; ++i) {
		//cin>>a[i]>>x;
		a[i] = read();
		x = read();
		for (int j = 1, y; j <= x; ++j) {
			c[i] |= 1 << (y = read() - 1);
		}
	}
	int S = 1 << n;
	memset(f, 0x3f, sizeof f);
	int inf = f[0][0];
	f[0][0] = 0;
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < S; ++j) {
			chkmin(f[i + 1][j | c[i + 1]], a[i + 1] + f[i][j]);
			chkmin(f[i + 1][j], f[i][j]);
		}
	}
	if (f[m][S - 1] == inf)puts("-1");
	else printf("%d\n", f[m][S - 1]);
}
int main() {
	solve();

	return 0;
}

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

using namespace std;

int main() {
  int n, x, y; cin >> n >> x >> y;
  x--; y--;

  int w = x - y + 1;

  vector<int> ans(n,0);
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      int d = j - i;
      d = min(d, abs(i - x) + abs(j - y) + 1);
      d = min(d, abs(i - y) + abs(j - x) + 1);
      ans[d]++;
    }
  }

  for(int i = 1; i < n; i++) {
    cout << ans[i] << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    let mut b=0;
    for i in 0..a.len(){
        if a[i]=='x'{
            b+=1
        }
    }
    println!("{}",if b>7{"NO"}else{"YES"})
}

Measured memory_bytes: 2156
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

class BIT{
private:
    vector<ll> bit;
    int n;
public:
    BIT(){};
    BIT(int N){
        init(N);
    }
    void init(int N){
        n = N;
        bit.clear();
        bit.resize(N+1,0);
    }
    ll sum(int i){
        ll s = 0;
        while(i>0){
            s += bit[i];
            i -= i&-i;
        }
        return s;
    }
    ll sum_range(int l,int r){
        if(l>r) return 0;
        return (sum(r)-sum(l-1));
    }
    void add(int i,ll x){
        while(i<=n){
            bit[i] += x;
            i += i&-i;
        }
    }
    ll sum0(int i){
        return sum(i);
    }
    void add0(int i,ll x){
        add(i,x);
    }
};

int main(){
    int N;
    cin >> N;
    vector<ll> P(N+1),pos(N+1);
    for(int i=1;i<=N;i++){
        cin >> P[i];
        pos[P[i]] = i;
    }
    BIT bit(N+1);
    bit.add(pos[N],1);
    ll ans = 0;
    for(ll i=N-1;i>=1;i--){
        int now = pos[i];
        ll l2l = 0,l2r = now;
        while(l2l+1<l2r){
            ll m = (l2l+l2r)/2;
            if(bit.sum_range(m,now)>=2) l2l = m;
            else l2r = m;
        }
        ll l1l = 0,l1r = now;
        while(l1l+1<l1r){
            ll m = (l1l+l1r)/2;
            if(bit.sum_range(m,now)>=1) l1l = m;
            else l1r = m;
        }
        ll r2l = now,r2r = N+1;
        while(r2l+1<r2r){
            ll m = (r2l+r2r)/2;
            if(bit.sum_range(now,m)>=2) r2r = m;
            else r2l = m;
        }
        ll r1l = now,r1r = N+1;
        while(r1l+1<r1r){
            ll m = (r1l+r1r)/2;
            if(bit.sum_range(now,m)>=1) r1r = m;
            else r1l = m;
        }
        ll l2 = l2l,l1 = l1l,r2 = r2r,r1 = r1r;
//        cerr << l2 << " " << l1 << " " << r1 << " " << r2 << endl;
        if(l1!=0) ans += i*(l1-l2)*(r1-now);
        if(r1!=N+1) ans += i*(now-l1)*(r2-r1);
        bit.add(pos[i],1);
  //      cerr << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        string S = NextString();
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            string T = S.Substring(0, i);
            string U = S.Substring(i);
            int score = 0;
            for (char c = 'a'; c <= 'z'; c++)
                if (T.Contains(c) && U.Contains(c)) score++;
            ans = Math.Max(ans,score);
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13280
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    stack<char> sta;

    for(char c : s){
        if(sta.size()==0){
            sta.push(c);
        }
        else if(sta.top()=='S' && c == 'T'){
            sta.pop();
        }
        else{
            sta.push(c);
        }
    }
    
    p(sta.size());
    
    return 0;
}

Measured memory_bytes: 720
from heapq import*
n=int(input())
a=[-int(e)for e in input().split()]
r=0
heapify(a)
while 1:
	x=heappop(a)
	if x>-n:break
	c=-x//n
	x+=c*n
	for i in range(n-1):a[i]-=c
	heappush(a,x)
	r+=c
print(r)

Measured memory_bytes: 45020
import java.util.Scanner;

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

	int N, K;
	N = sc.nextInt();
	K = sc.nextInt();

	int h[] = new int[N];
	int count = 0;
	for (int i = 0; i < N; i++) {
	    h[i] = sc.nextInt();
	    if (h[i] >= K)
		count++;
	}

	System.out.println(count);
    }
}

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


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


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

const int maxn = 2e5 + 7;

inline void read(int &x) {
    int w = 1; x = 0; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-' ) w = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    x*=w;
}

inline void print(int x) {
	if (x < 0) putchar('-'), x = -x;
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

int a[maxn];
ll sum[maxn];

unordered_map <ll, int> m;

int main() {
	int n; read(n);
	
	m[0]++;
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
		sum[i] = sum[i - 1] + (ll)a[i];
		m[sum[i]]++;
	}
	
	ll ans = 0;
	for (auto &it : m) {
		ans += (ll)it.second * (it.second - 1) / 2; 
		m[it.first] = 0;
	}
	printf("%lld\n", ans);
	return 0;
}




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

int main(){
    string s;
    cin >> s;
    int out;
    if(s == "SUN") out = 7;
    else if(s == "MON") out = 6;
    else if(s == "TUE") out = 5;
    else if(s == "WED") out = 4;
    else if(s == "THU") out = 3;
    else if(s == "FRI") out = 2;
    else if(s == "SAT") out = 1;
    cout << out << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
//

int main(){
    int n, m;
    cin >> n >> m;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<vector<int>> path(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        path[a - 1].push_back(b - 1);
        path[b - 1].push_back(a - 1);
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        bool bl = true;
        for(auto j : path[i]){
            bl &= (h[i] > h[j]);
        }
        if(bl) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc107_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int H, W;
  cin >> H >> W;

  vector<vector<char>> a(H, vector<char>(W));
  rep(i, H) rep(j, W) { cin >> a[i][j]; }

  vector<int> rows(0);
  rep(i, H) {
    bool ok = false;
    rep(j, W) {
      if (a[i][j] == '#') {
        ok = true;
        break;
      }
    }
    if (ok) rows.push_back(i);
  }

  vector<int> cols(0);
  rep(i, W) {
    bool ok = false;
    rep(j, H) {
      if (a[j][i] == '#') {
        ok = true;
        break;
      }
    }
    if (ok) cols.push_back(i);
  }

  for(auto i : rows) {
    for (auto j : cols) {
      cout << a[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256