akhauriyash/Code-Regression huggingface dataset:
N,x,y = map(int,input().split())
x -= 1
y -= 1
d = y-x
lk = [0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        a = min((j-i),(abs(x-i)+abs(j-y)+1))
        lk[a-1] +=1
for i in range(N-1):
    print(lk[i])


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

typedef long long LL;
const int mod = 1000000007;

struct matrix {
	int a[3][3];
	matrix operator * (const matrix &rhs) const {
		matrix ret;
		for (int i = 0; i < 3; ++i)
			for (int j = 0; j < 3; ++j) ret.a[i][j] = 0;
		for (int i = 0; i < 3; ++i)
			for (int k = 0; k < 3; ++k) if (a[i][k])
				for (int j = 0; j < 3; ++j)
					ret.a[i][j] = (ret.a[i][j] + (LL) a[i][k] * rhs.a[k][j]) % mod;
		return ret;
	}
};

const matrix A = (matrix) {1, 1, 1, 0, 1, 2, 1, 1, 2};
const matrix B = (matrix) {1, 1, 1, 0, 1, 2, 0, 0, 1};

matrix p[32], ans;

void transfer(int n) {
	#define ctz __builtin_ctz
	for (int i = ctz(n); n; i = ctz(n &= n - 1))
		ans = ans * p[i];
}

int n, m, x;

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m, ans.a[0][0] = 1;
	p[0] = A;
	for (int i = 1; i < 32; ++i) p[i] = p[i - 1] * p[i - 1];
	for (int i = 1, lst = 0; i <= m; ++i)
		std::cin >> x, ans = ans * B, transfer(x - lst - 1), lst = x;
	ans = ans * B, transfer(n - x - 1);
	std::cout << ans.a[0][2] << '\n';
	return 0;
}

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

frg = True
if frg:
    for yukichi in range(n+1):
        for higuchi in range(n - yukichi + 1):
            noguchi = n - yukichi - higuchi
            if yukichi * 10000 + higuchi * 5000 + noguchi * 1000 == y and frg:
                print(yukichi, higuchi, noguchi)
                frg = False
                break
