akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
    string s; cin >> s;
    int max = 0;
    int r = 0;
    for (int i = 0; i<s.size(); i++){
        if (s[i]=='A' || s[i]=='C' || s[i]=='T' || s[i]=='G'){
            r++;
            if (max < r){
                max = r;
            }
        }else{
            r = 0;
        }
    }

    cout << max << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <queue>

using namespace std;

struct Node {
    unordered_set<int> in, out;
    int d = 0;
};

int main() {
    int N, M;
    cin >> N >> M;

    Node* G = new Node[N + 1];

    int x, y;
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        G[x].out.insert(y);
        G[y].in.insert(x);
    }

    queue<int> que;

    for (int i = 1; i <= N; i++) {
        if (G[i].in.empty()) {
            que.push(i);
        }
    }

    int ans = 0;

    while (!que.empty()) {
        int s = que.front();
        que.pop();
        for (int t : G[s].out) {
            G[t].in.erase(s);
            G[t].d = max(G[t].d, G[s].d + 1);
            if (G[t].in.empty()) {
                que.push(t);
            }
        }
        ans = max(ans, G[s].d);
    }

    cout << ans << endl;
}

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

int compare_int(const void *a, const void *b){
  return *(int*)b - *(int*)a;
}

int main(void){
  int sword, hit, aReg, ab, aMax = 0, b[100000], result = 0;
  int i, first = 0;

  scanf("%d %d", &sword, &hit);
  for(i = 0; i < sword; i++){
    scanf("%d %d", &aReg, &b[i]);
    if(aMax < aReg){
      aMax = aReg;
      ab = b[i];
    }
  }

  qsort(b, sword, sizeof(int), compare_int);

  for(i = 0; i < sword; i++){
    if(b[i] >= aMax){
        hit -= b[i];
        result++;
        if(hit <= 0){
          printf("%d\n", result);
          return 0;
      }
    }
    else{
      break;
    }
  }

  if(first){
    for(; hit > ab; result++, hit -= aMax){}
  }
  else{
    for(; hit > 0; result++, hit -= aMax){}
  }

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

  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	ll k;
	cin >> k;
	ll m = k/50LL + 49LL;
	ll n = 50LL;
	vector<ll> a(n, m);
	ll p = k%50LL;
	int cnt = 1;
	const ll mx = 800;
	a[0] +=  min(mx, n * p);
	if (n * p - mx * 1 > 0) {
		a[1] += min(mx, n * p - mx * 1);
	}
	if (n * p - mx * 2 > 0) {
		a[2] += min(mx, n * p - mx * 2);
	}
	if (n * p - mx * 3 > 0) {
		a[3] += min(mx, n * p - mx * 3);
	}
	if (n * p - mx * 4 > 0) {
		a[3] += min(mx, n * p - mx * 4);
	}
	for(int i = n-1; i >= 0; i--) a[i] -= p;
	
	cout << n << endl;
	// cout << m << endl;
	// cout << m * n + p << endl;
	rep(i, n) cout << a[i] << ((i == n-1) ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<map>

int h[200];

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&h[i]);

    int r = 0;
    for(int i=0; i<n; i++)
        while(h[i] && ++r)
            for(int j=i; j<n && h[j]; j++)
                h[j]--;

    printf("%d\n", r);
}


Measured memory_bytes: 128
N = int(input())
A = [int(x) for x in input().split()]
L = [0] * 2 * N
R = [0] * 2 * N
for i in range(N):
    l = i + A[i]
    if l < N: L[l] += 1
    r = i - A[i]
    if r > 0: R[r] += 1
ans = 0 
for i in range(N):
    ans += L[i] * R[i]
print(ans)


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

