akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll inq(ll x, ll y, ll mod)
{
    if (y == 0) return 1;
    ll l = inq(x, y / 2, mod);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

ll rev(ll x, ll mod)
{
    return inq(x, mod - 2, mod);
}

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    n--;
    for (int j = 0; j <= n; j++)
    {
        ll l = a - j * d + (n - j) * c;
        ll r = a - j * c + (n - j) * d;
        if (l <= b && b <= r)
        {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

Measured memory_bytes: 256
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=6010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

string f[N],s,ans;
int n,a[N],b[N],id[N],p[N];
int find (int x)
{
	for (int i=1; i<=n>>1; i++)
		if (min (a[i],b[i])> x) return i;
	return n/2+1;
}
string get (int l,int r)
{
	string g="";
	for (int i=l; i<=r; i++)
		if (id[i]>=id[l]) g+=s[i];
	return g;
}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
    sc(n); n<<=1;
	cin>>s;
	for (int i=0; i< n; i++)
		if (s[i]=='a') a[++a[0]]=i,id[i]=a[0];
		else b[++b[0]]=i,id[i]=b[0];
	for (int i=n>>1; i>=1; i--)
	{
		f[i]=f[i+1];
		if (a[i]< b[i])
		{
			chkmax (f[i],"ab"+f[find (b[i])]);
		}
		else
		{
			int nx=a[i];
			for (int j=b[i]; j<=nx; j++)
				if (s[j]=='b') chkmax (nx,a[id[j]]);
			chkmax (f[i],get (b[i],nx)+f[find (nx)]);
		}
		chkmax (ans,f[i]);
		//cout<<i<<' '<<f[i]<<endl;
	}
	cout<<ans;


    return 0;
}

Measured memory_bytes: 14720
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   char c;
   cin >> c;
   if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')cout << "vowel";
   else cout << "consonant" << endl;
}


    

Measured memory_bytes: 3608
n, w = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
sumv = 0
for i in range(n):
    sumv += p[i][1]
p.insert(0, [0, 0])
inf = w + 1
dp = [[inf for _ in range(sumv + 1)] for _ in range(n + 1)]
for i in range(n + 1):
    dp[i][0] = 0
for i in range(1, n + 1):
    m = 0
    for j in range(1, sumv + 1):
        if j >= p[i][1]:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - p[i][1]] + p[i][0])
        else:
            dp[i][j] = dp[i - 1][j]
for i in range(sumv, -1, -1):
    if not dp[n][i] == inf:
        print(i)
        exit()

Measured memory_bytes: 170992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;

int main() {
  std::cin >> S;

  ll ans = 0;

  rep( i, S.size()/2 ) {
    ans += S[i] != S[S.size()-1-i];
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int d, c;
  cin >> d >> c;
  cout << d * c << endl;

  return 0;
}


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

const int NMAX = 1e6 + 5;

int n;
int a[NMAX];
int b[NMAX];
bool am;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        char x; cin >> x;
        a[i] = x - '1';
        if (a[i] == 1)
            am = 1;
        b[a[i]] += (((n - 1) & i) == i);
    }

    if (b[1] % 2 == 1) // imi da impar
        cout << 1;
    else if (!am && (b[2] % 2 == 1)) // nu am 1 si nici n-o sa am
        cout << 2;
    else // am 1
        cout << 0;


    return 0;
}


Measured memory_bytes: 6016
N, Q = map(int, input().split())

S = input()
d = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        d[i+1] += 1
for i in range(1,N):
    d[i] += d[i-1]

for i in range(Q):
    l, r = map(int, input().split())
    l, r = l-1, r-1

    print(d[r] - d[l])

Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
int a[100005];
int main()
{

    ll n,res=0;
    cin>>n;
    res=n*(n-1)/2;
    cout<<res<<endl;
//    int n;
//    cin>>n;

    return 0;
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<tuple>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int n;
	cin >> n;

	int a[n],b[n],c[n];
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> b[i];
	for(int i=0;i<n;i++) cin >> c[i];

	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);

	int la[n],lec[n];
	int ida=0,idc=0;
	for(int i=0;i<n;i++){
		while(ida < n && a[ida] < b[i]) ida++;
		la[i]=ida;
		while(idc < n && c[idc] <= b[i]) idc++;
		lec[i]=idc;
	}
	for(int i=n-1;i>=0;i--){
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans += 1LL*la[i]*(n-lec[i]);
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll POW3(ll x,ll n,ll m){
  x%=m;
  if(n==0)return 1;
  if(n%2==0)return POW3(x*x,n/2,m)%m;
  return x*POW3(x,n-1,m)%m;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)//xのm進数でのx^nの位の値
{
  return x%POW2(m,n+1)/POW2(m,n);
}

ll keta(ll x,ll n)//xのn進数での桁数
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)//x!のnで割り切れる回数
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)//xのnで割り切れる回数
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

