akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

template< typename T >
struct BinaryIndexedTree {
    vector< T > data;

    BinaryIndexedTree(int sz) {
        data.assign(++sz, 0);
    }

    T sum(int k) {
        T ret = 0;
        for(++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    void add(int k, T x) {
        for(++k; k < data.size(); k += k & -k) data[k] += x;
    }
};

template< typename T >
struct Compress {
    vector< T > xs;

    Compress() = default;

    Compress(const vector< T > &vs) {
        add(vs);
    }

    Compress(const initializer_list< vector< T > > &vs) {
        for(auto &p : vs) add(p);
    }

    void add(const vector< T > &vs) {
        copy(begin(vs), end(vs), back_inserter(xs));
    }

    void add(const T &x) {
        xs.emplace_back(x);
    }

    void build() {
        sort(begin(xs), end(xs));
        xs.erase(unique(begin(xs), end(xs)), end(xs));
    }

    vector< int > get(const vector< T > &vs) const {
        vector< int > ret;
        transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) {
        return lower_bound(begin(xs), end(xs), x) - begin(xs);
        });
        return ret;
    }

    int get(const T &x) const {
        return lower_bound(begin(xs), end(xs), x) - begin(xs);
    }

    const T &operator[](int k) const {
        return xs[k];
    }
};

int main(void) {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> a(N+1);
    for(int i=1; i<=N; i++) {
        cin >> a[i];
        a[i] -= K;
    }

    partial_sum(a.begin(), a.end(), a.begin());

    Compress<int64_t> comp;
    comp.add(a);
    comp.build();
    auto zart = comp.get(a);

    int64_t ans = 0;
    BinaryIndexedTree<int64_t> bit(N+1);
    for(int i=0; i<=N; i++) {
        ans += bit.sum(zart[i]);
        bit.add(zart[i], 1);
    }

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


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

#define int long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<pi>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int t;cin>>t;while(t--)solve()

void solve(){
	
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	if (s[0]=='R' && s[1]=='R' && s[2]=='R')cout<<3;
	else if (s[0]=='R' && s[1]=='R')cout<<2;
	else if (s[1]=='R' && s[2]=='R')cout<<2;
	else if (s[0]=='R' || s[1]=='R' || s[2]=='R')cout<<1;
	else cout<<0;

}


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

const int MAX = 1000100;
const int INF = 1 << 29;

int main()
{
    vector<int> dp(MAX, INF), odddp(MAX, INF);
    dp[0] = odddp[0] = 0;
    for (int i = 1;; ++i)
    {
        int num = i * (i + 1) * (i + 2) / 6;
        if (num >= MAX)
            break;
        for (int j = num; j < MAX; ++j)
        {
            dp[j] = min(dp[j], dp[j - num] + 1);
            if (num & 1)
                odddp[j] = min(odddp[j], odddp[j - num] + 1);
        }
    }
    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        cout << dp[n] << " " << odddp[n] << endl;
    }
}


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

 int DigitsSum_A (int A) {
   int sum = 0;
   while (A > 0){
     sum += A % 10;
     A /= 10;
   }
   return sum;
 }

 int DigitsSum_B (int B) {
   int sum = 0;
   while (B > 0){
     sum += B % 10;
     B /= 10;
   }
   return sum;
 }

int main() {
  int N, B, a, b;
  cin >> N;
  
  int min = 1000000;
  
  for (int A = 1; A < N ; A++) {
    B = N - A;
    a = DigitsSum_A(A);
    b = DigitsSum_B(B);
     if (a + b < min)
       min = a + b;
  }
  cout << min << endl;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] A = new int[n];

            for (int i = 0; i < n; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }

            Console.WriteLine(GetLIS(A));
        }

        static int GetLIS(int[] A)
        {
            int n = A.Length, length = 1;

            List<int> L = new List<int>();
            L.Add(A[0]);

            for (int i = 1; i < n; i++)
            {
                if (L[length - 1] < A[i])
                {
                    L.Add(A[i]);
                    length++;
                }
                else
                {
                    int index = LowerBound(L, A[i]);
                    L[index] = A[i];
                }
            }
            return length;
        }

        static int LowerBound(List<int> arr, int value)
        {
            int low = 0;
            int high = arr.Count;
            int mid;

            while (low < high)
            {
                mid = ((high - low) >> 1) + low;        // (low + high) / 2
                if (arr[mid] < value) low = mid + 1;
                else high = mid;
            }
            return low;
        }
    }
}