if  frg:
    print(-1, -1 ,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


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

int n,m,c,s,g;
//int x[10010],y[10010],d[10010],c[10010];
int ed[110][110][22];
int p[22];
int q[22][55];
int r[22][55];
int cost[22][100000];
int ans_dis[110];
vector<int> ans;
int flag=0;

int main(){
	while(1){
		cin>>n>>m>>c>>s>>g;
		if(n==0&&m==0&&c==0&&s==0&&g==0)break;
		REP(i,110)
			REP(j,110)
				REP(k,22)
					ed[i][j][k]=1e9;
		REP(i,110)
			REP(k,22)
			ed[i][i][k]=0;
		for(int i=0;i<m;i++){
			int x1,y1,d1,c1;
			cin>>x1>>y1>>d1>>c1;
			ed[x1][y1][c1]=min(d1,ed[x1][y1][c1]);
			ed[y1][x1][c1]=min(d1,ed[x1][y1][c1]);
		}
		for(int i=1;i<=c;i++){
			cin>>p[i];
		}
		for(int i=1;i<=c;i++){
			for(int j=1;j<=p[i]-1;j++){
				cin>>q[i][j];
			}
			for(int j=1;j<=p[i];j++){
				cin>>r[i][j];
			}
			cost[i][0]=0;
			int t=1;
			for(int j=1;j<100000;j++){
				if(t<p[i]&&q[i][t]+1==j)t++;
				cost[i][j]=cost[i][j-1]+r[i][t];
			}
		}
		/*for(int i=1;i<35;i++)printf("%3d",i);
		printf("\n");
		for(int i=1;i<=c;i++){
			for(int j=1;j<35;j++){
				printf("%3d",cost[i][j]);
			}
			cout<<endl;
		}*/
		for(int i=1;i<=c;i++){
			for(int k=1;k<=n;k++){
				for(int j=1;j<=n;j++){
					for(int l=1;l<=n;l++){
						
						ed[j][l][i]=min(ed[j][l][i],ed[j][k][i]+ed[k][l][i]);
					}
				}
			}
		}
		/*for(int i=1;i<=c;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					printf("%15d",ed[j][k][i]);
				}
				printf("\n");
			}
			printf("\n");
		}*/

		for(int i=1;i<=c;i++){
			for(int j=1;j<=n;j++){
				for(int l=1;l<=n;l++){
					if(ed[j][l][i]!=1e9&&ed[j][l][i]>=100000)flag=1;
					if(ed[j][l][i]!=1e9)
					ed[j][l][i]=cost[i][ed[j][l][i]];
				}
			}
		}
		REP(i,110)ans_dis[i]=1e9;
		ans_dis[s]=0;
		queue<int> qq;
		qq.push(s);
		while(qq.size()){
			int st1=qq.front();qq.pop();
			for(int i=1;i<=c;i++){
				for(int j=1;j<=n;j++){
					if(ed[st1][j][i]!=1e9){
						if(ans_dis[j]>ans_dis[st1]+ed[st1][j][i]){
							qq.push(j);
							ans_dis[j]=ans_dis[st1]+ed[st1][j][i];
						}
					}
				}
			}
		}
		if(ans_dis[g]==1e9)ans.push_back(-1);
		else ans.push_back(ans_dis[g]);
		/*if(ans_dis[g]==0){
			REP(i,20)
			cout<<"--------------"<<endl;
			cout<<n<<" "<<m<<" "<<c<<" "<<s<<" "<<g<<endl;
			cout<<"--------------"<<endl;
		}*/
	}
	REP(i,ans.size())
		cout<<ans[i]<<endl;
	//if(flag)cout<<"5"<<endl;
	return 0;
}


Measured memory_bytes: 12064
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int max_cnt=0,point=0;
    for(int i=0;i<s.size()-t.size()+1;i++){
        int cnt=0;
        for(int j=0;j<t.size();j++){
            if(t[j]==s[i+j])
            cnt++;
            if(cnt>max_cnt){
                point=i;
                max_cnt=cnt;
            }
        }
    }
    int ans=0;
    for(int i=0;i<t.size();i++){
        if(t[i]!=s[point+i])
        ans++;
    }
    cout<<ans<<endl;
}

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

long c2(long n) {
  return n * (n - 1) / 2;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N), cnt(N + 1);
  for (int i = 0, a; cin >> a; i++) A.at(i) = a, cnt.at(a)++;

  long sum = 0;
  for (int i : cnt) sum += c2(i);

  for (int i = 0; i < N; i++) {
    int tmp = cnt.at(A.at(i));
    cout << sum - c2(tmp) + c2(tmp - 1) << "\n";
  }
}

Measured memory_bytes: 4096
/**
 *    author: moririn_cocoa       
**/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