int main() {
  std::string alphabet = "abcdefghijklmnopqrstuvwxyz";
  int n;
  std::cin >> n;
  std::vector<std::string> v(n);

  for (int i = 0; i < v.size(); i++) {
    std::cin >> v[i];
    std::sort(v[i].begin(), v[i].end());
  }

  std::string out;
  std::vector<int> char_cnt(n);
  for(char c : alphabet) {
    for (int i = 0; i < char_cnt.size(); i++) {
      char_cnt[i] = std::count(v[i].begin(), v[i].end(), c);
    }
    int min = *std::min_element(char_cnt.begin(), char_cnt.end());
    if (min) {
      for (int i = 0; i < min; i++) {
        out += c;
      }
    }
  }
  if (out.size() != 0) {
    std::cout << out;
  } else {
    std::cout << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
// D - Road to Millionaire
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,arr[100];

int main(){
	cin >> n;
	for(int i=0;i<n;i++) cin >> arr[i];
	ll ans = 1000,s=0;
	for(int i=0;i<n-1;i++){
		if(arr[i] < arr[i+1]){
			s   += ans/arr[i];
			ans  = ans%arr[i];
		}else if(arr[i] > arr[i+1]){
			ans += arr[i] * s;
			s   = 0;   
		}
		//cout << i << " " << ans << " " << s <<  endl;
	}
	ans += s * arr[n-1];
	cout << max(1000ll,ans) << endl;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int n,k,sum;
  sum =0;
    cin >> n>> k;
    vector<int> p(n);
    rep(i,n){
        cin >>p[i];
    }
    sort(p.begin(),p.end());
    rep(i,k){
        sum +=p[i];
    }
    cout << sum << endl;
}

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

int main()
{
    ll n,i,a,b,c;
    cin>>n;
    ll dp[n+1][3];
    dp[0][0]=dp[0][1]=dp[0][2]=0;

    for(i=1;i<=n;i++)
    {
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<"\n";  
}


Measured memory_bytes: 2560
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

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

	for(int n, m; cin >> n >> m, n | m;) {
		vector<int> a(n);
		for(int i = 0; i < n; ++i)
			cin >> a[i];

		int time = m / a[0] * a[0];
		int who = 0;

		for(int i = 1; i < n; ++i) {
			int tmp = m / a[i] * a[i];
			if(time > tmp) {
				time = tmp;
				who = i;
			}
			else if(time == tmp) {
				if(a[who] > a[i])
					who = i;
				else if(a[who] == a[i])
					who = n - 1;
			}
		}

		cout << who + 1 << endl;
	}

	return EXIT_SUCCESS;
}

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

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

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int dist[n][n];
  rep(i,n)rep(j,n){
    if(i!=j) dist[i][j]=1e9;
    else dist[i][j]=0;
  }
  vector<edge> g;
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    g.push_back({a,b,c});
    dist[a][b]=c;
    dist[b][a]=c;
  }
  rep(k,n)rep(i,n)rep(j,n) dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
  vector<bool> flag(m,false);
  rep(i,n){
    rep(j,m){
      int u=g[j].a,v=g[j].b,cost=g[j].c;
      if(dist[i][v]==dist[i][u]+cost) flag[j]=true;
    }
  }
  int ans=0;
  rep(i,m) if(!flag[i]) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    Int res = mod_pow(x, a / 2, m);
    res = res * res % m;
    if(a % 2)res *= x;
    return res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}

Int n, k;
Int dp[110000];
Int exactly[110000];
Int ans;
int main(){
    cin >> n >> k;
    for(int g = 1;g <= k;g++){
        dp[g] = mod_pow(k/g, n);
    }
    for(int g = k;g >= 1;g--){
        exactly[g] = dp[g];
        for(int gg = 2*g;gg <= k;gg += g){
            exactly[g] -= exactly[gg];
        }
        exactly[g] %= MOD;
        ans += exactly[g] * g;
        ans %= MOD;
    }
    if(ans < 0)ans += MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  int D; int X; cin>>D>>X;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin>>A.at(i);
  }
  for(int i=0; i<N; i++){
   if(D%A.at(i)==0)
     X+=D/A.at(i);
    else X+=D/A.at(i)+1;
  }
  cout<<X<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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

bool is_ss(string s) {
  int l = s.length();
  if(l % 2 == 1) return false;
  rep(i, l/2) {
    if(s[i] != s[i+(l/2)]) return false;
  }
  return true;
}

