akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#define rev(x) std::reverse(x+1,x+n+1)
typedef long long ll;
typedef long double db;
const int maxn = 300100;
int n,m;
ll sum[maxn];
inline db p(int i,ll*f){return 2.*f[i]+2.*sum[i]+1.*i*i-i;}
inline db get(int i,int j,ll*f){return (p(i,f)-p(j,f))/(i-j);}
int q[maxn],l,r;
ll f[maxn],g[maxn];
inline void up(ll&a,ll b){if(a<b)a=b;}
inline void dp(ll*a,ll*f) {
	r=0;
	ll mxn=0;
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+a[i];
	q[++r]=0;
	for(int i=1;i<=n;++i){
		while(1<r && get(q[r-1],q[r],f) < 2 * i)--r;
		int j = q[r];
		f[i] = f[j] - (sum[i]-sum[j]) +(i-j)*(i-j+1ll)/2;
		up(f[i],mxn),up(mxn,f[i]);
		while(1<r&&get(q[r-1],q[r],f)<get(q[r],i,f))--r;
		q[++r]=i;
	}
}
ll ans[maxn],mx1[maxn],mx2[maxn];
ll a[maxn];
inline void _(int l,int r,ll*mx) {
	if(l==r){
		up(mx[l],f[l-1]+g[l+1]+1-a[l]);
		return ;
	}
	int mid=l+r>>1;
	_(l,mid,mx),_(mid+1,r,mx);
	int tl=0;
	for(int i=l-1;i<mid;++i){
		ans[i] = f[i];
		while(1<tl&&get(q[tl-1],q[tl],ans)<get(q[tl],i,ans))--tl;
		q[++tl]=i;
	} 
	for(int i=mid;i<=r;++i){
		while(1<tl && get(q[tl-1],q[tl],ans) < 2 * i)--tl;
		int j = q[tl];
		ans[i] = ans[j] - (sum[i]-sum[j]) +(i-j)*(i-j+1ll)/2 +g[i+1];
	}
	for(int i=r-1;i>=mid;--i)up(ans[i],ans[i+1]);
	for(int i=mid;i<=r;++i)up(mx[i],ans[i]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%lld",a+i),mx1[i]=mx2[i]=-1e15;
	dp(a,f),rev(a);
	dp(a,g),rev(g);
	rev(a);
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+a[i];
	_(1,n,mx1);
	rev(a);
	std::swap(f,g);
	rev(f),rev(g);
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+a[i];
	_(1,n,mx2);
	rev(mx2);rev(f);rev(g);
	std::swap(f,g);
	rev(a);
	scanf("%d",&m);
	for(int i=1;i<=m;++i){
		int p;ll c;
		scanf("%d%lld",&p,&c);
		ll ans=0;
		up(ans,f[p-1]+g[p+1]);
		up(ans,std::max(mx1[p],mx2[p])+a[p]-c);
		printf("%lld\n",ans);
	}
} 

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

int partition(int a[], int p, int r)
{
	int x = a[r];
	int i = p - 1;
	for (int j = p; j < r; j++) {
		if (a[j] <= x) {
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}

int main()
{
	int n, q;
	int a[100000] = { 0 };

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

	q = partition(a, 0, n - 1);

	for (int i = 0; i < n; i++) {
		if (i == q) cout << "[";
		cout << a[i];
		if (i == q)cout << "]";
		cout << ((i != n - 1) ? " " : "\n");
	}

	return 0;
}


Measured memory_bytes: 3524
/*
 * Problem     : AOJ1173
 * Title       : The Balance of the World (世界の天秤)
 * Author      : mizo0203
 * Copyright   : Your copyright free
 * Description : 文字列・スタック
 */

#include <stdio.h>
#include <stack>
#include <algorithm>
using namespace std;

char str[101];
stack<char> st;

bool input() {
  scanf("%[^\n]%*c", str);
  if (str[0] == '.')
    return false;
  return true;
}

int main() {
  int i;
  bool f;

  while (input()) {
    f = true;
    while(!st.empty()) st.pop();
    for (i = 0; str[i] != '\0' && f; i++) {
      switch (str[i]) {
      case '(':
        st.push(')');
        break;
      case ')':
        if (!st.empty() && st.top() == str[i])
          st.pop();
        else
          f = false;
        break;
      case '[':
        st.push(']');
        break;
      case ']':
        if (!st.empty() && st.top() == str[i])
          st.pop();
        else
          f = false;
        break;
      default:
        break;
      }
    }
    if (st.empty() && f)
      printf("yes\n");
    else
      printf("no\n");
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>(n);
		for(int i = 0; i < n; i++){
			list.add(sc.nextInt());
		}
		Collections.reverse(list);
		for(int i = 0; i < list.size(); i++){
			if(i == list.size() -1){
				System.out.println(list.get(i));
			}else{
				System.out.printf("%d ",list.get(i));
			}
		}
	}
}



Measured memory_bytes: 26272
def modpow(a,n,p):
    l = len(bin(n))-2
    res = 1
    for i in range(l):
        if n>>i &1:
            res = (res*a) % p
        a = (a**2) % p
    return res

def ncr_1(n,r,p):##　n>>r の場合のncr　O(r)
    x = 1
    y = 1
    for i in range(r):
        x*=(n-i)
        y*=(i+1)
        x%=p
        y%=p
    return x*modinv(y,p) %mod

def modinv(a,p):
    b,u,v = p,1,0
    while b:
        t = a//b
        a -= t*b
        a,b = b,a
        u -=t*v
        u,v = v,u
    u %=p
    return u


nmax = 10**6
mod = 10**9+7

n,a,b = map(int,input().split())
ans = modpow(2,n,mod) - 1 - ncr_1(n,a,mod) - ncr_1(n,b,mod)
print(ans%mod)


Measured memory_bytes: 39896
#include<bits/stdc++.h>
using namespace std;
const long long INF = 123456789;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
    string t;
    cin >> s >> t;
    sort(ALL(s));
    sort(RALL(t));
    if(s<t){
        cout << "Yes" << endl;
        
    }else{
        cout << "No" << endl;
        
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

checked = [False]*N
C = [None]*N
checked[0] = True

def dfs(p, c1, c2, depth):
    C[p] = c1 + c2
    d = 0
    for np in graph[p]:
        if not checked[np]:
            checked[np] = True
            d += 1
            g = 1 if depth > 0 else 0
            dfs(np, d, g, depth+1)
        

dfs(0, 0, 0, 0)
#print(C)

mod = 10**9+7
ans = 1
for n in range(N):
    ans = ans * (K-C[n]) % mod

print(ans)

Measured memory_bytes: 92404
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int X, Y, Z;
  int memory;

  scanf("%d", &X);
  scanf("%d", &Y);
  scanf("%d", &Z);

  memory = X;
  X = Y;
  Y = memory;

  memory = X;
  X = Z;
  Z = memory;

  printf("\n%d\n", X);
  printf("%d\n", Y);
  printf("%d\n", Z);

  return 0;
}


Measured memory_bytes: 1712
import heapq
N,M=map(int,input().split())
A=list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(A)

for _ in range(M):
    tmp=heapq.heappop(A)
    tmp=-tmp//2
    heapq.heappush(A,-tmp)

print(-sum(A))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
ll H,W;
ll N,M;
const ll N_MAX = 1010;
const ll M_MAX = 1010;

char A[N_MAX][M_MAX];


void solve() {
    ll i,j,k,l,r,x,y; string s;
    bool exit = false;
    
    cin>>N;
    string prefix,suffix;
    if(N<1000){
        prefix="ABC";
    }else{
        prefix="ABD";
        N -= 999;
    }
    if(10>N){
        suffix="00"+to_string(N);
    }else if(100>N){
        suffix="0"+to_string(N);
    }else{
        suffix=to_string(N);
    }
    cout<<prefix<<endl;
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=300009;
int ara[mx];
ll  cost[mx];
int  main()
{
    ll  n;
    cin>>n;
    for(ll  i=1;i<=n;i++) cin>>ara[i];
    cost[1]=0;
    cost[2]=abs(ara[2]-ara[1]);
    for(ll  i=3;i<=n;i++)
    {
        ll  a=cost[i-1]+abs(ara[i]-ara[i-1]);
        ll  b=cost[i-2]+abs(ara[i]-ara[i-2]);
        cost[i]=min(a,b);
    }
    cout<<cost[n]<<endl;


}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using ll = unsigned long long;
using namespace std;

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

    ll mult = 1;
    ll maxval = 1e18;
    ll in;
    bool over = false;

    for(int i = 0; i < n; i++){
        cin >> in;
        if(in == 0) {
            over = false;
            mult = 0;
            break;
        } else if(mult > maxval/in) over = true;
        else mult *= in;
    }

    if(over){
        cout << -1 << "\n";
    } else {
        cout << mult << "\n";
    }
    return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {
	
	int A, B;
	scanf("%d%d", &A, &B);
	if (A <= 9 && B <= 9) {
		printf("%d", A*B);
	}
	else {
		printf("%d", -1);
	}



	return 0;

}

Measured memory_bytes: 128
using System;
using System.Linq;

public class Program
{
	public static void Main()
	{
        //int[] num = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
        int a = int.Parse(Console.ReadLine());
        int ans = 0;
        for(int i = 0;i <= a;i++)ans += i;
        Console.WriteLine(ans);
	}
}

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k; cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    sort(h, h + n);
    int ans = h[n - 1];
    for (int i = 0; i <= n - k; ++i) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main() {
    int num;
    cin >> num;
    call(num);

    return 0;

}



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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		long l[] = new long[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			l[i] = Long.parseLong(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int k = j + 1; k < n; k++) {
					if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j] && l[i] != l[j] && l[i] != l[k]
							&& l[j] != l[k]) {
						ans++;
					}
				}
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 33248
N,W = raw_input().split()
N=int(N);W=int(W)
v=[]
w=[]
for i in xrange(N):
    vi,wi = raw_input().split()
    vi=int(vi);wi=int(wi)
    v.append(vi)
    w.append(wi)
dp=[[0]*(W+10) for i in xrange(N+10)]
for i in xrange(N):
    for j in xrange(W+1):
        if j>=w[i]:
            dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j])
        else:
            dp[i+1][j]=dp[i][j]
print dp[N][W]


Measured memory_bytes: 34680
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;

long long int N,M,X,T,Q,res=0,sum=0;
string S;

int main(){
    cout << fixed << setprecision(18);
    cin>>S;
    for(long long int i = 0; i < S.size(); i++){
        sum+=S[i]-'0';
    }
    IFYes(sum%9==0);
}



Measured memory_bytes: 3744
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
void lcs(string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
}  
int index = L[m][n]; 

char lcs[index+1]; 
lcs[index] = '\0'; 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; 
		i--; j--; index--; 
	} 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

	cout << lcs; 
} 
int main() 
{ 
string X,Y; cin >> X >> Y;
int m = X.size(); 
int n = Y.size(); 
lcs(X, Y, m, n); 
return 0; 
} 

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

