akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

ll coin[100100][3];

int main(){
    int x,y,z,n; cin >> x >> y >> z;
    n=x+y+z;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> coin[i][j];
        }
    }
    vector<pair<ll,int> > gs(n);
    for(int i=0;i<n;i++){
        gs[i]=make_pair(coin[i][0]-coin[i][1],i);
    }
    sort(gs.begin(),gs.end());
    vector<ll> silver(z+1,0);
    vector<ll> gold(z+1,0);
    priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int > > > sb;

    for(int i=0;i<y;i++){
        int id=gs[i].second;
        sb.push(make_pair(coin[id][1]-coin[id][2],id));
        silver[0]+=coin[id][1];
    }
    for(int i=0;i<z;i++){
        int id=gs[i+y].second;
        sb.push(make_pair(coin[id][1]-coin[id][2],id));
        silver[i+1]=silver[i]+coin[id][1];
        auto p=sb.top();
        sb.pop();
        silver[i+1]+=(coin[p.second][2]-coin[p.second][1]);
    }

    reverse(gs.begin(),gs.end());
    priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int > > > gb;
    for(int i=0;i<x;i++){
        int id=gs[i].second;
        gb.push(make_pair(coin[id][0]-coin[id][2],id));
        gold[0]+=coin[id][0];
    }
    for(int i=0;i<z;i++){
        int id=gs[i+x].second;
        gb.push(make_pair(coin[id][0]-coin[id][2],id));
        gold[i+1]=gold[i]+coin[id][0];
        auto p=gb.top();
        gb.pop();
        gold[i+1]+=(coin[p.second][2]-coin[p.second][0]);
    }

    ll ans=0;
    for(int i=0;i<=z;i++){
        ans=max(ans,silver[i]+gold[z-i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    int card[4][13]={};
    int n;
    cin >> n;
    REP(i,n){
        char s;
        int t;
        cin >> s >> t;
        if(s=='S') card[0][t-1]=1;
        else if(s=='H') card[1][t-1]=1;
        else if(s=='C') card[2][t-1]=1;
        else if(s=='D') card[3][t-1]=1;
    }
    REP(i,4){
        REP(j,13){
            if(card[i][j]==0){
                if(i==0)cout << 'S' << " " << j+1 << endl;
                else if(i==1)cout << 'H' << " " << j+1 << endl;
                else if(i==2)cout << 'C' << " " << j+1 << endl;
                else if(i==3)cout << 'D' << " " << j+1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
//#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vc visit(sze, false);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

vi dp(sze, oo);

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

	cin >> n >> k;
	vi h(n);

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

	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j <= i + k && j < n; j++)
		{
			mini(dp[j], dp[i] + abs(h[j] - h[i]));
		}
	}

	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 13312
//Object.entries()
function entries(obj) {
    array = [];
    for (var i of Object.keys(obj)) {
        tmp = new Array(i, obj[i]);
        array.push(tmp);
    }
    return array;
}
function Main(input) {
    input = input.split("\n");
    input[0] = input[0].split(" ").map(Number);
    N = input[0][0];
    K = input[0][1];
    A = input[1].split(" ").map(Number);
    obj = {};
    for (i of A) {
        if (!obj[i]) obj[i] = 1;
        else obj[i]++;
    }
    array = entries(obj).sort((a, b) => a[1] - b[1]);
    ans = 0;
    if (array.length > K) for (i = 0; i < array.length - K; i++) ans += array[i][1];
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 76824
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    string ans = "";
    for (int i=0; i<str.size(); ++i)
    {
        if(str[i] == 'B')
        {
            if(ans == "") continue;
            else
            {
                ans.erase(ans.size()-1);
            }
        }
        else
        {
            ans += str[i];
        }
    }

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

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 5000 * (10**5) * 2 + 1
for i in range(max(x, y)+1):
    A = a * (x - i) if x-i > 0 else 0
    B = b * (y - i) if y-i > 0 else 0
    C = 2 * c * i
    v = A + B + C
    if ans > v:
        ans = v
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=20000001;


int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      string s;
      cin>>s;
      // reverse(all(s));
      int n=s.length();
      int ans=0;
      int cnt=0;
      for(int i=0;i<n;i++)
      {
            if(s[i]=='1')
            {
                  ans+=mpow(2,cnt)*mpow(3,n-i-1);
                  ans%=MOD;
                  cnt++;
            }
      }
      ans=(ans+mpow(2,cnt))%MOD;
      cout<<(ans)%MOD;
}
// nothing is impossible
// I never lose. I either win or I learn

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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 60;

int main()
{
  int64 N, X[200000], Y[200000];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    if(X[i] > Y[i]) swap(X[i], Y[i]);
  }

  int64 ret = INF;

  int64 latte = INF, malta = -INF;
  for(int i = 0; i < N; i++) {
    latte = min(latte, X[i]);
    malta = max(malta, Y[i]);
  }

  int64 beet = latte, ukuku = malta;
  for(int i = 0; i < N; i++) {
    beet = max(beet, X[i]);
    ukuku = min(ukuku, Y[i]);
  }

  ret = min(ret, (beet - latte) * (malta - ukuku));

  vector< pair< int64, int64 > > vs;
  for(int i = 0; i < N; i++) {
    vs.emplace_back(X[i], Y[i]);
  }
  sort(begin(vs), end(vs));

  int64 front = vs.front().first, back = vs.back().first;
  int64 len = max(beet, malta) - min(ukuku, latte);

  latte = max(beet, malta);
  malta = vs.back().first;

  for(int i = 0; i < N; i++) {
    ret = min(ret, len * (malta - min(latte, i == N ? INF : vs[i].first)));
    if(i == N) break;
    latte = min(latte, vs[i].second);
    malta = max(malta, vs[i].second);
  }
  cout << ret << endl;
}

Measured memory_bytes: 9584
#include <stdio.h>
int main()
{
    int a;
    char s[100];
    scanf("%d",&a);
    scanf("%s",s);
    if(a>=2800 && a<3200)
        printf("red");
    else if(a>=3200 && a<5000)
        printf("%s",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	int N;
	cin >> N;
	vector<int> X(N);
	rep(i, N) {
		cin >> X.at(i);
	}
	sort(X.begin(), X.end());

	int ans = 1000005;
	 
	for (int i = X.at(0); i <=X.at(N-1) ; i++)
	{
		int tmp=0;
		for (int j = 0; j < N; j++)
		{
			int xxn = X.at(j) - i;
			tmp += xxn * xxn;
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

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

	vector<queue<int>> vq(n);

	rep(i, n)rep(j, n - 1) {
		int a;
		cin >> a;a--;
		vq[i].push(a);
	}

	int k = 0;
	int ans = 0;
	int match = 0;
	bool uso = false;

	while (true) {
		int yester = match;

		vector<bool> game(n, false);

		rep(i, n) {
			if (vq[i].empty())continue;
			if (game[i])continue;
			int j = vq[i].front();
			if (i != vq[j].front())continue;
			if (game[j])continue;

			vq[i].pop();game[i] = true;
			vq[j].pop();game[j] = true;
			match++;
		}


		if (yester == match)break;
		ans++;
		if (ans == 200000) { uso = true;break; }
	}

	if (uso)cout << n * (n - 1) / 2 << endl;
	else if (match != n * (n - 1) / 2)cout << -1 << endl;
	else cout << ans << endl;

}

Measured memory_bytes: 4736
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    int e,f,g,h;
    cin >> a >> b >> c >> d;
    cin >> e >> f >> g >> h;
    int x=a+b+c+d;
    int y=e+f+g+h;
    if(x>y){
        cout << x;
    }
    else if(y>x){
        cout << y;
    }
    else{
        cout << x;
    }
    cout << endl;
    
}


Measured memory_bytes: 3032
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define mem0(a) memset(a,0,sizeof(a))
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int mod=1e9+7;
const int N=1e5+5;
int a[N],b[N];
int main()
{
 int n;
 cin>>n;
 rep(i,0,n+1)
 {cin>>a[i];
 
 }
 ll ans=0;
 repb(i,1,n)
 {cin>>b[i];
   if(b[i]>=a[i-1]&&b[i]>=0&&a[i-1]>=0)
   {ans+=(a[i-1]);
  
   	b[i]-=a[i-1];
   	 a[i-1]=0;
   }
   else if(b[i]<a[i-1]&&b[i]>=0&&a[i-1]>=0)
   {
    ans+=b[i];
   
    a[i-1]-=b[i];
     b[i]=0;
   }
  //  ans+=min(b[i],a[i]);
   if(a[i]>=b[i]&&b[i]>=0&&a[i-1]>=0)
   {
   	ans+=b[i];
   	
   	a[i]-=b[i];
   	b[i]=0;
   }
   else if(a[i]<b[i]&&b[i]>=0&&a[i-1]>=0)
   {
   	 ans+=a[i];
   	 b[i]-=a[i];
   	 a[i]=0;
   }
  
 }
 cout<<ans;

}



Measured memory_bytes: 1152
#include <algorithm>
#include <cstdlib>
#include <iostream>

using namespace std;

int main() {
    long long x, k, d;
    cin >> x >> k >> d;

    if ((k - min(k, abs(x) / d)) % 2 == 0) {
        cout << abs(x) - min(k, abs(x) / d) * d << endl;
    } else {
        cout << d - abs(x) + min(k, abs(x) / d) * d << endl;
    }
}


Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int m;

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

    void run() {
        FastReader sc = new FastReader();
        m = sc.nextInt();
        solve();
    }

    void solve() {
        System.out.println(48 - m);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        Node root = null;
        for (int i = 0; i < m; i++) {
            String cmd = scanner.next();
            if ("insert".equals(cmd)) {
                Node node = new Node(scanner.nextInt());
                if (root == null) {
                    root = node;
                    continue;
                }
                insert(root, node);
            } else if ("find".equals(cmd)) {
                System.out.println(root.doesContain(scanner.nextInt())? "yes" : "no");
            } else {
                StringBuilder sb = new StringBuilder();
                root.inOrder(sb);
                sb.append("\n");
                System.out.print(sb.toString());
                sb = new StringBuilder();
                root.preOrder(sb);
                sb.append("\n");
                System.out.print(sb.toString());
            }
        }

    }

    private static void insert(Node root, Node node) {
        Node parent = root;
        while (true) {
            if (node.key < parent.key) {
                if (parent.left == null) {
                    parent.left = node;
                    break;
                }
                parent = parent.left;
            } else {
                if (parent.right == null) {
                    parent.right = node;
                    break;
                }
                parent = parent.right;
            }
        }
    }

    private static class Node {
        int key;
        Node parent;
        Node left;
        Node right;

        private Node(int key) {
            this.key = key;
        }

        private void inOrder(StringBuilder sb) {
            if (left != null) {
                left.inOrder(sb);
            }
            sb.append(" " + String.valueOf(key));
            if (right != null) {
                right.inOrder(sb);
            }
        }

        private void preOrder(StringBuilder sb) {
            sb.append(" " + String.valueOf(key));
            if (left != null) {
                left.preOrder(sb);
            }
            if (right != null) {
                right.preOrder(sb);
            }
        }

        private boolean doesContain(int k) {
            if (k == key) {
                return true;
            } else if (k < key) {
                if (left == null) {
                    return false;
                }
                return left.doesContain(k);
            } else {
                if (right == null) {
                    return false;
                }
                return right.doesContain(k);
            }
        }
    }
}

Measured memory_bytes: 315924
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
typedef long long ll;

using namespace std;

int main(){
  	int N, M;
	cin >> N >> M;
	vector<vector<int>> jobs(M);
	for(int i = 0; i < N; i++){
    	int A, B;
    	cin >> A >> B;
    	if(A > M) continue;
    	jobs[M-A].push_back(B);
  	}
  	priority_queue<int> q;
  	ll ans = 0;
  	for(int i = M-1; i >= 0; i--){
    	for(int j = 0; j < jobs[i].size(); j++){
      		q.push(jobs[i][j]);
        }
      	if(!q.empty()){
    		ans += q.top();
          	q.pop();
        }
  	}
	cout << ans << endl;
}

Measured memory_bytes: 5632
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		long X = Long.parseLong(sc.get());
		long K = Long.parseLong(sc.get());
		long D = Long.parseLong(sc.get());
		var floor = Math.floorDiv(X, D);
		var ceil = -Math.floorDiv(-X, D);
		if (Math.abs(floor) > K) {
			System.out.println(Math.abs(X - (floor < 0 ? -1 : 1) * K * D));
			return;
		}
		var floorDistance = Math.abs(X - floor * D);
		var ceilDistance = Math.abs(X - ceil * D);
		if (Math.abs(ceil) > K) {
			System.out.println(floorDistance);
		} else if ((K - floor) % 2 == 0) {
			System.out.println(floorDistance);
		} else if ((K - ceil) % 2 == 0) {
			System.out.println(ceilDistance);
		} else {
			System.out.println(D + Math.min(floorDistance, ceilDistance));
		}
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32720
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#define INF 2147483647
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int sum(string x) {
	int y = 0;
	for (int i = 0; i < x.size(); i++) {
		y += x[i] - '0';
	}
	return y;
}

int main() {
	int N;
	cin >> N;
	int ans = INF;
	for (int i = 1; i < N; i++) {
		int a = i; int b = N - i;
		ans = min(ans, sum(to_string(a)) + sum(to_string(b)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int N, M, X;
	int i;
	int fee;
	int left = 0, right = 0;
	scanf("%d %d %d", &N, &M, &X);
	for (i = 0; i < M; i++) {
		scanf("%d", &fee);
		(fee < X) ? left++ : right++;
	}
	printf("%d", (left < right) ? left : right);
	return 0;
}

Measured memory_bytes: 128
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

main = putStrLn . solve . map read . words =<< getLine

solve [n, m, k] = ans where
    xs = take 1 $ do
            a <- [0 .. n]
            b <- [0 .. m]
            let u = a * (m - b)
            let v = b * (n - a)
            if u + v == k
                then [1]
                else []
    ans = if xs == [] then "No" else "Yes"

Measured memory_bytes: 1020
N = int(input())
S = input()

if N%2 == 0:
    jdg_1 = S[0:int(N/2)]
    jdg_2 = S[int(N/2):int(N)]
    if jdg_1==jdg_2:
      out = 'Yes'
    else:
      out = 'No'
else:
  out = 'No'

print(out)

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		long[]A = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
		}
		Array.Sort(A);
		long ans = A[0];
		if(ans>0){
			Array.Sort(A,(x,y)=>y.CompareTo(x));
          	ans = A[0];
		for(var i=1;i<N;i++){
			int t = 0;
			long a1 = ans;
			for(var j=1;j<=18;j++){
				if(ans >= (long)Math.Pow(10,j)){
					t = j;
				} else {
					break;
				}
			}
			int t2 = 0;
			long a2 = A[i];
			for(var j=1;j<=18;j++){
				if(A[i] >= (long)Math.Pow(10,j)){
					t2 = j;
				} else {
					break;
				}
			}
			if(t+t2>=19){
				ans = -1;
				break;
			} else if(t+t2>=17){
				bool flag = false;
				if(t>=9){
					flag = true;
					a1 /= (long)Math.Pow(10,9);
				} else if(t2>=9){
					flag = true;
					a2 /= (long)Math.Pow(10,9);
				}
				if(flag && a1*a2>(long)Math.Pow(10,9)){
					ans = -1;
					break;
				}
				ans = ans * A[i];
			} else {
				ans = a1 * a2;
			}
			if(ans > (long)Math.Pow(10,18)){
				ans = -1;
				break;
			}
		}
		}
		Console.WriteLine(ans);
	}
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

string s;
int n;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>s;
  n = s.length();
  vector<bool> dp(n, false);
  set<string> st;
  st.insert("dream"); st.insert("dreamer"); st.insert("erase"); st.insert("eraser");

  
  for (int i=0; i<n; i++) {
    string cur;
    for (int j=0; j<7 && i-j>=0; j++) {
      reverse(cur.begin(), cur.end());
      cur += s[i-j];
      reverse(cur.begin(), cur.end());

      if (st.count(cur)) {
	dp[i] = i-j-1<0 || dp[i-j-1];
      }
    }
  }

  if (dp[n-1]) out("YES");
  out("NO");
  

  return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
        string ss="";
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='9')
            {
               ss+="1";
            }
            else
            {
                ss+="9";
            }

        }
        cout<<ss<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
h,w = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

from collections import deque

def solve(x,y,gx,gy):
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    start = [x, y]
    dist = [[10**3]*w for i in range(h)]
    dist[y][x] = 0
    Q = deque()
    Q.append(start)

    while Q:
        p = Q.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx < w and 0 <= ny < h:
                if l[ny][nx]=="." and dist[ny][nx]==10**3:
                    Q.append([nx, ny])
                    dist[ny][nx] = dist[p[1]][p[0]] + 1
                    if nx==gx and ny==gy:
                        return dist[ny][nx]
    return -1

cnt=0
for i in range(h):
    for j in range(w):
        if l[i][j] == ".":
            cnt+=1

res=solve(0,0,w-1,h-1)

if res==-1:
    print(res)
else:
    print(cnt-solve(0,0,w-1,h-1)-1)

Measured memory_bytes: 3316
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    s = input()
    ans = 0
    for i1 in range(10):
        for i2 in range(10):
            for i3 in range(10):
                ii1 = s.find(str(i1))
                if ii1 == -1 or ii1 >= n-2:
                    continue
                ii2 = s[ii1+1::].find(str(i2))
                if ii2 == -1 or ii2 >= n-1:
                    continue
                ii3 = s[ii1+1+ii2+1::].find(str(i3))
                if not ii3 == -1:
                    ans += 1
    print(ans)


    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 39148
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int X; cin >> X;
    // X以上の数を順に探索　高々O(10^2)で見つかるはず
    for (int n = X;; ++n)
    {
        // 素数判定 O(log(n))≤O(log(10^5))
        bool isPrime = true;
        for (int p = 2, root = static_cast<int>(sqrt(X)) + 1; p < root; ++p)
        {
            if (n % p == 0)
            {
                isPrime = false;
                break;
            }
        }
        if (isPrime)
        {
            cout << n << endl;
            break;
        }
    }
}


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

int main()
{
    char a[1000];
    gets(a);
    int n,i,c=0,d;
    n=strlen(a);
    for(i=0;i<n;i++){
            d=i+1;
        if(i%2==0){
            if(a[i]=='R'||a[i]=='U'||a[i]=='D'){
                continue;
            }
            else{
                c=1;
                break;
            }
        }
        else{
            if(a[i]=='L'||a[i]=='U'||a[i]=='D'){
                continue;
            }

            else{
                c=1;
                break;
            }
        }
    }
    if(c==0){
        printf("Yes\n");

    }
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
    string s; cin >> s;
    if(s == "ABC") puts("ARC");
    else puts("ABC");
}

Measured memory_bytes: 3600
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;


void main()
{
  int n, c;
  readf("%d %d\n", &n, &c);
  
  auto r = new int[][](n, 3);
  foreach (i; 0..n) {
    r[i] = readln.chomp.split.to!(int[]);
  }

  sort!((a,b) => a[2] == b[2] ? a[1] < b[1] : a[2] < b[2])(r);

  foreach (i; 1..n) {
    if (r[i-1][2] == r[i][2] && r[i-1][1] == r[i][0]) {
      r[i][0] = r[i-1][0];
      r[i-1][0..2] = 10^^5+1;
    }
  }

  auto d = new int[](10^^5+3);
  foreach (i; 0..n) {
    d[r[i][0]]++;
    d[r[i][1]+1]--;
  }
  int m, lm;
  foreach (i; 0..10^^5+1) {
    lm += d[i];
    m = max(m, lm);
  }
  m.writeln;
}


Measured memory_bytes: 18940
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    lli n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    lli dp[n];
    memset(dp, 0, sizeof(dp));

    //cout << dp[0] << ' ';
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'C' and s[i - 1] == 'A') {
            dp[i] = dp[i - 1] + 1;
        } else {
            dp[i] = dp[i - 1];
        }
        //cout << dp[i] << ' ';
    }
    //cout << endl;
    while (q--) {
        lli l, r;
        cin >> l >> r;
        l--;
        r--;
        if (l== 0) {
            cout << dp[r] << "\n";
        } else {
            cout << (dp[r] - dp[l]) << "\n";
        }
    }
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 1872
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int x,y,s;
  queue<pi> data;
  while(scanf("%d%d%d",&x,&y,&s)){
    if(x==0&&y==0&&s==0)break;
    int ans=-INF;
    rep(i,s+1){
      rep(j,s+1){
	if(i*(100+x)/100+j*(100+x)/100==s&&i!=0&&j!=0){
	  ans=max(ans,i*(100+y)/100+j*(100+y)/100);
	}
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(int argc, char const *argv[]) {
    string s;
    cin>>s;
    vector<int> v(30,0);
    rep(i,s.size()){
        //cout<<"v[i]"<<s[i]-'a'<<endl;
        v[s[i]-'a']++;
    }
    //cout<<"t"<<t<<endl;
    rep(i,v.size()){
      if(v[i]%2==1){
        cout<<"No"<<endl;
        return 0;
      }
      else{
        continue;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

bool ok=true;
ll y=0,m=0,d=0,c=0;
string s;

int main(void){
	cin>>s;
	rep(i,4){
		y=y*10+(s[c]-'0');
		c++;
	}
	c++;
	rep(i,2){
		m=m*10+(s[c]-'0');
		c++;
	}
	c++;
	rep(i,2){
		d=d*10+(s[c]-'0');
		c++;
	}
	//
	//cout<<y<<" "<<m<<" "<<d<<endl;
	if(y<2019){
		ok=false;
	}else if(y==2019){
		if(m<4){
			ok=false;
		}else if(m==4){
			if(d<=30){
				ok=false;
			}
		}
	}
	cout<<(ok?"TBD":"Heisei")<<endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

int main(){

    int n;cin>>n;
    int x[10],y[10];
    rep(i,n) {
        cin>>x[i]>>y[i];
    }
    int array[n];
    rep(i,n) {
        array[i]=i;
    }
    double sum=0;
    do{
        for(int i=0; i<n-1; i++){
            sum+=sqrt((x[array[i]]-x[array[i+1]])*(x[array[i]]-x[array[i+1]]) + (y[array[i]]-y[array[i+1]])*(y[array[i]]-y[array[i+1]]));
        }
    }while(next_permutation(array,array+n));

    rep(i,n) {
        sum/=(double)(i+1);
    }

    cout << fixed << setprecision(10) << sum << endl;

}

// int main(){
//     int array[]={1,2,3,4,5,6,7,8};
//     do{
//         for(int i=0; i<8; i++){
//             cout<<array[i];
//             if(i!=7)cout<<" ";
//         }
//         cout<<endl;
//     }while(next_permutation(array,array+8));
//     return 0;
// }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
typedef long long int ll;


using namespace std;

ll up(ll rent){
	if(rent%1000!=0)return (rent/1000*1000+1000);
	else return rent;
}

int main(){
	ll rent=10*10000;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		rent*=1.05;
		rent=up(rent);
	}
	cout<<rent<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    cout << (1 + 2 + 3 - a - b) << "\n";

    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = [input() for _ in range(N)]

res = True

dic = {}

last = ""

for w in W:
    if last != "":
        if w in dic:
            res = False
        if not w[0] == last:
            res = False

    dic[w] = 1
    last = w[-1]


if res:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9100
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int a=Read.Int();
        long[] ans = new long[87];
        ans[0] = 2;
        ans[1] = 1;
        for(long i = 2; i <= 86; i++)
        {
            ans[i] = ans[i - 1] + ans[i - 2];
        }
        Console.WriteLine(ans[a]);Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13140
mod = 10**9 + 7

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

ans = pow(K, N, mod)
cnts = [0] * (K + 1)
for k in range(K, 0, -1):
    r = K // k
    if r == 1:
        cnt = 1
        ans += (k - 1) * 1
    else:
        cnt = pow(r, N, mod)
        for c in range(2, r + 1):
            cnt -= cnts[k * c]
        cnt %= mod
        ans += (k - 1) * cnt

    cnts[k] = cnt
    ans %= mod

print(ans)


Measured memory_bytes: 69320
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
void push(int);
int pop();
 
int S_num[1000],top;
 
int main(){
  int num_a,num_b;
  char str_num[100];
 
  top=0;
 
  while(scanf("%s",str_num)!=EOF){
    if(str_num[0]=='+'){
      num_a=pop();
      num_b=pop();
      push(num_a+num_b);
    }else if(str_num[0]=='-'){
      num_b=pop();
      num_a=pop();
      push(num_a-num_b);
    }else if(str_num[0]=='*'){
      num_a=pop();
      num_b=pop();
      push(num_a*num_b);
    }else{
      push(atoi(str_num));
    }
  }
  
  printf("%d\n",pop());
 
  return 0;
}
 
void push(int x){
  top++;
  S_num[top]=x;
}
 
int pop(){
  top--;
  return S_num[top+1];
}


Measured memory_bytes: 2108
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc085/tasks/abc085_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(S):
    return S[:3] + '8' + S[4:]


def main(args):
    S = input().strip()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
 int A,B,C,D;
 cin>>A>>B>>C>>D;
 if(A+B==C+D){
     cout<<"Balanced"<<endl;
 }
 else if(A+B<C+D)
 {
     cout<<"Right"<<endl;
 }
 else
 {
     cout<<"Left"<<endl;
 }
 
 
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstring>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erase(unique(all(v)),v.end());
#define pvec(v) rep(i,v.size()){ cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sizeof(m))

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}





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

	ll a = 0, b = 0, c = 0, d, e, ans = 0,j=0, n, ret = M, m, x = 0, y = 0;
	//bool x = false;
	string s,t;
	cin >> n;
	vi v(n);
	rep(i, n) cin >> v[i];
	sort(reall(v));
	rep(i, n) {
		if (i == 0)ans += (v[i] / 2);
		else ans += v[i];
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;


const ll MOD = 1e9+7;
 
template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    
 
    bool operator!() const{return !x;}
 
    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }
 
    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }
 
    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }
 
    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }
 
    modint operator-() const{ return modint(-x); }
 
    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }
 
 
    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }
 
    modint inv() const{
        return this->pow(MOD-2);
    }
 
    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }
 
    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

