akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return power(a*a,n/2);
  else
    return a*power(a*a,n/2);    
}
int main(){
FASTIO  
int n;
cin>>n;
vector<int> a(n);
for(int i=1;i<n;i++){
  int b;
  cin>>b;
  a[b-1]++;
}
for(int i=0;i<n;i++){
  cout<<a[i]<<"\n";
}
return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define L long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define aa first
#define bb second
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,m,x[2010][2010],w[2010][2010],f[2010],q,p;
char s[2010][2010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	  scanf("%s",&s[i][0]+1);
	for(i=1;i<n;i++)
	  for(j=1;j<m;j++)
		if((s[i][j]=='#')^(s[i+1][j]=='#')^(s[i][j+1]=='#')^(s[i+1][j+1]=='#')^1)
		  x[i][j]=1,w[i][j]=w[i-1][j]+1;
	p=max(n,m);
	for(i=1;i<n;i++)
	  {
	   q=0;
	   for(j=1;j<m;j++)
	     {
		  while(q && w[i][j]<w[i][f[q]])
		    {
			 p=max(p,(w[i][f[q]]+1)*(j-f[q-1]));
		     q--;
			}
		  f[++q]=j;
		 }
	   for(j=1;j<=q;j++)
	     p=max(p,(m-f[j-1])*(w[i][f[j]]+1));
	  }
	printf("%d\n",p);
	return 0;
}


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

#define pb push_back
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pf push_front

using namespace std;

typedef long long llong;

const int MXN = (int)1e6 + 7;
const llong INF = (llong)1e18 + 7;
const int MOD = (int)1e9 + 7;

int a, b;
string s, t, u;

int main()
{
  cin >> s >> t;
  cin >> a >> b >> u;
  if(u == t){
    b--;
  }else a--;
  cout << a << ' ' << b;
  return 0;
}


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


int main(){
   int n,m; cin>>n>>m;
   vector<int> ac(n),wa(n);
   rep(i,m){
      int p;
      string s;
      cin>>p>>s;
      --p;
      //既にACしていたら飛ばす
      if(ac[p]) continue;
      if(s=="AC") ac[p]=1;
      else wa[p]++;
   }
   int a=0,w=0;
   rep(i,n){
      a+=ac[i];
      if(ac[i]) w+=wa[i];
   }
   cout<<a<<" "<<w<<endl;
   return 0;
}

   


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007

using namespace std;

int n, m;

int main() {
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	s := next()
	sub := s[:n/2]

	if sub + sub == s {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
Acum = [0]
for a in A:
    Acum.append(Acum[-1] + a)

Apair = []
for i, al in enumerate(Acum):
    for ar in Acum[i + 1:]:
        Apair.append(ar - al)
Apair = np.asarray(Apair, dtype=np.int64)

d = 45  # 10*9*1000 = 1<<40ぐらい
ans = 0
while d >= 0:
    Atmp = np.bitwise_and(np.right_shift(Apair, d), 1)
    if np.count_nonzero(Atmp) >= K:
        ans += 2 ** d
        Apair = Apair[np.nonzero(Atmp)]
    d -= 1

print(ans)


Measured memory_bytes: 36168
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

int main(){
    int a, b; cin >> a >> b;
    char ans = 'x';
    if(a + b == 15) ans = '+';
    else if(a * b == 15) ans = '*';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=str(input())
M=len(S)
T=''
Al='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(M):
  for j in range(26):
    if S[i]==Al[j]:
      T +=str(Al[j+N])
      break
print(T)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int X;
  cin >> X;
  int ans = 0;
  ans += 1000 * (X / 500);
  X %= 500;
  ans += 5 * (X / 5);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	double a,b,c,d,e,f;
	double det,x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF)
	{
		det = a*e-b*d;
		x = (c*e-b*f)/det;
		y = (a*f-c*d)/det;
		if(x <= 0.0 && x >= -0.0005)x = 0.0;
		if(y <= 0.0 && y >= -0.0005)y = 0.0;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
ans = -float('inf')
for i in range(1,1024):
    tmp = 0
    for j in range(N):
        cnt = 0
        for k in range(10):
            if (i>>k & 1) & F[j][k]:
                cnt += 1
        tmp += P[j][cnt]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 41964
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int h, w;
bool check(int y, int x) {
  if (0 <= y && y < h && 0 <= x && x < w) return true;
  else return false;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> h >> w >> n;
  int sr, sc; cin >> sr >> sc; --sr; --sc;
  string s, t; cin >> s >> t;
  int y = sr, x = sc;
  // REP(i, n) {
  //   if (s[i] == 'U') ++y;
  //   else if (s[i] == 'R') ++x;
  //   if (!check(y, x)) {
  //     cout << "NO\n";
  //     return 0;
  //   }
  //   if (t[i] == 'D' && y > 0) --y;
  //   else if (t[i] == 'L' && x > 0) --x;
  // }
  // y = sr; x = sc;
  // REP(i, n) {
  //   if (s[i] == 'U') ++y;
  //   else if (s[i] == 'L') --x;
  //   if (!check(y, x)) {
  //     cout << "NO\n";
  //     return 0;
  //   }
  //   if (t[i] == 'D' && y > 0) --y;
  //   else if (t[i] == 'R' && x < w) ++x;
  // }
  // y = sr; x = sc;
  // REP(i, n) {
  //   if (s[i] == 'D') --y;
  //   else if (s[i] == 'L') --x;
  //   if (!check(y, x)) {
  //     cout << "NO\n";
  //     return 0;
  //   }
  //   if (t[i] == 'D' && y > 0) --y;
  //   else if (t[i] == 'R' && x < w) ++x;
  // }
  REP(i, n) {
    if (s[i] == 'U') --y;
    if (!check(y, x)) {
      cout << "NO\n";
      return 0;
    }
    if (t[i] == 'D' && y < h - 1) ++y;
  }
  y = sr; x = sc;
  REP(i, n) {
    if (s[i] == 'D') ++y;
    if (!check(y, x)) {
      cout << "NO\n";
      return 0;
    }
    if (t[i] == 'U' && y > 0) --y;
  }
  y = sr; x = sc;
  REP(i, n) {
    if (s[i] == 'L') --x;
    if (!check(y, x)) {
      cout << "NO\n";
      return 0;
    }
    if (t[i] == 'R' && x < w - 1) ++x;
  }
  y = sr; x = sc;
  REP(i, n) {
    if (s[i] == 'R') ++x;
    if (!check(y, x)) {
      cout << "NO\n";
      return 0;
    }
    if (t[i] == 'L' && x > 0) --x;
  }
  cout << "YES\n";
  return 0;
}


Measured memory_bytes: 920
while True:
    n = int(raw_input())
    if n == 0:
        break
    num_a = 0
    num_b = 0
    for j in range(n):
        ta, tb = map(int,raw_input().split())
        if ta > tb:
            num_a += (ta+tb)
        elif ta < tb:
            num_b += (ta+tb)
        else:
            num_a += ta
            num_b += tb
    print "%d %d" % (num_a, num_b)

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	cout << S.substr(0, 3) << endl;
	return 0;
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

struct card{
  char suit;
  int num;
};

void print(card A[],int N){
  rep(i,N){
    if(i>0) cout<<" ";
    cout<<A[i].suit<<A[i].num;
  }
  cout<<endl;
}

void BubbleSort(card A[],int N){
  rep(i,N){
    for(int j=N-1;j>i;j--){
      if(A[j].num<A[j-1].num) swap(A[j-1],A[j]);
    }
  }
}

void SelectionSort(card A[],int N){
  rep(i,N){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j].num<A[minj].num) minj=j;
    }
    swap(A[i],A[minj]);
  }
}

bool isSame(card A[],card B[],int N){
  bool b=true;
  rep(i,N){
    if(A[i].suit != B[i].suit) b=false;
  }
  return b;
}

int main() {
  int n;
  cin>>n;
  
  card vec1[n],vec2[n];
  rep(i,n) cin>>vec1[i].suit>>vec1[i].num;
  rep(i,n) vec2[i]=vec1[i];
  
  BubbleSort(vec1,n);
  SelectionSort(vec2,n);
  
  bool b=isSame(vec1,vec2,n);
  
  print(vec1,n);
  cout << "Stable"<<endl;
  print(vec2,n);
  cout << (b ? "Stable" : "Not stable") <<endl;
 

  
  return 0;
}


Measured memory_bytes: 3092
fn main() {
    proconio::input! {
        n: usize,
        a_s: [i128; n],
    }
    const M: i128 = 1_000_000_007;
    let mut add = 0;
    let mut ans = 0;
    for i in 1..n {
        add += a_s[i - 1];
        ans += add * a_s[i];
        ans %= M;
    }
    println!("{}", ans);
}


Measured memory_bytes: 7156
s = gets.chop.to_s
n = s.size

if s == s.reverse && s[0, ((n - 1) / 2)] == s[0, ((n - 1) / 2)].reverse && s[((n + 2) / 2), n] == s[((n + 2) / 2), n].reverse
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    vector<bool> win(k + 1);
    irep(i, k)
    {
        win[i] = false;
        rep(j, n)
        {
            if (i - a[j] >= 0) {
                win[i] = win[i] || !win[i - a[j]];
            }
        }
    }
    if (win[k]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b;

main() {
    cin >> a >> b;
    if (a+b >= 10) ct("error")
    else ct(a+b)
}


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

using namespace std;

int main(int argc, char *argv[]) {
	string S1, S2;
	cin >> S1 >> S2;

	bool is_ok(false);
	if (S1[0] == S2[2] && S1[1] == S2[1] && S1[2] == S2[0]) {
		is_ok = true;
	}

	cout << ((is_ok) ? "YES" : "NO") << endl;
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<tuple<string,int,int>> a(n);
  for(int i=0;i<n;i++){
    string k;
    cin>>k;
    int s;
    
    cin>>s;
    int g=100-s;
    int j=i+1;
    a[i]=make_tuple(k,g,j);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    int w;
    tie(ignore,ignore,w)=a[i];
    cout<<w<<endl;
  }
}


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

int main() {
    ll N;
    cin >> N;
    int M;
    M = (int)log10(N)+ 1;
    int A, B, m;
    for(ll i = 1; i*i <= N; i++){
        if(N % i != 0) continue;
        m = 0;
        A = (int)log10(i) + 1;
        B = (int)log10(N / i) + 1;
        m = max(A, B);
        M = min(M, m);
    }
    cout << M << endl;
}

Measured memory_bytes: 3932
s = input()

def genStr(s):
  stuck = []
  for i in s:
    if i == "0" or i == "1":
      stuck.append(i)
    elif i == "B":
      if len(stuck) != 0:
        stuck.pop()
    else:
      return None
    
  return "".join(stuck)

print(genStr(s))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[3*n];for(ll i=0;i<3*n;i++)cin>>a[i];
  ll mi[3*n],ma[3*n];
  mi[n-1]=0;ma[2*n]=0;
  multiset<ll>f,s;
  for(ll i=0;i<n;i++){
    mi[n-1]+=a[i];
    ma[2*n]+=a[3*n-1-i];
    f.insert(a[i]);
    s.insert(a[3*n-1-i]);
  }
  for(ll i=n;i<2*n;i++){
    auto k=f.begin();
    //cout<<*k;return 0;
    if(a[i]>*k){
      mi[i]=mi[i-1]+a[i]-*k;
      f.erase(f.begin());
      f.insert(a[i]);
    }
    else mi[i]=mi[i-1];
  }
  for(ll i=2*n-1;i>=n;i--){
    auto k=s.end();
    k--;
    if(a[i]<*k){
      ma[i]=ma[i+1]+a[i]-*k;
      s.erase(k);
      s.insert(a[i]);
    }
    else ma[i]=ma[i+1];
  }
  ll ans=-100000000000000000;
  for(ll i=n-1;i<2*n;i++){
    //cout<<mi[i]<<" "<<ma[i+1]<<endl;
    ans=max(ans,mi[i]-ma[i+1]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 13568
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    vector<ll> used(n,0);
    vector<ll> b(0);
    ll now=0;
    ll count=1;
    ll sta,T;
    while(true){
        if(used[now]>0){
            T=count-used[now];
            sta=used[now]-1;
            break;
        }
        b.push_back(now);
        used[now]=count;
        // kousin
        count++;
        now=a[now];
    }
    ll itr;
    if(k<sta){
        itr=k;
    }else{
        itr=sta+(k-sta)%T;
    }
    cout<<b[itr]+1<<endl;

}

Measured memory_bytes: 8496
# coding: utf-8
# Your code here!

# 標準入力から2つの文字列を受け取る
bad_id = input()
co_id = input()

# 文字列を1文字づつ配列に入れる
bad_id_array = [bad_id[i: i+1] for i in range(0, len(bad_id), 1)]
co_id_array = [co_id[i: i+1] for i in range(0, len(co_id), 1)]

# co_id_arrayから最後の1文字を削除
co_id_array.pop(-1)

# bad_id_array と co_id_arrayを比較して、出力する
if bad_id_array == co_id_array:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9064
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(uniqu7e(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << "Yes" << endl; exit(0);}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int n;
	string s;
	cin >> n >> s;
	REPx(x, s) cout << alp[((x-'A')+n)%26];
	ENDL

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll ans = 0;
    if(K <= A) {
        ans = K;
    } else if (K <= A + B) {
        ans = A;
    } else {
        ans = A - (K - (A + B));
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
def main():
    N = int(input())
    cnt = [[0] * 10 for _ in range(10)]
    for i in range(1,N+1):
        tmp = str(i)
        top = int(tmp[0])
        end = int(tmp[-1])
        cnt[top][end] += 1
    ans = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a == d and b == c:
                        ans += cnt[a][b] * cnt[c][d]

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 42076
#include <iostream>
#include <string.h>
#include <vector>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> P;

int main() 
{
	set<int> set;
	int A, n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> A;
		set.insert(A);
	}

	int size = set.size();
	if (size == n)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

}

Measured memory_bytes: 9600
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n; double r, x, y, cx[200009], cy[200009]; pair<double, double> p[200009]; bool vis[200009];
int main() {
	scanf("%d%lf", &n, &r);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x, &y);
		double ex = x * 0.28 - y * 0.96;
		double ey = x * 0.96 + y * 0.28;
		p[i] = make_pair(ex, ey);
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) cx[i] = p[i].first, cy[i] = p[i].second;
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (vis[i]) continue;
		int ptl = lower_bound(cx, cx + n, cx[i] - r - 1.0e-4) - cx;
		int ptr = lower_bound(cx, cx + n, cx[i] + r + 1.0e-4) - cx;
		for (int j = ptl; j < ptr; j++) {
			double dx = cx[i] - cx[j];
			double dy = cy[i] - cy[j];
			if (dx * dx + dy * dy <= 2.0 * r * r) vis[j] = true;
		}
		ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 9724
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;cin>>s;
  if(s=="SUN")cout<<7<<endl;
  if(s=="MON")cout<<6<<endl;
  if(s=="TUE")cout<<5<<endl;
  if(s=="WED")cout<<4<<endl;
  if(s=="THU")cout<<3<<endl;
  if(s=="FRI")cout<<2<<endl;
  if(s=="SAT")cout<<1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef int64_t ll;

int main(){
  ll n,q;
  cin>>n>>q;
  atcoder::dsu d(n);
  for(int i=0;i<q;i++){
    ll t,u,v;
    cin>>t>>u>>v;
    if(t==0){
      d.merge(u,v);
    }
    else{
      cout<<d.same(u,v)<<endl;
    }
  }
}


Measured memory_bytes: 4052
a, b, c = [int(i) for i in input().split(" ")]
A = [a,b,c]
A.sort()
a, b, c = A[0], A[1], A[2]

s = sum(A)
if 3*c%2 == s%2:
    print((3*c - a - b - c)//2)
else:
    print((3*c-a-b-c+3)//2)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int a,b;

int main(){
  cin >> a >> b;
  if((a+b) == 15){
    cout << "+" << endl;
  } else if ((a*b) == 15){
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    // freopen("A.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,x;
    scanf("%d %d %d",&a,&b,&x);
    (a+b<x or x<a)?printf("%s","NO"):printf("%s","YES");
    return 0;
}

Measured memory_bytes: 3820
#include <cstdio> 
using namespace std; //This makes the code much more cleaner

int main()
{
	
/*
	int a, b, c, d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int area = a*b;
	int areatwo = c*d;
		if (area>=areatwo)
		{
			printf("%d", area);
		}
		else
		{
			printf("%d",areatwo);
		}
		*/
	//--------------------------------------------

	/*
	int a,b;
	scanf("%d %d", &a, &b);
	if (a==1 and b!=1)
	{

		printf("Alice");

	}
	else if (b == 1 and a!=1)
	{

		printf("Bob");

	}
	else if (a>b)
	{

		printf("Alice");

	}
	else if (a == b)
	{

		printf("Draw");
	}
	else
	{

		printf("Bob");
	}

	*/



	int a, b;
	scanf("%d %d",&a,&b);
	if ((a+b) % 3 == 0 or a%3==0 or b%3==0)
	{
		printf("Possible");

	}
	else
	{
		printf("Impossible");
	}





	return 0;

}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

int main(){
    int n, a, b;  cin >> n >> a >> b;

    ll res=0;
    for(int i=1; i<=n; i++){
        int tmp=i, x=0;
        while(0<tmp){
            x += tmp%10;
            tmp /= 10;
        }
        if(a<=x && x<=b) res += i;
    }

    cout << res << endl;
}

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

int main(){

  int N;
  cin >> N;
  
  for(int i=1;i<10;i++){
  if(N%i==0 && N/i<10){
    cout << "Yes" << endl;
    exit(0);
  }
  
  else{
    continue;
}
  }
   cout << "No" << endl;
}

Measured memory_bytes: 256
# ref https://atcoder.jp/contests/agc025/submissions/2609185
def main():
    n = int(input())
    L, R = [0], [0]
    for i in range(n):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
    L.sort()
    L.reverse()
    R.sort()

    res = 0
    for i in range(n + 1):
        if L[i] > R[i]:
            res += 2 * (L[i] - R[i])

    print(res)
if __name__ == '__main__':
    main()

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

long long solve(long long n,long long r,long long e){
  long long ans=1;
  for(int i=0;i<r;i++){
    ans*=n-i;
    ans/=i+1;
  }
  for(int i=0;i<e;i++)
    ans*=2;
  return ans;
}

int main(){
  int n,p;
  cin >> n >> p;
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  long long o=0,e=0,ans=0;
  for(int i=0;i<n;i++)
    if(a.at(i)%2==0)
      e++;
  o=n-e;
  for(int i=(p==0?0:1);i<=o;i+=2){
    ans+=solve(o,i,e);
  }
  cout << ans << endl;
  //cout << n << "/" << e << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;

int main() {
    int N;
    cin >> N;
    map<ll, int> MP;
    rep(i, 0, N){
        ll tmp;
        cin >> tmp;
        MP[tmp]++;
    }
    ll ans = 0;
    for(auto & s : MP){
        ans += s.second%2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define MaxN 200000
#define MOD 1000000007
using namespace std;

int col[MaxN+1];
int dp[MaxN+1];
int v[MaxN+1];
int N, M;

int main(){


	int i, x, pos;

  	scanf("%d", &N);
  	for(i = 1; i <= N; ++i) scanf("%d", &v[i]);

  	v[++M] = v[1];
  	for(i = 2; i <= N; ++i)
  		if(v[i] != v[i-1]) v[++M] = v[i];

    N = M;
    dp[0] = 1;
    for(i = 1; i <= N; ++i)
    {
        dp[i] = (dp[i] + dp[i-1]) % MOD;
        pos = col[ v[i] ];

        if(pos) dp[i] = (dp[i] + dp[pos]) % MOD;
        col[ v[i] ] = i;
    }

  	printf("%d\n", dp[N]);


return 0;
}


Measured memory_bytes: 2560
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    cout<<min(N*A,B)<<endl;
}


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair <int, int> cn;
const int N = 1e5 + 100;

int main() {
	long long sum = 0;
	int n, m, a[N];
	auto cmp = [](cn a, cn b) {
		return a.second < b.second;
	};
	priority_queue <cn, vector<cn>, decltype(cmp)> q(cmp);
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i) {
		scanf("%d", a + i);
	}
	sort(a, a + n);
	cn z[m];
	for (int i = 0; i < m; ++i) {
		scanf("%d%d", &z[i].first, &z[i].second);
		q.push(z[i]);
	}
	int i = 0;
	--m;
	for (; i < n; ++i) {
		cn t = q.top();
		int f = t.second;
		if (a[i] >= t.second) { break; }
		sum += t.second;
		q.pop();
		if (t.first-- > 1) {
			q.push(t);
			continue;
		}
		if (m-- == 0) {
			++i;
			break;
		}
	}
	for (;i < n; ++i) {
		sum += a[i];
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int x(char c) {
  if(c=='l') return 0;
  return 1;
}

int main() {
  int n;
  while(cin >> n && n) {
    int p=0,cnt=0;
    bool z=false;
    string s;
    while(n--) {
      cin >> s;
      p^=(1<<x(s[0]));
      if(z) {
	if(p==0) {
	  z=false;
	  cnt++;
	}
      } else {
	if(p==3) {
	  z=true;
	  cnt++;
	}
      }
    }
    pr(cnt);
  }
  return 0;
}


Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count = 0;
  string S;
  cin >> N >> S;
  
  for(int i = 0;i < N - 2;i++){
    if(S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C'){
      count++;
    }
  }
  cout << count << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

template <class Iit>
void vout(const Iit &begin,const Iit &end,ostream &out) {
    for(auto it = begin; it != end; it++) {
        auto tmp = it;
        if (++tmp == end) out << *it << '\n';
        else out << *it << " ";
    }
}

void calc(vector<ll> &v,const ll &x) {
    int i = 0;
    while(1LL << i < x) i++;

    ll tmp = 0;
    while(i >= 0) {
        if (1LL << i <= x-tmp) {
            REP(j,i) v[j] += pow(2,i-1);
            tmp += 1LL << i;
            v[i] += x-tmp+1;
        }
        i--;
    }

}

int main(void)
{
    IOS
    constexpr size_t B = 50;
    ll a,b;
    cin >> a >> b;
    vector<ll> va(B),vb(B);

    if (a !=0) calc(va,a-1);
    calc(vb,b);
    ll ans = 0;
    REP(i,B) {
        if (abs(va[i]-vb[i]) % 2 == 1) ans += 1LL << i;
    }

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int t_hp = sc.nextInt();
    int t_atk = sc.nextInt();
    int a_hp = sc.nextInt();
    int a_atk = sc.nextInt();
    while(true){
      a_hp -= t_atk;
      if(a_hp<=0) { System.out.println("Yes"); return;}
      t_hp -= a_atk;
      if(t_hp <= 0) { System.out.println("No"); return;}
    }
  }
}

Measured memory_bytes: 35788
use proconio::input;

fn main() {
    input! {
        n: u32,
    }
    let ans = match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => "hoge",
    };
    println!("{}", ans);
}


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

const int maxn = 1000005;
int n, m, K;
set<int> s[2];
char S[maxn], T[maxn];

void solve(int pos, int step)
{
	set<int>::iterator z[2] = {s[0].upper_bound(pos), s[1].upper_bound(pos)};
	int p = *z[0] < *z[1] ? 0 : 1, q = 1 - p;
	if (step < *z[p] - pos)
	{
		s[0].insert(pos + step);
		s[1].insert(pos + step);
		return;
	}
	step -= *z[p] - pos;
	s[q].insert(*z[p]);
	int lst = *z[p] - 1;
	for (auto it = z[p]; it != s[p].end(); lst = *it, s[p].erase(it++))
		if (*it - lst != 1)
			break;
	if (s[q].count(lst + 1))
		s[q].erase(lst + 1), solve(lst + 1, step);
	else
		s[p].insert(lst + 1);
}

int main()
{
	scanf("%d%d%d%s%s", &n, &m, &K, S + 1, T + 1);
	reverse(S + 1, S + 1 + n);
	reverse(T + 1, T + 1 + m);
	for (int i = 1; i <= n; ++i) S[i] -= '0';
	for (int i = 1; i <= m; ++i) T[i] -= '0';
	int l = max(n, m);
	s[0].insert(1 << 30), s[1].insert(1 << 30);
	for (int i = l; i; --i)
	{
		if (S[i] && !T[i])
			s[0].insert(i);
		if (!S[i] && T[i])
			s[1].insert(i);
		if (S[i] && T[i])
			solve(i, K);
	}
	for (int d = 0; d < 2; ++d)
	{
		s[d].erase(1 << 30);
		int lst = 0;
		string ans;
		for (int p : s[d])
		{
			for (int j = lst + 1; j < p; ++j)
				ans += '0';
			ans += '1', lst = p;
		}
		reverse(ans.begin(), ans.end());
		puts(ans.c_str());
	}
	return 0;
}


Measured memory_bytes: 44516
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll x;
cin>>x;
if(x<1200){
    cout<<"ABC"<<endl;
}else{
    cout<<"ARC"<<endl;
}
}










Measured memory_bytes: 256
#include<cstdio>

typedef long long LL;

const int maxn = 1e5+5;

const LL mod = 1e9+7;

char s[maxn];

LL cnt[26];

int main(){

	int n; scanf("%d",&n);

	scanf("%s",s);

	for(int i = 0; i < n; i++){

		cnt[s[i]-'a']++;
	}

	LL ans = 1;

	for(int i = 0; i < 26; i++){

		ans = (cnt[i]+1)*ans%mod;
	}

	printf("%lld\n",ans-1);
	
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int n,a=1;
  scanf("%d",&n);
  char d[n+1];
  scanf("%s",d);
  for(int i=0;i<n-1;i++){
    if(d[i]!=d[i+1]){
      a++;
    }
  }
  printf("%d",a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ll a, v, b, w, t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;
  bool ok = true;
  if (abs(a-b) > (v-w)*t) ok = false;
  cout << (ok?"YES\n":"NO\n");
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const int MAX = 100000;
static const int NIL = -1;
using namespace std;


int main() {
    ll n,s,k; cin >> n >> k >> s;
    ll p = 0;
    ll c = s/k;
    ll d = s-c*(k-1);

    rep(i,n){
        if(p < k){
            cout << s << " ";
            p ++;
        }
        else {
            if(s != 1) cout << s-1 << " ";
            else cout << s+1 << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 3524
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define LIMIT 5637

int primejudge(int);	// 素数かどうか判定
int ansersum(int *,int);	// 回答の要素の合計
int anserjudge(int*, int);	// 回答に満たしているかどうか


int main()
{
	int N;
	scanf("%d", &N);

	/*
	//srand((unsigned int)time(NULL));

	int anser[55] = { 0 };	// 回答の数列
	int primenumber[LIMIT];	// 素数LIMIT分
	int number = 2;

	// LIMIT分だけ素数を入れる
	for (int i = 0; i < LIMIT; number++) {
		if (primejudge(number) == 1) {
			primenumber[i] = number;
			i++;
		}
	}

	// ひとまず素数を入れる
	for (int i = 0; i < N; i++) {
		anser[i] = primenumber[i];
	}
	*/

	// 答え出るまでループを回す

	//while ((anserjudge(anser,N)) != 0) {
		
		//int cut;
		//cut = LIMIT / N;

		/*for (int i = 0; i < N; i++) {
			anser[i] = primenumber[rand()%cut+cut*i];
		}*/

		for (int i = 31; N != 0; i += 30) {
			if ((primejudge(i)) == 1) {
				printf("%d ", i);
				N--;
			}
		}

		/*
		for (int i1 = 0; i1 < LIMIT - 4; i1++) {
			for (int i2 = i1 + 1; i2 < LIMIT - 3; i2++) {
				for (int i3 = i2 + 1; i3 < LIMIT - 2; i3++) {
					for (int i4 = i3 + 1; i4 < LIMIT - 1; i4++) {
						for (int i5 = i4 + 1; i5 < LIMIT; i5++) {

						}
					}
				}
			}
		
		*/
	//}

	// 答えの表示
	/*for (int i = 0; i < N; i++) {
		printf("%d ", anser[i]);
	}*/

	return 0;
}

int ansersum(int* anser,int n) {

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += *(anser+4*i);
	}
	return sum;
}

int anserjudge(int* anser, int n)
{
	int sum = 0;

	for (int i1 = 0; i1 < n - 4; i1++) {
		for (int i2 = i1 + 1; i2 < n - 3; i2++) {
			for (int i3 = i2 + 1; i3 < n - 2; i3++) {
				for (int i4 = i3 + 1; i4 < n - 1; i4++) {
					for (int i5 = i4 + 1; i5 < n; i5++) {
						sum = (*(anser + 4 * i1) + *(anser + 4 * i2) + *(anser + 4 * i3) + *(anser + 4 * i4) + *(anser + 4 * i5));
						if (primejudge(sum) == 1) {
							return 1;
						}
					}
				}
			}
		}
	}
	return 0;
}

int primejudge(int n)
{
	if (n == 1) {
		return 0;
	}else if (n == 2) {
		return 1;
	}
	
	if (n % 2 == 0) {
		return 0;
	}

	for (int i = 3; i <= n / i; i += 2) {
		if (n%i == 0) {
			return 0;
		}
	}

	return 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////


	
int main() {
	ll K;
	ll X;
	cin >> K >> X;
	for (ll x = X - K + 1; x <= X + K - 1; x++) {
		cout << x << " ";
	}

	system("PAUSE");
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

int main() {
    ll T;
    cin >> T;
    vector<ll> N(T), A(T), B(T), C(T), D(T);
    rep(i, T) { cin >> N[i] >> A[i] >> B[i] >> C[i] >> D[i]; }
    rep(i, T) {
        ll n, d;
        n = N[i];
        d = D[i];
        vector<ll> a = {A[i], B[i], C[i]};
        map<ll, ll> m;
        function<ll(ll)> rec = [&](ll x) {
            if (m[x] > 0) return m[x];
            if (x == 1) return m[x] = d;

            vector<ll> op = {2, 3, 5};
            ll res = (ll)4e18;
            if ((long double)d * (long double)x < res) {
                res = d * x;
            }
            rep(j, 3) {
                ll s, t, o;
                o = op[j];
                s = x % o;
                t = o - x % o;
                if ((x - s) / o < x) res = min(res, rec((x - s) / o) + d * s + a[j]);
                if ((x + t) / o < x) res = min(res, rec((x + t) / o) + d * t + a[j]);
            }
            // cout << x << " " << res << endl;
            return m[x] = res;
        };
        cout << rec(n) << endl;
    }
    return 0;
}


Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int donutKinds = Integer.parseInt(tokens[0]);
		int sozaiWeight = Integer.parseInt(tokens[1]);
		int[] mList = new int[donutKinds];
		for (int i = 0; i < donutKinds; ++i) {
			mList[i] = Integer.parseInt(in.nextLine());
		}
		// 最低限の消費量
		int result = donutKinds;
		int remainWeight = sozaiWeight;
		for (int i = 0; i < donutKinds; ++i) {
			remainWeight -= mList[i];
		}
		// 最小の消費量の種類を探す
		int minSpentWeight = Integer.MAX_VALUE;
		for (int i = 0; i < donutKinds; ++i) {
			if (minSpentWeight > mList[i]) {
				minSpentWeight = mList[i];
			}
		}
		result += (int) Math.floor((double) remainWeight / (double) minSpentWeight);
		System.out.println(result);
		in.close();
	}

}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <typename T, int base=0>
class fenwick_tree_0 {
 public:
    vector<T> x;
 public:
    fenwick_tree_0(int n) : x(n+base,0) { }
    void add(int k, T a=1) { for (; k<x.size(); k|=k+1) x[k] += a; }
    T sum(int i, int j) {
        if (i == base) {
            T S = 0; for (; j>=0; j=(j&(j+1))-1) S += x[j]; return S;
        } else {
            return sum(base, j) - sum(base, i-1);
        }
    }
};

int zaatsu(int N, vi& src, vi &dest, int offset=0) {
    set<int> uniq(ALL(src));
    map<int,int> mp;
    int ix = 0;
    for (int x : uniq) mp[x] = ix++;

    dest.resize(N);
    for (int i=0; i<N; ++i) {
        dest[i] = offset + mp[src[i]];
    }
    return ix;
}

ll count_inversion(vector<int>& a) {
    int N=a.size();
    vi b(N);
    int num_indices = zaatsu(N, a, b, 1);

    int _N = 1; while (_N < N+1) _N *= 2;
    fenwick_tree_0<int> ft(_N);

    ll cnt = 0;
    for (int i=N-1; i>=0; --i) {
        cnt += ft.sum(1, b[i]-1);
        ft.add(b[i]);
    }
    return cnt;
}

ll solve(string& s){
    int L=s.size();
    vi a(L);
    rep(i,L){
        a[i] = s[i]=='B' ? 1 : 0;
    }
    return count_inversion(a);
}

int main() {
    string s; cin >> s;
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
double a, b, h, m;
double j, l, r, mid, s;
int main()
{
	scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
	h = h*5+m*5*1.0/60;
	j = fabs(h-m)*6;
	if(j > 180) j = 360-j;
	//printf("%f\n", j);
	j = cos(j*M_PI/180);
	s = a*a+b*b-2*a*b*j;
	r = sqrt(s);
	printf("%.20f", r);
}

Measured memory_bytes: 4204
m,n=map(int,input().split())
a=list(map(int,input().split()))
if m==2:
  x=y=0
  for i in range(n):
    b=i%2+1
    c=(i+1)%2+1
    if a[i]!=b:x+=1
    if a[i]!=c:y+=1
  print(min(x,y))
  exit()
x=0
for i in range(1,n):
  if a[i-1]==a[i]:a[i]=-1;x+=1
print(x)


Measured memory_bytes: 16664