akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

const int INF = 0xffffff;

int w, h;
int ans = INF;
pair<int, int> s, g;
vector<pair<int, int> > m;
vector<vector<int> > cost;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};

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

int dijkstra(pair<int, int> s, pair<int, int> t) {
	priority_queue<P, vector<P>, greater<P> > que;
	vector<vector<int> > d(h, vector<int>(w, INF));
	d[s.first][s.second] = 0;
	que.push(P(0, s));
	
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int x = p.second.second;
		int y = p.second.first;

		if(x == t.second && y == t.first)
			return d[y][x];

		if(d[y][x] < p.first)
			continue;

		for(int i = 0; i < 4; ++i) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(nx < 0 || ny < 0 || nx >= w || ny >= h || cost[ny][nx] == INF)
				continue;

			if(d[ny][nx] > d[y][x] + cost[y][x]) {
				d[ny][nx] = d[y][x] + cost[y][x];
				que.push(P(d[ny][nx], make_pair(ny, nx)));
			}
		}
	}
}

void dfs(pair<int, int> pos, int visited = 0, int dist = 0) {
	if(dist >= ans)
		return;

	if(visited == (1 << m.size()) - 1) {
		ans = min(ans, dist + dijkstra(pos, g));
		return;
	}

	for(int i = 0; i < m.size(); ++i) {
		int bit = (1 << i);
		if(visited & bit)
			continue;

		dfs(m[i], visited | bit, dist + dijkstra(pos, m[i]));
	}
}

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

	cin >> w >> h;

	vector<string> field(h);
	for(int i = 0; i < h; ++i)
		cin >> field[i];

	cost.resize(h, vector<int>(w, 1));

	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if(field[i][j] == 'S')
				s = make_pair(i, j);

			else if(field[i][j] == 'G')
				g = make_pair(i, j);

			else if(field[i][j] == 'M')
				m.push_back(make_pair(i, j));

			else if(field[i][j] == '#') {
				for(int x = 2; x >= 1; --x)
					for(int k = -x; k <= x; ++k) if(0 <= i + k && i + k < h)
						for(int l = -x; l <= x; ++l) if(0 <= j + l && j + l < w)
							cost[i + k][j + l] = max(cost[i + k][j + l], 4 - x);

				cost[i][j] = INF;
			}
		}
	}

	dfs(s);

	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

int main(){
    int N,K;
    cin>>N>>K;

    vector<long long> data;
    for(int i=0;i<N;i++){
        long long x;
        cin>>x;
        data.push_back(x);
    }

    long long ans=10000000000;

    for(int i=0;i<=N-K;i++){
        long long L,R;
        long long x;
        L=data.at(i);
        R=data.at(i+K-1);
        if(L*R>=0) x=max(abs(L),abs(R));
        else x=min(R-2*L,2*R-L);
        if (x<ans) ans=x;

    }
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> hashVal;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int K = 26;
const ll mod1 = 1e9 + 7;
const ll mod2 = 1e9 + 9;

inline hashVal operator+(hashVal a, hashVal b){
	ll x = a.first + b.first; if(x >= mod1)x -= mod1;
	ll y = a.second + b.second; if(y >= mod2)y -= mod2;
	return {x, y};
}

inline hashVal operator-(hashVal a, hashVal b){
	ll x = a.first - b.first; if(x < 0)x += mod1;
	ll y = a.second - b.second; if(y < 0)y += mod2;
	return {x, y};
}

inline hashVal operator*(hashVal a, hashVal b){
	return {a.first*b.first%mod1, a.second*b.second%mod2};
}

inline hashVal operator*(hashVal a, ll k){
	return {a.first*k%mod1, a.second*k%mod2};
}

inline hashVal operator*(ll k, hashVal a){
	return {a.first*k%mod1, a.second*k%mod2};
}

hashVal base, val[K];

void pre(){
	base = {0, 0};
	while(base.first == 0 || base.second == 0){
		base = {rng()%mod1, rng()%mod2};
	}
	for(int i = 0; i < K; i++){
		val[i] = {0, 0};
		while(val[i].first == 0 || val[i].second == 0){
			val[i] = {rng()%mod1, rng()%mod2};
			for(int j = 0; j < i; j++){
				if(val[i].first == val[j].first || val[i].second == val[j].second){
					val[i] = {0, 0};
					break;
				}
			}
			if(val[i].first == base.first || val[i].second == base.second){
				val[i] = {0, 0};
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(32);

	pre();
	int n; cin>>n;
	vector<string> v(n);
	for(auto &x : v){
		cin>>x;
	}
	sort(v.begin(), v.end(), [](string &a, string &b){
		return a.size() < b.size();
	});
	map<hashVal, int> mp;
	ll ans = 0;
	for(int i = 0; i < n; i++){
		reverse(v[i].begin(), v[i].end());
		vector<int> f(K);
		for(auto ch : v[i]){
			f[ch - 'a']++;
		}
		int sz = v[i].size();
		hashVal hv = {0, 0};
		for(int j = 0; j < sz; j++){
			for(int k = 0; k < K; k++){
				if(f[k]){
					hashVal tmp = hv*base + val[k];
					if(mp.count(tmp))ans += mp[tmp];
				}
			}
			f[v[i][j] - 'a']--;
			hv = hv*base + val[v[i][j] - 'a'];
		}
		mp[hv]++;
	}
	cout<<ans;


	return 0;
}

Measured memory_bytes: 21908
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    double n = sc.nextDouble();

    double k = sc.nextDouble();

    double result = 0;

    for (int i = 1; i <= n ; i++) {
      double r = 1.0d / n;
      int tmp = i;
      while (tmp < k) {
        tmp *= 2;
        r /= 2;
      }
      result += r;
    }
    os.println(result);
  }

}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
	cin >> n;
    int a[n];
    fr(i,n){
      cin >> a[i];
    }
    int max=0;
    int h = 0;
    fr(i,n){
      if(max<i-h)max=i-h;
      if(i<n-1&&a[i+1]>a[i]){
        h=i+1;
      }
    }
      cout << max<< endl;
}

Measured memory_bytes: 640
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sr = new Scanner(System.in);
    int X[] = new int[5];
    for(int i=0;i<=4;i++)
      X[i] = sr.nextInt();
    for(int j:X)
      if(X[j]==0){System.out.println(j+1);break;}
  }

}