ll SGS(ll x,ll y, ll m)//1+x+…+x^(y-1)をmで割った余り
{
  if(y==0)return 0;
  if(y%2==0){
    return (1+POW3(x,y/2,m))*SGS(x,y/2,m)%m;
  }
  return (1+x*SGS(x,y-1,m))%m;
}

ll SSGS(ll x,ll y,ll m)//Σ[k=1→y](1+x+…+x^(k-1))をmで割った余り
{
  if(y==0)return 0;
  if(y==1)return 1;
  if(y%2==0){
    return (SSGS(x,y/2,m)*(POW3(x,y/2,m)+1)%m+SGS(x,y/2,m)*y/2%m)%m;
  }
  return (SSGS(x,y-1,m)*x%m+y)%m;
}

int main()
{
  string s;
  ll a=0;
  cin >> s;
  if(s[0]==s[s.length()-1])a++;
  if((s.length()+a)%2!=0)printf("First");
  else printf("Second");
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <utility>
#include <functional>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <deque>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

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

	while (n != 0) {
		// カードの山を作成
		deque<int> card(n);
		rep(i, 0, n) card.push_front(i + 1);
		// シャッフル
		pair<deque<int>, deque<int>> pa;
		rep(i, 0, r) {
			int p, c;
			cin >> p >> c;
			// cardの上からp-1枚をとってpa.firstに入れる
			rep(i, 0, p - 1) {
				pa.first.pb(card.front());
				card.pop_front();
			}
			// cardの上からc枚をとってpa.secondに入れる
			rep(i, 0, c) {
				pa.second.pb(card.front());
				card.pop_front();
			}
			// pa.firstの末尾をcardの先頭に入れる
			while(!pa.first.empty()) {
				card.push_front(pa.first.back());
				pa.first.pop_back();
			}
			// pa.secondの末尾をcardの先頭に入れる
			while(!pa.second.empty()){
				card.push_front(pa.second.back());
				pa.second.pop_back();
			}
		}

		cout << card.front() << endl;

		cin >> n >> r;
	}

	return 0;
}


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