int main(void) {
  
  string S;
  string T;
  
  cin >> S;
  cin >> T;
  
  cout << T + S << endl;
  
  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int n,a[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int w=1,j=a[1];
		do{
		if(j==2)
		break;
		else{
			j=a[j];
			w++;
		}
	}while(w<=n);
	if(w>n)
	printf("-1");
	else
	printf("%d",w);
	return 0;	
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	ll n;
	cin >> n;
	if(n%2){
		cout << 0 << endl;
	}else{
		ll ans = 0;
		ll m = 10;
		while(m<=n){
			ans += n/m;
			m *= 5;
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
  vector<int> mountain;
  int m=0;
  for(int i=0;i<10;i++){
    cin>>m;
    mountain.push_back(m);
  }
  sort(mountain.begin(),mountain.end(),greater<int>());
  
  for(int i=0;i<3;i++)
    cout<<mountain[i]<<endl;

  return 0;
}



Measured memory_bytes: 3144
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
b = []
i = 0
for i in 0..n-1
    b[i] = 0
    while(true)
        if a[i]%2 == 0
            a[i] = a[i]/2
            b[i] += 1
        else 
            break
        end
    end
end
print b.min

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int H,W;
	cin >> H >> W;
	vector<string> map(H);
	for (int i = 0; i < H; ++i) {
		cin >> map.at(i);
	}

	for (int i = 0; i < H+2; ++i) {
		if(i==0||i==H+1){
			for (int j = 0; j < W+2; ++j) {
				cout << '#';
			}
			cout << endl;
			continue;
		}else{
			cout << '#' << map.at(i-1) << '#' << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int num = 0;
        int max = -1;
        for(int i = 0; i < n; i++) {
            if(max <= h[i]) num++;
            max = Math.max(max,h[i]);
        }
        System.out.println(num);

    } 
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int A[11][11];

int main() {
    int K;
    
    cin >> K;
    
    for (int i = 0; i <= 9; ++i)
        A[1][i] = 1;
    
    for (int i = 2; i <= 10; ++i) {
        A[i][0] = A[i-1][0] + A[i-1][1];
        for (int j = 1; j <= 9; ++j) {
            A[i][j] = A[i-1][j-1] + A[i-1][j] + A[i-1][j+1];
        }
    }
    
    int sum = 0;
    int i = 1;
    int last = 0;
    bool ok = true;
    for (i = 1; i <= 10 && ok; ++i) {
        for (int j = 1; j < 10; ++j) {
            if (sum + A[i][j] >= K) {
                cout << j;
                last = j;
                K -= sum;
                ok = false;
                break;
            }
            sum += A[i][j];
            //cout << sum;
        }
    }
    --i;
    //cout << i << endl;
    
    while (i > 0) {
        int sum = 0;
        --i;
        for (int j = last-1 >= 0 ? last-1 : 0; j <= last+1; ++j) {
                if (sum + A[i][j] >= K) {
                    cout << j;
                    last = j;
                    K -= sum;
                    break;
                }
                sum += A[i][j];
                //cout << sum;
            }
    }
    
    return 0;
}




Measured memory_bytes: 256
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
//	   cin>>t;
      

	      while(t--)
{
ll n;
cin>>n;
if(n%1000!=0)
cout<<1000-(n)%1000;
else
cout<<0;
ee;	







}
return 0;
}














Measured memory_bytes: 3624
h,n=map(int,input().split())
l=[]
s=0
for i in range(n):
    a,b=map(int,input().split())
    s=max(s,a)
    l.append((a,b))
dp=[10**10]*(h+s)
dp[0]=0
for i in range(h):
    for s,t in l:
        dp[i+s]=min(dp[i]+t,dp[i+s])
print(min(dp[h:]))


Measured memory_bytes: 41452
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int BIG = 1e+18+3;
int mod = 1e+9+7;

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

    int activity[n+1][4];

    repa(i,1,n)
        repa(j,1,3)
            cin>>activity[i][j];

    int dp[n+1][4];

    repa(i,1,3) dp[1][i] = activity[1][i];

    repa(i,2,n)
    {
        dp[i][1] = max(dp[i-1][2],dp[i-1][3]) + activity[i][1];
        dp[i][2] = max(dp[i-1][1],dp[i-1][3]) + activity[i][2];
        dp[i][3] = max(dp[i-1][1],dp[i-1][2]) + activity[i][3];
    }

    cout<< *max_element(dp[n]+1,dp[n]+4) <<endl;

}

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	long long s1=a*c, s2=a*d, s3=b*c, s4=b*d;
	long long ans=max(s1,max(s2,max(s3,s4)));
	printf("%lld\n",ans);
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>

long long b[60], h[60], n, r, ans;

void solve(int now)
{
	if (r <= 0) return;
	if (!now) { --r, ++ans; return; }
	if (r >= h[now]) { r -= h[now], ans += b[now]; return; } 
	--r;
	if (r > 0) solve(now - 1);
	if (r > 0) ++ans, --r;
	if (r > 0) solve(now - 1);
	--r;
}

int main()
{
	scanf("%lld%lld", &n, &r);
	h[0] = 1, b[0] = 1;
	for (int i = 1; i <= 50; ++i) h[i] = (h[i - 1] << 1) + 3, b[i] = 1 + (b[i - 1] << 1);
	solve(n); 
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		ol:
		for (long i = -1000; i <= 1000; i++) {
			for (long j = -1000; j <= 1000; j++) {
				if (i*i*i*i*i - j*j*j*j*j == x) {
					System.out.println(i + " " + j);
					break ol;
				}
			}
		}
	}
}


Measured memory_bytes: 27228
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
int main() {
	cin >> N;
	LL sum = 0;
	REP(i, 0, N) {
		LL a;
		cin >> a;
		sum += a;
	}
	YESNO(sum % 2 == 0);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using IV = std::vector<int>;
IV ToFixedArray(std::istream& is, int n) {
	IV ret(n);
	auto* dst = ret.data();
	while(n > 0) {
		--n;
		is >> *dst++;
	}
	return ret;
}
void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
int main() {
	DisableIOSync();
	const int N = ToFixedArray(std::cin, 1)[0];
	int sum = 0;
	for(int i=0 ; i<N ; i++) {
		const auto g = ToFixedArray(std::cin, 2);
		sum += g[1] - g[0] + 1;
	}
	std::cout << sum << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<double,ll> mp;
ll inf =  1e9;
double EPS = 1e-12;

int main(){
 ll n;
 double k;
 cin>>n>>k;
 vector<double> s(n),ls(n+1,0);
 for(ll i=0;i<n;i++)cin>>s[i];
 for(ll i=0;i<n;i++){
  if( s[i] == 0.0 ){
   cout<<n<<endl;
   return 0;
  }
 }

 for(ll i=0;i<n;i++)ls[i+1] = log( s[i] );
 for(ll i=1;i<=n;i++)ls[i] += ls[i-1];
 ll ans = 0;
 ll st=0;
 double lk = log(k);
 
 vector<mp> lss(n+1);
 for(ll i=0;i<=n;i++){
  lss[i] = mp( ls[i] , i );
 }
 sort( lss.begin() , lss.end() );
 for(ll i=n;i>=1;i--){
  lss[i-1].second = min( lss[i-1].second , lss[i].second );
 }
 
 //尺とり
 /*for(ll i=1;i<=n;i++){
  while( ls[i]-ls[st] > lk + EPS ) st++;
  ans = max( ans , i-st );
 }*/
 for(ll i=1;i<=n;i++){
  auto it = lower_bound( lss.begin() , lss.end() , mp( ls[i] - lk , 0 ) ); 
  if( it == lss.end() ) continue;
  ans = max( ans , i - it->second );
 }

 cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 6404
S = input()

K = ['A', 'K', 'I', 'H', 'B', 'R']

ans = 'YES'
p = 0
cont = False
for s in S:
    if not s in K:
        ans = 'NO'
    elif s == 'A':
        if (p == 0 or p == 3 or p == 4 or p == 5) and not cont:
            cont = True
        else:
            ans = 'NO'
    elif p == 5:
        ans = 'NO'
        break
    elif s == K[p+1]:
        p += 1
        cont = False
    else:
        ans = 'NO'
if p != 5:
    ans = 'NO'
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
using namespace std;    
const int N = int(3e5), mod = int(1e9)  + 7;

string s;

int main () {
	cin >> s;
	int k;
	cin >> k;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != 'a' && (s[i] - 'a' + k) >= 26){
			k -= (26 - s[i] + 'a');
			s[i] = 'a';
		}
	}
	if(k > 0){
		int sz = s.size();
		s[sz - 1] = char((s[sz - 1] - 'a' + k) % 26 + 'a');
	}
	cout << s << endl;

return 0;
}

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

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a>=1 && a<=9 && b >=1 && b <=9){
    cout << a*b << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, ans = INF;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> s;
    vii d(n+1);
    rep(i, 0, n) 
        d[i+1] = d[i] + (s[i] == 'E' ? 1 : 0);
    
    ans = n;
    rep(i, 0, n) {
        ans = min(ans, i - d[i] + d[n] - d[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1812
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

const int inf=2147483647;

string s;

int main()
{
	cin>>s;
	
	cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = 505;
char f[N][N];


int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

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

    for (int i = 0; i < n; i++)
        scanf("%s", f[i]);

    for (int t = 0; t < 2; t++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
                if (f[i][j] == '#' || i == t * (n - 1) || (i != 0 && i != n - 1 && j % 2 == t))
                    printf("#");
                else
                    printf(".");
            printf("\n");
        }
        printf("\n");
    }



	return 0;
}




Measured memory_bytes: 1024
<?php
$arr = [];
for($i = 0; $i < 5; $i++) {
    fscanf(STDIN, '%d', $d);
    $arr[] = $d;
}
rsort($arr);
fscanf(STDIN, '%d', $k);
for($j = 0; $j < 5; $j++) {
    for($h = 1; $h < 5; $h++) {
        if($arr[$j] - $arr[$h] > $k) {
            echo ':(', PHP_EOL;
            exit;
        }
    }
}
echo 'Yay!', PHP_EOL;

Measured memory_bytes: 4728
#include <stdio.h>
int main(void)
{
    int H, W;
    int i, j;

    do{
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(i = 1; i <= H; i++){
            if(i % 2){
                for(j = 1; j <= W; j++){
                    if(j % 2) printf("#");
                    else      printf(".");
                }
            }
            else{
                for(j = 1; j <= W; j++){
                    if(j % 2) printf(".");
                    else      printf("#");
                }
            }
            putchar('\n');
        }
        putchar('\n');
        
    } while(H != 0 || W != 0);

    return 0;
}


Measured memory_bytes: 2048
n=int(input())
r=[[0 for i in range(n)]for j in range(n)]

for i in range(n):
    a=list(map(int,input().split()))
    y=a[1]
    if y!=0:
        for j in range(2,2+y):
            r[i][a[j]-1]=1

for i in range(n):
    for j in range(n):
        if j!=0:
            print(" ",end="")
        print(r[i][j],end="")
    print("\n",end="")


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

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

  if (S == "SUN") {
    cout << 7 << endl;
  }
  else if (S == "MON") {
    cout << 6 << endl;
  }
  else if (S == "TUE") {
    cout << 5 << endl;
  }
  else if (S == "WED") {
    cout << 4 << endl;
  }
  else if (S == "THU") {
    cout << 3 << endl;
  }
  else if (S == "FRI") {
    cout << 2 << endl;
  }
  else if (S == "SAT") {
    cout << 1 << endl;
  }
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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

    ll N;
    cin >> N;

    set <ll> s;
    rep (i, N) {
        ll A;
        cin >> A;
        s.insert(A);
    }

    if (N == s.size()) {
        YES;
    } else {
        NO;
    }
    return 0;
}

Measured memory_bytes: 9600
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

    int A, B;

    cin >> A >> B;

    if(A < 10 && A > 0) {
        if(B < 10 && B > 0) {
            cout << A * B << endl;
            return 0;
        }
    }

    cout << -1;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String []question = sc.nextLine().split(""); 

 		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < question.length; i++) {
          	String chr = question[i];
          	String target = "";
			if (chr.equals("?")) {
            	//最初の時
              	if (i == 0) {
                  if (i == question.length - 1) {
                    ans.append("D");
                  }
                  else if (question[i+1].equals("P")) {
                    ans.append("D");
                  }
                  else {
                    ans.append("P");
                  }
                }
              	//最後の時
              	else if ( i == question.length - 1) {
                    ans.append("D");
                }
              	else {
                  if (question[i-1].equals("P")) {
                    ans.append("D");
                  }
                  else if (question[i+1].equals("D")) {
                    ans.append("P");
                  }
                  else {
                    ans.append("D");
                  }
                }
            }
          	else {
            	ans.append(chr);
            }
        }
        System.out.println(ans);
    }
}

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int H, W, A, B;