int prime(int x){
    if(x == 2){
        return true;
    }else if(x % 2 == 0){
        return false;
    }
    double sqi = sqrt(x);
    for(int j = 3; j <= sqi; j+=2){
        if(x % j == 0){
            return false;
        }
    }
    return true;
}

int main(){
    int x;
    cin >> x;
    for(int i = x; i <= 110000; i++){
        if(prime(i)){
            cout << i << endl;
            return 0;
        }        
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> t(n), x(n), y(n), z(n);
  for(int i = 0; i < n; i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
    z.at(i) = x.at(i) + y.at(i);
  }
  
  string ans = "Yes";
  if(((t.at(0) % 2) != (abs(z.at(0)) % 2))
      || (t.at(0) < abs(z.at(0)))){
    ans = "No";
  }
  
  for(int i = 1; i < n; i++){
    if(((t.at(i) - t.at(i - 1)) % 2) != (abs(z.at(i) - z.at(i - 1)) % 2)
      || (t.at(i) - t.at(i - 1) < abs(z.at(i) - z.at(i - 1)))){
      ans = "No";
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, i;
    cin >> n >> i;
    cout << n - i + 1;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;
map<int,int> m;
vector<int> v;
queue<pair<int,int>> q;
int n,x,y;
int num=1;

void monmo(int k,int c){
    if(num<c){
        q.push(make_pair(k,c));
    }
    else if(k==n){
        
    }else if(v[k]!=0) {//再帰終わり
        //if(v[k]>c)v[]
    }else{
        num++;
        m[c]++;
        v[k]=c;
        if(x-k<=0){
            int xx=abs(x-k);
            if(y-k-1>xx)q.push(make_pair(y-1,xx+1));
        }
        q.push(make_pair(k-1,c+1));
        q.push(make_pair(k+1,c+1));

        
        if(x==k+1)q.push(make_pair(y-1,c+1));
    }
    
    while(!q.empty()){
        int a=q.front().first;
        int b=q.front().second;
        q.pop();
        monmo(a,b);
    }
}

int main() {
    cin>>n>>x>>y;
    
    for(int i=1;i<n;i++){
        for(int j=0;j<n;j++){
            v.push_back(0);
        }
        v[i-1]=1;
        num=1;
        monmo(i,1);
      /*
        for(int xx=0;xx<n;xx++){    //
            cout<<v[xx]<<" ";       //
        }
        cout<<endl;                 //
        */
        v.clear();
    }
    
    for(int i=1;i<n;i++){
        cout<<m[i]<<endl;
    }
}

Measured memory_bytes: 16128
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];

        for(int i = 0; i < n; i++)x[i] = scanner.nextInt();
        for(int i = 0; i < n; i++)y[i] = scanner.nextInt();


        double d_inf = 0, d1=0, d2=0, d3=0;
        double sub;

        for(int i = 0; i < n; i++){
            sub = Math.abs(x[i]-y[i]);
            d2 += sub*sub;
            d3 += sub*sub*sub;
            if(sub > d_inf)d_inf = sub;
            d1 += sub;
        }
        d2 = Math.sqrt(d2);
        d3 = Math.cbrt(d3);

        System.out.println(d1+"\n"+d2+"\n"+d3+"\n"+d_inf);

    }
}



Measured memory_bytes: 26500
import java.util.Scanner;
public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        String s = next();
        String t = next();
        int sum = 0;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)!=t.charAt(i)){
                sum += 1;
            }
        }
        print(sum);
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