Measured memory_bytes: 10728
n = int(input())
a = list(map(int, input().split()))
if n == 1:
  print(0)
else:
  before = a[0]
  cnt = 0
  ans = 0
  for i in range(1, n):
    if a[i] == before:
      cnt += 1
    else:
      ans += (cnt + 1) // 2
      cnt = 0
    before = a[i]
  ans += (cnt + 1) // 2
  print(ans)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

class Main {
	
	static class LongestCommon {
		public void longestcommon (InputReader in) {
			
			int n = in.nextInt();
			
			for (int i = 0; i < n; i++) {
				char[] str1 = in.nextString().toCharArray();
				char[] str2 = in.nextString().toCharArray();
				
				int len1 = str1.length;
				int len2 = str2.length;
				
				int[][] lc = new int[len1 + 1][len2 + 1];
				for (int j = 0; j < len1; j++) {
					for (int k = 0; k < len2; k++) {
						if (str1[j] == str2[k]) {
                            lc[j + 1][k + 1] = lc[j][k] + 1;
                        } else {
                            lc[j + 1][k + 1] = Math.max(lc[ j + 1][k], lc[j][k + 1]);
                        }
					}
				}
				
				System.out.println(lc[len1][len2]);
				
			}
			
		}
	}
	
	static class InputReader {
		BufferedReader input;
		StringTokenizer tok;
		
