akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

    float temp = 0;
    for(int i=0; i < n; i++){
        float m;
        cin >> m;
        temp += 1/m; 

    }

    cout << (1/temp) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void str(const char c[4][4]){
    int i;

    for(i = 0; i < 3; i++){
        putchar(c[i][i]);
    }
}

int main(void){
    char c[4][4];
    int i;

    for(i = 0; i < 3; i++){
        scanf("%s", c[i]);
    }

    str(c);

    return 0;
}

Measured memory_bytes: 128
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
x.sort(key=lambda x:-x[2])
dp=[[0]*101 for i in range(101)]
bp=[[0]*101 for i in range(101)]
for j in range(101):
  for k in range(101):
    a,b,c=x[0]
    r=0
    asa=abs(a-j)+abs(b-k)+c
    for i in range(N):
      count=abs(x[i][0]-j)+abs(x[i][1]-k)
      if x[i][2]==max(asa-count,0):
        r+=1
    if r==N:
      print(j,k,asa)
      exit()

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

using namespace std;

long long gcd(long long A,long long B){
    long long P = max(A,B);
    long long Q = min(A,B);
  
    while(true){
        P %=Q;
        if(P==0){
            break;
        }
        long long memo = P;
        P = Q;
        Q = memo;
    }

    return Q;
}

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

    long long num = gcd(A,B);
    long long sqr = sqrt(num);

    long long result =1;
    for(long long i=2;i<=sqr;i++){
        if(num %i ==0){
          result++;
        while(num % i ==0){
          num /=i;
        }
          sqr = sqrt(num);
        }
    }
  
  	if(num != 1)result ++;
  
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  cin.tie(0);ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<ll, ll> mp;
  rep (i, n) {
    int x; cin >> x;
    ++mp[x];
  }

  ll total = 0;
  for (auto v : mp) {
    total += v.first * v.second;
  }

  int q; cin >> q;
  vector<ll> ans;
  rep (i, q) {
    ll b, c;
    cin >> b >> c;
    total -= mp[b] * b;
    total += c * mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    ans.push_back(total);
  }

  for (auto v : ans) {
    cout << v << endl;
  }
  return 0;
}


Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0; i < (long long)n; i++)
constexpr long long mod = 1000000007;

long long mod_pow(long long a, long long n) {
    long long ret = 1, tmp = a;
    while(n > 0) {
        if(n % 2) {
            ret *= tmp; ret %= mod;
        }
        tmp = tmp * tmp; tmp %= mod;
        n /= 2;
    }
    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<long long>> dp(n, vector<long long>(m));
    rep(i, n) {
        long long sum = 0;
        rep(j, m) {
            if(i == 0) {
                dp[i][j] = mod_pow(2, j + 1);
                continue;
            }
            dp[i][j] = (((j + 2) * dp[i - 1][j]) % mod + sum) % mod;
            sum *= 2; sum %= mod;
            sum += (j + 1) * dp[i - 1][j]; sum %= mod;
        }
    }
    cout << dp[n - 1][m - 1] << endl;
    return 0;
}


Measured memory_bytes: 198760
N = int(input())
H = list(map(int, input().split()))

H.reverse()
ans = 0
val = 0
for i in range(N-1):
    if H[i] <= H[i+1]:
        val +=1
        ans = max(ans,val)
        #print(ans)
    else:
        ans = max(ans,val)
        val = 0
        #print(ans)

#print(H)
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,I,r,c,AS;
  	AS = 0;
  	cin >> N;
  	for(c = 0;c < N;c++){
      	cin >> I >> r;
      	AS+= r-I+1;
    }
  	cout << AS << endl;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

#define MAX_AB_ABS 119

vector<ll> pow_5(MAX_AB_ABS+1, -1);

ll get_pow_5(ll x) {
  if (pow_5[x] == -1) {
    ll x_sq = x*x;
    ll x_qu = x_sq * x_sq;
    pow_5[x] = x_qu * x;
  }

  return pow_5[x];
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll X;
  READ(X);

  // main procedure
  for(ll A = 1; A <= MAX_AB_ABS; ++A) {
    for(ll B = 0; B < A; ++B) {
      if (get_pow_5(A) - get_pow_5(B) == X) {
        cout << A << " " << B;
        return 0;
      } else if (get_pow_5(A) + get_pow_5(B) == X) {
        cout << A << " " << -B;
        return 0;
      }
    }
  }
  return 1;
}


