akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
int main()
{
    int n, x, y, h, w;
    while (cin >> n, n) {
        int tc = 0;
        while (n--) {
            cin >> x >> y >> h >> w;
             
            int tc1 = 0, tc2 = 0, size = x+y+h;
            bool tf1 = false, tf2 = false;
             
            if (size <= 60) tc1 = 600;
            else if (size <= 80) tc1 = 800;
            else if (size <= 100) tc1 = 1000;
            else if (size <= 120) tc1 = 1200;
            else if (size <= 140) tc1 = 1400;
            else if (size <= 160) tc1 = 1600;
            else tf1 = true;
             
            if (w <= 2) tc2 = 600;
            else if (w <= 5) tc2 = 800;
            else if (w <= 10) tc2 = 1000;
            else if (w <= 15) tc2 = 1200;
            else if (w <= 20) tc2 = 1400;
            else if (w <= 25) tc2 = 1600;
            else tf2 = true;
             
            if (tf1||tf2) continue;
            else tc += max(tc1, tc2);
        }
        cout << tc << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
def quicksort(array):
    if len(array) < 2:
        return array
    else:
        pivot = array[0]
        less = [i for i in array[1:] if i <= pivot]

        greater = [i for i in array[1:] if i > pivot]

        return quicksort(less) + [pivot] + quicksort(greater)


array = []
for _ in range(10):
    array.append(int(input()))

sorted_array = quicksort(array)
for i in range(3):
    print(sorted_array[9-i])

Measured memory_bytes: 7688
//Author : Ayush Jain

#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
const int N=1e5 + 5;
const int M=1e5 + 5;

ull pw[67];
void pre()
{
	pw[0]=1;
	for(int i=1;i<64;i++) pw[i]=2*pw[i-1];
}

int main()
{
	ios_base::sync_with_stdio(false);
	pre();
	int n,i,j;
	int c[505],s[505],f[505];
	cin>>n;
	for(i=0;i<n-1;i++){
		cin>>c[i]>>s[i]>>f[i];
	}	
	for(i=0;i<n-1;i++){
		int t=0;
		for(j=i;j<n-1;j++){
			if(s[j]>=t){
				t=s[j]+c[j];
			}
			else{
				if(t%f[j] == 0){
					t+=c[j];
				}
				else{
					int rm=t%f[j];
					t+=f[j]-rm;
					t+=c[j];
				}
			}
		}
		cout<<t<<endl;
	}
	cout<<0<<endl;
	
		
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define M 2001

using namespace std;

int main()
{
	long long x;
	cin >> x;
	int q = (int)sqrt(x);

	long long m, n;

	for (int i = q; i >= 1; i--)
	{
		if (x%i == 0)
		{
			m = i;
			n = x / i;
			break;
		}
	}

	cout << m + n - 2 << endl;

	return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    vector<float> cash;
    int n;
    float x;
    cin >> n;
    for(int i=0; i < n; i++)
    {
        cin >> x;
        cash.push_back(x);
    }
    for(int i = 1; i < n; i++)
    {
        sort(cash.begin(),cash.end());
        cash[i] = (cash[i-1] + cash[i])/2;
        cash[i-1] = 0;
    }
    cout << cash[n-1];
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = sorted(map(int, input().split()), reverse=True)

ans = A[0]
d = (N-2) // 2
m = (N-2) % 2
ans += sum(A[1:1+d]) * 2
if m == 1:
  ans += A[1+d]

print(ans)


Measured memory_bytes: 31536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int n;
  cin >> n;
  int p[n+1];

  for (size_t i = 0; i < n; i++)
  {
    cin >> p[i];
  }

  int tmp;
  int ans = 0;

  for (size_t i = 1; i < n; i++)
  {
    if (p[i - 1] == i)
    {
      swap(p[i - 1], p[i]);
      ans += 1;
    }
    else
    {
      continue;
    }
  }

  if (p[n - 1] == n)
  {
    ans += 1;
  }

  cout << ans << endl;

  return 0;
}


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

void dire(string X, string &Y, int Z){
	char c;
	for(int i = 0; i < Z; i++){
		c = X.at(i);
		Y = Y + c;
	}
	
	Y = Y + "...";
	
	return;
}

int main(){
	string S, T;
	int K,L;
	
	cin >> K >> S;
	
	T = "";
	L = S.size();
	
	if(L>K)
		dire(S, T, K);
	else
		T = S;
		
	cout << T << endl;
}

Measured memory_bytes: 3632
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
int a[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

void solve() {
  {
    bool zero = true;
    for (int i = 0; i < n; i++) {
      if (a[i]) {
        zero = false;
        break;
      }
    }
    if (zero) {
      printf("Yes\n");
      return;
    }
  }
  if (n % 3) {
    printf("No\n");
    return;
  }
  int k = n / 3;
  sort(a, a + n);
  int x = a[0], y = a[k], z = a[2 * k];
  for (int i = 0; i < k; i++) {
    if (a[i] != x) {
      printf("No\n");
      return;
    }
  }
  for (int i = k; i < 2 * k; i++) {
    if (a[i] != y) {
      printf("No\n");
      return;
    }
  }
  for (int i = 2 * k; i < n; i++) {
    if (a[i] != z) {
      printf("No\n");
      return;
    }
  }
  if (x ^ y ^ z) {
    printf("No\n");
    return;
  }
  printf("Yes\n");
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


const string YES = "Yes";
const string NO = "No";

void solve(long long X){
    if(X>=30){
        cout<<YES<<endl;
    }else{
        cout<<NO<<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 X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3660
let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let sqrt n = upper_bound 0 2147483648 (fun i -> i * i <= n)

let () = Scanf.scanf "%d\n" @@ fun n ->
  for i = 0 to n - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      let n = sqrt (a * b - 1) in
      Printf.printf "%d\n" @@
        if n = 0 then 0
        else 
          2 * n
          - (if a <= n then 1 else 0)
          - (if b <= n then 1 else 0)
          - (if (a * b - 1) / n = n then 1 else 0)
  done


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

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    string S;
    cin >> S;
    
    if (S[0] - '0' == 7 || S[1] - '0' == 7 || S[2] - '0' == 7){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
ll n;
vl a;
void solve()
{
    cin>>n;
    a.resize(n);
    forr(i, n)
    {
    	cin>>a[i];
    }
    ll gcd=__gcd(a[0], a[1]);
    for(ll i=2; i<n; i++)
    	gcd=__gcd(gcd, a[i]);
    map<ll, ll> mp1;
    bool check=true;
    for(ll i=0; i<n; i++)
    {
    	// break a[i] down
    	for(ll j=2; j<=(ll)sqrt(a[i]); j++)
    	{
    		if(a[i]%j==0)
    		{
    			if(mp1.find(j)!=mp1.end())
    			{
    				check=false;
    				break;
    			}
    			mp1[j]++;
    			while(a[i]%j==0)
    				a[i]/=j;
    		}
    	}
    	if(a[i]!=1)
    	{
    		if(mp1.find(a[i])!=mp1.end())
    		{
    			check=false;
    			break;
    		}
    		else
    			mp1[a[i]]++;
    	}
    	if(!check)
    		break;
    }
    if(check==false)
    {
    	if(gcd==1)
    		cout<<"setwise coprime\n";
    	else
    		cout<<"not coprime\n";
    	return;
    }
    else
    {
    	cout<<"pairwise coprime\n";
    	return;
    }
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

#define maxn 100005

using namespace std;
typedef long long ll;

int n;
ll a[maxn];

int main(){
  #define TASK "ABC"
//  freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
  ios_base::sync_with_stdio(0);

  cin >> n;

  ll sumxor = 0, maxbit = 60;

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sumxor ^= a[i];
  }

  for (int i = 0; i < n; ++i)
    a[i] &= ~sumxor;

  int index = 0;

  for (int i = maxbit; i >= 0; --i) {
    int id = -1;

    for (int j = index; j < n; ++j)
      if ((a[j] >> i)&1)
        id = j;

    if (id == -1) continue;

    swap(a[id], a[index]);

    for (int j = 0; j < n; ++j)
      if ((a[j] >> i)&1 && j != index)
        a[j] ^= a[index];

    index++;
  }

  ll ret = 0;

  for (int j = 0; j < n; ++j)
    ret ^= a[j];

  cout << ret + (ret ^ sumxor);
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
const long nPrime = 1000000007;

long Factorial(const long &n){
    //nPrime = 1000000007
    long nReturn = 1;
    for(long i = 2; i <= n; i++){
        nReturn *= i;
        nReturn %= nPrime;
    }
    return nReturn;
}

long Inverse(const long &n){
    //nPrime = 1000000007
    if (n % nPrime == 0){
        return 0;
    }
    long a = n, b = nPrime, u = 1, v = 0;
    while (b > 0) {
        long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= nPrime;
    if (u < 0){
        u += nPrime;
    }
    return u;    
}

int main(){
    long x,y;
    scanf("%ld %ld", &x, &y);
    if((x + y) % 3 != 0 || 2 * x < y || 2 * y < x){
        printf("0");
        return 0;
    }
    long a,b;
    a = (2 * x - y) / 3;
    b = (2 * y - x) / 3;
    if(a * b == 0){
        printf("1");
    } else {
        long nAns = Factorial(a+b) * Inverse(Factorial(a));
        nAns %= nPrime;
        nAns *= Inverse(Factorial(b));
        nAns %= nPrime;
        printf("%ld", nAns);
    }
    
    return 0;
}


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

typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int
main()
{
  int N, X; cin >> N >> X;
  vector<int> L(N);
  REP(i, N) cin >> L[i];

  int D = 0;
  for (int i = 1; i < N+1; ++i) {
    D = D + L[i-1];	// i
    if (X < D) {
      ANS(i);
      return 0;
    }
  }
  /*
4 9
3 3 3 3
0 3 6 9 12
  */

  ANS(N+1);
  
  return 0;
}


Measured memory_bytes: 256
;; #!/usr/bin/env sbcl --script

(declaim (optimize (speed 3) (safety 0) (debug 0)))

(defun main ()
  (let* ((n (read))
         (k (read))
         (a (make-array n :element-type 'fixnum))
         (dp (make-array n :element-type 'fixnum :initial-element (floor most-positive-fixnum 2))))
    (let ((stream (make-string-input-stream (read-line))))
      (loop for i from 0
         for j = (read stream nil) until (null j)
         do (setf (aref a i) j)))
    (setf (aref dp 0) 0)
    (dotimes (i n)
      (dotimes (j k)
        (when (>= (+ i j 1) n) (return))
        (let* ((jj (+ i j 1))
               (from-val (aref dp i))
               (to-val (aref dp jj))
               (nval (+ from-val (abs (- (aref a i) (aref a jj))))))
          (setf (aref dp jj) (min to-val nval)))))
    (format t "~a~%" (aref dp (- n 1)))))

(main)


Measured memory_bytes: 57704
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int[] a =new int [n+1];
		int[] b =new int [n];
		for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		}
		
		long ans=0;
		int old=0;
		for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		}
		//ans+=Math.min(a[n], old);
		

		System.out.print(ans);
		
}
}
//end

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

char in[120];
pair<pair<string ,int>, int> p[110];

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

  for (int i = 0; i < n; i++) {
    int t;
    cin >> in >> t;
    string tmp = in;
    p[i] = make_pair(make_pair(in, -t), i);
  }
  sort(p, p + n);
  for (int i = 0; i < n; i++) {
    cout << p[i].second+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const long long INF = 1e18;
const double PI = 2 * asin(1);

int main(){
  int N; ll K; cin >> N >> K;
  
  vector < pair<ll, ll> > AB(N);
  for (int i = 0; i < N; i++){
    ll A, B; cin >> A >> B;
    AB[i] = make_pair(A, B);
  }
  sort(AB.begin(), AB.end(), greater<pair<ll,ll> >());

  vector <ll> candi;
  candi.push_back(K);

  ll cnt = 0;
  while (pow(2, cnt) <= K){
    cnt++;
  }

  vector <bool> k(cnt);
  for (int i = 0; i < cnt; i++){
    if (K % 2 == 1) k[i] = true;
    K /= 2;
  }
  
  ll now = 0;
  for (int i = cnt - 1; i >= 0; i--){
    if (k[i] == true){
      ll C = now;
      for (int j = i - 1; j >= 0; j--){
        C += pow(2, j);
      }
      candi.push_back(C);
      now += pow(2, i);
    }
  }

  ll ans = 0;
  for (int i = 0; i < candi.size(); i++){
    ll now = 0, A = 0;
    for (int j = 0; j < N; j++){
      ll n = now | AB[j].first;
      if (n <= candi[i]){
        now = n;
        A += AB[j].second;
      }
    }
    ans = max(A, ans);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <bitset>
#include <iostream>
#include <vector>
using namespace std;
typedef long long hyper;
const hyper INF = 1000000000000000;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> keys(m + 1);
  vector<int> key_cost(m + 1);
  vector<vector<hyper>> dp(m + 1, vector<hyper>(1 << n, INF));
  // dp[i][j]; i番目の鍵まで使ってj(bit)だけ箱を開けるときの金額の最小値
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    key_cost[i] = a;
    int box = 0;
    for (int i = 0; i < b; i++) {
      int c;
      cin >> c;
      box |= 1 << (c - 1);
    }
    keys[i] = box;
  }
  dp[0][0] = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < (1 << n); j++) {
      dp[i][j | keys[i]] =
          min(dp[i][j | keys[i]],
              min(INF, dp[i - 1][j] + key_cost[i])); // i番目の鍵を使う
      dp[i][j] = min(dp[i][j], dp[i - 1][j]);        // 使わない
    }
  }
  hyper ans = dp[m][(1 << n) - 1];
  if (ans>=INF)ans = -1;
  cout << ans << endl;
}


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

int main(){
	int n;
    cin >> n;
    VI c(n-1), s(n-1), f(n-1);
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];

    VI out;
    rep(i,n-1){
        rep(j,out.size()){
            int next = (out[j]+f[i]-1)/f[i]*f[i];
            out[j] = max(s[i], next);
        }
        out.push_back(s[i]);
        rep(j,out.size()){
            out[j] += c[i];
        }
    }

    for(auto x : out){
        cout << x << endl;
    }
    cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

char ps[23][2333];
bool pf[23];

int heng(int n,int m,int p)
{
	int l=1,q=1,pi[25]={0},sum=0;
	while(l<=m)
	{
		pi[0]=1;
		for(int i=1; i<=n; i++)
		{
			if(ps[i][l]=='1')
			{
				pi[pi[0]]++;
				if(pi[pi[0]]>p)
				{
					if(l==q) return 23333;
					sum++; q=l; l--;
					for(int j=1; j<=n; j++) pi[j]=0;
					break;
				}
			}
			if(pf[i]==true) pi[0]++;
		}
		l++;
	}
	return sum;
}

int sou(int k,int n,int m,int p)
{
	if(k==n)
	{
		int sum=0;
		for(int i=1; i<=n; i++) if(pf[i]==true) sum++;
		return sum+heng(n,m,p);
	}
	int sum=23333;
	pf[k]=true;
	sum=min(sum,sou(k+1,n,m,p));
	pf[k]=false;
	sum=min(sum,sou(k+1,n,m,p));
	return sum;
}

int main()
{
	int n,m,p; scanf("%d%d%d",&n,&m,&p);
	for(int i=1; i<=n; i++) scanf("%s",ps[i]+1);
	printf("%d",sou(1,n,m,p));
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int H,R;
	scanf("%d %d",&H,&R);
	if(H+R==0){
		printf("0\n");
	}
	else if(H+R>0){
		printf("1\n");
	}
	else{
		printf("-1\n");
	}
	return 0;
}

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

using namespace std;

long long collatz(long long k) {
    if (k%2 == 0) {
        return k/2;
    }
    return 3*k+1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin >> n;
    set<long long> xs;
    int i;
    for (i = 0; xs.size() == i; ++i) {
        xs.insert(n);
        n = collatz(n);
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S.at(K - 1) += 32;
    cout << S << endl;
}

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N, K;
    string S;

    cin >> N >> S >> K;

    for(int i = 0; i < S.length(); i++) {
        cout << (S[i] == S[K - 1] ? S[i] : '*');
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#define MAXN 1010
using namespace std;

int n,t,a,ans;
double h[MAXN],be=1000000000000.0;

int main()
{
	scanf("%d",&n);
	scanf("%d",&t);scanf("%d",&a);
	for (int i=1;i<=n;i++) scanf("%lf",&h[i]);
	for (int i=1;i<=n;i++)
	{
		double tmp=t-h[i]*0.006;
		if (fabs(tmp-a)<be)
		{
			be=fabs(tmp-a);
			ans=i;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc;
	static PrintWriter out;
	public static void main(String[] args){
		sc = new FastScanner();
		out = new PrintWriter(System.out);
//		solve();
		out.println(solve());
		out.flush();
	}

	static int solve(){
		return sc.nextInt() + sc.nextInt() / 2;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
}

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

int main(){
    int N;
    cin >> N;
    //cout << S.back() << '\n';
    string S = "";
    for (int i = 0; i < N; i++)
    {
        S += "ACL";
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3624
# (+1,+2)をn回，(+2,+1)をm回とすると
#  n + 2m = X
# 2n +  m = Y でn,mが求まる．
# このとき答えは(n+m)Cn通り

def combination(n,r):
	"""
    高速な組み合わせの計算．
	nCrは必ず整数になるため分母を全部約分で1にしてから残った分子の積を求める．
	[参考]https://kadzus.hatenadiary.org/entry/20081211/1229023326
    """

	if n-r < r: r = n-r
	if r == 0: return 1
	if r == 1: return int(n)

	numerator = [i+1 for i in range(n-r, n)]
	denominator = [i+1 for i in range(r)]

	for p in range(2,r+1):
		pivot = denominator[p-1]
		if pivot > 1:
			offset = (n-r)%p
			for k in range(p-1, r, p):
				numerator[k-offset] /= pivot
				denominator[k] /= pivot
	
	ans = 1
	for i in range(r):
		if numerator[i] > 1:
			ans *= numerator[i]
			if ans >= 1e9+7: ans %= 1e9+7
	
	return int(ans)

X,Y = map(int, input().split())

if (X+Y)%3 != 0:
	ans = 0
else:
	n = int((2*Y-X)/3)
	m = int(Y-2*n)
	if n<0 or m<0:
		ans = 0
	else:
		ans = combination(n+m, n)

print(ans)

Measured memory_bytes: 44056
N, M = map(int, input().split())
MOD = 10**9+7
x = [int(c) for c in input().split()]
y = [int(c) for c in input().split()]
X = 0
Y = 0
for i, c in enumerate(x):
  X += i*c-(N-1-i)*c
  X %= MOD
for i, c in enumerate(y):
  Y += i*c-(M-1-i)*c
  Y %= MOD
print(X*Y%MOD)

Measured memory_bytes: 19580
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n , syattukin = 100000;
    cin >> n;
    for(int i = 0; i < n ; ++i){
        syattukin = syattukin*1.05;
        if(syattukin%1000 != 0 ){
            syattukin = syattukin/1000*1000 + 1000;
        }
    }
    cout<<syattukin<<endl;
}



Measured memory_bytes: 3016
w, h, n = map(int, input().split())
b = 0
l = 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    elif a == 2:
        w = min(w, x)
    elif a == 3:
        b = max(b, y)
    else:
        h = min(h, y)

print(max(h - b, 0)*max(w - l, 0))

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Stack;

class Main{
    static Stack<Integer> stack;
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        stack = new Stack<>();
        while(sc.hasNext()){
            String str = sc.next();
            switch(str.charAt(0)){
                case '+':
                polandp();
                break;
                case '-':
                polandm();
                break;
                case '*':
                polanda();
                break;
                default:
                stack.push(Integer.parseInt(str));
            }
        }
        System.out.println(stack.pop());
    }
    
    private static void polandp(){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a+b);
    }
    private static void polandm(){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
    }private static void polanda(){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a*b);
    }
}


Measured memory_bytes: 26164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A == B){
    if(B != C){
      cout << "Yes" << endl;
      return 0;
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  else if(B == C){
    cout << "Yes" << endl;
    return 0; 
  }
  else if(C == A){
    cout << "Yes" << endl;
    return 0;
  }
  else{
    cout << "No" << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    ll ans;
    ll zx = X;
    if(zx < 0){
        zx = -zx;
    }

    if(zx / D >= K){
        ans = zx - K*D;
        cout << ans;
        return 0;
    }

    ll p = zx % D;
    ll m = D - zx%D;
    if((K - zx/D) % 2 == 0){
        cout << p;
    }else{
        cout << m;
    }

}


Measured memory_bytes: 3644
fun main(args :Array<String>) {
    val n = readInteger()
    val aArray = readIntegerArray()
    var count = 0
    var index = 1
    for (a in aArray) {
        if (index != a) {
            count++
        } else {
            index++
        }
    }

    if (count == n) {
        println(-1)
        return
    }
    println(count)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerArray() = readStringList().map(String::toInt).toIntArray()
fun readLongArray() = readStringList().map(String::toLong).toLongArray()


Measured memory_bytes: 84976
#include <bits/stdc++.h>
using namespace std;
int main(){
    int i;
    int n,ac=0,wa=0,tle=0,re=0;
    cin >> n;
    string str;
    string acs="AC",was="WA",tles="TLE",res="RE";
    for(i=0;i<n;i++){
        cin >> str;
        
        if(str==acs){
        ac++;
        }else if(str==was){
           wa++ ;
        }else if (str==tles){
            tle++;
        }else{
            re++;
        }
    
    }
    cout << "AC" << endl << "x" << endl << ac << endl;
    cout << "WA" << endl << "x" << endl << wa << endl;
    cout << "TLE" << endl << "x" << endl << tle << endl;
    cout << "RE" << endl << "x" << endl << re << endl;
        
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>

#define MAXN 300000

using namespace std;

int A[MAXN];
int B[MAXN];

int main()
{
  string s;
  int sum = MAXN+1;
  int tmp;

  cin >> tmp;

  cin >> s;

  for ( int i = 0; i < s.size(); ++i ) {
    if ( s[i] == 'E' ) ++A[i];
    else ++B[i];
  }

  for ( int i = 1; i < s.size(); ++i ) {
    A[i] = A[i-1]+A[i];
    B[i] = B[i-1]+B[i];
  }

  sum = A[s.size()-1]-A[0];
  for ( int i = 1; i < s.size(); ++i ) {
    int tmp = B[i-1]+A[s.size()-1]-A[i];
    if ( tmp < sum ) sum = tmp;
  }

  cout << sum << endl;
}


Measured memory_bytes: 3068
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn dfs(idx: i64, n: i64, a: &Vec<i64>, sum: i64) -> i64 {
   if idx == n {
       if sum %2 == 0 { return 1; }
       else { return 0; }
   }

   let mut res:i64 = 0;
   for i in -1..2 {
       res += dfs(idx+1, n, a, sum*(a[idx as usize]+i as i64));
   }
   return res;
}

fn main() {
    input!{n:usize, a:[i64; n]};
    let ans = dfs(0, n as i64, &a, 1);
    println!("{}", ans);
}


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

int main() {

    int A, B, C, K;

    cin >> A >> B >> C >> K;

    if (A >= B && A >= C) {
        cout << (A * pow(2, K)) + B + C << endl;
    }

    else if (B >= A && B >= C) {
        cout << A + (B * pow(2, K)) + C << endl;
    }

    else if (C >= B && C >= A) {
        cout << A + B + (C * pow(2, K)) << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0
for i in S:
    if i == 'AC':
        AC += 1
    elif i == 'WA':
        WA += 1
    elif i == 'TLE':
        TLE += 1
    else:
        RE += 1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))


Measured memory_bytes: 16260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD=1000000007;
long long memo[2010];

long long func(long long x){
  if(memo[x] != -1) return memo[x];
  if(x<3){
    return 0;
  }
  else if(x==3){
    return  1;
  }
  else{
    memo[x]=(func(x-1)+func(x-3))%MOD;     
    return memo[x];
  }
}

int main(){
  int s;
  cin>>s;
  for(int i=0;i<2005;i++){
    memo[i]=-1;
  }
  cout<<func(s)<<endl;
  return 0;
}



Measured memory_bytes: 3684
#include <bits/stdc++.h> 
using namespace std; 
const int mod = 1e9 + 7;
int main(){
    int n,k;
    cin>>n>>k;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(int i=1;i<=k;i++)  
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        int sum[k+1];
        sum[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sum[j]=(sum[j-1]+dp[i-1][j])%mod;  
        }
        for(int j=0;j<=k;j++)
        {
            int tt=sum[j];  
            int un=j-arr[i]-1; 
            if(un>=0)
            {
                tt=(tt-sum[un]+mod)%mod; 
            }
            dp[i][j]=tt;
          //  cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
  	cout<<dp[n][k];
	return 0;
}  


Measured memory_bytes: 40064
N, M = map(int, input().split())
G = []
for _ in range(M):
    a, b, c = map(int, input().split())
    G.append((a, b, -c))

inf = float('inf')
d = [inf]*(N+1)
d[1] = 0
for i in range(N+1):
    for v, nv, cost in G:
        if d[v] != inf and d[nv] > d[v]+cost:
            d[nv] = d[v]+cost
            if i == N-1:
                tmp = d[N]
            if i == N and d[N] != tmp:
                print('inf')
                exit()
print(-d[N])


Measured memory_bytes: 3396
#include <iostream>
using namespace std;
int main(void){
	int n,a,b,i,count,ans = 0;
	cin >> n;
	count = 0;
	for (i=0;i<n;i++) {
		cin >> a >> b;
		if (a==b) {
			count++;
			if ( count >= 3) {
				ans = 1;
			}
		} else {
			count = 0;
		}
	}
	if (ans>0) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 3592
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    A = [int(i) for i in input().split()]
    Q = int(input())
    BC = [[int(i) for i in input().split()] for j in range(Q)]

    cA = [0]*(10**5+1)
    for a in A:
        cA[a] += 1
    sumA = sum(A)
    for b, c in BC:
        miA = cA[b]*b
        plA = cA[b]*c
        cA[c] += cA[b]
        cA[b] = 0
        sumA -= miA
        sumA += plA
        print(sumA)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91020
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

class edge{
public:
	Int cost;
	size_t from, to;
	edge(Int c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
using edges = vector<edge>;
using graph = vector<edges>;
bool operator<(const edge &e, const edge &f){
	return e.cost != f.cost ? e.cost > f.cost : e.from != f.from ? e.from < f.from : e.to < f.to;
}
void dijkstra(size_t s, const graph &g, vector<Int> &dist){
	size_t V = g.size();
	dist = vector<Int>(V, 1e18);
	dist[s] = 0;
	priority_queue<edge> q;
	q.push(edge(0, s, s));
	while(!q.empty()){
		edge e = q.top();
		q.pop();
		if(dist[e.to] < e.cost) continue;
		for(size_t i=0; i<g[e.to].size(); ++i){
			edge f = g[e.to][i];
			if(dist[f.to] > dist[e.to] + f.cost){
				dist[f.to] = dist[e.to] + f.cost;
				q.push(edge(dist[f.to], s, f.to));
			}
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, m, s, t; cin >> n >> m;
	graph g(3*n);
	for(Int i=0; i<m; ++i){
		Int u, v; cin >> u >> v; --u; --v;
		for(int j=0; j<3; ++j)
			g[3*u+j].push_back(edge(1, 3*u+j, 3*v+(j+1)%3));
	}
	cin >> s >> t; --s; --t;
	vector<Int> dist;
	dijkstra(3*s, g, dist);
	cout << (dist[3*t] == 1e18 ? -1 : dist[3*t] / 3) << "\n";
}

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

int main(){
  int n, A[100];
  cin >> n;
  for ( int i = 0; i < n; i++) cin >> A[i];

  for ( int i = n-1; i >= 0; i-- ) {
    if( i != n-1 ) cout << " ";
    cout << A[i]; 
  }
  cout << endl;

  return 0;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define For(i, a, b) for(long long i = (a); i < (b); i++)
#define rep(i, n) for(long long i = 0; i <= (n); i++)
using namespace std;

const int mod = 1000000007;
long long calc(long long a, long long b, long long p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		long long d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else
		return (a * calc(a, b - 1, p)) % p;
}

long long nCr(long long n, long long r) 
{
  long long x = 1;
  long long y  = 1;
  for (long long i = 1; i <= r; ++i ) {
    x *= (n-i+1);
	x %= mod;
    y  *= i;
	y %= mod;
  }
  return x * calc(y, mod - 2, mod) % mod;
}

signed main(void)
{
	long long x, y, n, m, ans;

	cin >> x >> y;
	if ((x + y) % 3)
	{
		cout << "0" << endl;
		return 0;
	}
	n = (x + y) / 3;
	m = x - n;
	n -= m;
	if (n < 0 || m < 0)
	{
		cout << "0" << endl;
		return 0;
	}
	ans = nCr(n + m, m);
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int ans = 0;
    char old = 'A';
    int cnt = 0;
    for(int i = 0;i < n;i++){
        if(s[i] != old){
            cnt++;
            old = s[i];
        }else{
            ans++;
        }
    }

    while(k > 0 && cnt > 1){
        if(cnt == 2){
            ans++;
            cnt -= 1;
        }else{
            ans += 2;
            cnt -= 2;
        }
        k--;
    }

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


Measured memory_bytes: 512
n,v,u = map(int,input().split())
dist_taka = [100000 for i in range(n)]
dist_aoki = [100000 for i in range(n)]
dist_taka[v-1] = 0
dist_aoki[u-1] = 0
M = [[] for i in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())
  M[a-1].append(b-1)
  M[b-1].append(a-1)
stack = []
check = [0]*n
for i in range(len(M[v-1])):
  stack.append([v-1,M[v-1][i]])
while len(stack) != 0:
  cur = stack.pop()
  check[cur[0]] = 1
  dist_taka[cur[1]] = dist_taka[cur[0]]+1
  for i in range(len(M[cur[1]])):
    if check[M[cur[1]][i]] == 0:
      stack.append([cur[1],M[cur[1]][i]])

check = [0]*n
for i in range(len(M[u-1])):
  stack.append([u-1,M[u-1][i]])
while len(stack) != 0:
  cur = stack.pop()
  check[cur[0]] = 1
  dist_aoki[cur[1]] = dist_aoki[cur[0]]+1
  for i in range(len(M[cur[1]])):
    if check[M[cur[1]][i]] == 0:
      stack.append([cur[1],M[cur[1]][i]])
ans = 0
for i in range(n):
  if dist_taka[i] < dist_aoki[i]:
    ans = max(ans,dist_aoki[i])
print(max(0,ans-1))


Measured memory_bytes: 29956
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin >> x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf", x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s", x);}
void _print(const string &x) {printf("%s", x.c_str());}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {putchar('\n');}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}


#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

const int MOD = 1000000007;

//}}}
#define MAX_N 100005

int cnt[100];
char S[MAX_N];

int main()
{
    int N;
    read(N);
    read(S);
    LL ans = 0;
    REP(i, N) {
        int k = int(S[i] - 'a');
        LL c = 1;
        REP(j, 26) {
            if(j != k) {
                c = (c * (cnt[j] + 1)) % MOD;
            }
        }
        cnt[k] += 1;
        ans = (ans + c) % MOD;
    }
    print(ans);
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

struct Sieve {
  vector<bool> isprime;

  void init(size_t max){
    if(max+1 > isprime.size()){     // resizeで要素数が減らないように
        isprime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    isprime[0] = false; // 0は素数ではない
    isprime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(isprime[i]) // iが素数なら
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                isprime[i*j] = false;      // 素数ではない
  }
};

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2;i<MAX;i++) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

ll COM(int n, int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}



int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;

  map< int, int> a;
  for(int i=2; i*i<m+1;i++) {
      while(m%i == 0) {
        m /= i;
        a[i]++;
      }
  }
  if(m > 1) a[m]++;

  vector<int> k;
  MFOR(i, a) {
    k.pb(i->second);
  }

  COMinit();
  vll c(SZ(k));
  REP(i, SZ(k)) {
    c[i] = COM(n+k[i]-1, n-1);
  }

  ll ans = 1;
  REP(i, SZ(k)) {
    ans = (ans * c[i]) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 12160
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

///
struct PriorityQueue(alias _fun, T) {
    import std.functional : binaryFun;
    import std.algorithm : swap;
    alias fun = binaryFun!_fun;

    ///
    this(T[] ts) {
        foreach (t; ts) enqueue(t);
    }

    ///
    PriorityQueue!(_fun, T) enqueue(T e) {
        if (this.tree.length == 0) this.tree.length = 1;
        if (this.tree.length == this.n) this.tree.length *= 2;
        this.tree[this.n] = e;
        auto i = this.n;
        this.n += 1;
        while (i) {
            auto j = (i-1)/2;
            if (fun(this.tree[i], this.tree[j])) {
                swap(this.tree[i], this.tree[j]);
                i = j;
            } else break;
        }
        return this;
    }

    alias insertFront = enqueue;
    alias insert = enqueue;

    ///
    T dequeue() {
        auto ret = this.tree[0];
        this.n -= 1;
        this.tree[0] = this.tree[this.n];
        this.tree = this.tree[0..$-1];
        size_t i;
        for (;;) {
            auto l = i*2+1;
            auto r = i*2+2;
            if (l >= this.n) break;
            size_t j;
            if (r >= this.n) {
                j = l;
            } else {
                j = fun(this.tree[r], this.tree[l]) ? r : l;
            }
            if (fun(this.tree[j], this.tree[i])) {
                swap(this.tree[i], this.tree[j]);
                i = j;
            } else break;
        }
        return ret;
    }

    ///
    @property
    T front() {
        return this.tree[0];
    }

    ///
    @property
    bool empty() {
        return this.n == 0;
    }

    ///
    void popFront() {
        this.dequeue();
    }

    alias removeFront = popFront;

    ///
    @property
    size_t length() {
        return this.n;
    }

private:
    size_t n;
    T[] tree;
}

///
PriorityQueue!(fun, T) priority_queue(alias fun, T)(T[] ts = []) {
    return PriorityQueue!(fun, T)(ts);
}

alias Path = Tuple!(int, "to", long, "d");

void main()
{
    auto ver = readln.split.to!(int[]);
    auto V = ver[0];
    auto E = ver[1];
    auto r = ver[2];

    Path[][] G;
    G.length = V;
    foreach (_; 0..E) {
        auto std = readln.split.to!(int[]);
        auto s = std[0];
        auto t = std[1];
        long d = std[2];
        G[s] ~= Path(t, d);
    }

    auto LS = new long[](V);
    LS[] = long.max/3;
    LS[r] = 0;

    auto pq = priority_queue!("a.d < b.d", Path)();
    pq.enqueue(Path(r, 0));
    while (!pq.empty) {
        auto h = pq.dequeue();
        foreach (p; G[h.to]) if (LS[p.to] > h.d + p.d) {
            LS[p.to] = h.d + p.d;
            pq.enqueue(Path(p.to, LS[p.to]));
        }
    }

    foreach (l; LS) if (l <= 10^^9) writeln(l); else writeln("INF");
}


Measured memory_bytes: 59688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	string s, t;
	cin >> s >> t;
	string ans = "";
	rep(i, t.size()){
		ans += s[i];
		ans += t[i];
	}
	if(s.size() - t.size() != 0)ans += s.back();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256