		public String nextString() {
			
			 while (!tok.hasMoreTokens()) {
	                try {
	                    tok = new StringTokenizer(input.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            }
			return tok.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(nextString());
		}
					
		public InputReader (InputStream inputStream) {
			input = new BufferedReader (new InputStreamReader (inputStream));
			tok = new StringTokenizer ("");
		}
		
	}
	
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		InputReader in = new InputReader (inputStream);
		LongestCommon obj = new LongestCommon();
		obj.longestcommon(in);
		
		
	}
}


Measured memory_bytes: 63132
#include<iostream>
using namespace std;
int main(void){
  int X,Y;
  cin >> X >> Y;
  if((Y-2*X)% 2!=0){
    cout << "No" <<endl;
    return 0;
  }
  int x = (Y-2*X)/2;
  int y = (Y-4*x)/2;
 
  if(x >= 0 && y>= 0 && (x+y == X) &&  ((4*x+2*y) ==Y)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;

namespace atcoder.abc173.c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] paramArray = getIntParams();

            int H = paramArray[0];
            int W = paramArray[1];
            int K = paramArray[2];

            string[,] itemArray = new string[H, W];
            for (int i = 0; i < H; i++)
            {
                char[] pArray = getStringParam().ToCharArray();
                for (int j = 0; j < W; j++)
                {
                    itemArray[i, j] = pArray[j].ToString();
                }
            }

            int ret = 0;
            for (int x = 0; x < 1 << H; x++)
            {
                for (int y = 0; y < 1 << W; y++)
                {
                    int count = 0;
                    for (int i = 0; i < H; i++)
                    {
                        if (((x >> i) & 1) == 1)
                        {
                            continue;
                        }
                        for (int j = 0; j < W; j++)
                        {
                            // 赤で塗りつぶした列は無視
                            if (((y >> j) & 1) == 1)
                            {
                                continue;
                            }
                            // 黒のとき
                            if (itemArray[i, j] == "#")
                            {
                                count++;
                            }
                        }
                    }
                    if (count == K)
                    {
                        ret++;
                    }
                }
            }
            Console.WriteLine(ret);
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


Measured memory_bytes: 28208
#include<iostream>
using namespace std;
int main(){
    int a;
    char b;
    int c;
    
    while (1) {
        cin >> a >> b >> c;
        if (b=='+'){
            cout << a+c <<endl;
        }else if (b=='-'){
            cout << a-c << endl;
        }else if (b=='*'){
            cout << a*c << endl;
        }else if (b=='/'){
            cout << a/c << endl;
        }else if (b=='?'){
            break;
        }
    }
    
}


Measured memory_bytes: 3108
#define _USE_MATH_DEFINES
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
typedef long long int LL;
typedef pair<int,int> P;


int main() {
	int n;
	int p[50];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> p[i];
	int cnt = 0;
	for(int i = 0;i < n;i++) {
		if(p[i]!=(i+1)) cnt++;
	}
	if(cnt>2) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  ml=[]
  al=[]
  rl=[]
  cl=[]
  hl=[]

  n=I()
  for _ in range(n):
    s=S()
    if s[0]=='M':
      ml.append(s)
    elif s[0]=='A':
      al.append(s)
    elif s[0]=='R':
      rl.append(s)
    elif s[0]=='C':
      cl.append(s)
    elif s[0]=='H':
      hl.append(s)

  l=[len(ml),len(al),len(rl),len(cl),len(hl)]
  sm=0

  for i in range(2):
    for j in range(2):
      for k in range(2):
        for m in range(2):
          for n in range(2):
            lx=[i,j,k,m,n]
            if lx.count(1)==3:
              _s=1
              for x in range(len(lx)):
                if lx[x]==1:
                  _s*=l[x]
              sm+=_s

  return sm

print(main())


Measured memory_bytes: 13608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
vi G;
vvi rG;
int out;
int n,k;
int dfs(int a){
	int t=inf;
	rep(i,rG[a].size())t=min(t,dfs(rG[a][i]));
	if(t==inf)t=0;
	t++;
	if(t<=k&&G[a])out++;
	return t;
}
int main(){
	cin>>n>>k;
	G=vi(n);
	rep(i,n)cin>>G[i];
	rG=vvi(n);
	rep(i,n)if(G[i])rG[G[i]-1].pb(i);
	out=0;
	rep(i,n)if(!G[i]){
		out++;
		dfs(i);
	}
	cout<<out<<endl;
}

Measured memory_bytes: 13368
#include<iostream>
#include<bitset>
#define int long long
using namespace std;
main(){
    int a,b;
    cin>>a>>b;
    bitset<32>c(a);
    bitset<32>d(b);
    cout<<(c&d)<<endl;
    cout<<(c|d)<<endl;
    cout<<(c^d)<<endl;
    return 0;
}
/*
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
  int x,y;
  cin>>x>>y;
  bitset<32>a(y),b(x);
  //cout<<b<<endl;
  //cout<<(~b)<<endl;
  //cout<<(b<<1)<<endl;
  //cout<<(b>>1)<<endl;
  cout<<(a&b)<<endl;
  cout<<(a|b)<<endl;
  cout<<(a^b)<<endl;
}
*/


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long

#define INF 1e+9
#define MAX_V 100008

vector<pair<ll, int>> factrized(ll num){
  vector<pair<ll, int>>  res;
 
  for(ll i = 2; i * i <= num; i++){
    if(num % i)continue;
    res.emplace_back(i, 0);
    while(num % i == 0){
          num /= i;
      res.back().second++;
    }
  }
  if(num != 1) res.emplace_back(num, 1);
  return res;
}

int main(){
    int x, y;
    cin >> x >> y;
    
    int b = y - 2 * x;
    double a = x - b / 2.0;
    
    if (b % 2 == 0 && a >= 0 && b >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;

int main(){
    int n, w;
    cin >> n >> w;
    vector<vector<ll>> dp(n + 10, vector<ll>(w + 1, 0));
    rep(i, n){
        int weight, value;
        cin >> weight >> value;
        srep(j, 0, w + 1){
            if (j >= weight) dp[i + 1][j] = max(dp[i][j], dp[i][j - weight] + value);
            else dp[i + 1][j] = dp[i][j];
        }
    }
    cout << dp[n][w] << endl;
}


Measured memory_bytes: 87296
#include <bits/stdc++.h>
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sax(x) cout << "!!!!!!!!!!! " << #x << " = " << x << '\n'
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)
#define one(x) x.insert(x.begin(), 0);
#define TCT template <class T>
#define TCT12 template <class T1, class T2>
#define IS istream
#define OS ostream
#define OP operator

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> imsi;

TCT IS& OP>>(IS &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT IS& OP>>(IS &I, deque<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const deque<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, priority_queue<T> v) {while (!v.empty()) {O << v.top() << ' '; v.pop();} return O;}
TCT OS& OP<<(OS &O, stack<T> v) {while (!v.empty()) {O << v.top() << '\n'; v.pop();} return O;}
TCT OS& OP<<(OS &O, queue<T> v) {while (!v.empty()) {O << v.front() << ' '; v.pop();} return O;}
TCT12 IS& OP>>(IS &I, pair<T1,T2>& p) {return I >> p.first >> p.second;}
TCT12 OS& OP<<(OS &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}
TCT12 OS& OP<<(OS &O, const unordered_map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT12 OS& OP<<(OS &O, const map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
typedef pair<int,int> pii;
typedef vector<int> vi;





void _main() {
        int n; cin >> n;
        vi vec(n); cin >> vec;
        int ans = 0, i, j;
        bool ok = false;
        for (i = 0, j = 1; i < n; i++) {
                if (vec[i] == j) j++, ok = true;
                else ans++;
        }

        if (!ok) cout << -1;
        else cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N+1];
	  int[] B = new int[N];
	  long count = 0;  
	  for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }
	  
	  for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  }
	  out.println(count);  
	  
  }
}

Measured memory_bytes: 89188
<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ", trim(fgets(STDIN)));
$b = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
$ans = array_sum($b);
for ($i = 1; $i < $n; $i++) if ($a[$i] - $a[$i - 1] == 1) $ans += $c[$a[$i] - 2];
echo $ans;
?>

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

using namespace std;

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

    unsigned long long int n;
    cin >> n;
   unsigned long long int sum = 0;
    for (int i = 1; i <= n; i ++)
    {
        if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0)
        {
            sum += i;
        }
    }
    cout << sum;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define pii pair<int, int>
#define fir first
#define sec second
#define ll long long
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 307;
inline void add(int &x, int y) {x += y; if (x >= mod) x -= mod;}
vector<pii>vec[MAXN];
int dp[MAXN][MAXN][MAXN];
int main()
{
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 1, l, r, c; i <= m; i++)
    {
        scanf("%d%d%d", &l, &r, &c);
        vec[r].emplace_back(l, c);
    }
    dp[1][0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (pii t : vec[i])
        {
            int l = t.fir, c = t.sec;
            for (int j = 0; j < i; j++)
                for (int k = 0; k <= j; k++)
                {
                    int cnt = 1;
                    if (j >= l) cnt++;
                    if (k >= l) cnt++;
                    if (c != cnt) dp[i][j][k] = 0;
                }          
        }
        for (int j = 0; j < i; j++)
            for (int k = 0; k <= j; k++)
            {
                add(dp[i + 1][j][k], dp[i][j][k]);
                add(dp[i + 1][i][j], dp[i][j][k]);
                if (j != k) add(dp[i + 1][i][k], dp[i][j][k]);
            }
    }
    int ans = 0;
    for (int j = 0; j <= n; j++)
        for (int k = 0; k <= j; k++)
        {
            if (j || k) add(ans, (ll)dp[n][j][k] * 6 % mod);
            else add(ans, (ll)dp[n][j][k] * 3 % mod);
        }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 110848
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

auto charcount(string s)
{
    char current = s[0];
    auto ret = new long[](1);
    foreach (e; s)
    {
        if (e != current)
        {
            ret ~= [0];
            current = e;
        }
        ret[$ - 1]++;
    }
    return ret;
}

void main()
{
    auto s = sread();
    auto t = sread();
    char[char] trans;
    foreach (i; iota(s.length))
    {
        if (s[i] in trans)
        {
            if (trans[s[i]] != t[i])
            {
                writeln("No");
                return;
            }
        }
        else
        {
            trans[s[i]] = t[i];
        }
    }
    auto check = new long[](26);
    foreach (e; trans)
        check[e - 'a']++;

    foreach (e; check)
    {
        if (e > 1)
        {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

Measured memory_bytes: 840
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll a, b, c;
ll x[51] = {};
ll dp[55][55][2505] = {};
string s1,s2;


int main(){
    cin>>s1>>s2;
    for(int i=0; i<s1.size(); i++){
        if(s1[s1.size()-1-i] != s2[i]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 256
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math as mt
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
h1, s1, h2, s2 = get_ints()
flag = False
while h1 > 0 and h2 > 0:
    h2 -= s1
    if h2 <= 0:
        flag = True
        break
    h1 -= s2
print("Yes") if flag else print("No")

# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int INF=1e9;
int h, w;
string s[1333];
int sy, sx, d[1333][1333], dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int bfs(){
	queue<pair<pii, int>> q;
	REP(i, h){
		REP(j, w) d[i][j]=INF;
	}
	REP(i, h){
		REP(j, w){
			if(s[i][j]=='#'){
				q.push(make_pair(pii(i, j), 0));
				d[i][j]=0;
			}
		}
	}
	int res=0;
	while(q.size()){
		auto p=q.front();
		q.pop();
		REP(i, 4){
			int nx=p.first.first+dx[i];
			int ny=p.first.second+dy[i];
			if(nx>=0 && nx<h && ny>=0 && ny<w && s[nx][ny]!='#' && d[nx][ny]==INF){
				q.push(make_pair(pii(nx, ny), p.second+1));
				d[nx][ny]=d[p.first.first][p.first.second]+1;
				CHMAX(res, p.second+1);
				s[p.first.first][p.first.second]='#';
			}
		}
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	cin>>h>>w;
	REP(i, h){
		cin>>s[i];
	}
	int ans=bfs();
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 19600
//
// Created on 2020/05/08.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans;
    int p,q,r;
    cin>>p>>q>>r;
    ans = min(p+q,min(q+r,r+p));

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
const int inf = (int)1e9;

ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}
 
 
ll dp[305][305][305];
 
 
int main(void){
	ll n,m,d;
	cin>>n>>m>>d;
	double ans = 0.0;
	if(d==0){
		ans = (double)(m-1)/n;
	}
	else{
		ans = (double)2*(n-d)*(m-1)/(n*n);
	}
	printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
	int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);

	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}



Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n,d;
  cin >> n >> d;
  int x[d][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin >> x[j][i];
    }
  }
  int h,cnt=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      h=0;
      for(int k=0;k<d;k++){
        h += (x[k][i]-x[k][j])* (x[k][i]-x[k][j]);
      }
      if(((int)(pow(h,0.5)))*((int)(pow(h,0.5)))==h)cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, dg[N], h[N], z, ans, st;
bool dp[N];
vector<int> gr[N];
set <pair< int, pair<int, int> > > s;
void find(int v, int par) {
	h[v] = h[par] + 1;
	s.insert({-h[v], {v, par}});
	for (auto u : gr[v]) {
		if (u != par) {
			find(u, v);
		}
	}
}
void dfs(int v, int par) {
	for (auto u : gr[v]) {
		if (u != par)
			dfs(u, v);
	}
	int zr = 0, seen = 0;
	for (auto u : gr[v]) {
		if (u != par && !dp[u])
			zr++;
		if (u != par && dp[u])
			seen = 1;
	}
	if (zr > 1) {
		ans += zr - 1, dp[v] = 1;
	}
	if (seen)
		dp[v] = 1;
	return;
}
int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		gr[x].push_back(y);
		gr[y].push_back(x);
		dg[x]++, dg[y]++;
	}
	for (int i = 0; i < n; i++) {
		if (dg[i] >= 3)
			z = i + 1;
	}
	if (!z) {
		cout << 1;
		return 0;
	}
	z--;
	find(z, z);
	while (!s.empty()) {
		auto p = *s.begin();
		int par = p.second.second;
		if (dg[par] >= 3) {
			st = p.second.first;
			break;
		}
		s.erase(s.begin());
	}
	dfs(st, st);
	cout << ans + 1;
	return 0;
}


Measured memory_bytes: 18048
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
package main
import (
  "fmt"
)

func main() {
  var A, B, C, X, count int
  fmt.Scan(&A, &B, &C)
  fmt.Scan(&X)
  for i := 0; i <= A; i++ {
    for j := 0; j <= B; j++ {
      tmp := X - 500 * i - 100 * j
      if tmp < 0 {
        break
      }
      if tmp / 50 <= C {
        count++;
      }
    }
  }
  fmt.Println(count)
}


Measured memory_bytes: 512
#include<stdio.h>

int main() {
	int H,W,i,j,c=1;

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

	return 0;
}


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

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

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<string> d(n);
    REP(i,n){
      string w;
      cin>>w;
      d[i] = w + string(11-w.size(), '`');
    }
    d.erase(unique(begin(d),end(d)),end(d));
    vector<vector<int>> dst(27,vector<int>(27,0));
    REP(i,n-1){
      REP(j,11){
        if(d[i][j] != d[i+1][j]) {
          dst[d[i][j]-'`'][d[i+1][j]-'`'] = 1;
          break;
        }
      }
    }
    REP(i,27)
      if(i) dst[0][i] = 1;
    REP(k,27)REP(i,27)REP(j,27) dst[i][j] = max(dst[i][j], dst[i][k] * dst[k][j]);
    bool ok = true;
    REP(i,27)
      if(dst[i][i]) ok = false;
    if (ok)
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

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

// 区間(l, r)の最小値を求める
int solv( std::vector<int> &in, int l, int r )
{
	int result = 101;
	int idx = 0;
	if ( l >= r )
	{
		return ( 0 );
	}

	for ( int i = l; i < r; i++ )
	{
		if ( in[i] < result )
		{
			result = in[i];
			idx = i;
		}
	}
	for ( int i = l; i < r; i++ )
	{
		in[i] -= result;
	}

	return ( result + solv( in, l, idx ) + solv( in, idx + 1, r ) );
}

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

	std::vector<int> v( N );
	for ( int i = 0; i < N; i++ )
	{
		std::cin >> v[i];
	}

	std::cout << solv( v, 0, N ) << std::endl;

	return ( 0 );
}


Measured memory_bytes: 256
def main():
  import sys
  b=sys.stdin.buffer
  h,w=map(int,b.readline().split())
  x=w+1
  s=[c>>3for c in b.read()]
  dp=[10000]*h*x
  a=p=s[0]
  dp[0]=b=q=5-a
  for i in range(1,w):
    t=s[i]
    dp[i]=b=b+(a^t)
    a=t
  for i in range(x,h*x,x):
    t=s[i]
    dp[i]=b=q=q+(p^t)
    a=p=t
    for j in range(1,w):
      k=i+j
      sk=s[k]
      b+=a^sk
      l=k-x
      t=dp[l]+(s[l]^sk)
      if b>t:b=t
      dp[k]=b
      a=sk
  print(b+1>>1)
main()

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct P {
  double x, y;
  bool f;
  P(double x, double y, bool f) : x(x), y(y), f(f) {}
};
bool operator<(const P &a, const P &b) {
  return a.x!=b.x?a.x<b.x : a.y<b.y;
}

double X[100];
double Y[100];
int n;

double func(double x) {
  if (x<=X[0] || x>=X[n-1]) return 0;
  int q = upper_bound(X, X+n, x) - X;
  int p = q-1;
  return (Y[q]-Y[p])/(X[q]-X[p])*(x-X[p])+Y[p];
}

int main() {
  double r;
  while(cin>>n>>r,n) {
    vector<P> v;
    REP(i, n) {
      cin >> X[i] >> Y[i];
      v.push_back(P(X[i], Y[i], 0));
      v.push_back(P(X[i]-r, Y[i], 1));
    }
    sort(ALL(v));
    double ans = 0;
    REP(i, v.size()-1) {
      double a = v[i].x;
      double b = v[i+1].x;
      double c = (a+b)/2;
      double fa = func(a)*func(a+r);
      double fb = func(b)*func(b+r);
      double fc = func(c)*func(c+r);
      ans += (b-a)/6*(fa+4*fc+fb);
    }
    printf("%.10f\n",ans);
  }
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

ll modpow(ll a,ll n,ll m){
    ll res=1;
    while(n){
        if(n&1)res=res*a%m;
        a=a*a%m;
        n>>=1;
    }
    return res;
}


ll fermat(ll a,ll b,ll m){
    return (a%m)*modpow(b,m-2,m)%m;
}

int main(){
    int n,k;cin>>n>>k;
    ll a;
    vector<pair<ll,int>> b(n);
    rep(i,n){
        cin>>a;
        if(a>0)b[i]=mp(a,1);
        else if(a==0)b[i]=mp(a,0);
        else b[i]=mp(-a,-1);
    }
    sort(all(b));reverse(all(b));
    int mnum=0;int pnum=0;
    ll lm=(ll)1;ll lp=(ll)1;
    ll ans=(ll)1;
    rep(i,k){
        if(b[i].second==0){
            ans=0;
            break;
        }
        if(b[i].second==-1){
            mnum++;
            lm=b[i].first;
        }
        else if(b[i].second==1){
            pnum++;
            lp=b[i].first;
        }
        ans*=b[i].first;
        ans%=inf;
    }
    if(mnum%2==0){
        cout<<ans<<endl;
        return 0;
    }
    if(k==n){
        cout<<inf-ans<<endl;
        return 0;
    }
    if(mnum%2){
        ll x=-2*inf;ll y=-2*inf;
        rep2(i,k,n){
            if(b[i].second==0){
                x=0;
                break;
            }
            if(b[i].second==1){
                x=b[i].first;
                break;
            }
        }
        rep2(i,k,n){
            if(b[i].second==0){
                y=0;
                break;
            }
            if(b[i].second==-1){
                y=b[i].first;
                break;
            }
        }
        if(pnum==0&&x==-2*inf){
            ans=(ll)1;
            reverse(all(b));
            rep(i,k){
                ans*=b[i].first;
                ans%=inf;
            }
            cout<<inf-ans<<endl;
            return 0;
        }
        if(pnum&&x*lp<y*lm){
            ans*=y;ans%=inf;
            ans=fermat(ans,lp,inf);
        }
        else{
            ans*=x;ans%=inf;
            ans=fermat(ans,lm,inf);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6356
import math
import heapq

n, m = map(int, input().split())
prices = list(map(int, input().split()))
hq = []


def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)


def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt


# 優先度付キューの作成
for price in prices:
    _heappush_max(hq, price)

# 割引適用
for _ in range(m):
    target = _heappop_max(hq)
    _heappush_max(hq, target/2)

total = 0
for price in hq:
    total += math.floor(price)

print(total)


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

using ll  = long long;
using pii = pair<int,int>;
#define dbg(n) cout<<'\n'<<#n<<" is "<<n<<'\n';
#define pb push_back
#define all(v) v.begin(), v.end()
#define cs(i) cout<<"Case "<<i+1<<": \n"; 
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N   = 1e5+5;
const int INF = 0x7fffffff;
const double pi = acos(-1);


int main(){
	int n,t,hold=0;

	cin>>n;
	double at=(double)2*pi*n;
	cout<<fixed<<setprecision(20);
	cout<<at<<endl;
	
	return 0;
}

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

using namespace std;

int n; char s[200010];

int main() {
	cin >> n; scanf("%s", s + 1);
	int i = 1, j = n, cnt = 0;
	while(i < j) {
		while(i < j && s[i] == 'R') i++;
		while(i < j && s[j] == 'W') j--;
		if(i < j) swap(s[i], s[j]), cnt++;;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <set>
using namespace std;
#define SZ 666666
//只有单调栈内的才有ls
int n,k,p[SZ],s[SZ],ls[SZ],nx[SZ],rv[SZ],op[SZ];
typedef pair<int,int> pii;
set<pii> si;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%d",p+i),s[p[i]]=i,ls[i]=i;
	for(int i=1;i<=n;++i)
	{
		int g=s[i]+k;
		set<pii>::iterator p=si.lower_bound(pii(g,0));
		if(p!=si.begin())
		{
			--p;
			while(1)
			{
				if(p->first<=s[i]) break;
				int x=p->second;
				nx[x]=ls[i]; ls[i]=ls[x];
				si.erase(p++);
				if(p==si.begin()) break;
				--p;
			}
		}
		si.insert(pii(s[i],i));
	}
	int on=0;
	for(set<pii>::iterator i=si.begin();
	i!=si.end();++i)
	{
		int r=i->second;
		for(int p=ls[r];p;p=nx[p]) op[++on]=s[p];
	}
	for(int i=1;i<=on;++i) rv[op[i]]=i;
	for(int i=1;i<=n;++i) printf("%d\n",rv[i]);
}
/*
定义临界态：s[i]<s[i+1]+K。
猜想：一个排列只能到一个临界态
*/

Measured memory_bytes: 41856
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int m=1000000007;


int main() {
    ll n;
    cin>>n;
    vector<ll> arr(n,0);
    for(ll i=0;i<n;i++)cin>>arr[i];
    
    vector<ll> psum(n,0);
    
    
    for(ll i=n-2;i>=0;i--)
    {
        psum[i]=(arr[i+1]+psum[i+1])%m;
    }
    
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ans =  (ans + (psum[i]*arr[i])%m)%m;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <limits>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
#include <set>
#include <algorithm>
#define     llongmax numeric_limits<long long>::max()
#define     llongmin numeric_limits<long long>::max()
#define     TEST(x) cout << "Value of "<< #x << " = " << x << endl
#define     all(x) x.begin(), x.end()
#define     pb push_back
using namespace std;
typedef long long int ll;
int main()
{
    ll a, b;
    cin >> a >> b;
    ll aa = a+b, ab = a-b, ac = a*b;
    cout << max(aa, max(ab, ac)) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

ll roundUp(double x)
{
	ll y = x;

	double z = x - (double)y;
	
	if(z != 0)
		return y + 1;
	else 
		return y;
}

int main()
{
	ll a,b, ans = -1;
	double a1, b1;
	ll a2,b2;
	string s;

	cin >> a >> b;

	a1 = roundUp((double)a * 12.5);
	a2 = roundUp(((double)(a+1) * 12.5));

	b1 = roundUp((double)b * 10);
	b2 = roundUp(((double)(b+1) * 10));

	if (a1 > b1)
	{
		if (a1 < b2)
			ans = a1;
	}
	else
	{
		if (b1 < a2)
			ans = b1;
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
using namespace std;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    string s;cin>>s;
    int a,b,c,d;
    a = s[0]-'0';
    b = s[1]-'0';
    c = s[2]-'0';
    d = s[3]-'0';
    if(a+b+c+d == 7)
        printf("%d+%d+%d+%d=7\n",a,b,c,d);
    else if(a+b+c-d == 7)
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
    else if(a+b-c+d == 7)
        printf("%d+%d-%d+%d=7\n",a,b,c,d);
    else if(a-b+c+d == 7)
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
    else if(a+b-c-d == 7)
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
    else if(a-b+c-d == 7)
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
    else if(a-b-c+d == 7)
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
    else if(a-b-c-d == 7)
        printf("%d-%d-%d-%d=7\n",a,b,c,d);






    return 0;
}


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

int main(){
  ll n;cin >> n;
  vector<ll> a(200000);
  vector<ll> m(n);
  ll ans = 0;//合計値を保存
  for(int i=0;i<n;++i){
    cin >> m.at(i);
    ans += m.at(i);//合計を求める
    a.at(m.at(i))++;//その値が何個出てきたか保存
  }
  //cout << ans << endl;
  ll q;cin >> q;
  for(int i=0;i<q;++i){
    ll b,c;
    cin >> b >> c;
    a.at(c) += a.at(b);
    ans = ans - a.at(b)*b + a.at(b)*c;
    a.at(b) = 0;
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
using namespace std;
#define lol long long


int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	vector<bool> T(8,false);
	int T1 = 0;
	int T2 = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] < 3200) {
			T[a[i] / 400] = true;
		}
		else {
			T2++;
		}
	}
	for (int i = 0; i < 8; i++) {
		if (T[i]) {
			T1++;
		}
	}
	cout << max(T1,1) << " " << T1 + T2 << endl;
}

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

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

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

ll ans=0;
string s;

int main(){
	cin>>s;
	int t=0;
	int counta=0;
	while(t<s.size()){
		counta=0;
		if(s[t]=='B'||s[t]=='C'){
			t++;
			continue;
		}
		counta=1;
		t++;
		while(1){
			if(t>=s.size())break;
			if(s[t]=='A'){
				counta++;
				t++;
			}else if(t<s.size()-1&&s[t]=='B'&&s[t+1]=='C'){
				ans+=counta;
				t+=2;
			}else{
				t++;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int q[32];
char s[100005];
int n,a;

int main(){
	scanf("%s",s);n=strlen(s);
	for(int i=0;s[i];++i)q[s[i]-'a']++;
	sort(q,q+3);
	puts(q[0]>=q[2]-1&&q[1]>=q[2]-1?"YES":"NO");
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <set>
#include <vector>
#include <string>
using namespace  std;

void fnDictionaryIns(set<string> &a_sesKey, vector<string> &a_vsFind)
{
  int iCommandCnt;
  cin >> iCommandCnt;

  for (int i = 0; i < iCommandCnt; i++)
  {
    string sCommand;
    string sKey;
    cin >> sCommand >> sKey;

    if (sCommand[0] == 'i')
      a_sesKey.insert(sKey);
    else if (sCommand[0] == 'f')
    {
      auto itsesKey = a_sesKey.find(sKey);
      if (itsesKey != end(a_sesKey))
        a_vsFind.push_back("yes");
      else
        a_vsFind.push_back("no");
    }
  }
}

void fnDictionaryFnd(const vector<string> &a_cnvsFind)
{
  for (int i = 0; i < a_cnvsFind.size(); i++)
    cout << a_cnvsFind[i] << endl;
}

void fnResultOut(int a_iFound)
{
  cout << a_iFound << endl;
}

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

  set<string> sesKey;
  vector<string> vsFind;
  fnDictionaryIns(sesKey, vsFind);
  fnDictionaryFnd(vsFind);
  
  return 0;
}

Measured memory_bytes: 50860