Measured memory_bytes: 35756
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string N;
    cin >> N;
    write(N[0] == '7' || N[1] == '7' || N[2] == '7' ? "Yes" : "No");
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
//#include <algorithm>

#include <stdio.h>
using namespace std;

void swap(int &a, int &b) {
    int tmp = b;
    b = a;
    a = tmp;
}

int selectionSort(int A[], int N) {
    int sw = 0;
    int i = 0;
	for (int i = 0; i < N - 1; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (A[j] < A[minj])
				minj = j;
		}
		if (minj != i) {
			swap(A[i], A[minj]);
			sw++;
		}
	}
    return sw;
}

int main(void) {
	int N;
    int sw;
	int A[100];
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];
    sw = selectionSort(A, N);


	for (int i = 0; i < N; i++) {
		if (i != 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}



Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void)
{
	int d;
	int i;
	int s;
	
	while (scanf("%d", &d) != EOF){
		s = 0;
		for (i = 1; i < 600 / d; i++){
			s += (int)pow(d, 3) * (int)pow(i, 2);
		}
		printf("%d\n", s);
	}
	
	return (0);
}

Measured memory_bytes: 652
import sys

sys.setrecursionlimit(10**7)
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

S = [0] + LS2()
n = len(S)
mod = 10**9+7

a,c,d = [0]*(n+1),[0]*(n+1),[0]*(n+1)
for i in range(1,n):
    a[i] = a[i-1]
    c[i] = c[i-1]
    d[i] = d[i-1]
    if S[i] == 'A':
        a[i] += 1
    elif S[i] == 'C':
        c[i] += 1
    elif S[i] == '?':
        d[i] += 1

X = [1]
for _ in range(n):
    X.append((X[-1]*3) % mod)

ans = 0
for i in range(1,n):
    if S[i] == 'B':
        ans += a[i-1]*(c[n-1]-c[i])*X[max(d[n-1],0)]
        ans %= mod
        ans += a[i-1]*(d[n-1]-d[i])*X[max(d[n-1]-1,0)]
        ans %= mod
        ans += d[i-1]*(c[n-1]-c[i])*X[max(d[n-1]-1,0)]
        ans %= mod
        ans += d[i-1]*(d[n-1]-d[i])*X[max(d[n-1]-2,0)]
        ans %= mod
    elif S[i] == '?':
        ans += a[i-1]*(c[n-1]-c[i])*X[max(d[n-1]-1,0)]
        ans %= mod
        ans += a[i-1]*(d[n-1]-d[i])*X[max(d[n-1]-2,0)]
        ans %= mod
        ans += d[i-1]*(c[n-1]-c[i])*X[max(d[n-1]-2,0)]
        ans %= mod
        ans += d[i-1]*(d[n-1]-d[i])*X[max(d[n-1]-3,0)]
        ans %= mod