int main(){
    cin >> H >> W >> A >> B;

    rep(i, H){
        rep(j, W){
            if (i < B && j < A) {
                cout << "0";
            } else if (i < B && j >= A) {
                cout << "1";
            } else if (i >= B && j < A) {
                cout << "1";
            } else if (i >= B && j >= A) {
                cout << "0";
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

signed main(){

    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;

    if(a+b >= c){
        cout << b + c << endl;
    }else{
        cout << b + b + a + 1;
    }

    //cout << ans << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
def f(n):
  a=set()
  i=2
  while i*i<=n:
    while n%i==0:
      a.add(i)
      n//=i
    i+=1
  if n>1: a.add(n)
  return a

while 1:
  a,b=map(int,input().split())
  if (a|b)==0: break
  a,b=f(a),f(b)
  print("a" if 2*max(a)-sum(a)>2*max(b)-sum(b) else "b")

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e2) + 9;
const int M = (1e4) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 100;
const int SQRT = BUCK+9;

const int MAX = 10000;
int a[N];

void solve()
{
	int n, i, cnt, ans = 0;
	cin >> n;
	fo(i,1,n+1)
		cin >> a[i];
	cnt = 1;
	fo(i,2,n+1)
	{
		if(a[i] != a[i-1])
		{
			ans += (cnt/2);
			cnt = 1;
		}
		else
			cnt++;
	}
	ans += (cnt/2);
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

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

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

vector<int> conn[51];
vector< vector< set<int> > > path;

bool visit[51][101];
void dfs(int p, int k, set<int>& st) {
	if(k==0) {
		st.insert(p);
		return;
	}
	if(visit[p][k]) return;
	visit[p][k] = true;

	for(int i=0; i<conn[p].size(); i++) {
		if( !visit[conn[p][i]][k-1] ) {
			dfs(conn[p][i], k-1, st);
		}
	}
}

int main() {
	int n,m,a,b,c;
	cin >> n >> m >> a >> b >> c;
	rep(i,m) {
		int u,v;
		cin >> u >> v;
		conn[u].push_back(v);
	}
	path.resize(n+1);
	for(int i=1; i<=n; i++) {
		path[i].resize(3);
		memset(visit, 0, sizeof(visit));
		dfs(i, a, path[i][0]);
		memset(visit, 0, sizeof(visit));
		dfs(i, b, path[i][1]);
		memset(visit, 0, sizeof(visit));
		dfs(i, c, path[i][2]);
	}

	bool changed = true;
	set<int> marked;
	marked.insert(n);
	int res = -1;
	int cnt[101]={};
	memset(cnt, -1, sizeof(cnt));
	cnt[n] = 0;
	int lp = 1;
	while(changed) {
		changed = false;
		vector<int> adds;
		for(int i=1; i<=n; i++) {
			if(marked.find(i) != marked.end()) continue;
			int mark = 0;
			rep(j,3) {
				bool found = false;
				for(set<int>::iterator it=path[i][j].begin(); it!=path[i][j].end(); it++) {
					if( marked.find(*it) != marked.end() ) {
						found = true;
					}
				}
				if(found) {
					mark++;
				}
			}
			if(mark == 3) {
				adds.push_back(i);
				changed = true;
				cnt[i] = lp;
			}
		}
		lp++;
		rep(i, adds.size()) {
			marked.insert(adds[i]);
		}
	}
	if(cnt[1] == -1)
		cout << "IMPOSSIBLE" << endl;
	else
		cout << cnt[1] << endl;

	return 0;
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    vector<int> nums(3);
    rep(i, 3) cin >> nums[i];

    sort(all(nums));
    reverse(all(nums));

    cout << nums[0] * 10 + nums[1] + nums[2] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//def   puts(a) printf("%s\n", a) 文字はこっち
//your code here!
//残り日数を後ろから優先度付きキューに入れると、最大値がすぐ出る
//優先度付きキュー　　最大値を求める場合
#define MAX_HEAP 100005
ll a[MAX_HEAP];
ll g_idx = -1;

ll PQ_pop(void){//最大値を取り出す ヒープからその最大値は削除される
    ll i, j, ret = a[0];
    if(g_idx<0){
        exit(1);
        puts("Queue has no data");
    }
    a[0] = a[g_idx--];
    i = 0;
    while(i*2+1<=g_idx){
        j = i*2+1;
        if(j+1<=g_idx && a[j]<a[j+1]){//min ならここを変更
            j++;
        }
        if(a[i] >= a[j]){//min ならここを変更
            break;
        }
        swap(a[i],a[j]);
        i = j;
    }
    return ret;
}

void PQ_push(ll elem){//ヒープに要素elemを追加する
    if(g_idx >= MAX_HEAP-1){
        exit(1);
        puts("Queue has no room");
    }
    a[++g_idx] = elem;
    ll x = g_idx;
    while(x>0 && a[(x-1)/2]<a[x]){//min ならここを変更
        swap(a[(x-1)/2], a[x]);
        x = (x-1)/2;
    }
}

typedef struct{
    ll day; ll sal;
}data;

int cmp(const void *a, const void *b){
    ll A=((data *)a)->day, B=((data *)b)->day;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート1,2,....9
}

int main(void){
    ll N, M, ans=0, idx=0;
    data d[MAX_HEAP];
    in2(N, M);
    rep(i, N) in2(d[i].day, d[i].sal);
    qsort(d, N, sizeof(data), cmp);
    rep(i, M){
        while(idx<N && d[idx].day<=i+1) PQ_push(d[idx++].sal);
        if(g_idx>-1) ans += PQ_pop();
    }
    put(ans);
    return 0;
}


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

int main()
{
    int in=0;
    
    while(cin >> in){
        
        int cnt=0;
        
        for (int n=0; n<10; n++) {
            for (int o=0; o<10; o++) {
                for (int p=0; p<10; p++) {
                    for (int q=0; q<10; q++) {
                        if(in == n+o+p+q) cnt++;
                    }
                }
            }
        }
        
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

using namespace std;

void output(const vector<int>& vec) {
  for(int i=0; i<vec.size(); i++) {
    if(i) cout << " ";
    cout << vec[i];
  }
  cout << endl;
}

int main() {
  
  int N; cin >> N;
  vector<int> vec(N);
  
  for(int i=0; i<N; i++) {
    cin >> vec[i];
  }
  
  output(vec);
  
  for(int j=1; j<N; j++) {
    int key = vec[j];
    int i;
    for(i = j-1; i >= 0 && key < vec[i]; i--) {
      vec[i+1] = vec[i];
    }
    vec[i+1] = key;
    output(vec);
  }
  
  return 0;
}

Measured memory_bytes: 1196
/* ##     ##  #######  # #  ######
    ##     ##  ##   ##  ###    ##
    ##     ##  ##    #  # #    ##
    #########  #######  # #    ## */
 
 #include <bits/stdc++.h>
 using namespace std;
 
 const long long int MODPRIME {1000000007};
 const long long int BABYMOD  {998244353};
 const long int MAXN = (long int) 1e6;
 
 typedef long long int ll;
 
 #define LUCILLE_IS_THIRSTY()       ios_base::sync_with_stdio(false); cin.tie(0)
 #define TESTCASES_ARE_THERE()      long int Test; cin>>Test; while(Test--)
 #define mems(arr,val)              memset((arr), val, sizeof((arr)))
 #define endl                       "\n"
 
 inline int readint() {
     int res = 0; char c = 0;
     while(!isdigit(c)) c = getchar();
     while(isdigit(c)) res = res*10+c-'0', c = getchar();
     return res;
 }
 
 
 void solveEach() {
     unsigned long long int a; long double b;
     cin >> a >> b;
     long double ans = a * b;
     unsigned long long int ans2 = (unsigned long long int) ans;
     cout << ans2 << endl;
     return;
 }
 
 signed main() {
 
     LUCILLE_IS_THIRSTY();

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     // freopen("output.txt", "w", stdout);
    // #endif 

    //  TESTCASES_ARE_THERE()
         solveEach();
 
     return 0;
 }
 /*
 THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
 SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
 (I Own the code if no link is provided here or I may have missed mentioning it)
 >>> DO NOT PLAGIARISE.
 TESTCASES:
 */

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> cc(26,1);
    rep(i,n) {
        char c = s[i];
        cc[(int)(c-'a')]++;
    }
    int ans = 1;
    rep(i,26) {
        ans *= cc[i];
        ans %= mod;
    } 
    ans--;
    cout << ans << endl;
    return 0;
}



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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 1005;
int a[N];
ll dp[N], b[N*N];

#define in(x) int x; cin >> x
#define ou(x) cout << x << endl

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	in(n); in(k);

	dp[0] = 0;
	REPU(i, 0, n) {
		cin >> a[i];
		dp[i + 1] = dp[i] + a[i];
	}

	int idx = 0;
	REPU(i, 0, n) REPU(j, i, n) {
		b[idx++] = dp[j + 1] - dp[i];
	}
	ll ans = 0;
	REPD(j, 40, -1) {
		int cnt = 0;
		REPU(i, 0, idx) if (b[i] >> j & 1) {
			cnt++;
		}
		if (cnt >= k) {
			ans |= 1LL << j;
			int nidx = 0;
			REPU(i, 0, idx) if (b[i] >> j & 1) {
				b[nidx++] = b[i];
			}
			idx = nidx;
		}
	}
	ou(ans);

	return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K & 1) {
    cout << B - A << endl;
  } else {
    cout << A - B << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

long long X[100000];
long long diff_Xs[100000];
long long sum_diff_Xs[100000];
int main(){
    int N;
    long long A;
    long long B;
    cin >> N >> A >> B;

    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    for(int i = 1; i < N; i++){
        diff_Xs[i - 1] = X[i] - X[i - 1];
    }
    sort(diff_Xs, diff_Xs + N - 1, greater <long long>());

    sum_diff_Xs[0] = diff_Xs[0];
    for(int i = 1; i < N - 1; i++){
        sum_diff_Xs[i] = sum_diff_Xs[i - 1] + diff_Xs[i];
    }
    
    long long ans = LLONG_MAX;
    long long total_dist = X[N - 1] - X[0];
    for(int teleport_num = 0; teleport_num < N ; teleport_num++){
        long long tmp_ans = teleport_num * B;
        tmp_ans += (total_dist - sum_diff_Xs[teleport_num - 1]) * A;
        ans = min(ans, tmp_ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
char s[100005];
int n;
int main(){
  cin>>s;
  n=strlen(s);
  int lim=n/2;
  int p=0;
  REP(i,n) if(s[i]=='p') ++p;
  cout<<lim-p<<endl;
  return 0;
}





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



int main(){
    int N;
  	cin >> N;
    int ans = 0;
    int count = 0;

    for(int i = 1;i<=N;i++){
      	count = 0;
        for(int j=1;j<=i;j++){
            if(i%j == 0){
                count++;
              	//cout << j << endl;
            }
        }
        if(count == 8 && i%2 == 1){
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main(){
    deque<char> dq;
    char c;
    while (cin >> c)
    {
        if (c=='1')
        {
            dq.push_back('1');
        }
        else if (c=='0')
        {
            dq.push_back('0');
        }
        else
        {
            if(dq.empty())
            {
                continue;
            }
            else
            {
                dq.pop_back();
            }
            
        }
    }
    while (!dq.empty())
    {
        cout << dq.front();
        dq.pop_front();
    }
    cout << endl;
}

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

int h,w,ch,cw,dh,dw;
char g[1005][1005];
int dis[1005][1005];
int dx[]={-1,0,1,0},dy[]={0,1,0,-1};

int main(){

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

    cin>>h>>w;
    cin>>ch>>cw;
    cin>>dh>>dw;
    for(int i=1;i<=h;i++){
        cin>>g[i]+1;
    }
    deque<pair<int,int>> q;
    memset(dis,0x3f,sizeof(dis));
    dis[ch][cw]=0;
    q.emplace_back(ch,cw);
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;
        q.pop_front();
        for(int d=0;d<4;d++){
            int nx=dx[d]+x,ny=dy[d]+y;
            if(nx>=1&&ny>=1&&nx<=h&&ny<=w&&dis[nx][ny]>dis[x][y]&&g[nx][ny]=='.'){
                dis[nx][ny]=dis[x][y];
                q.emplace_front(nx,ny);
            }
        }
        for(int nx=x-2;nx<=x+2;nx++)for(int ny=y-2;ny<=y+2;ny++){
            if(nx>=1&&ny>=1&&nx<=h&&ny<=w&&dis[nx][ny]>dis[x][y]+1&&g[nx][ny]=='.'){
                dis[nx][ny]=dis[x][y]+1;
                q.emplace_back(nx,ny);
            }
        }
    }
    cout<<(dis[dh][dw]==0x3f3f3f3f?-1:dis[dh][dw])<<endl;

    return 0;
}

Measured memory_bytes: 8476
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;

int main(){
	int n,k;
	cin>>n>>k;
	if(n >= 10)
		cout<<k<<"\n";
	else{
		cout<<k + 100*(10-n) <<"\n";
	}
	return 0;
}

Measured memory_bytes: 256