Measured memory_bytes: 41220
#include <stdio.h>
int main(void)
{
	int n,i,a=1;
	scanf("%d",&n);
	for(i=0; i<=7; i++){
		a=a*2;
		if(a>n){
			printf("%d\n",a/2);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
s=input();d=input()
l=('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')
for a,c in zip(sorted([s.count(i)for i in l]),sorted([d.count(i)for i in l])):
  if a!=c:print("No");exit()
print("Yes")

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll le,ri;
int main(){
	cin>>le>>ri;
	ri=min(ri,le+2019*3);
	ll minn=1e9;
	for(ll i=le;i<=ri;i++){
		for(ll j=i+1;j<=ri;j++){
			minn=min(minn,i*j%2019);
		}
	}
	cout<<minn;
	return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map &:to_i

DIRS = [[1, 0], [0, 1], [-1, 0], [0, -1]]
board = $<.map{|s|
  s.split.map &:to_i
}
visited = H.times.map{ [false] * W }
y, x = 0, 0

ans = []
0while DIRS.any?{|dy, dx|
  yy = y + dy
  xx = x + dx
  next if !yy.between?(0, H-1)
  next if !xx.between?(0, W-1)
  next if visited[yy][xx]
  if board[y][x].odd?
    board[y][x] -= 1
    board[yy][xx] += 1
    ans << [y, x, yy, xx]
  end
  y, x = yy, xx
  visited[yy][xx] = true
}
# p board
p ans.size
puts ans.map{|a| a.map(&:succ)*" " }


Measured memory_bytes: 56956
N = int(input())
S = [list(map(str, input().split())) for i in range(N)]
Y = 0
for i in range(N):
    if(S[i][1] == 'BTC'):
        Y += float(S[i][0]) * 380000
    else:
        Y += float(S[i][0])
print(Y)


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

typedef long long ll;

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

  int n; cin>>n;
  vector<ll> p(n);
  for (int i=0; i<n; i++) cin>>p[i];
  map<ll,ll> idx;
  for (int i=0; i<n; i++) idx[p[i]]=i+1;

  ll ret=0;
  set<ll> st={0,n+1};
  for (ll i=1; i<=n; i++) {
    ll cur=idx[i];
    set<ll>::iterator it=st.upper_bound(cur);
    ll r=(*it), l=(*(--it));
    ret+=(cur-l)*(r-cur)*i;
    st.insert(cur);
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 23680
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 200010
using namespace std;
typedef long long ll;
char s[MAXN];
ll ans,cnt[30];
int main(){
	SF("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++){
		ans+=(i-cnt[s[i]-'a']);
		cnt[s[i]-'a']++;
	}
	PF("%lld",ans+1ll);
}

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

static const int MAXN = 1e5 + 4;

static int a = 0, b = 0, c = 0;

int main()
{
    bool finished = false;
    while (!finished) switch (getchar()) {
        case 'a': ++a; break;
        case 'b': ++b; break;
        case 'c': ++c; break;
        default: finished = true; break;
    }

    int cyc = (a + b + c) / 3;
    if ((a -= cyc) < 0 || (b -= cyc) < 0 || (c -= cyc) < 0) {
        puts("NO"); return 0;
    }
    if (std::max(std::max(a, b), c) > 1) {
        puts("NO"); return 0;
    }

    puts("YES"); return 0;
}


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

struct DinicFlow {
    static const int INF=(int)1e9+7;
    vector<int> dist,head,q,work;
    vector<int> point,capa,flow,next;
    int n,m;

    DinicFlow() {
        n=0;m=0;
    }
    DinicFlow(int n) {
        this->n=n;m=0;
        dist.assign(n+7,0);
        head.assign(n+7,-1);
        q.assign(n+7,0);
        work.assign(n+7,0);
    }
    void add(int u,int v,int c1,int c2) {
        point.push_back(v);capa.push_back(c1);flow.push_back(0);next.push_back(head[u]);head[u]=m++;
        point.push_back(u);capa.push_back(c2);flow.push_back(0);next.push_back(head[v]);head[v]=m++;
    }
    bool bfs(int s,int t) {
        fill(dist.begin(), dist.end(), -1);
        int sz=0;
        q[sz++]=s;dist[s]=0;
        for (int x=0;x<sz;x=x+1) {
            int u=q[x];
            for (int i=head[u];i>=0;i=next[i])
                if (dist[point[i]]<0 && flow[i]<capa[i]) {
                    dist[point[i]]=dist[u]+1;
                    q[sz++]=point[i];
                }
        }
        return (dist[t]>=0);
    }
    int dfs(int s,int t,int f) {
        if (s==t) return (f);
        for (int &i=work[s];i>=0;i=next[i])
            if (dist[point[i]]==dist[s]+1 && flow[i]<capa[i]) {
                int d=dfs(point[i],t,min(f,capa[i]-flow[i]));
                if (d>0) {
                    flow[i]+=d;
                    flow[i^1]-=d;
                    return (d);
                }
            }
        return (0);
    }
    int maxFlow(int s,int t) {
        int totflow=0;
        while (bfs(s,t)) {
            copy(head.begin(), head.end(), work.begin());
            while (true) {
                int d=dfs(s,t,INF);
                if (d<=0) break;
                totflow+=d;
            }
        }
        return (totflow);
    }
    void resetFlow() {
        fill(flow.begin(), flow.end(), 0);
    }
};

const int N = 100;
string s[N];
int m, n;

int conv(int x, int y, int c) {
    return x * n + y + c * m * n;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> m; cin >> n;
    for (int i = 0; i < m; ++i) cin >> s[i];
    int source = m * n * 2, sink = m * n * 2 + 1;
    DinicFlow f = DinicFlow(m * n * 2 + 2);
    for (int i = 0; i < m; ++i)
        for (int j = 0; j < n; ++j)
            f.add(conv(i, j, 0), conv(i, j, 1), 1, 0);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i + 1 < m) {
                f.add(conv(i, j, 1), conv(i + 1, j, 0), 1000000, 0);
                f.add(conv(i + 1, j, 1), conv(i, j, 0), 1000000, 0);
            }
            if (j + 1 < n) {
                f.add(conv(i, j, 1), conv(i, j + 1, 0), 1000000, 0);
                f.add(conv(i, j + 1, 1), conv(i, j, 0), 1000000, 0);
            }
            if (i == 0 || i == m - 1 || j == 0 || j == n - 1)
                f.add(source, conv(i, j, 0), 1000000, 0);
            if (s[i][j] == 'X')
                f.add(conv(i, j, 0), sink, 1000000, 0);
        }
    }
    int res = f.maxFlow(source, sink);
    cout << (res >= 1000000 ? -1 : res) << endl;
    return 0;
}


Measured memory_bytes: 2664
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
/*
      int n = Integer.parseInt(sc.next());

      int[] a = new int[n];
      for(int i=0;i<n;i++){
        a[i] = Integer.parseInt(sc.next());
      }
*/
      String s = sc.next();
      int lng = s.length();
      char[] c = new char[lng];

      for(int i=0;i<lng;i++){
        c[i] = s.charAt(i);
      }

      int lll = (lng-1)/2;

      int cnt = 0;
      for(int i=0;i<=lll;i++){
        //System.out.println("aaa");
        if(c[i]!=c[lng-1-i]){
          cnt++;
        }
      }

      System.out.println(cnt);

    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int main ( void )
{
	int a, b, c, n;

	char check[301];

	while (cin >> a >> b >> c, a | b | c)
	{
		int abc = a + b + c;

		memset(check, '2', sizeof(char)*(abc+1));

		cin >> n;

		vector< vector<int> > v(n, vector<int>(4, 0));

		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < 4; ++j) { cin >> v[i][j]; }

			if (v[i][3])
			{
				for (int j = 0; j < 3; ++j) { check[v[i][j]] = '1'; }
			}
		}

		for (int i = 0; i < n; ++i)
		{
			if (!v[i][3])
			{
				int x = 0, one = 0, two = 0;

				for (int j = 0; j < 3; ++j)
				{
					char c = check[v[i][j]];
					if (c == '2')
					{
						x = v[i][j];
						++two;
					}
					else if (c == '1') { ++one; }
				}

				if (one == 2 && two == 1) { check[x] = '0'; }
			}
		}

		for (int i = 1; i <= abc; ++i)
		{
			cout << check[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1264
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)



int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b >= c){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int x,y,h,b,r[4],a[4],i,j,cnt1,cnt2;
	while(1){
		cin>>x>>y;
		if(x==0 && y==0) break;
		for(i=3;i>=0;i--){
			r[i]=x%10;
			x=x/10;
			a[i]=y%10;
			y=y/10;
		}
		cnt1=0;
		cnt2=0;
		for(i=0;i<4;i++){
			if(r[i]==a[i]) cnt1=cnt1+1;
			for(j=0;j<4;j++){
				if(r[i]==a[j]) cnt2=cnt2+1;
			}
		}
		h=cnt1;
		b=cnt2-cnt1;
		cout<<h<<' '<<b<<endl;
	}
	return 0;
}



Measured memory_bytes: 3024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    vector<int> ans(s.size());

    int i = 0;
    while(i < s.size()) {
        int a = i;
        while(s[i]=='R') i++;
        int b = i;
        while(s[i]=='L' && i < s.size()) i++;
        int c = i;

        int odd = 0, even = 0;
        if(a%2==0) {
            even = (c-a+1)/2;
            odd = (c-a)-even;
        }
        else {
            odd = (c-a+1)/2;
            even = (c-a)-odd;
        }
        if(b%2==0) {
            ans[b] = even;
            ans[b-1] = odd;
        }else {
            ans[b-1] = even;
            ans[b] = odd;
        }
    }
    rep(i,ans.size()) {
        cout << ans[i] << endl;
    }


    return 0;
}

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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	bool f = true;
	while (0 < a && 0 < c) {
		if (f) {
			c -= b;
		}
		else {
			a -= d;
		}
		f = !f;
	}

	if (0 < a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
import sys
def f(b,a,e):
  if e=="+":x=a+b
  elif e=="-":x=a-b
  elif e=="*":x=a*b
  else:x=a/b
  return x
for s in sys.stdin:
  A=[]
  for e in s.split():
    try:x=float(e)
    except:x=f(A.pop(),A.pop(),e)
    A+=[x]
  print A[0]

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  int ans;
  sort(d.begin(), d.end());
  ans = d[n/2] - d[n/2-1];

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


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int L[110000], R[110000];
pint p[110000];
pint lcum[110000], rcum[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> L[i] >> R[i], p[i] = {L[i], R[i]}; }
    sort(p, p + N);
    lcum[0] = p[0], rcum[N - 1] = p[N - 1];
    for (int i = 1; i < N; i++) {
        lcum[i] = {max(p[i].first, lcum[i - 1].first), min(p[i].second, lcum[i - 1].second)};
    }
    for (int i = N - 2; i >= 0; i--) {
        rcum[i] = {max(p[i].first, rcum[i + 1].first), min(p[i].second, rcum[i + 1].second)};
    }
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        chmax(ans, max(0LL, lcum[i].second - lcum[i].first + 1)
            + max(0LL, rcum[i + 1].second - rcum[i + 1].first + 1));
    }
    for (int i = 1; i < N - 1; i++) {
        chmax(ans,
              p[i].second - p[i].first + 1 + max(0LL,
                                                 min(lcum[i - 1].second, rcum[i + 1].second)
                                                     - max(lcum[i - 1].first, rcum[i + 1].first) + 1));
    }
    cout << ans << endl;

}