Measured memory_bytes: 3612
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	k=II()
	a=0

	for i in range(k+10):
		b=pow(10,i,k)
		a+=7*b
		a%=k
		if a==0:
			print(i+1)
			exit()

	print(-1)





if __name__ == "__main__":
	main()


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

vector<llint> A(200000);
llint R = 1;
llint B = 2;
llint G = 3;

llint dfs() {
	llint bans=0;
	
	return bans;
}

int main (void)
{
	//INPUT
	llint N;
	cin >> N;
	rep(i,0,N) {
		cin >> A[i];
	}
	
	//SOLVE
	llint ans=0;
	llint Rno = 0;
	llint Bno = 0;
	llint Gno = 0;
	
	if (A[0] == 0) {
		ans = 3;
		Rno++;
	}
	
	rep(i,1,N) {
		llint c=0;
		if (A[i] == Rno) {
			c++;
		}
		if (A[i] == Bno) {
			c++;
		}
		if (A[i] == Gno) {
			c++;
		}
		
		ans *= c;
		ans %= 1000000007;
		
		if (A[i] == Rno) {
			Rno++;
		} else if (A[i] == Bno) {
			Bno++;
		} else if (A[i] == Gno) {
			Gno++;
		} else {
			break;
		}
	}
	
	//OUTPUT
	cout << ans << endl;
	
	return 0;
}






Measured memory_bytes: 1792
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def plecak_rozwiazanie(pojemnosc, lista_przedmiotow): 
    bez_przedmiotu = [0] * (pojemnosc + 1)
    for waga, wartosc in lista_przedmiotow:
        z_przedmiotem = [None] * (pojemnosc + 1)
        for i in range(pojemnosc+1): 
            if waga > i: 
                z_przedmiotem[i] = bez_przedmiotu[i]
            else: 
                z_przedmiotem[i] = max(bez_przedmiotu[i-waga]+wartosc, bez_przedmiotu[i])
        bez_przedmiotu = z_przedmiotem
    return bez_przedmiotu[pojemnosc]

def plecak_1(): 
    N, W = wczytaj_liste()
    przedmioty = []
    for i in range(N): 
        waga, wartosc = wczytaj_liste()
        przedmioty.append((waga, wartosc))
    print (plecak_rozwiazanie(W,przedmioty))   
    
plecak_1()

Measured memory_bytes: 122564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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++)
#define MOD 1000000007