int main() {
  string s;
  cin >> s;

  rep1(i, s.length()) {
    if(is_ss(s.substr(0, s.length()-i))) {
      cout << s.length() - i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

ll gcd(ll a, ll b){
  if(a % b == 0) return b;
  else return gcd(b, a%b);
}

//最小公倍数
ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  return a / g * b;
}

int f(ll x){
  int res = 0;
  while (x % 2 == 0){
    res++;
    x /= 2;
  }
  return res;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] /= 2; 
  }

  ll x = 1;
  rep(i, n){
    x = lcm(x, a[i]);
    if (f(x) != f(a[i])){
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = (m / x + 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    if(a+b>=10){out("error");}
    else out(a+b);

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

int n, mem, a[100000], cnt;

int main(){
	cnt = 0;
	cin >> n;
	lp(100000)
		a[i] = 0;
	lp(n) {
		cin >> mem;
		if (mem > 100000)cnt++;
		else a[mem - 1]++;
	}
	lp(100000) {
		if (a[i] < i + 1)cnt += a[i];
		else cnt += a[i] - (i + 1);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main(){
    int N, M;
    bool can = true;
    cin >> N >> M;
    vector<int> keta(N, -1);
    vector<int> s(M);
    vector<int> c(M);
    for (int i = 0; i < M;i++){
        cin >> s.at(i) >> c.at(i);
    }
    for (int i = 0; i < M;i++){
        if(keta.at(s.at(i)-1)!=-1&&c.at(i)!=keta.at(s.at(i)-1)){
            can = false;
            break;
        }
        if(s.at(i)==1&&c.at(i)==0&&N!=1){
            can = false;
            break;
        }
        keta.at(s.at(i) - 1) = c.at(i);

    }
    if(can){
        for (int i = 0; i < N;i++){
            if (i == 0&&N!=1)
            {
                cout << max(1, keta.at(i));
            }
            else
                cout << max(0, keta.at(i));
        }
    }
    else cout << -1;
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    vector<ll> asum(n+1);
    asum[0] = 0; 
    rep(i,n) asum[i+1] = asum[i] + a[i];
    double key = asum[n]/2.0;
    ll ans = asum[n];
    rep(i,n){
        ans = min(ans, abs(2*asum[i] - asum[n]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 100010
long long a[N];
int n;
int main()
{
    int i,j,k,flag;
    long long l,r,mid,s1,s2;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    if(a[n]!=2)
    {
        printf("-1\n");
        return 0;
    }
    flag=0;
    l=2;
    r=2;
    for(i=n;i>=1;i--)
    {
        if(l%a[i])
        l=(l/a[i]+1)*a[i];
        r=r/a[i]*a[i]+a[i]-1;
        if(l>r)
            break;
    }
    if(i!=0)
    printf("-1\n");
    else
    printf("%lld %lld\n",l,r);
    return 0;
}


Measured memory_bytes: 896
al = [list(map(int, input().split())) for i in range(3)]
al = sum(al, [])
n = int(input())
bl = [int(input()) for i in range(n)]
check = [0 for i in range(9)]

for b in bl:
    if b in al:
        check[al.index(b)] = 1

if [1,1,1] in [check[:3], check[3:6], check[6:], check[0:7:3], check[1:8:3], check[2:9:3], check[0:9:4], check[2:8:2]]:
    print("Yes")
else:
    print("No")


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 075_abc_d / Link: https://abc075.contest.atcoder.jp/tasks/abc075_d?lang=en  ----- */
/* ------問題------

2次元座標上に N 個の点があります。
i(1≦i≦N) 番目の点の座標は (xi,yi) です。
長方形の内部に N 点のうち K 個以上の点を含みつつ、それぞれの辺がX軸かY軸に平行な長方形を考えます。
このとき、長方形の辺上の点は長方形の内部に含みます。
それらの長方形の中で、最小の面積となるような長方形の面積を求めてください。

-----問題ここまで----- */
/* -----解説等-----

O(N^5)、すき


----解説ここまで---- */

LL N,K;

LL ans = 0LL;

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

	cin >> N>>K;
	VL x(N), y(N);
	VL xc(N), yc(N);
	FOR(i, 0, N) {
		cin >> x[i] >> y[i];
		xc[i] = x[i];
		yc[i] = y[i];
	}

	SORT(xc);
	SORT(yc);
	ans = (xc[N-1]- xc[0])*(yc[N - 1] - yc[0]);
	FOR(u1, 0, N) {
		FOR(u2, u1+1, N) {
			FOR(d1, 0, N) {
				FOR(d2, d1+1, N) {
					LL X = xc[u2] - xc[u1];
					LL Y = yc[d2] - yc[d1];
					int cnt = 0;
					FOR(i, 0, N) {
						if (xc[u1] <= x[i]
							&& x[i] <= xc[u2]
							&&yc[d1] <= y[i]
							&& y[i] <= yc[d2]
							)
							cnt++;
					}

					if (cnt >= K) {
						ans = min(ans, X*Y);
					}



				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


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

int main() {
    int result = 0;
    int n, buf = 0;
    string s;
    cin >> n >> s;
    
    for(int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            buf++;
        }
        else {
            buf--;
        }
        result = max(buf,result);
    }
    
    cout << result << endl;
}


Measured memory_bytes: 256
ans = 0
l = [10]
for i in range(5):
    x = int(input())
    ans += x
    if x%10!=0:
        ans += 10-x%10
    if x%10 != 0:
        l.append(x%10)
l.sort()
ans -= 10-l[0]
print(ans)

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


void solve(long long A, long long B, long long C){
    if(A>=B+C){
        cout << 0 << endl;
    }else
    {
        cout << B - (A - C) << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

int main(){
  string S;
  cin>>S;
  if(S.at(0)==S.at(1)||S.at(1)==S.at(2)||S.at(2)==S.at(3)){
    cout<<"Bad"<<endl;
  }else{
    cout<<"Good"<<endl;
  }
}

Measured memory_bytes: 256
n, l = map(int,input().split())
a = list(map(int,input().split()))

loc = -1
for i in range(n-1):
    if a[i] + a[i + 1] >= l:
        loc = i + 1
        break

if loc < 0:
    print("Impossible")
    exit()

print("Possible")

for i in range(1, loc):
    print(i)
for i in range(n - 1, loc - 1, -1):
    print(i)


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<long,long>> ab(n);
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        ab.at(i) = make_pair(a,b);
    }
    sort(ab.begin(), ab.end());
    int buy = 0;
    long long cost = 0;
    for(int i = 0; i < n; i++){
        if(buy+ab.at(i).second < m){
            buy = buy + ab.at(i).second;
            cost = cost + ab.at(i).first * ab.at(i).second;
        } else if(buy + ab.at(i).second >= m){
            cost = cost + ab.at(i).first * (m-buy);
            break;
        }
    }
    cout << cost;
}

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

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


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

for i in range(n-1,0,-1):
    if h[i-1] - 1 == h[i]:
        h[i-1] -= 1

for j in range(n-1):
    if h[j] > h[j+1]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 14396
fn main() {
    let sc = std::io::stdin();
    let mut sc = Scanner { reader: sc.lock() };
    let l: usize = sc.read();

    let mut r = 0;
    while (1 << (r + 1)) <= l {
        r += 1;
    }

    let n = r + 1;
    let mut graph = vec![vec![]; n];
    for i in 0..r {
        graph[i].push((i + 1, 1 << i));
        graph[i].push((i + 1, 0));
    }

    let mut l = l;
    for i in (0..(n - 1)).rev() {
        if l >= (1 << r) + (1 << i) {
            graph[i].push((n - 1, l - (1 << i)));
            l -= 1 << i;
        }
    }

    let mut ans = vec![];
    for i in 0..n {
        for &(next, w) in graph[i].iter() {
            ans.push((i, next, w));
        }
    }

    println!("{} {}", n, ans.len());
    for &(i, next, w) in ans.iter() {
        println!("{} {} {}", i + 1, next + 1, w);
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
//69行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

//Simple Array Input
#define SAI int n;cin >> n;vi a(n);ain(a)
//Simple Graph Input
#define SGI(m) for(int i=0;i<m;i++){int a,b;cin >> a >> b;g[--a].pb(--b);g[b].pb(a);}
//Simple Tree Input
#define STI SGI(n-1)

typedef long long ll;
typedef long long integer;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){
    for(int i=0;i<a.size();i++)cout << a[i] << (i < a.size()-1 ? ' ' : '\n');
}
///////////////////////////////////////////////////////////

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

    int n,m;cin >> n >> m;
    vi a(n);rep(i,m)cin >> a[i];
   	int sum = 0;
   	rep(i,m)sum += a[i];
   	if(sum > n){
   		cout << -1 << '\n';
   	}else{
   		cout << n - sum << '\n';
   	}
    return 0;
}
/*
 *!!CHECK!! 
 * 制約をよく読め：まず最も愚直な解法を考えろ
 * intの掛け算をしてる場合：overflowは大丈夫？
 * 制約の下限・上限は大丈夫？
 * 木構造は一直線にした時TLEしない？
 * */

/*
* DEBUG before you submit!
* 入力はされてる？
* vectorはサイズを初期化している？
* まずは変数が適切かをチェックする
* 特に二重ループ内部の変数が適切か？
* while文はカウンタがインクリメントされてるかチェック！
*/


Measured memory_bytes: 7160
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define ld long double
#define int ll
#define INF LLONG_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

vector<int> Pos;
vector<int> Neg;

signed main() {
  
  int N, K; cin >> N >> K;
  rep(i, N) {
    int x; cin >> x;
    if ( x < 0) {
      Neg.push_back(abs(x));
    } else {
      Pos.push_back(abs(x));
    }
  }
  int ans = INF;
  sort(Neg.begin(), Neg.end());
  // cout << Pos.size() << endl;
  // cout << Neg.size() << endl;

  for (int i = Pos.size() - 1; i >= -1; i--) {
    int positemnum = i + 1;
    int negitemnum = K - positemnum;
    int j = negitemnum - 1;
    if (negitemnum < 0) continue;
    if (negitemnum > Neg.size()) continue;
    if (negitemnum == 0) {
      ans = min(ans, Pos[i]);
    } else if (positemnum == 0) {
      ans = min(ans, Neg[j]);
    } else {
      int temp = min(2 * Pos[i] + Neg[j], 2 * Neg[j] + Pos[i]);
      ans = min(ans, temp);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1656
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    ll N;
    cin >> N;
    ll ans = 0;

    for (ll i = 1; i < N + 1; i++) {
        ll num = N / i;
        ans += i * (1 + num) * num / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int p, q, r;
    cin >> p >> q >> r;

    int ans = min({p+q, q+r, r+p});

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = 3 * TEN(18) + 10;
const int mod = TEN(9) + 7;

int N, M, V, P;
int A[200100];

bool check(int idx)
{
	int zan = M * V;

	for (int i = 0; i <= idx; ++i) {
		zan -= M;
	}

	for (int i = N - 1; i >= N - (P - 1); --i) {
		zan -= M;
	}

	int mx = A[idx] + M;

	for (int i = idx + 1; i <= N - P; ++i) {
		zan -= max(mx - A[i], 0ll);
	}

	return zan <= 0 and mx >= A[N - P];
}

signed main()
{
	cin >> N >> M >> V >> P;
	rep(i, N) cin >> A[i];
	sort(A, A + N);

	int lo = -1, hi = N - 1;

	int cnt = 0;

	while (hi - lo > 1) {
		int mid = (hi + lo) / 2;

		if (check(mid)) {
			hi = mid;
		} else {
			lo = mid;
		}

		cnt++;
	}

	cout << N - hi << endl;
}



Measured memory_bytes: 1152
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  string s,t;
  while(cin>>s){
    cin>>t;
    int sln=s.length(),tln=t.length();
    int mx=0;
    for(i=0;i<sln;i++){
      for(j=0;j<min(sln-i,tln);j=k){
	for(;j<min(sln-i,tln)&&s[i+j]!=t[j];j++);
	for(k=j;k<min(sln-i,tln)&&s[i+k]==t[k];k++);
	mx=max(mx,k-j);
      }
    }
    for(i=0;i<tln;i++){
      for(j=0;j<min(tln-i,sln);j=k){
	for(;j<min(tln-i,sln)&&t[i+j]!=s[j];j++);
	for(k=j;k<min(tln-i,sln)&&t[i+k]==s[k];k++);
	mx=max(mx,k-j);
      }
    }
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,fre[26]={0};
	string str;
	long long ans=1;
	const int mod=1e9+7;
	cin>>n;
	cin>>str;
	for(int i=0;i<str.length();++i)
		fre[str[i]-'a']++;
	for(int i=0;i<26;++i)
		ans=(ans*(fre[i]+1))%mod;
	ans=(ans+mod-1)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        a_ss: [[usize]; k],
    }
    let mut h = std::collections::HashMap::new();
    for i in 1..=n {
        h.insert(i, 0);
    }
    for a_s in a_ss {
        for a in a_s {
            *h.entry(a).or_insert(0) += 1;
        }
    }
    let ans = h.iter().filter(|(_, value)| **value == 0).count();
    println!("{}", ans);
}


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

int main()
{
	string s;
	cin >> s;
	int k = s.size();
	for (int i = 0; i < k; ++i)
	{
		cin >> s[i];
	}
	int a = 0;
	for (int i = 0; i < k; ++i)
	{
		if (s[i] == 'o')
		{ 
			a = a+1;
		}
	}
	if (a+(15-k) > 7)
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k; cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = 0;
    rep(i,n){
        ans += min(x[i], abs(k-x[i])) * 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# input
#a = int(input())
a = input()
#a, b, c = map(int, input().split())
#a, b, c = input().split()
o = 0
#o = []

# calc
for i in range(len(a)):
    if a[i] in ('A', 'C', 'G', 'T'):
        t = 1
        for j in range(i+1, len(a)):
            if a[j] in ('A', 'C', 'G', 'T'):
                t += 1
                # print(a[j])
               # if j == len(a)-1 and o < t:
               #     o = t
            else:
               # if o < t:
               #     o = t
                break
        if o < t:
            o = t

# output
print(o)
# for i in range(a):
#    print(o[i])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,x=0;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=9;i>=0;i--)
    {
        if(a==i)
        {
            x=a;
            break;
        }
        if(b==i)
        {
            x=b;
            break;
        }
        if(c==i)
        {
            x=c;
            break;
        }
    }
    printf("%d",(10*x)+a+b+c-x);
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_k

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 100;
const int K_MAX = 1e5;

int N, K;
int a[N_MAX];

bool win[K_MAX + 1];

void solve() {
  FOR(i, 1, K) {
    REP(j, N) {
      int aa = a[j];
      if (aa <= i && !win[i - aa]) {
        win[i] = true;
        break;
      }
    }
  }
  puts(win[K] ? "First" : "Second");
}

void input() {
  scanf("%d%d", &N, &K);
  REP(i, N) scanf("%d", a + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

int main(){
  int a[3];
  int cnt[4] = {0, 0, 0, 0};
  while (true) {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] + a[1] > a[2]) {
      cnt[0] ++;
      if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) cnt[1] ++;
      if (a[0] * a[0] + a[1] * a[1]  > a[2] * a[2]) cnt[2] ++;
      if (a[0] * a[0] + a[1] * a[1]  < a[2] * a[2]) cnt[3] ++;
    } else {
      break;
    }
  }

  cout << cnt[0];
  cout << " " << cnt[1];
  cout << " " << cnt[2];
  cout << " " << cnt[3];
  cout << endl;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int& x : a) cin >> x;

    for(int i=0; i<n; i++) {
        for(int j=i; j >= 1 && a[j-1] > a[j]; j--) {
            swap(a[j-1], a[j]);
        }
        
        for(int j=0; j<n; j++) {
            cout << a[j] << (j != n-1 ? " " : "\n");
        }
    }

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int x;
            cin >> x;
            --x;
            a[x]++;
        }
    }

    int ans = 0;
    rep(i, n) {
        if(a[i] == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;

    bool ok = false;
    for(int c = 0; c<=(100/4); c++) {
        for(int d =0; d<=(100/7); d++) {
            if (4*c+7*d==N) {
                ok = true;
                break;
            }
        }
        if (ok) break;
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

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

    float L;
    cin>>L;
    long double ans;
    long double a = L/3.0;
    L-=a;
    long double b = L/2.0;
    if(a*b*b > a*a*a) ans = a*b*b;
    else ans=a*a*a;
    cout<<fixed<<setprecision(12)<<ans<<endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const int N = 1e5+7;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(0.0) * 2;
int n;
LL a[N];
bool cmp(LL a,LL b) {
    return a>b;
}
int main() {
    while(~scanf("%d",&n)) {
        int cnt = 0;
        for(int i = 0;i<n;i++)scanf("%lld",a+i);
        sort(a,a+n,cmp);
        LL a1 = 0,a2 = 0;
        LL cmp = 0;
        for(int i = 0;i<n;i++) {
            if(a[i] == a[i+1]&&a[i+1] == a[i+2]&&a[i+2] == a[i+3]&&cnt == 0) {
                a1 = a[i];
                a2 = a[i];
                break;
            }
            if(a[i] != cmp&&a[i] == a[i+1]) {
                cnt++;
                if(cnt == 1)a1 = a[i];
                else a2 = a[i];
            }
            cmp = a[i];
            if(cnt == 2)break;
        }
        printf("%lld\n",a1*a2);
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];

int main(){
  scanf("%d", &n);
  scanf("%s", s);
  ll ans = 1;
  REP(i,26){
    ll c = count(s,s+n,'a'+i);
    ans *= (c+1);
    ans %= MOD;
  }
  ans += MOD-1;
  ans %= MOD;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 384
gets
a=gets.split.map(&:to_i)
tmp = 0
side=[]
a.sort_by { |i| -i }.each do |i|
  if i == tmp
    tmp = 0
    side << i
    break if side.count == 2
  else
    tmp = i
  end
end
puts side[0].to_i * side[1].to_i

Measured memory_bytes: 11648
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){

    int N;
    cin >> N;
    
    vector<string> s(N);
    
    int ans = 0;
    int numA = 0;
    int numB = 0;
    int ff = 0;
    int ab = 0;
    
    
    
    for (int i = 0; i < N; i ++) {
        cin >> s[i];
        
        int len = s[i].length();
        
        
        if (s[i].substr(0, 1) == "B") {
            numB += 1;
            ff += 1;
        }
        
        
        for (int j = 0; j < len - 1; j++) {
            if(s[i].substr(j, 1) == "A"){
                if (s[i].substr(j+1, 1) == "B") {
                    ans += 1;
                }
            }
        }
        
        
        if (s[i].substr(len-1, 1) == "A") {
            if (ff == 1) {
                numB -= 1;
                ab += 1;
            }else{
                numA += 1;
            }
        }
        
        ff = 0;
    }
    
    if (ab > 0) {
        ans = ans + ab - 1;
        if (numA > 0) {
            ans += 1;
            numA -= 1;
        }
        if (numB > 0) {
            ans += 1;
            numB -= 1;
        }
    }
    
    if (numA - numB >= 0) {
        ans += numB;
    }else if(numB - numA > 0) {
        ans += numA;
        
    }
    
    
    
    cout << ans << endl;

    
    
    
    return 0;
    
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
// const int N = 1e5 + 5;
string s = "a";
vector<string> ans;
void gen(int pos, int len)
{
	if (pos == len) {ans.pb(s); return;}
	auto x = *max_element(begin(s), end(s));
	for (char c = 'a'; c <= x+1; ++c)
	{
		s += c;
		gen(pos+1, len);
		s.pop_back();
	}
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	gen(1, n);
	// cout << ans.size();
	for (auto x : ans)
		cout << x << '\n';
}

Measured memory_bytes: 9716
#include <iostream>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
 
int solve(int x,int p){
    return floor(p*(1+x*0.01));
}
 
int main() {
    int n;
    int a[6][10];
    memset(a,0,sizeof(a));
    while(cin >> n && n){
        for(int i=0;i<n;i++) for(int j=0;j<5;j++) cin >> a[j][i];
        int sum=0;
        int csum;
        do{
            csum=sum;
            for(int i=0;i<n;i++){
                int current=0;
                int count=0;
                int start;
                for(int j=0;j<6;j++){
                    if(current != a[j][i]){
                        if(count>=3){
                            sum+=count*current;
                            for(int k=1;k<=count;k++){
                                a[j-k][i]=0;
                            }
//                          cout << "count:" << count << endl;
//                          cout << "current:" << current << endl;
                        }
                        current = a[j][i];
                        count=1;
                    } else {
                        count++;
                    }
                }
            }
/*          for(int i=0;i<n;i++){
                for(int j=0;j<5;j++){
                    cout << a[j][i] << " ";
                }
                cout << endl;
            }*/
            for(int j=0;j<5;j++){
                for(int i=n-1;i>0;i--){
                    if(a[j][i]==0){
                        for(int k=i-1;k>=0;k--){
                            if(a[j][k]!=0){
//                              cout << j << " swap " << i << " " << k << endl;
                                swap(a[j][k],a[j][i]);
                                break;
                            }
                        }
                    }
                }
            }
        }while(csum!=sum);
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>

int main() {
	while (1) {
		char s1[210];
		char s2[210];
		scanf("%s", s1);
		if (s1[0] == '.') break;
		scanf("%s", s2);
		int n1 = strlen(s1);
		int n2 = strlen(s2);
		
		if (n1 == n2) {
			bool j = true;
			for (int i = 0; i < n1; i++) {
				if (s1[i] != s2[i]) {
					j = false;
					break;
				}
			}
			if (j) {
				printf("IDENTICAL\n");
				continue;
			}
		}

		char s1str[100][210] = {};
		bool s1j[100] = {};
		char s2str[100][210] = {};
		bool s2j[100] = {};
		int a1;
		int a2;
		bool j = false;
		int a = 0;
		char z1[210];
		char z2[210];
		int z = 0;
		for (int i = 0; i < n1; i++) {
			if (s1[i] == '"') {
				
				s1j[a] = true;
				int j = 0;
				for (i++; i < n1; i++) {
					if (s1[i] != '"') {
						s1str[a][j] = s1[i];
					}
					else {
						s1str[a][j] = '\0';
						break;
					}
					j++;
				}
				a++;
				z1[z] = 'a';
				z++;
			}
			else {
				z1[z] = s1[i];
				z++;
			}
			
			a1 = a;
		}
		z1[z] = '\0';
		
		a = 0;
		z = 0;
		for (int i = 0; i < n2; i++) {
			if (s2[i] == '"') {
				
				s2j[a] = true;
				int j = 0;
				for (i++; i < n2; i++) {
					if (s2[i] != '"') {
						s2str[a][j] = s2[i];
					}
					else {
						s2str[a][j] = '\0';
						break;
					}
					j++;
				}
				a++;
				z2[z] = 'a';
				z++;
			}
			else {
				z2[z] = s2[i];
				z++;
			}
			
			a2 = a;
		}
		z2[z] = '\0';
		if (strcmp(z1, z2)) {
			printf("DIFFERENT\n");
			continue;
		}
		

		if (a1 != a2) {
			printf("DIFFERENT\n");
			continue;
		}
		else {
			int dif = 0;
			for (int i = 0; i < a1; i++) {
				if (strcmp(s1str[i], s2str[i])) {
					dif++;
				}
				if (dif >= 2) break;
			}
			if (dif >= 2) {
				printf("DIFFERENT\n");
				continue;
			}
			else {
				printf("CLOSE\n");
				continue;
			}
		}
	}
}


Measured memory_bytes: 2712
k, x = list(map(int, input().split()))

ans_list = []
if (x - k) < -1000000:
    for i in range(-1000000, x + k):
        ans_list.append(str(i))
elif (x + k) > 1000000:
    for i in range(x - k + 1, 1000001):
        ans_list.append(str(i))
else:
    for i in range(x - k + 1, x + k):
        ans_list.append(str(i))
print(' '.join(ans_list))

Measured memory_bytes: 3064
def calc0(N, K):
    r = 0
    for a in range(1, N + 1):
        for b in range(1, N + 1):
            if a % b >= K:
                print(a, b, a % b)
                r += 1
    return r

def calc1(N, K):
    result = 0
    for i in range(K, N):
        for x in range(i + 1, N + 1):
            if i > 0:
                r = (N + x - i) // x
            else:
                r = (N + x - i) // x - 1
            # print(i, x, r)
            result += r
    return result

def calc2(N, K):
    if K == 0:
        return N**2
    result = 0
    for x in range(1, N + 1):
        for i in range(K, min(N, x)):
            r = (N - i) // x + 1
            result += r
    return result

def calc2(N, K):
    if K == 0:
        return N**2
    result = 0
    for x in range(1, N + 1):
        for i in range(K, min(N, x)):
            r = (N - i) // x + 1
            result += r
    return result

def calc3(N, K):
    if K == 0:
        return N**2
    result = 0
    for x in range(1, N + 1):
        st = N - min(N, x) + 1
        ed = N - K
        if (ed < x):
            r = (ed - st + 1)
        else:
            r = 0
            for j in range(st, ed + 1):
                r += j // x + 1
        print(st, ed, x, r)
        result += r
    return result

def calc(N, K):
    if K == 0:
        return N**2
    result = 0
    for b in range(1, N + 1):
        if b <= K:
            continue
        n, m = divmod(N, b)
        r1 = (b - K) * n
        r2 = 0
        if m >= K:
            r2 = m - K + 1
        result += r1 + r2
    return result

N, K = [int(_) for _ in input().split()]
# print(calc2(N, K))
print(calc(N, K))


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

namespace CSharpSample01
{


    class Program
    {
        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            var list = new List<int>();
            for(int i = 0; i < n; i++)
            {
                list.Add(int.Parse(str[i]));
            }

            list.Sort((u, v) => v - u);

            int a = 0;
            int b = 0;
            for(int i = 0; i < n; i++)
            {
                if (i % 2 == 0) a += list[i];
                else b += list[i];
            }

            Console.WriteLine(a - b);

        }
    }
}

Measured memory_bytes: 11220