int main(){
    string s;
    cin >> s;
    int ans=1000000000;
    for(int i=0;i<s.size()-2;i++){
        int k=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        if(abs(k-753)<ans)ans=abs(k-753);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long n;
  scanf("%ld",&n);
  
  char s[n][10];
  for(int i = 0;i < n;i ++){
    scanf("%s",s[i]);
  }
  
  long ninn[5] = {0,0,0,0,0};
  for(int i = 0;i < n;i ++){
    if(s[i][0] == 'M'){
      ninn[0] ++;
    }
    else if(s[i][0] == 'A'){
      ninn[1] ++;
    }
    else if(s[i][0] == 'R'){
      ninn[2] ++;
    }
    else if(s[i][0] == 'C'){
      ninn[3] ++;
    }
    else if(s[i][0] == 'H'){
      ninn[4] ++;
    }
  }
  
  long long ans = 0;
  int l = 0;
  for(int i = 0;i < 5;i ++){
    for(int j = i + 1;j < 5;j ++){
      for(int k = j + 1;k < 5;k ++){
        ans += ninn[i] * ninn[j] * ninn[k];
      }
    }
  }
  printf("%lld",ans);
  
  return 0;
}


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

void fnInput(vector<int>& rvnNode, vector<vector<int>>& rvvnEdge)
{
  int nNodeSiz, nEdgeSiz;
  cin >> nNodeSiz>> nEdgeSiz;
  rvnNode.resize(nNodeSiz);
//rvvnEdge.resize(nNodeSiz, vector<int>(nNodeSiz, 0));
  rvvnEdge.resize(nNodeSiz);   //２次元目  push_back

  for (int& rnNode : rvnNode)
    cin >> rnNode;

  for (int i = 0; i <= nEdgeSiz; i++)
  {
    int nLeft, nRigt;
    cin >> nLeft >> nRigt;
    rvvnEdge[ nLeft - 1 ].push_back( nRigt - 1 );
    rvvnEdge[ nRigt - 1 ].push_back( nLeft - 1 );
  }
}

int fnPeakCnt(const vector<int> cnrvnNode, const vector<vector<int>>& cnrvvnEdge)
{
  int nPeakCnt = 0;

  for (int nBgn = 0; nBgn < cnrvnNode.size(); nBgn++)
  {
    bool bPeak = true;

    for (int nEnd : cnrvvnEdge[nBgn])
      if (cnrvnNode[nBgn] <= cnrvnNode[nEnd])
      {
        bPeak =false;
        break;
      }

    if (bPeak) nPeakCnt++;
  }
  return nPeakCnt;
}
  
int main()
{
  vector<int> vnNode;
  vector<vector<int>> vvnEdge;

  fnInput(vnNode, vvnEdge);
  cout << fnPeakCnt(vnNode, vvnEdge) << endl;

  return 0;
}

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

int main(){
  int N,t;
  string S;
  cin >> N;
  vector<pair<string,int>> vec(N),vec2(N);
  for(int i=0;i<N;i++){
    cin >> S >> t;
    t=100-t;
    vec[i]=make_pair(S,t);
    vec2[i]=make_pair(S,t);
  }
  sort(vec.begin(),vec.end());
  for(int j=0;j<N;j++){
    for(int k=0;k<N;k++){
      if(vec[j]==vec2[k])
        cout << k+1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define llint long long
#define mod 10000

using namespace std;

string a, b;
llint m;
llint beki[505];
llint dp[505][505][10][2][2];

llint calc(string &s)
{
	int n = s.size();
	
	llint ret = 0;
	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < m; j++){
			for(int k = 0; k < 10; k++){
				for(int l = 0; l < 2; l++){
					for(int b = 0; b < 2; b++){
						dp[i][j][k][l][b] = 0;
					}
				}
			}
		}
	}
	for(int i = n-1; i >= 0; i--){
		for(int j = 1; j <= 9; j++){
			if(i == n-1 && j > s[i]-'0') continue;
			for(int k = 0; k < 2; k++){
				if(i == 0 && k == 1) continue;
				int l = 1;
				if(i == n-1 && j == s[i]-'0') l = 0;
				dp[i][(j*beki[i])%m][j][l][k] = 1;
			}
		}
	}
	for(int i = n-1; i > 0; i--){
		for(int j = 0; j < m; j++){
			for(int k = 0; k < 10; k++){
				for(int l = 0; l < 2; l++){
					for(int b = 0; b < 2; b++){
						for(int nk = 0; nk < 10; nk++){
							if(b == 0 && k >= nk) continue;
							if(b == 1 && k <= nk) continue;
							if(l == 0 && nk > s[i-1]-'0') continue;
							int nl = l;
							if(nk < s[i-1]-'0') nl = 1;
							(dp[i-1][(j+nk*beki[i-1])%m][nk][nl][1-b] += dp[i][j][k][l][b]) %= mod;
						}
					}
				}
			}
		}
	}
	for(int k = 0; k < 10; k++){
		for(int l = 0; l < 2; l++){
			for(int b = 0; b < 2; b++){
				ret += dp[0][0][k][l][b], ret %= mod;
			}
		}
	}
	
	return ret;
}

int main(void)
{
	cin >> a >> b >> m;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	
	beki[0] = 1;
	for(int i = 1; i < 505; i++) beki[i] = beki[i-1] * 10 % m;
	
	llint ans = (calc(b) - calc(a) + mod) % mod;
	
	llint sum = 0;
	for(int i = 0; i < a.size(); i++) sum += beki[i]*(a[i]-'0'), sum %= m;
	
	bool flag = true;
	for(int i = 1; i < a.size()-1; i++){
		int x = a[i-1]-'0', y = a[i]-'0', z = a[i+1]-'0';
		if((y-x)*(z-y) >= 0) flag = false;
	}
	
	if(flag && sum == 0) ans++, ans %= mod;
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 81972
import numpy as np
N = int(input())
list_all =np.zeros((9,9))
num_list = [str(i) for i in range(1,N+1)]
overlap = [0 for i in range(9)]
for i in range(N):
    head = int(num_list[i][0])
    length = len(num_list[i])
    tail = int(num_list[i][length -1])
    if (head == 0) or (tail == 0):
        continue
    list_all[head-1,tail -1] += 1
sum1 = 0
for i in range(9):
    for j in range(i+1):
        if i ==j:
            sum1 += (list_all[i,j] * list_all[j,i])
        else:
            sum1 += (list_all[i,j] * list_all[j,i]) *2
print(int(sum1))

Measured memory_bytes: 40972
#include <iostream>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
#include <climits>
#include <iomanip>

#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rforr(i, t, n) (int i = n-1; i>=t; --i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1024;

//STRUCTS


//OPERATORS


//GLOBALS


//FUNCTIONS


//PROBLEM: 
//LINK: 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
		int n;
		cin >> n;
		string s;
		cin >> s;
		int l = 0;
		int slimes = 1;
		while(l<s.size()-1)
		{
			if (s[l] != s[l+1]) slimes++;
			l++;
		}
		cout << slimes;



	return 0;
}

Measured memory_bytes: 512
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def main():
    s = S()
    N = len(s)

    R = [0] * N
    R[0] = 1
    L = [0] * N
    L[-1] = 1

    for i in range(1,N):
        if s[i] == "R":
            R[i] = R[i-1] + 1
            R[i-1] = 0
    for i in range(N-2,-1,-1):
        if s[i] == "L":
            L[i] = L[i+1] + 1
            L[i+1] = 0

    ans = [0]*N
    for i in range(N-1):
        if R[i] > 0:
            ans[i] = (R[i]+1)//2 + L[i+1]//2
    for i in range(1,N):
        if L[i] > 0:
            ans[i] = (L[i]+1)//2 + R[i-1]//2

    return(" ".join(map(str,ans)))
    

if __name__ == "__main__":
    print(main())


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

int main(){
  string n;
  cin>>n;
  ll a=0;
  for(int i=0;i<n.size();i++){
    a+=(n[i]-'0');
    a%=9;
  }
  cout<<(a==0 ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(void)
{
	int x, y,s;
	cin >> x >> y;
	s = x + y;
	if (s >= 10)
	{
		cout << "error";
	}
	else
	{
		cout << s;
	}
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val n, x = Scanner.nextDouble

	pw.println(scala.math.ceil(n / x).toInt * Scanner.nextInt)
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54624
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
int n;
int main(){
	 cin>>n; 
	 for(int i=1;i<=n;i++){
	 	if(n%i==0)ans+=n/i-1;
	 	else ans+=n/i;
	 	//cout<<ans<<endl;
	 }
	 cout<<ans<<endl;
	 return 0;
} 

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
  int n, i, m=0, s=0;
  cin >> n;
  int a[n];
  for(i=0; i<n; i++){
    cin >> a[i];
    if(a[i]>m){
      s=m;
      m=a[i];
    }
    else if(a[i]>s){
      s=a[i];
    }
  }
    for(i=0; i<n; i++){
      if(a[i]==m) cout << s <<endl;
      else cout << m <<endl;
    }
  return 0;
}

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

int main(){
  string str, s1, s2;
  int m, h;
  while(1){
    cin >> str >> m;
    if(str == "-") break;
    for(int i = 0; i < m; i++){
      cin >> h;
      s1 = str.substr(0, h);
      s2 = str.substr(h, str.size());
      str = s2 + s1;
    }
    cout << str << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3184
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
void print(int arr[],int n){
	for(int i=0;i<n;++i)
	cout<<arr[i]<<" ";
	cout<<endl;
}
int fre[1000000];
int32_t main()
{
	string s;
	cin>>s;
	for(int i=0;i<sz(s);++i){
		for(int j=i;j<sz(s);++j){
			string ss=s.substr(0,i);
			string sss=s.substr(j,sz(s)-j);
			ss+=sss;
			//cout<<ss<<endl;
			if(ss=="keyence"){
				cout<<"YES";
				return 0;
			}
		}
	}
	cout<<"NO\n";	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 82;
int A[N];
int main() {
	double d,t,s;
	cin >> d >> t >> s;
	double t2 = d/s;
	if (t2<=t)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3740
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    s=sum(A)
    for i in range(n-1):
        A[i+1]+=A[i]
    ans=INF
    for i in range(n-1):
        ans=min(ans,abs(A[i]-(s-A[i])))
    print(ans)
resolve()

Measured memory_bytes: 82468
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var tbl = new int[2][];
        for (int i = 0; i < 2; i++) {
            tbl[i] = ToIntArray(input.ReadLine(), n);
        }

        var score = new int[2][];
        score[0] = new int[n];
        score[1] = new int[n];

        score[0][0] = tbl[0][0];

        for(int i=1; i<n; i++) {
            score[0][i] = score[0][i - 1] + tbl[0][i];
        }

        score[1][0] = score[0][0] + tbl[1][0];
        for (int i = 1; i < n; i++) {
            score[1][i] = Math.Max(score[0][i], score[1][i-1]) + tbl[1][i];
        }

        return score[1][n - 1];
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13268
import java.util.Scanner ;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		X -= A;
		int result=0;
		for(int i=0;X-i*B>=0;i++){
			result = X-i*B;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,x;
	scanf("%d %d",&x,&n);
	set<int> a;
	while(n--)
	{
		scanf("%d",&i);
		a.insert(i);
	}
	int k=0;
	while(1)
	{
		if(a.find(x-k)==a.end())
		{
			printf("%d",x-k);
			return 0;
		}
		if(a.find(x+k)==a.end())
		{
			printf("%d",x+k);
			return 0;
		}
		k++;
	}
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;

int main(){
    ll N;
    cin >> N;
    vl A(N + 1);
    vl B(N);
    for(ll i = 0; i < N + 1; i++){
        cin >> A.at(i);
    }
    for(ll i = 0; i < N; i++){
        cin >> B.at(i);
    }
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        if(A.at(i) - B.at(i) < 0){
            if(A.at(i + 1) - (B.at(i) - A.at(i)) < 0){
                ans += (A.at(i) + A.at(i + 1));
                A.at(i + 1) = 0;
            }
            else{
                A.at(i + 1) -= (B.at(i) - A.at(i));
                ans += B.at(i);
            }
        }
        else{
            ans += B.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#define  LL long long
using namespace std;

int n, k, a[100005], pos, minn=10000000;
LL ans;

int main()
{
    scanf("%d%d", &n, &k);
    for(int i=1; i<n; i+=k) ans++, i--;
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define floop(i,a,b) for (int i=(a);i<(b);i++)
#define rloop(i,a,b) for (int i=(a);i>=(b);i--)
#define floopeq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
void dfs(int i,int j,int n,int m,vector<vector<char>>a,vector<vector<bool>>&vis)
{
    vis[i][j]=1;
    if(i<(n-1) && vis[i+1][j]==0 && (a[i+1][j]!='#'))
    {
        dfs(i+1,j,n,m,a,vis);
    }
    if(i>0 && vis[i-1][j]==0 &&(a[i-1][j]!='#'))
    {
        dfs(i-1,j,n,m,a,vis);
    }
    if(j<(m-1) && vis[i][j+1]==0 && (a[i][j+1]!='#'))
    {
        dfs(i,j+1,n,m,a,vis);
    }
    if(j>0 && vis[i][j-1]==0 && ((a[i][j-1]!='#')))
    {
        dfs(i,j-1,n,m,a,vis);
    }
}
void solve()
{
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int al = (60*(h2-h1)) + (m2-m1);
	cout<<al-k<<endl;
}
int main() 
{ 
   
    int t;
    t=1;
    while(t--){
    	solve();
    }
    return 0; 

} 


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,k;
    cin>>n>>k;
  ll a[1000000];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  ll s[1000000];
  s[0]=0;
  s[1]=abs(a[1]-a[0]);
  for(ll i=1;i<n;i++)
  {
    s[i]=s[i-1]+abs(a[i]-a[i-1]);
	for(ll j=2;j<=min(k,i);j++)
      s[i]=min(s[i-j]+abs(a[i]-a[i-j]),s[i]);
  }
    cout<<s[n-1];
 return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <math.h>
#include <stdio.h>

#define INF 1'000'000'007

typedef long long ll;

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  if (abs(N - M) > 1) {
    printf("0\n");
  } else {
    ll a = 1;
    for (ll i = 2; i <= N; ++i) {
      a = (a * i) % INF;
    }
    ll b = 1;
    for (ll i = 2; i <= M; ++i) {
      b = (b * i) % INF;
    }
    printf("%lld\n", (a * b * (1 + (N == M))) % INF);
  }
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    ll count = 0;
    for (int i = 0; i < s.size() / 2;i++)
    {
        if(s[i]!= s[s.size()-i-1])
        {
            count++;
        }
    }
    cout << count;
}

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

#define rep(i,n) for(i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;

signed main(){
 int n,h,w;
  cin>>n>>h>>w;
  int ans=(n-h+1)*(n-w+1);
  print(ans);
  
  return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(2));
  dp[0][0] = 1;
  const int64_t mod = 1'000'000'007;

  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      dp[i + 1][0] = dp[i][0];
      dp[i + 1][1] = dp[i][1] * 3 % mod;
    } else {
      dp[i + 1][0] = dp[i][0] * 2 % mod;
      dp[i + 1][1] = (dp[i][0] + dp[i][1] * 3) % mod;
    }
  }
  cout << (dp[n][0] + dp[n][1]) % mod << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, Q;
  int A;
  cin >> N >> K >> Q;
  vector<int> points(N);
  for (int i = 0; i < Q; i++){
    cin >> A;
    A--;
    points.at(A)++;
  }
  
  for (int i = 0; i < N; i++){
    if (points.at(i) + K-Q > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    int sum = 0, ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'I') ans = max(ans, ++sum);
        else --sum;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//  Copyright © 2018 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long ll;

int N, M;
int ans[MAX];
bool vis[MAX];
vector < int > ady[MAX];

void bfs( int ini )
{
    queue < int > q;
    q.push( ini );
    vis[ini] = 1;
    ans[ini] = 1;
    while( ! q.empty() )
    {
        int x = q.front();
        q.pop();
        for( auto v : ady[x] )
        {
            if( vis[v] )
                continue;
            vis[v] = 1;
            ans[v] = x;
            q.push( v );
        }
    }
}

int main()
{
    optimiza_io
    cin >> N >> M;
    while( M -- ) {
        int u, v;
        cin >> u >> v;
        ady[u].push_back( v );
        ady[v].push_back( u );
    }
    bfs( 1 );
    for( int i = 1; i <= N; i ++ )
        if( ! vis[i] ) {
            cout << "No\n";
            exit(0);
        }
    cout << "Yes\n";
    for( int i = 2; i <= N; i ++ )
        cout << ans[i] << "\n";
    return 0;
}

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

const int N = 1e5+5, M = 1e9+7;
ll p[N];

ll tot(int n) {
	for(int i = 0; i < n; ++i)
		scanf("%lld",p+i);
	ll ans = 0;
	for(int i = 1; i < n; ++i)
		ans = (ans + 1LL * i * (n-i) % M * (p[i]-p[i-1])) % M;
	return ans;
}

int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%lld\n",tot(n) * tot(m) % M);
}

Measured memory_bytes: 1024
s=input().split()
h,w=int(s[0]),int(s[1])
n=int(input())
s=input().split()
l=[int(s[i]) for i in range(n)]
res=[]
for i in range(1,n+1):
    res+=[i]*l[i-1]
for i in range(h):
    ll=res[i*w:i*w+w]
    if i%2==1:
        ll=ll[-1::-1]
    for j in ll[:-1]:
        print(j,end=" ")
    print(ll[-1])

Measured memory_bytes: 43880
#include <stdio.h>
int main(void){
// Your code here!
    int a,b;

    scanf("%d %d", &a, &b);
     -1000 <= a, b <= 1000;
    if (a > b) printf ("a > b\n");
    if (a < b) printf ("a < b\n");
    else if (a == b)printf ("a == b\n");
    return 0;
}



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

w_accumulate = [0]
e_accumulate = [0]

for i in range(1, N):
    w_accumulate.append(w_accumulate[-1] + (S[i - 1] == "W"))
    e_accumulate.append(e_accumulate[-1] + (S[-i] == "E"))

e_accumulate.reverse()

print(min([c1 + c2 for c1, c2 in zip(w_accumulate, e_accumulate)]))


Measured memory_bytes: 39256
s = ""
while True:
    try:
        s += input().lower()
    except:
        break

Ans = [0] * 26

for x in range(len(s)):
    if ord(s[x:x+1]) -97 >=0 and ord(s[x:x+1]) -97 <=26:
        Ans[ord(s[x:x+1]) -97] +=1

for x in range(26):
    print(chr(x+97) + " : " + str(*Ans[x:x+1]))





Measured memory_bytes: 5564
#include <cstdio>
#include <string>

using namespace std;

int main() {
    char buf[16];
    scanf("%s", buf);
    string s(buf), t;
    for (char c: s) {
        switch (c) {
            case 'B':
                if (!t.empty())
                    t.pop_back();

                break;
            default:
                t.push_back(c);
        }
    }

    printf("%s\n", t.c_str());
    return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int p[n];; 
	for(int i = 1; i <= n; i++){
		cin >> p[i];
	}
	int min_val = n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(min_val >= p[i]) ans++;
		min_val = min(min_val,p[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import math
import os
import sys

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

SX, SY, TX, TY = list(map(int, sys.stdin.readline().split()))
N = int(sys.stdin.readline())
X, Y, R = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

X = np.concatenate([X, [SX, TX]])
Y = np.concatenate([Y, [SY, TY]])
R = np.concatenate([R, [0, 0]])

S = N
T = N + 1
XI, XJ = np.meshgrid(X, X)
YI, YJ = np.meshgrid(Y, Y)
RI, RJ = np.meshgrid(R, R)
V, U = np.meshgrid(np.arange(N + 2), np.arange(N + 2))
D = np.maximum(0, np.sqrt(np.power(XI - XJ, 2) + np.power(YI - YJ, 2)) - RI - RJ)

ret = dijkstra(csr_matrix((D.ravel(), (U.ravel(), V.ravel()))), directed=False, indices=S)
print(ret[T])


Measured memory_bytes: 116236
N = int(input())
S = [str(input())[0] for i in range(N)]
S = ''.join(S)
count = []
for char in 'MARCH':
    tmp = S.count(char)
    if tmp != 0:
        count.append(tmp)
ans = 0
for i in range(1<<len(count)):
    if bin(i).count('1') == 3:
        tmp = 1
        for j in range(len(count)):
            if i>>j & 1 == 1:
                tmp *= count[j]
        ans += tmp
print(ans)

Measured memory_bytes: 3864
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <iterator>
#include <sstream>
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
#define modmod 1000000007
#define modddd 998244353

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

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

    if(S.length()>9){
        puts("NO");
        return 0;
    }

    if(S[0]!='A'){
        S = "A" + S;
    }
    if(S[S.length()-1]!='A'){
        S = S + "A";
    }

    bool isR = false;

    for(int i = 0; i < S.length(); i++){
        if(i!=S.length()-1 and S[i]=='A' and S[i+1]=='A'){
            puts("NO");
            return 0;
        }
        if(S[1]!='K'){
            puts("NO");
            return 0;
        }
        if(S[i]=='K' and S[i+1]!='I'){
            puts("NO");
            return 0;
        }
        if(S[i]=='I'){
            if(S[i+1]!='H'){
                puts("NO");
                return 0;
            }
        }
        if(S[i]=='H'){
            if(S[i+1]!='A' and S[i+1]!='B'){
                puts("NO");
                return 0;
            }
        }
        if(S[i]=='B'){
            if(S[i+1]!='A' and S[i+1]!='R'){
                puts("NO");
                return 0;
            }
        }
        if(S[i]=='R'){
            isR = true;
            if(S[i+1]!='A'){
                puts("NO");
                return 0;
            }
        }
    }

    if(isR){
        puts("YES");
    }else{
        puts("NO");
    }

    return 0;

}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    for(int i = 0;;i++){
        int a,b,c;
        char op;
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?'){
            break;
        }
        if(op == '+'){
            c = a + b;
        }
        if(op == '-'){
            c = a - b;
        }
        if(op == '*'){
            c = a * b;
        }
        if(op == '/'){
            c = a / b;
        }
        printf("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll k,q,n,x,m,D{},p,ans;
    in>>k>>q;
    vector<ll> d(k);
    for(auto&i:d) in>>i,D+=i;
    fr(_,q){
        in>>n>>x>>m;
        p=0;
        fr(i,k) p+=d[i]%m;
        x%=m;
        x+=p*((n-1)/k);
        fr(i,(n-1)%k) x+=d[i]%m;
        ans=n-1-x/m;
        fr(i,k) if(!(d[i]%m)) ans-=(n-i-2+k)/k;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a,b;
void solve(){
    cin>>a>>b;
    if(a>b)swap(a,b);
    for(int i=1;i<=b;++i){
        printf("%d",a);
    }
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


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

	rep(i, s.size()) {
		s[i] = 'x';
	}

	cout << s << endl;
}

Measured memory_bytes: 256
A,B = map(int,input().split())

if A > B:
    if (A-B)%2 != 0:
        print("IMPOSSIBLE")
    else:
        print(A - ((A-B)//2))
else:
    if (B-A)%2 != 0:
        print("IMPOSSIBLE")
    else:
        print(B - ((B-A)//2))

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

using namespace std;

int main() {
  string s;
  int a, b;
  cin >> a >> s >> b;
  if (s == "+"){
    cout << (a + b) << "\n";
  } else if (s == "-") {
    cout << (a - b) << "\n";
  }
}


Measured memory_bytes: 256
import math
import itertools

k = int(input())
lst = [i for i in range(1,k+1)]
itr = itertools.combinations_with_replacement(lst, 3)
ans = 0

for i in itr:
  st = set(i)
  num = len(st)
  if num == 1:
    ans += i[0]
  elif num == 2:
    a,b = st
    ans += math.gcd(a,b) * 3
  else:
    ans += math.gcd(math.gcd(i[0],i[1]), i[2]) * 6

print(ans)

Measured memory_bytes: 9124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[400010];//適宜変える(ecnt)
	int id[200010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

ll q;
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld%lld",&n,&q);
	rep(i,0,n-1){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
	}
	g.vcnt=n;
	g.ecnt=2*n-2;
	qsort(g.e,g.ecnt,sizeof(E),esort);
//	qsort(g.e,g.ecnt,sizeof(E),csort);
//	makeinvedge();

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


ll ans[200010];
ll x[200010];
//dfs
ll dfs(int v,int pre,ll sum){
	ans[v]=sum+=x[v];	
	rep(i,g.id[v],g.id[v+1]){
		if(g.e[i].g!=pre){
			dfs(g.e[i].g,v,sum);
		}
	}
}

int main(){
	readgraph();
	rep(i,0,q){
		ll p,xx;
		scanf("%lld%lld",&p,&xx);
		x[p-1]+=xx;
	}
	dfs(0,-1,0);
	rep(i,0,g.vcnt)printf("%lld ",ans[i]);
}

Measured memory_bytes: 27868
object Main extends App{
  import scala.io.StdIn.readLine
  import scala.math._
  case class Segment(left:Int, right:Int){
    var isUsed:Boolean = false
  }
  val n = readLine().toInt
  val segments = Array.tabulate(n){_ ⇒ val Array(l, r) = readLine().split(' ').map(_.toInt)
    Segment(l, r)
  }
  val leftSegment = segments.sortBy{_.right}
  val rightSegment = segments.sortBy{-_.left}
  var leftFirst:Long = 0
  if (leftSegment(0).right < 0)
    leftFirst = solve(leftSegment, rightSegment, 1, 0, leftSegment(0).right)
  var rightFirst = 0l
  if (rightSegment(0).left > 0)
    rightFirst = solve(leftSegment, rightSegment, 0, 1, rightSegment(0).left)
  println(max(leftFirst, rightFirst))
  def solve(leftSegment: Array[Segment], rightSegment:Array[Segment], leftIdx:Int, rightIdx:Int, defPos:Int):Long = {
    var sum:Long = abs(defPos)
    var pos = defPos
    var left = leftIdx
    var right = rightIdx
    for (_ ← 1 until leftSegment.size){
      if (leftSegment(left).right < pos){
        sum += pos - leftSegment(left).right
        pos = leftSegment(left).right
        left += 1
      }else if (pos < rightSegment(right).left){
        sum += rightSegment(right).left - pos
        pos = rightSegment(right).left
        right += 1
      }
    }
    return sum + abs(pos)
  }
}


Measured memory_bytes: 83756
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
using namespace std;

const int N_MAX = 100001;
long long N, X, x[N_MAX];

long long Euclid(long long a, long long b) {
	if (a < b) swap(a, b);
	long long r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main() {
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		x[i] = abs(x[i] - X);
	}
	sort(x,x+N);
	long long ans = x[0];
	for (int i = 0; i < N; i++) {
		if (x[i] % ans != 0) {
			ans = Euclid(x[i], ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < 1 << 3; i++) {
        int ans = S[0] - '0';
        for (int j = 0; j < 3; j++) {
            if ((i >> j) & 1)ans += S[1 + j] - '0';
            else ans -= S[1 + j] - '0';
        }
        if (ans == 7) {
            cout << S[0] << (((i >> 0) & 1) ? "+" : "-") << S[1] << (((i >> 1) & 1) ? "+" : "-") << S[2] << (((i >> 2) & 1) ? "+" : "-") << S[3] << "=7" << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = 0
b = 0
s = 10 ** 5
for i in range(1, N):
	a = sum(int(j) for j in str(i))
	b = sum(int(k) for k in str(N - i))
	if s >= a + b:
		s = a + b
print(s)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;

int main() {
    int n, m;
    cin >> n >> m;
    Graph G(n);
    vector<int> ans(n, -1);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<P> que;
    que.push({0, -1});
    while(!que.empty()){
        P a = que.front(); que.pop();
        int v = a.first, p = a.second;
        for(auto nv : G[v]){
            if(nv == p)continue;
            if(ans[nv] == -1){
                ans[nv] = v;
                que.push({nv, v});
            }
        }
    }
    cout << "Yes" << endl;
    REP(i, n-1)cout << ans[i]+1 << endl;
}

Measured memory_bytes: 10496