int main(void) {
  int n;
  cin >> n;
  //a > b
  int maxa=sqrt(n);
  int cnt=0;
  // nより小さくなるa*bをみつける
  for(int b = 1; b < n; b++) {
    //if(n/b < b)break;
    if(n%b==0)cnt+=(n/b-1);
    else cnt+=n/b;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3676
program moving_piece
  implicit none
  integer :: n, k, p(5000) = 0, i, j, m, h, q, r
  integer(8) :: c(5000) = 0, x = -6e18, w, s
  read(*,*) n, k
  read(*,*) p(1:n)
  read(*,*) c(1:n)
  do i = 1, n
    m = i
    h = 1
    s = c(m)
    x = max(x, s)
    do while (h < k .and. p(m) /= i)
      m = p(m)
      h = h + 1
      s = s + c(m)
      x = max(x, s)
    end do
    if (h == k .or. s < 0) cycle
    q = k / h
    r = mod(k, h)
    m = i
    w = 0
    do j = 1, h
      w = w + c(m)
      x = max(x, s * merge(q - 1, q, j > r) + w)
      m = p(m)
    end do
  end do
  write(*,'(i0)') x
end program moving_piece

Measured memory_bytes: 2996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

bool p[100000] = {};
vector<ll> ans;

int main() {
	ll n = 100000;
	rep(i, 0, n)p[i] = true;
	p[0] = false;
	p[1] = false;
	for (int i = 2; i*i < n; i++) {
		if (p[i]) {
			for (int j = 2; i*j < n; j++) {
				p[i*j] = false;
			}
		}
	}
	rep(i, 0, n) {
		if (p[i] && i % 10 == 1) {
			ans.push_back(i);
		}
	}

	ll N; cin >> N;
	rep(i, 0, N) {
		cout << ans[i];
		if (i != N - 1) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<utility>
#include<algorithm>
#include<limits>
using namespace std;
int main()
{
	const int N1 = 3, N2=8;
	int i,j;
	pair<double,int>a[N2], w1,w2;
	w1.first = w2.first = numeric_limits<double>::max();
	for(i=0;i<N1;++i)
	{
		for(j=0;j<N2;++j)
		{
			scanf("%d %lf",&a[j].second, &a[j].first);
		}
		sort(a, a+N2);
		for(j=0;j<2;++j)
			printf("%d %.2f\n",a[j].second, a[j].first);
		for(j=2;j<4;++j)
		{
			if(w1.first > a[j].first)
			{
				w2=w1;
				w1=a[j];
			}
			else if(w2.first > a[j].first)
				w2 = a[j];
		}	
	}
	printf("%d %.2f\n"
		"%d %.2f\n", w1.second, w1.first, w2.second, w2.first);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

struct cum_sum_lm {
	vector<ll> sum;
	int N;
	cum_sum_lm() = default;
	cum_sum_lm(int _N) {
		N = _N;
		sum.resize(N + 1);
	}

	void setup(vector<ll>& _ar, int _N) {
		N = _N;
		sum.resize(N + 1);
		for (int i = 0; i < N; i++) {
			if(_ar.size() > i)
			sum[i + 1] = sum[i] + _ar[i];
			else sum[i + 1] = sum[i];
		}
	}
	ll getval(int l, int r) {
		//[l, r)
		ll ret = sum[r] - sum[l];
		return ret;
	}
};

int N;
vector<ll> E(1001 + 10);

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		ll L;
		cin >> L;
		E[L]++;
	}
	ll ans = 0;
	cum_sum_lm sum;
	sum.setup(E, 2000 + 10);
	//すべて違う場合
	for (int i = 1; i <= 1000; i++) {
		for (int j = i; j <= 1000; j++) {
			if (i != j) {
				ll tmp = E[i] * E[j];
				ll kakeru = sum.getval(max(i, j) + 1, i + j);
				tmp *= kakeru;
				ans += tmp;
			}
		}
	}
	//2つ同じの場合
	for (int same = 1; same <= 1000; same++) {
		if (E[same] <= 1)continue;
		ll tmp = E[same] * (E[same] - 1) / 2;
		tmp *= sum.getval(1, same * 2) - E[same];
		ans += tmp;
	}
	//3つ同じの場合
	for (int same = 1; same <= 1000; same++) {
		if (E[same] <= 2)continue;
		ans += (E[same]) * (E[same] - 1) * (E[same] - 2) / 6;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n) cin>>a[i];  
  int min=200001;
  int count=0;
  rep(i,n){
    if(a[i]<min){
      min=a[i];
    }
    if(min==a[i]) count++;
  }
  cout<<count<<endl;
}

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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)


int main(){
 int n,m;
   cin >> n >> m;

  vector<int> num(n,1);
  vector<bool> red(n,false);
  red[0]=true;
  
  rep(i,0,m){
   int x, y;
    cin >> x >> y;
    x--;
    y--;
    
    if(red[x]) red[y]=true;
    num[x]--;
    num[y]++;
    if(!num[x]) red[x]=false; 
  
  }  
  
  int res=0;
  for(auto r:red) if(r) res++; 
   cout << res << endl;
}

Measured memory_bytes: 640
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

inp = int(input())

print(a[inp-1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string a;
  while(cin>>a){
    int b=0,c=0;
    rep(i,a.size()-2){
      if(a[i]=='J'&&a[i+1]=='O'&&a[i+2]=='I')b++;
      if(a[i]=='I'&&a[i+1]=='O'&&a[i+2]=='I')c++;
    }
    cout<<b<<endl<<c<<endl;
  }
  return (0);
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    ll p[a], q[b], r[c+1];
    r[0] = INT_MIN;
    for(int i = 0; i < a; i++ ) cin >> p[i];
    for(int i = 0; i < b; i++ ) cin >> q[i];
    for(int i = 0; i < c; i++ ) cin >> r[i];
    sort(p,p+a); sort(q,q+b); sort(r,r+c);
    int apple[x+y+c];
    int ind = 0;
    for(int i = 0; i < x; i++){
        apple[ind] = p[a-1-i];
        ind++;
    }
    for(int i = 0; i < y; i++){
        apple[ind] = q[b-1-i];
        ind++;
    }
    for(int i = 0; i < c; i++){
        apple[ind] = r[i];
        ind++;
    }
    sort(apple, apple+x+y+c);
    ll ans = 0;
    for(int i = 0; i < x+y; i++){
        ans += apple[x+y+c-1-i];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int>ans(N-1);
  double num = (double)(X + Y) / 2;
  for (int i = 1; i < N; i++) {
    for (int j = i+1; j < N+1; j++) {
      if ((i < X && j < X) || (i > Y && j > Y) || (i < X && j == X) || (i == Y && j > Y)) {
        ans.at(j-i-1)++;
      }
      else if (i <= X && j >= Y) {
        ans.at(j-Y+X-i)++;
      }
      else if (i < X && X < j && j < Y) {
        if (j <= num) {
          ans.at(j-i-1)++;
        }
        else {
          ans.at(Y-j+X-i)++;
        }
      }
      else if (X < i && i < Y && Y < j) {
        if (num <= i) {
          ans.at(j-i-1)++;
        }
        else {
          ans.at(j-Y+i-X)++;
        }
      }
      else {
        ans.at(min(j-i-1, Y-j+i-X))++;
      }
    }
  }
  for (int i = 0; i < N-1; i++) {
    cout << ans.at(i) << endl;
  }
}


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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
ll n, w;
vector<pll> val;
vector<vector<ll>> dp;

ll rec(int idx, ll currw){
    // cout << "idx: " << idx << " currw: " << currw << "\n";
    if(idx == -1){
        return 0;
    }

    // cout << "dp[" << idx << "][" << currw << "] = " << dp[idx][currw] <<endl;
    if(dp[idx][currw] != -1){
        return dp[idx][currw];
    }
    ll res1 = 0, res2  = 0;
    if(currw >= val[idx].first){
        res1 = rec(idx -1, currw - val[idx].first) + val[idx].second;
    }

    res2 = rec(idx -1,currw);
    dp[idx][currw] = max(res1, res2);
    return max(res1, res2);
}

void solve()
{
    cin >> n >> w;
    val.clear();
    for(auto &i : dp)
        i.clear();
    dp.clear();
    val.resize(n);
    forn(i, n)
    {
        cin >> val[i].first >> val[i].second;
    }

    dp.resize(n);
    for(int i = 0; i < n; i++){
        dp[i].assign(w + 1, -1);
    }

    ll ans = rec(n-1, w);
    cout << ans << endl;
}

int main()
{
    zoom;
    ll t = 1;
    // cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 81612
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define F first
#define S second
ll inf=100000000000000000,mod=1000000007;
ll prime[1000006];
unordered_map<ll, ll> max_map;
#define MAX 1000006
// Function to return a^n
ll power(ll a, ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2) % mod;
    p = (p * p) % mod;
    if (n & 1)
        p = (p * a) % mod;
    return p;
}

// Function to find the smallest prime factors
// of numbers upto MAX
void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (ll j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}

// Function to return the LCM modulo M
ll lcmModuloM(const ll* ar, ll n)
{

    for (ll i = 0; i < n; i++) {
        ll num = ar[i];
        unordered_map<ll, ll> temp;

        // Temp stores mapping of prime factor to
        // its power for the current element
        while (num > 1) {

            // Factor is the smallest prime factor of num
            ll factor = prime[num];

            // Increase count of factor in temp
            temp[factor]++;

            // Reduce num by its prime factor
            num /= factor;
        }

        for (auto it : temp) {

            // Store the highest power of every prime
            // found till now in a new map max_map
            max_map[it.first] = max(max_map[it.first], it.second);
        }
    }

    ll ans = 1;

    for (auto it : max_map) {
        ans = (ans * power(it.F, it.S)) % mod;
    }

    return ans;
}
int main(){
   
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll n;
    cin>>n;
    ll arr[n],gg[n],lc[n],num;
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    sieve();
    lc[0]=lcmModuloM(arr, n);
    ll barr[n];
    for(ll i=0;i<n;i++)
    {
       barr[i]=(lc[0]*power(arr[i],mod-2))%mod;
    }
    ll sum=0;
    for(ll i=0;i<n;i++)
    sum=(sum+barr[i])%mod;
    cout<<sum<<endl;
}


Measured memory_bytes: 8704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        while (true) {
            int n = ni();

            if (n == 0) return;

            int[] a = nia(n);
            Arrays.sort(a);

            int sum = 0;
            for (int i = 1; i < n - 1; i++) {
                sum += a[i];
            }

            out.println(sum / (n - 2));
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24388
#include<iostream>
#include<algorithm> 
using namespace std;
int main(){
  int N;
  cin >> N;
  int p[N];
  int q[N];
  for (int i = 0; i < N; i++){
    cin >> p[i];
    q[i] = p[i];
  }
  sort(q, q+N);
  int cnt = 0;
  for (int j = 0; j < N; j++)
    if (p[j] != q[j])
      cnt++;
  if (cnt == 0 || cnt == 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		int a[] = new int[N+1];
		for (int i=0;i<N;i++) {
			a[i] =sc.nextInt();
		}
		long sum =0;
		long dp0[]= new long[N+1];
		long dp1[]= new long[N+1];
		long dp2[]= new long[N+1];
		dp0[0] = 0;
		dp1[0] = a[0];
		dp0[1] = 0;
		dp1[1] = Math.max(a[0], a[1]);
		dp2[1] = Math.max(a[0], a[1]);
		dp0[2] = 0;
		dp1[2] = Math.max(a[0], Math.max(a[1], a[2]));
		dp2[2] = a[0]+a[2];
		for (int i=3;i<N;i++) {
			if (i%2==0) {
				dp0[i] = Math.max(dp0[i-2]+a[i], dp1[i-2]);
				dp0[i] = Math.max(dp0[i], dp0[i-1]);
				dp1[i] = Math.max(dp1[i-2]+a[i], dp2[i-2]);
				dp1[i] = Math.max(dp1[i], dp1[i-1]);
				dp2[i] = dp2[i-2]+a[i];
			} else {
				dp0[i] = Math.max(dp0[i-2]+a[i],dp1[i-2]);
				dp0[i] = Math.max(dp0[i], dp1[i-1]);
				dp1[i] = Math.max(dp1[i-2]+a[i],dp2[i-1]);
				dp2[i] = dp1[i];
			}
		}
		if (N%2==1) {
			System.out.println(Math.max(dp1[N-1], dp1[N-2]));
		} else {
			System.out.println(Math.max(dp1[N-1], dp2[N-2]));
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll K, N;
  cin >> K >> N;

  ll A[N * 2];
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (ll i = 0; i < N; i++) {
    A[N + i] = K + A[i];
  }

  ll m = LLONG_MAX;
  for (ll i = 0; i < N; i++) {
    // cout << i << " " << A[i + N - 1] << " " << A[i] << endl;
    m = min(m, A[i + N - 1] - A[i]);
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){

	long long int a[10000], su=0, mi=1000001, ma=-1000001,b;
	cin >> b;
	for (int i = 0; i < b; i++){
		cin >> a[i];
		su += a[i];
		if (a[i]>ma){
			ma = a[i];
		}
		if (a[i] < mi){
			mi = a[i];
		}
	}
	cout << mi << " " << ma << " " << su << endl;
}


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

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i,n) {
    ll tmp;
    cin >> tmp;
    tmp--;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

vl patty(52), siz(52);

ll cnt(int n, ll x)
{
    if(n == 0) return 1;
    if(x == 1) return 0;
    if(x <= 1 + siz[n-1]) return cnt(n-1, x-1);
    if(x == 2 + siz[n-1]) return patty[n-1] + 1;
    if(x <= 2 + 2 * siz[n-1]) return patty[n-1] + 1 + cnt(n-1, x - 2 - siz[n-1]);
    return patty[n];
}

void solve()
{
    { // Preprocess
        patty[0] = 1; siz[0] = 1;
        rep(i, 1, 51) {
            patty[i] = 2 * patty[i-1] + 1;
            siz[i] = 2 * siz[i-1] + 3;
        }
    }

    int n; ll x;
    scn(n); lscn(x);

    lprin(cnt(n, x));
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fori(i,a,b) for(int i=a;i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
const ll MOD = 1000000007;

int a[2020];
void solve(){
    int n;
    cin>>n;
    ll k;
    cin>>k;
    repi(i,n)cin>>a[i];

    ll ans1=0;
    ll ans2=0;
    repi(i,n)fori(j,i+1,n){
        if(a[i]>a[j])ans1++;
        if(a[i]!=a[j])ans2++;
    }

    cout<<(k*ans1+k*(k-1)/2%MOD*ans2)%MOD<<endl;
}

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


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll N, T;
	cin >> N >> T;

	vector<ll> t(N);
	rep(i, N) cin >> t[i];

	ll sum = T;
	rep(i, N - 1) {
		sum += min(T, t[i + 1] - t[i]);
	}

	out(sum);

	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
def main():
    M, K = map(int, input().split())
    if K == 0:
        print(*[i//2 for i in range(2**(M+1))])
    else:
        if K >= 2**M or M <= 1:
            print(-1)
        else:
            nums = []
            for i in range(2**M):
                if i != K:
                    nums.append(i)
            a = [nums[0], K, nums[0]]
            b = []
            for i in range(1,2**M-1):
                b.append(nums[i])
            b.append(K)
            for i in range(1,2**M-1):
                b.append(nums[2**M-1-i])
            print(*a,*b)
if __name__ == "__main__":
    main()

Measured memory_bytes: 21260
#include <iostream>
#include <math.h> 
#include <algorithm>
#include <iomanip>
using namespace std;
const double PI = 3.141593;

int main(){
    int a, b;
    double x;
    cin >> a >> b >> x;
    double ans;
    if(2*x <= a*a*b) ans = 90 - (atan(2*x /a/b/b)) * 180 /PI;
    else ans = (atan(2*(a*a*b -x)/a/a/a)) * 180 / PI;
    cout << setprecision(8) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int c[9][9];
map<ll, int> prime_factor(ll num) {
	map<ll, int> mp;
	ll k = (ll)sqrt(num);
	mp[1]++;
	rep(i, 2, k + 1) {
		while (num % i == 0) {
			num /= i;
			mp[i]++;
		}
	}
	if (num != 1)mp[num]++;
	return mp;
}
//mpの各要素は(first:素因数, second:指数)
//mp.size()にすれば素因数が何種類かを取得できる
//1が含まれることに注意
const ll mod = 1000000007;
int main() {
	int n, d = 0, c = 0;
	char str[101];
	scanf("%d", &n);
	scanf("%s", str);
	rep(i, 0, n) {
		if (str[i] == '(')d++;
		else d--;
		c = min(d, c);
	}
	rep(i, c, 0)printf("(");
	printf(str);
	rep(i, 0, d - c)printf(")");
	puts("");
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    vector<ll> B(M);
    REP(i,N){
        cin >> A[i];
    }
    REP(i,M){
        cin >> B[i];
    }

    vector<ll> SA(N);
    vector<ll> SB(M);
    REP(i,N){
        SA[i] = A[i];
        if(i > 0)
        SA[i] += SA[i-1];
    }
    REP(i,M){
        SB[i] = B[i];
        if(i > 0)
        SB[i] += SB[i-1];
    }

    int ans = upper_bound(SB.begin(), SB.end(), K) - SB.begin();
    REP(i,N){
        ll rem = K - SA[i];
        if(rem < 0) break;

        int idx = upper_bound(SB.begin(), SB.end(), rem) - SB.begin();

        chmax(ans, idx + i + 1);
    }

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


Measured memory_bytes: 9596
#include <stdio.h>

int soma (int num) {
    int soma = 0;
    while (num != 0) {
        soma += num % 10;
        num /= 10;
    }
    return soma;
}

int main () {
    long int n;
    scanf("%d", &n);
    printf(n % soma(n) == 0 ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int count = 0;
        int max = 0;
        for(int i = 0; i < s.length(); i++){
            char c = s.charAt(i);
            if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
                count++;
                if(count > max){
                    max = count;
                }
            }else{
                count = 0;
            }
        }
        
        System.out.println(max);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    int h ,w,k;
    int sum = 0;
    int ans = 0;
    int black = 0;
    vector<vector<char> > c;
    vector<int> black_num;
    vector<int> row;
    cin >> h >> w >> k;
    c.resize(h,vector<char>(w));
    //row.resize(h,0);
    //column.resize(w,0);
    black_num.resize(w+h,0);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
            if(c[i][j] == '#'){
                black_num[i]++;
                black++;
            }
        }
    }
    for(int j = 0; j < w; j++){
        for(int i = 0; i < h; i++){
            if(c[i][j] == '#'){
                black_num[h+j]++;
                //black++;
            }
        }

    }
    /*
    for(int i = 0; i < w+h; i++){
        cout << black_num[i] << endl;
    }
    cout << black << endl;
    */

    for(int bit = 0; bit < (1<<(w+h)); bit++){
        for(int i = 0; i < w+h; i++){
            if(bit & (1 << i)){
                sum+= black_num[i];
                if( i < h){
                    row.push_back(i);
                    
                }else if(row.size() > 0){
                    for(int j = 0; j < row.size(); j++){
                        //cout << "rpow" << row[j] << endl;
                        if(c[row[j]][i-h] == '#')sum--;
                        //cout << i - h << endl;
                    }
                }
            }

        }
        if((black - sum) == k){
            ans++;
        }
        //cout << "ext" << endl;
        row.clear();
        sum=0;
    }

    cout << ans << endl;






    
    return 0;
}

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

typedef struct tree_{
    int parent;
    int left;
    int right;
    int depth;
    int height;
    int sibling;
}tree;

int height(tree *node, int id, int depth){
    if(id==-1)return -1;
    int l = node[id].left;
    int r = node[id].right;
    node[id].depth = depth;
    node[id].height = std::max(height(node, l, depth+1),height(node, r, depth+1)) + 1;
    return node[id].height;
}

int main(){
    int i, n, id, left, right;
    scanf("%d",&n);
    tree node[n];
    for(id=0;id<n;id++){
        node[id].parent = -1;
        node[id].sibling = -1;
    }
    for(i=0;i<n;i++){
        scanf("%d %d %d",&id,&left,&right);
        node[id].left = left;
        node[id].right = right;
        node[left].parent = id;
        node[right].parent = id;
        node[left].sibling = right;
        node[right].sibling = left;
    }
    int root;
    for(root=0;root<n;root++)if(node[root].parent==-1)break;
    if(root==n)return -1;
    int h = height(node, root, 0);
    int degree;
    for(id=0;id<n;id++){
        int degree = 0;
        if(node[id].left>=0)degree++;
        if(node[id].right>=0)degree++;
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",id,node[id].parent,node[id].sibling,degree,node[id].depth,node[id].height);
        if(node[id].parent == -1)printf("root\n");
        else if(node[id].left*node[id].right==1)printf("leaf\n");
        else printf("internal node\n");
    }
    return 0;
}



Measured memory_bytes: 2668
#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>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N, M;
    vector<int> X;

    void input() {
        cin >> N >> M;
        rep(i, 0, M) {
            int tmp;
            cin >> tmp;
            X.push_back(tmp);
        }

        sort(all(X));

    }


    void solve() {
        input();

        struct edge {
            int a, b;
            int dist;
        };

        vector<edge> edges;
        for (int i = 0; i + 1 < M; ++i) {
            int a = i;
            int b = i + 1;
            int dist = X[i + 1] - X[i];
            edge edge1{a, b, dist};
            edges.push_back(edge1);
        }

        sort(all(edges), [](edge tapi, edge tapu) {
            return tapi.dist < tapu.dist;
        });

        ll ans = 0;
        for (int i = 0, gr = M; gr > N; gr--, i++) {
           ans += edges[i].dist;
        }
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 2548
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n  = read::<i32>();
    let s = read::<String>();
    let cs = s.chars().collect::<Vec<char>>();
    let mut ans = Vec::new();
    for i in 1..n{
        let mut sub = cs.clone();
        let mut cut = sub.split_at(i as usize);
        let mut a1 = cut.0.to_vec();
        let mut a2= cut.1.to_vec();
        a1.sort();
        a2.sort();
        a1.dedup();
         a2.dedup();
        // let a1:Vec<char> = cut.0.to_vec().dedup().collect();
        // let a2:Vec<char> = cut.1.to_vec().dedup().collect();
        let count = a1.iter().fold(0,|x,y| {match  a2.contains(y) {
                true => x + 1,
                false => x,
        }});

        ans.push(count);    
    }
    // ans.sort_by_key(|&(a,b)|b);
    println!("{}",ans.iter().max().unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int main(){
  int h,r;
  cin >> h >> r;

  if(h<0 && h+r==0) cout << "0";
  else if(h>=0) cout << "1";
  else cout << "-1";

  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3096
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#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++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main() {
  ll n,m ; cin >>n>>m;
  cout <<pow(2,m)*((n-m)*100+1900*m)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

// bitの数を数える
int pcnt(int x)
{
    return __builtin_popcount(x);
}

int f(int x)
{
    if (x == 0)
    {
        return 0;
    }
    return f(x % pcnt(x)) + 1;
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        x[i] = s[i] - '0';
    }
    int pc = 0;
    rep(i, n) pc += x[i];
    vector<int> ans(n);
    for (int b = 0; b < 2; b++)
    {
        int npc = pc;
        if (b == 0)
        {
            npc++;
        }
        else
        {
            npc--;
        }
        if (npc <= 0)
        {
            continue;
        }
        int r0 = 0;
        for (int i = 0; i < n; i++)
        {
            r0 = (r0 * 2) % npc;
            r0 += x[i];
        }
        int k = 1;
        for (int i = n - 1; i >= 0; --i)
        {
            if (x[i] == b)
            {
                int r = r0;
                if (b == 0)
                {
                    r = (r + k) % npc;
                }
                else
                {
                    r = (r - k + npc) % npc;
                }
                ans[i] = f(r) + 1;
            }
            k = (k * 2) % npc;
        }
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

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

int main()
{
	string s;
  int ctr = 0;
  	cin>>s;
  
  for(int i=0;i<s.length()/2;i++)
  {
  	if(s[i]!=s[s.length()-i-1]) ctr++;
  }
  
  cout<<ctr<<endl;
}

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

using namespace std;

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for (auto &p : P) {
    cin >> p;
    p++;
  }
  int m = 0;
  int now = 0;
  for (int i = 0; i < N; i++) {
    now += P[i];
    if (i - K >= 0) {
      now -= P[i - K];
    }
    chmax(m, now);
  }
  double ans = (double)m / 2;
  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    h: usize,
    w: usize,
    k: usize,
    s: [Chars; h]
    }
    let mut map = vec![vec![0; w]; h];
    let mut n = 1;
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '#' {
                map[i][j] = n;
                let (mut l, mut r) = (j, j);
                loop {
                    let (mut lf, mut rf) = (false, false);
                    if l > 0 && s[i][l - 1] != '#' && map[i][l - 1] == 0 {
                        map[i][l - 1] = n;
                        l -= 1;
                        lf = true;
                    }
                    if r + 1 < w && s[i][r + 1] != '#' && map[i][r + 1] == 0 {
                        map[i][r + 1] = n;
                        r += 1;
                        rf = true;
                    }
                    if !lf && !rf { break; }
                }
                let (mut yl, mut yr) = (i, i);
                loop {
                    let (mut lf, mut rf) = (true, true);

                    if yl > 0 {
                        for k in l..=r {
                            if s[yl - 1][k] == '#' || map[yl - 1][k] != 0 {
                                lf = false;
                                break;
                            }
                        }
                        if lf {
                            for k in l..=r {
                                map[yl - 1][k] = n;
                            }
                            yl -= 1;
                        }
                    } else {lf = false}
                    if yr + 1 < h {
                        for k in l..=r {
                            if s[yr + 1][k] == '#' || map[yr + 1][k] != 0 {
                                rf = false;
                                break;
                            }
                        }
                        if rf {
                            for k in l..=r {
                                map[yr + 1][k] = n;
                            }
                            yr += 1;
                        }
                    } else {rf = false}
                    if !lf && !rf { break; }
                }
                n += 1;
            }
        }
    }
    for i in 0..h {
        for j in 0..w {
            print!("{} ", map[i][j])
        }
        print!("\n")
    }
}


Measured memory_bytes: 2804
s=list(input())
t=list(input())
n=len(t)
m=len(s)
mn=n
for i in range(m-n+1):
    err=0
    for j in range(n):
        if s[i+j]!=t[j]:
            err+=1
    mn=min(mn,err)
print(mn)

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

int main(){
	int N,K;
  	cin >> N >> K;
  	int A[N];
  	int S[N];
  	for(int i = 0; i < N ; i++)cin >> A[i];
  	
  	for(int i = 0; i < N ; i++)S[i]=0;
  	
  	int a;
  	for(int i = 0; i < N ; i++){
    	a =  A[i];
    	S[a-1]++;
    }
  		
  	sort(S,S+N,greater<int>());
  	
  	int cnt = 0;
  	for(int i = 0; i < N ; i++){
    	if(S[i]!=0)cnt++;
      	//cout << S[i]<<" ";
    }
  	//cout << endl;
	//cout <<"cnt:"<< cnt << endl;
  	//cout <<"K:"<< K << endl;
  	if(cnt<=K){
      	//cout << "A" << endl;
    	cout << 0 << endl;
      	return 0;
    }
  	int ans=0;

  	for(int i = 0; i < cnt-K+1 ; i++){
    	//cout << S[cnt-i] << endl;
      	ans+=S[cnt-i];
    }
  	
	//cout << "B" << endl;
	cout << ans<< endl;
}

Measured memory_bytes: 1792