print(ans)


Measured memory_bytes: 91204
#include <bits/stdc++.h>
using namespace std;
// for(long long i = 0;i < num; i++){}
int main() {
    //
    int k, s;
    int cnt = 0;

    cin >> k >> s;

    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            int x = s - i - j;
            if (x >= 0 && x <= k) cnt++;
        }
    }

    cout << cnt;
    //
}


Measured memory_bytes: 3596
//
//  main.cpp
//  ITP1_3
//
//  Created by Saicj on 2015/07/13.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
using namespace std;
#include <stdio.h>

int main()
{
    int x;
    int i=0;
    
    while (true) {
        
        cin >> x;
        
        if (x == 0){
            break;
            
        }
        
          printf("Case %d: %d\n", ++i, x);
    }

    
    

    
    return 0;
}

Measured memory_bytes: 1144
# 書き換える枚数は確定できる
# cの大きい順にしたものでaの小さい順にしたものを置き換えるイメージ
# なんか尺取っぽくなった

n, m = map(int, input().split())
arr = sorted(list(map(int, input().split())))

bcs = []
for _ in range(m):
    bc = list(map(int, input().split()))
    bcs.append(bc)

bcs = sorted(bcs, key=lambda x: x[1], reverse=True)
ans = 0

i = 0
for b in bcs:
    while i < n and arr[i] < b[1] and b[0] > 0:
        ans += b[1]
        b[0] -= 1
        i += 1
print(ans + sum(arr[i:]))


Measured memory_bytes: 83352
import java.util.*;

class Main{
    final static long mod = 1000000007;
    //
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double w = sc.nextDouble(), h = sc.nextDouble(), x = sc.nextDouble(), y = sc.nextDouble();
        System.out.print(w * h / 2);
        if(w / 2 == x && h / 2 == y) System.out.println(" " + 1);
        else System.out.print(" " + 0);
    }
}

Measured memory_bytes: 23252
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
n=0
ans=[]
for i in reversed(range(N)):
    t=0
    for j in range(2*(i+1)-1,N,i+1):
        if b[j]==1:
            t^=1
    b[i]=a[i]^t
    if b[i]==1:
        n+=1
        ans.append(str(i+1))
print(n)
print(' '.join(ans))

Measured memory_bytes: 17204
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();
		
		int e = (b * c) + (a - b) * d;
		int f = (a * c);
		
		if (a > b) {
			System.out.println(e);
		} else {
			System.out.println(f);
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    static int cntmin[26];
    fill(cntmin, cntmin + 26, INF);

    for (int i = 0; i < n; ++i) {
        int cnt[26] = {0};
        string s;
        cin >> s;
        for (int i = 0; i < s.length(); ++i)
            cnt[s[i] - 'a']++;
        for (int i = 0; i < 26; ++i)
            cntmin[i] = min(cnt[i], cntmin[i]);
    }

    for (int i = 0; i < 26; ++i)
        for (int j = 0; j < cntmin[i]; ++j)
            cout << (char)('a' + i);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!.toInt()
    var arr = mutableListOf(s)
    var n = next(s)
    while (!arr.contains(n)) {
        arr.add(n)
        n = next(n)
    }
    println(arr.size + 1)
}


fun next(n: Int): Int {
    return if (n % 2 == 0) {
        n / 2
    } else {
        n * 3 + 1
    }
}

Measured memory_bytes: 33660
#include <iostream>
using namespace std;
int main () {
  int a, b;
  cin >> a >> b;
  if (a>b)
    cout << "a > b" << endl;
  else if (a<b)
    cout << "a < b" << endl;
  else
    cout << "a == b" << endl;
  return 0;
}