Measured memory_bytes: 6912
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


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

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//











int main(){
         Int x;
         cin >> x;
         Int moves = x/11;
         x -= moves*11;
         moves *= 2;
         if(x > 6) moves += 2;
         else if(x > 0) moves += 1;
         cout << moves << endl;
         return 0;
}






















Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp;
  int[char] cnt;
  foreach (e; s) {
    cnt[e]++;
  }
  if (cnt.keys.length == 2 && cnt[cnt.keys[0]] == 2) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define se second
#define endll "\n"
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll w,s;cin>>s>>w;
    if(w>=s)cout<<"unsafe"<<endll;
    else cout<<"safe"<<endll;
}


Measured memory_bytes: 3652
import numpy as np

N, K = map(int, input().split())
p = list(map(int, input().split()))

p_mapped = [(i + 1) / 2 for i in p]
p_m_cumsum = np.cumsum(p_mapped)

max = 0
for i in range(len(p_m_cumsum)-K+1):
    if i != 0:
        answer = p_m_cumsum[i+K-1] - p_m_cumsum[i-1]
    else:
        answer = p_m_cumsum[i+K-1]
    if answer >= max:
        max = answer
print(max)

Measured memory_bytes: 35696
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int[][] map;
    int h = 10;
    int w = 10;
    int[] a = {1, 0, -1, 0, 1, -1, 1, -1, 2, 0, -2, 0};
    int[] b = {0, 1, 0, -1, 1, 1, -1, -1, 0, 2, 0, -2};
    // 3まで小、7まで中、11まで大
    int count;
    int max;

    void run(){
	map = new int[h][w];
	max = 0;
	count = h*w;
	while(sc.hasNext()){
	    String[] i = sc.next().split(",");
	    int x = Integer.parseInt(i[0]);
	    int y = Integer.parseInt(i[1]);	
	    int s = Integer.parseInt(i[2]);
	   
	    drop(x, y, s);
	}
	System.out.println(count+"\n"+max);
    }

    void drop(int x, int y, int s){
	ink(x, y);
	for(int i=0; i<s*4; i++)
	    ink(x+a[i], y+b[i]);
    }

    void ink(int x, int y){
	if(x>=0 && y>=0 && x<10 && y<10){
	    map[x][y]++;
	    if(max < map[x][y]) max = map[x][y];
	    if(map[x][y]==1) count--;
	}
    }
}