int main(){ 
    ll n;
    string s;
    cin >> n >> s;
    ll cnt[26] = {};
    rep(i,0,n){
        cnt[s[i] - 'a']++;
    }

    mint ans = 1;
    rep(i,0,26){
        if(cnt[i] != 0) ans *= (cnt[i]+1);
    }

    cout << ans-1 << endl;
}


Measured memory_bytes: 3696
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 2000010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll MOD = MODBASE;

ll binPowMod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll sub(ll a, ll b) {
    return (a - b + MOD) % MOD;
}

ll mul(ll a, ll b) {
    return a * b % MOD;
}

ll f[MAXN], rev[MAXN];

ll C(int n, int k) {
    if (k > n || k < 0) return 0;
    return mul(f[n], mul(rev[n-k], rev[k]));
}

int k;
string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> k >> s;
    int n = k + SZ(s);
    f[0] = 1;
    rev[0] = binPowMod(f[0], MOD-2);
    FOR(i,1,2000000) {
        f[i] = mul(f[i-1], i);
        rev[i] = binPowMod(f[i], MOD-2);
    }
    ll res = 0;
    FOR(i,0,SZ(s)-1) res = add(res, mul(binPowMod(25, n-i), C(n, i)));
    cout << sub(binPowMod(26, n), res);
    return 0;
}


Measured memory_bytes: 35668
using System;

class test {
    static void Main() {
        string[] s = Console.ReadLine().Split(' ');
        int[] n = new int[3];
        for (int i = 0; i < 3; i++) {
            n[i] = int.Parse(s[i]);
        }
        Array.Sort(n);
        int ans = 0;
        while (n[0] != n[1] || n[0] != n[2]) {
            ans++;
            if (n[0] != n[1]) {
                n[0] += 2;
            } else {
                n[0]++;
                n[1]++;
            }
            Array.Sort(n);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
bool sortDescByFirst(const pair<int,int>&a, const pair<int,int>&b){
    return a.first>=b.first;
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        n<=999?cout<<"ABC"<<endl:cout<<"ABD"<<endl;
    }
    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999

using namespace std;

#define int long long

int32_t main(){
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	
	int flag=0;
	int ans=1;
	for(int i=1; i<n; i++){
		if(flag==0){
			if(a[i-1]<a[i]){
				flag=1;
			}
			if(a[i-1]>a[i]){
				flag=-1;
			}
		}

		if(flag>0 && a[i-1]>a[i]){
			flag=0;
			ans++;
		}
		
		if(flag<0 && a[i-1]<a[i]){
			flag=0;
			ans++;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1024