Measured memory_bytes: 3056
'use strict';
(function(stdin) { 
  var inputs = stdin.toString().trim();
  var params = inputs.split('\n')[0].split(' ').map(Number) ;
  (function (a,b,c){
    if(a<b && b<c){
        console.log('Yes');
    } else {
        console.log('No');
    }
})(params[0],params[1],params[2]);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

#define INF 1e9
using namespace std;

int main() {

    int N; cin >> N;

    while (true) {
        int a; a = N / 100;
        int b; b = (N % 100) / 10;
        int c; c = N % 10;

        if (a == b && b == c) {
            cout << N << endl;
            return 0;
        }

        ++N;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = b*d;
	ans = max(ans,a*c);
	ans = max(a*d,ans);
	ans = max(b*c,ans);
	cout<<ans;
	
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<algorithm>
#include <cstring>
#include<set>
#include<cmath>
# define ll long long 
using namespace std;

int main()
{
	ll n;
	cin>>n;
	set<string>st;
	string x;
	while(n--)
	{
		cin>>x;
		st.insert(x);
	}
	cout<<st.size();
}

Measured memory_bytes: 19124
#include<bits/stdc++.h>
 
using namespace std;
 
/*
 
        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/
 
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()
 
 
#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
 
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
 
#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
 
 
int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};
 
/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/
 
 
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;
 
vector < int > g[maxn];
vector < ll > cost[maxn];
bool visited[maxn];
int color[maxn];
 
void bfs(int src){
    queue < int >Q;
 
    Q.push(src);
    visited[src]=1;
    color[src]=1;
 
    while(!Q.empty()){
        int u=Q.front();
        Q.pop();
 
        for(int i=0 ; i<g[u].size() ; i++){
            int v=g[u][i];
            if(!visited[v]){
Q.push(v);
visited[v]=1;
                int w=cost[u][i];
                if(w%2==0){
                    color[v]=color[u];
                }else {
                    if(color[u]==0) color[v]=1;
                    else color[v]=0;
                }
            }
        }
    }
}
 
 
int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 
    int n;
    cin >> n;
 
 
    f1(i,n-1){
        int u,v;
        ll w;
        cin >> u >> v >> w;
 
        g[u].pb(v);
        g[v].pb(u);
        cost[u].pb(w);
        cost[v].pb(w);
    }
 
    bfs(1);
    for(int i=1 ; i<=n ; i++){
        cout << color[i] << endl;
    } cout << endl;
 
    return 0;
}
 
 

Measured memory_bytes: 17152
#include<stdio.h>
#include<math.h>
#include<ctype.h>

int main()
{
    char a[102],b[102],c[102];
    scanf("%s %s %s", a, b, c);
        printf("%c%c%c\n", toupper(a[0]), toupper(b[0]), toupper(c[0]));

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,a[105];
int32_t main(){
CODE_START;
ll ans=0;
cin>>n;
for(ll i=1;i<=n;i++)
{
    cin>>a[i];
}
for(ll i=1;i<=n;i++)
{
    for(ll j=i+1;j<=n;j++)
    {
        for(ll k=j+1;k<=n;k++)
        {
            //cout<<i<<' '<<j<<' '<<k<<endl;
            if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]){
                ans++;
            }
        }
    }
}
cout<<ans<<endl;
}



Measured memory_bytes: 3648
n = int(input())
s = list(map(int, input().split()))
ln = []
for i in range(n):
    for j in range(1, s[i] // 2 + 1):
        if s[i] % (2 ** j) == 0 and s[i] % (2 ** (j + 1)) != 0:
            ln.append(j)
            break
        elif s[i] % 2 == 1:
            ln.append(0)
            break
print(min(ln))

Measured memory_bytes: 39152
#include<iostream>
#include<string>
#define For(N) for (int i = 0; i < N; i++)
#define FOR(i,N) for (i = 0; i < N; i++)
using namespace std;
using ll = long long int;

int main() {
	const string sample = "AKIHABARA";
	string s;
	cin >> s;
	int ps = 0, psample = 0;
	bool flag = true;
	while (psample < sample.length()) {
		if (s[ps] == sample[psample]) {
			psample++;
			ps++;
			continue;
		}
		else {
			if (sample[psample] == 'A') {
				psample++;
				continue;
			}
			else {
				flag = false;
				break;
			}
		}
	}
	if (flag && ps  >= s.length())cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

/*
AAAKIHABARAAA
KIHBR

*/

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int x,y;
    int a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a);
    vector<int> q(b);
    vector<int> r(c);
    rep(i, a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(),q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    vector<int> temp;
    rep(i,x)
    {
        temp.push_back(p[i]);
    }
    rep(i, y)
    {
        temp.push_back(q[i]);
    }
    for (auto &&i : r)
    {
        temp.push_back(i);
    }
    sort(temp.begin(),temp.end(),greater<int>());
    ll sum= 0;
    rep(i,x+y)
    {
        sum += temp[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3572
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
  _, vs, cs := nextLine(), nextLine(), nextLine()
  vv := strings.Split(vs, " ")
  cc := strings.Split(cs, " ")
  var max int
  for i, v := range vv {
    vi, _ := strconv.Atoi(v)
    ci, _ := strconv.Atoi(cc[i])
    if vi > ci {
      max += vi - ci
    }
  }
  fmt.Println(max)
}


Measured memory_bytes: 640
n = gets.to_i
q = gets.split.map(&:to_i)
 
count = 0
x = q.sort
 
n.times{|i|
  count += 1 if q[i] != x[i]
  }
 
if count == 0 or count == 2
  puts "YES"
else
  puts "NO"
end

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int a[maxn], l[maxn], r[maxn];

int main() {
    int n, res = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    l[1] = a[1], r[n] = a[n];
    for (int i = 2; i <= n; i++) l[i] = __gcd(l[i - 1], a[i]);
    for (int i = n - 1; i >= 1; i--) r[i] = __gcd(r[i + 1], a[i]);
    for (int i = 2; i < n; i++) res = max(res, __gcd(l[i - 1], r[i + 1]));
    printf("%d\n", max({res, l[n - 1], r[2]}));
    return 0;
}


Measured memory_bytes: 8832
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int x;
    cin >> x;
    int ans = 0;
    for (int i = 1; i <= 180; ++i) {
        int val = 360 * i;
        if (val % x == 0) {
            cout << val / x;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        ans += (N/i) * (N/i * i + i)/2;
    }
    printf("%lld\n", ans);

}

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

const int maxn = 2018;
vector<int> g[maxn];
int pr[maxn];
int a[maxn];
int cnt[maxn];
int root[maxn];
int bot[maxn];
int h[maxn];
int n;
vector<int> ord;

enum Type {
  BAD,
  GOOD,
  DONE
};
Type type[maxn];

void dfs1(int u) {
  cnt[u] = 1;
  for (int v : g[u]) {
    h[v] = h[u] + 1;
    dfs1(v);
    cnt[u] += cnt[v];
  }
  ord.push_back(u);
}

void dfs2(int u, int rt) {
  root[u] = rt;
  bot[rt] = u;
  if (g[u].empty()) {
    return;
  }
  int best = g[u][0];
  for (int v : g[u]) {
    if (cnt[v] > cnt[best]) {
      best = v;
    }
  }
  for (int v : g[u]) {
    int nrt = v == best ? rt : v;
    dfs2(v, nrt);
  }
}

bool good_root[maxn];
void mark_all(int u) {
  bool all_done = a[u] == u;
  for (int v : g[u]) {
    mark_all(v);
    all_done &= type[v] == DONE;
    if (root[v] != root[u] && type[v] != DONE) {
      good_root[root[u]] = false;
    }
  }
  type[u] = all_done ? DONE : BAD;
}

vector<int> ans;
void rot(int u) {
  ans.push_back(u);
  int val = a[0];
  while (true) {
    swap(val, a[u]);
    if (u == 0) {
      break;
    }
    u = pr[u];
  }
  //cerr << "array: ";
  //for (int i = 0; i < n; ++i) {
    //cerr << a[i] << ' ';
  //}
  //cerr << '\n';
}

signed main() {
#ifdef LOCAL
  assert(freopen("h.in", "r", stdin));
#endif
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u;
    cin >> u;
    g[u].push_back(i);
    pr[i] = u;
  }
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  dfs1(0);
  dfs2(0, 0);
  while (true) {
    for (int i = 0; i < n; ++i) {
      good_root[i] = true;
    }
    mark_all(0);
    if (type[0] == DONE) {
      break;
    }
    for (int i = 0; i < n; ++i) {
      if (good_root[root[i]] && type[i] != DONE) {
        type[i] = GOOD;
      }
    }
    //for (int i = 0; i < n; ++i) {
      //cerr << type[i] << ' ';
    //}
    //cerr << '\n';
    while (true) {
      bool done = true;
      for (int i = 0; i < n; ++i) {
        if (type[i] == GOOD) {
          done = false;
        }
      }
      if (done) {
        break;
      }
      int to = a[0];
      if (type[to] == BAD) {
        int v = -1;
        for (int u : ord) {
          if (type[a[u]] == GOOD) {
            v = u;
            break;
          }
        }
        if (v != -1) {
          //cerr << "rot bad " << v << '\n';
          rot(v);
        }
      } else {
        assert(type[to] == GOOD);
        int rt = root[to];
        int u = bot[rt];
        while (u != rt && root[a[u]] == rt && type[a[u]] != GOOD && h[a[u]] > h[to]) {
          u = pr[u];
        }
        //cerr << "rot good " << u << '\n';
        rot(u);
        type[to] = BAD;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    assert(a[i] == i);
  }
  assert((int) ans.size() <= 25000);
  cout << (int) ans.size() << '\n';
  for (int x : ans) {
    cout << x << '\n';
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
double n,tmp;
string s;
int main(){
	cin>>n;
  	double ans = 0;
  	for(int i=1;i<=n;i++){
      cin>>tmp>>s;if(s=="BTC")tmp*=380000.0;ans+=tmp;
    }
  	cout<<fixed<<setprecision(9)<<ans;
}

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

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

    int n;
    cin >> n;

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

    vector<int> a_type;
    for(auto x : mp) {
        if(x.second >= 2) a_type.emplace_back(x.first);
        if(x.second >= 4) a_type.emplace_back(x.first);
    }

    sort(a_type.rbegin(), a_type.rend());

    if((int)a_type.size() < 2) {
        cout << 0 << endl;
        return 0;
    }

    else {
        ll ans = ll(a_type[0])*a_type[1];
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 8292
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<ll, ll> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int n;
ll arr[nn];
ll dp[nn];
int main()
{
	fast();
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	memset(dp, oo, sizeof dp);
	dp[0] = 0;
	for (int i = 1; i < n; i++)
	{
		if (i == 1)
			dp[i] = abs(arr[i - 1] - arr[i]) + dp[0];
		else
			dp[i] = min({ dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]) });
	}
	cout << dp[n - 1] << endl;
	return 0;
}

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

int main()
{
    string s;
	cin>>s;
	if(s=="RRR")cout<<3;
	if(s=="RRS")cout<<2;
	if(s=="SRR")cout<<2;
	if(s=="RSS")cout<<1;
	if(s=="SSR")cout<<1;
	if(s=="SRS")cout<<1;
	if(s=="RSR")cout<<1;
	if(s=="SSS")cout<<0;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    long long ans = 0;
    for (int bit = 0; bit < (1 << n - 1); bit++) {
        // cout << "bit: " << bit << endl;
        int l = 0;
        for (int r = 0; r < n; r++) {
            // cout << "bit&: " << (bit & (1 << r)) << endl;
            if (r == n - 1) {
                // cout << stoll(s.substr(l, r - l + 1)) << endl;
                ans += stoll(s.substr(l, r - l + 1));
            }
            else if (bit & (1 << r)) {
                // cout << stoll(s.substr(l, r - l + 1)) << endl;
                ans += stoll(s.substr(l, r - l + 1));
                l = r + 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.lang.*;
import java.util.*;
  
class Main{
   public static void main(String[] args){
     Scanner stdId = new Scanner(System.in);
     int a = stdId.nextInt(); 
		 int b = stdId.nextInt();
     System.out.println((a*b) + " " + (a+a+b+b));
  }
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    
    vector<ll> ab;
    rep(i, x) rep(j, y) ab.push_back(a[i] + b[j]);
    sort(rALL(ab));
    ab.resize(k);

    vector<ll> abc;
    rep(i, ab.size()) rep(j, z) abc.push_back(ab[i] + c[j]);
    sort(rALL(abc));

    rep(i, k) cout << abc[i] << endl;
}

Measured memory_bytes: 43368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  ll n, k; cin >> n >> k;

  ll ans;
  if (k & 1) {
    ans = powl(n / k, 3);
  } else {
    ans = powl(n / k, 3);
    ll cnt = 0;
    for (int i = 1; i <= n; i++) {
      if (i % k == (k / 2)) cnt++;
    }
    ans += powl(cnt, 3);
  }

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


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int len;
    len = s.size();
    char tmp;
    int x;
    for( int i=0; i<len; i++){
        x = s[i] - 'A'; // num from A
        //cout << x << endl;
        x = (x+n)%26;
        putchar('A'+x);
    }
    putchar('\n');
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    vector<ll>a(3);
    rep(i,3){
        cin>>a[i];
    }
    sort(all(a));
    bool f=0;
    if(a[0]==a[1]&&a[1]!=a[2])f=1;
    if(a[1]==a[2]&&a[0]!=a[2])f=1;
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace abc153_c
{
    class Program
    {
        static void Main()
        {
            var tmpNk = Console.ReadLine().Split();
            var n = long.Parse(tmpNk[0]);
            var k = long.Parse(tmpNk[1]);
            var tmpH = Console.ReadLine().Split();
            var hList = new List<long>();
            foreach (var strH in tmpH)
            {
                hList.Add(long.Parse(strH));
            }
            hList.Sort();
            long result = 0;
            for (var i = 0; i < n-k; i++)
            {
                result += hList[i];
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 33128
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

ll mod=1000000007;
ll powdp[401][401];

void fill_powdp(){
    for(int i=1; i<401; ++i){
        powdp[i][0]=1;
        for(int j=1; j<401; ++j){
            powdp[i][j]=(powdp[i][j-1]*i)%mod;
        }
    }
    for(int i=0; i<401; ++i){
        for(int j=1; j<401; ++j){
            powdp[j][i]=(powdp[j][i]+powdp[j-1][i])%mod;
        }
    }
}

int main() {
	int N, C;
	cin >> N >> C;
	vector<int> a(N), b(N);
	for(int i=0; i<N; ++i) cin >> a[i];
	for(int i=0; i<N; ++i) cin >> b[i];
	fill_powdp();
	vector<vector<ll>> dp(N+1, vector<ll>(C+1, 0));
	dp[0][0]=1;
	for(int i=0; i<N; ++i){
	    for(int j=0; j<=C; ++j){
	        ll mul=(powdp[b[i]][j]+mod-powdp[a[i]-1][j])%mod;
	        for(int k=0; j+k<=C; ++k){
	            dp[i+1][j+k]=(dp[i+1][j+k]+(dp[i][k]*mul)%mod)%mod;
	        }
	    }
	}
	cout << dp[N][C] << endl;
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
const int M=1e4;
int a[M],b[M],c[M];
void jingwei(int cnt){
	while (c[cnt]>=10){
		c[cnt+1]+=c[cnt]/10;
		c[cnt]%=10;
		cnt++;
	}
}
int main(){
	string s;
	int n1=0,n2=0,n3=0;
	cin>>s;
	for (int i=s.size()-1;i>=0;i--){
		a[++n1]=s[i]-'0';
	}
	cin>>s;
	for (int i=s.size()-1;i>=0;i--){
		if (s[i]=='.')continue;
		b[++n2]=s[i]-'0';
	}
//	for (int i=)
	for (int i=1;i<=n1;i++){
		int cnt=i;
		for (int j=1;j<=n2;j++){
			c[cnt]+=a[i]*b[j];
			jingwei(cnt);
			cnt++; 
		}
	}
	for (int i=M-1;i>=0;i--){
		if (c[i]){
			n3=i;
			break;
		}
	}
	if (n3<3)cout<<0<<endl; 
	else for (int i=n3;i>=3;i--)cout<<c[i];
	return 0;
}



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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}


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

    //ll tmp = 0;
    ll i = 1;
    while (true) {
        //cout << (i*(i+1))/2 << endl;
        if(n <= (i*(i+1))/2 ) {
            cout << i << endl;
            break;
        }
        i++;
    }
    return 0;
}


Measured memory_bytes: 256
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	long long a,b1=0,c;
	char b[5];
	cin>>a>>b;
	for(int i=0;b[i];i++)
	{
		if(b[i]=='.') continue;
		b1*=10;
		b1+=b[i]-'0';
	}
	c=a*b1/100;
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 3652
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        Map<Character, Integer> map = new HashMap<>();
        map.put('a', 0);
        map.put('b', 0);
        map.put('c', 0);
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            map.put(ch, map.get(ch) + 1);
        }
        int min = Integer.MAX_VALUE;
        int max = 0;
        for (char key : map.keySet()) {
            int x = map.get(key);
            min = Math.min(min, x);
            max = Math.max(max, x);
        }
        if (Math.abs(max - min) <= 1) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 24148
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scan(&x)
	
	ans := 1
	for j := 1; j < x; j++ {
		for k := 2; k < x; k++ {
			tmp := int(math.Pow(float64(j), float64(k)))
			if tmp > x {
				break
			}
			if ans < tmp {
				ans = tmp
			}
		}
	}
	fmt.Println(ans)
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

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

ll most(ll n) {
	ll ret = 0;
	while(n > 0) {
		ret = n%10;
		n/=10;
	}
	return ret;
}

ll rev(ll n) {
	ll ret = n % 10;
	ret*=10;
	n/=10;
	ret += n%10;
	return ret;
}

void solve()
{
    ll n;
    cin >> n;
    vll cnt(100, 0);
    for(ll i=1;i<=n;i++) {
    	if(i < 10) {
    		cnt[i]++;
    		continue;
    	}
    	ll cd = i % 10;
    	cd += 10*most(i);
    	cnt[cd]++;
    }
    // for(ll i=11;i<=n;i++) {
    	// cout << i << " " << cnt[i] << "\n";
    // }
    ll ans = min(n, 9ll);
    for(ll i=1;i<=9;i++) {
    	ans += 2*cnt[i]*cnt[11*i];
    }
    // cout << ans << "\n";
    for(ll i=11;i<=99;i++) {
    	ll oo = i;
    	ll nn = rev(i);
    	if(oo % 10 == 0) {
    		continue;
    	}
    	if(nn!=oo) {
    		ans += cnt[nn]*cnt[oo];
    	} else {
    		ans += (cnt[nn]*cnt[oo]);
    	}
    	// cout << oo << " " << nn << " " << ans << "\n";
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n; int a[n][3],dp[n][3];
    for(int i=0;i<n;i++)
    {cin>>a[i][0]>>a[i][1]>>a[i][2];}
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    sort(dp[n-1] , dp[n-1]+3);
    cout<<(dp[n-1][2]);
    return 0;
}

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

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

	if (a == b && a != c)
	{
		cout << c;
	}
	else if (a == c && b != c)
	{
		cout << b;
	}
	else 
	{
		cout << a;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = 0
i = 0
while D <= X:
    D = (D + L[i])
    i += 1
    if i == N and D <= X:
        print(i+1)
        sys.exit()
print(i)


Measured memory_bytes: 3060
def search_maximum_profit(rs):
    """
        rs: ??´??°?????????
        search max[s | s = rs[j] - rs[i] (j > i)]
        return: s
    """
    l = len(rs)
    if l <= 1:
        return None
    elif l == 2:
        return rs[1] - rs[0]
    else:
        left_profit = search_maximum_profit(rs[:l // 2])
        right_profit = search_maximum_profit(rs[l // 2:])
        left_min = min(rs[:l // 2])
        right_max = max(rs[l // 2:])
        profits = []
        if left_profit != None:
            profits.append(left_profit)
        if right_profit != None:
            profits.append(right_profit)
        profits.append(right_max - left_min)
        return max(profits)

n = int(input())
rs = []
for i in range(n):
    rs.append(int(input()))

print(search_maximum_profit(rs))

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

int     main() {
        int A, B, X;
        cin >>A >>B >>X;
        if (X>=A)
                if (X<=A+B) {
                        cout <<"YES" <<endl;
                        return 0;
                }
        cout <<"NO" <<endl;
        return 0;
};

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int sx, sy;
    int tx, ty;
    int i;

    scanf("%d %d", &sx, &sy);
    scanf("%d %d", &tx, &ty);

    for (i = 0; i < tx - sx; ++i){
        putchar('R');
    }
    for (i = 0; i < ty - sy; ++i){
        putchar('U');
    }
    for (i = 0; i < tx - sx; ++i){
        putchar('L');
    }
    for (i = 0; i < ty - sy; ++i){
        putchar('D');
    }

    putchar('D');
    for (i = 0; i < tx - sx + 1; ++i){
        putchar('R');
    }
    for (i = 0; i < ty - sy + 1; ++i){
        putchar('U');
    }
    putchar('L');
    putchar('U');
    for (i = 0; i < tx - sx + 1; ++i){
        putchar('L');
    }
    for (i = 0; i < ty - sy + 1; ++i){
        putchar('D');
    }
    putchar('R');
    putchar('\n');

    return (0);
}


Measured memory_bytes: 128