Measured memory_bytes: 17168
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int sum=1;
	int i=0;
	while(i<k){
		sum=sum*2;
		i++;
	}
	cout<<max({a,b,c})*sum+a+b+c-max({a,b,c})<<endl;
	return 0;
}


Measured memory_bytes: 256
(defun input (n)
  (let ((A (make-array n)))
    (loop for i below n do (setf (aref A i) (read)))
    A))

(defun solve (A)
  (if (find 'Y A) "Four" "Three"))

(let* ((n (read))
      (a (input n)))
  (princ (solve a)))

Measured memory_bytes: 13412
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

int N, M;
int node[10][10] = {0};
int res = 0;

void dfs(int key, bool on[], int cnt){
    for (int i = 2; i <= N; i++){
	if ((node[key][i] == 1) && (!on[i])){
	    if (cnt+1 == N){
		res++;
	    } else {
		on[i] = true;
		cnt++;
		dfs(i, on, cnt);
		on[i] = false;
		cnt--;
	    }
	}
    }
}

int main(){
    cin >> N >> M;
    for (int i = 1; i <= M; i++){
	int a, b;
	cin >> a >> b;
	node[a][b] = 1;
	node[b][a] = 1;
    }
    bool on[10];
    for (int i = 0; i < 10; i++) on[i] = false;

    on[1] = true;
    dfs(1, on, 1);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
number = int(input())
target_list = input().split()

loopFlg = True
loopCnt = 0

while loopFlg == True:
  for i in range(number):
    if int(target_list[i])%2 == 1:
      loopFlg = False
    target_list[i] = str(int(target_list[i])//2)

  if loopFlg == True:
  	loopCnt += 1

print(loopCnt)

Measured memory_bytes: 9008
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N;
string S;
ll esp = 1e9 + 7;

void solve() {

	map<char, ll> mp;

	rep(i, S.size()) {
		mp[S[i]]++;
	}

	ll ans = 1;

	for (char c = 'a'; c <= 'z'; c++) {
		ans = (ans*(mp[c]+1)) % esp;
	}

	cout << ans-1;

	return;
}

int main() {

	cin >> N >> S;

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

Measured memory_bytes: 512
// abc131c.cpp : Anti-Division
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
#define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

void p1(vi v){
  for(auto a: v){ot(a);ot(",");}
}
void p2(vvi &x){
  for(auto v: x){ot("[");p1(v);ot("]\n");}
}

ll gcd(ll a, ll b){
  if(a<b) swap(a,b);
  while(b){
    ll r = a%b;
    a = b; b = r;
  }
  return a;
}

int main(){
  ll A,B,C,D; cin>>A>>B>>C>>D;
  ll count = B/C - A/C;
  count += B/D - A/D;
  ll g = gcd(C, D);
  count -= B/(C/g*D) - A/(C/g*D);
  if(A%C==0) count++;
  if(A%D==0) count++;
  if(A%(C/g*D)==0) count--;

  ote(B-A+1-count);

}

Measured memory_bytes: 256
#include <map>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int n=0,N,i,j,k,c;
	scanf("%d",&N);
	vector<map<int,int> >dist(N);
	vector<bool>used(N);
	vector<int>cost(N);
	for(;n<N;n++){
		cost[n]=999999;
		for(scanf("%d%d",&i,&k);k--;dist[i][j]=c)scanf("%d%d",&j,&c);
	}
	for(cost[0]=0;;){ //dijkstra
		int m=999999;
		for(i=0;i<N;i++)if(!used[i]&&m>cost[i])m=cost[i];
		if(m==999999)break;
		for(j=0;j<N;j++)if(m==cost[j]){
			map<int,int>::iterator it=dist[j].begin();
			for(used[j]=1;it!=dist[j].end();it++)if(cost[it->first]>it->second+cost[j])cost[it->first]=it->second+cost[j];
		}
	}
	for(i=0;i<n;i++)printf("%d %d\n",i,cost[i]);
}

Measured memory_bytes: 1268
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <numeric>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define rrep(i, n) for(ll (i) = 1;(i) <= (n);(i)++)

ll mpow(ll base, ll power) {
    if (power == 0) return 1;
    ll h = mpow(base, power / 2);
    h = (h * h) % mod;
    if (power % 2) h *= base;
    return h % mod;
}

int main() {
    ll n, k, cnt1[100005] = {0}, cnt2[100005] = {0};
    cin >> n >> k;
    ll y[100005];
    for (ll i = 1; i <= k; i++) y[i] = k / i;
    for (ll i = 1; i <= k; i++) cnt1[i] = mpow(y[i], n);
    for (ll i = k; i > 0; i--) {
        for (ll j = i * 2; j <= k; j += i) {
            cnt1[i] = (cnt1[i] - cnt1[j] + mod) % mod;
        }
    }
    ll r = 0;
    for (ll i = 1; i <= k; i++) {
        r = (r + cnt1[i] * i) % mod;
    }
    cout << r << endl;
}


Measured memory_bytes: 5184
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int n, x[55], y[55];
main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d%d", &x[i], &y[i]);
    }
    int ans = n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i!=j){
                int p = x[i] - x[j], q = y[i] - y[j], cnt = 0;
                for(int k=0; k<n; k++){
                    for(int l=0; l<n; l++){
                        if(k != l){
                            if(x[k]-x[l] == p && y[k]-y[l] == q)cnt++;
                        }
                    }
                }
                ans = min(ans, n-cnt);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    vector<char> real(3,0);
    vector<char> predict(3,0);

     for(int k=0;k<3; k++){
           cin>>real[k];
        }

    for(int j=0;j<3; j++){
           cin>>predict[j];
        }

    
    int jud=0;
    if(real[0]==predict[0]){
       jud++;
    }
    if(real[1]==predict[1]){
       jud++;
    }
    if(real[2]==predict[2]){
       jud++;
    }

    
        cout <<jud <<endl;
  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define s(n) scanf("%d",&n)
using namespace std;
const int mx = 5e5;
int arr[mx + 5], blk;
struct st {
	int l, r, ind;
};
st nd[mx + 5];
bool cmp(st a, st b)
{
	if (a.l / blk == b.l / blk)
		return a.r < b.r;
	return a.l / blk < b.l / blk;
}
int track[mx + 5];
int an[mx + 5];
int main() {
	int n;
	s(n);
	int m;
	s(m);
	int arr[n];
	for (int i = 0; i < n; i++)
		s(arr[i]);
	blk = sqrt(n);
	for (int i = 0, a, b; i < m; i++)
	{
		s(a);
		s(b);
		nd[i].l = a - 1;
		nd[i].r = b - 1;
		nd[i].ind = i;
	}
	sort(nd, nd + m, cmp);
	int ans = 1;
	int start = 0;
	int end = 0;
	track[arr[0]]++;
	for (int i = 0; i < m; i++)
	{
		int ll = nd[i].l;
		int rr = nd[i].r;
		//	cout << ll << " " << rr << " " << nd[i].ind << endl;
		while (start < ll)
		{
			track[arr[start]]--;
			if (track[arr[start]] == 0)
				ans--;
			start++;
		}
		while (start > ll)
		{
			start--;
			track[arr[start]]++;
			if (track[arr[start]] == 1)
				ans++;
		}
		while (end < rr)
		{
			end++;
			track[arr[end]]++;
			if (track[arr[end]] == 1)
				ans++;
		}
		while (end > rr)
		{
			track[arr[end]]--;
			if (track[arr[end]] == 0)
				ans--;
			end--;
		}
		an[nd[i].ind] = ans;
	}
	for (int i = 0; i < m; i++)
		printf("%d\n", an[i]);
}

Measured memory_bytes: 15464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		s = s + s;
		String p = sc.nextLine();

		if (s.indexOf(p) > -1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}



Measured memory_bytes: 26276