akhauriyash/Code-Regression huggingface dataset:
import sys

MOD = 1000000007

def union(x,y):
    if len(x)==1:
        if len(y)==1:
            return (1 if x[0]==y[0] else 0)
        else:
            return (1 if y[-1]>=x[0] else 0)
    if len(x)>1:
        if len(y)==1:
            return (1 if x[-1]>=y[0] else 0)
        else:
            return min(len(x),len(y))

n = int(input())
a = list(map(lambda x: int(x) % MOD, input().split()))
b = list(map(lambda x: int(x) % MOD, input().split()))
x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
x[0] = 1
y[-1] = 1
z = 1

for i in range(1,n):
    if a[i-1]<a[i]:
        x[i] = 1
    else:
        x[i] = 0

for j in range(n-1, 0, -1):
    if b[j-1]>b[j]:
        y[j-1] += 1
    else:
        y[j-1] += 0

for i in range(n):
    if x[i] == 1 and y[i] == 0:
        if a[i] > b[i]:
            print(0)
            sys.exit()
    elif x[i] == 0 and y[i] == 1:
        if a[i] < b[i]:
            print(0)
            sys.exit()
    elif x[i] == 1 and y[i] == 1:
        if a[i] != b[i]:
            print(0)
            sys.exit()
    else:
        z *= min(a[i],b[i])
        z = z % MOD

print(z)


Measured memory_bytes: 19264
# -*- coding: utf-8 -*-
"""
http://abc069.contest.atcoder.jp/tasks/abc069_b

"""

def solve(text):
    text_length = len(text)
    return text[0] + str(text_length-2) + text[-1]

def main():
    S = input()
    result = solve(S)
    print(result)


if __name__ == '__main__':
    main()

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

int main()
{
int i;
int w;
char S[ 1010 ];
char C;

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

	cin >> S;
	cin >> w;

	i = 0;
	while( C = S[ i ] )
	{
		if( i % w == 0 ) cout << C;

		i++;
	}

	cout << endl;

	return 0;
}


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

#define DEBUG(C) std::cerr << #C << " = " << C << std::endl;

const int MOD = (int)1e9 + 7;

/**
* Binary_Indexed_Tree(BIT) 2d by mod
* Fenwick Tree
* 0-indexed!!!
* O((log N)(log M))
*/
template<int mod>
class binary_indexed_tree_2d_by_mod {
private:
    int N;
    int M;
    std::vector<std::vector<int>> bit;

    void add(int &a, int b) {
        if (b < 0) b += mod;
        a += b;
        if (a >= mod) a -= mod;
    }

    int sum(int x, int y) {
        int res = 0;

        for (int i = x; i > 0; i -= i & (-i)) {
            for (int j = y; j > 0; j -= j & (-j)) {
                this->add(res, this->bit[i - 1][j - 1]);
            }
        }
        return res;
    }

public:
    binary_indexed_tree_2d_by_mod() {}
    binary_indexed_tree_2d_by_mod(int n, int m) : N(n + 2), M(m + 2), bit(n + 2, std::vector<int>(m + 2)) {}

    void add(int x, int y, long long val) {
        // for mod calc
        val %= mod;
        // for 0-indexed
        x++; y++;

        for (int i = x; i - 1 < N; i += i & (-i)) {
            for (int j = y; j - 1 < M; j += j & (-j)) {
                this->add(this->bit[i - 1][j - 1], val);
            }
        }
    }

    // [ (x1, y1), (x2, y2) )
    int sum(int x1, int y1, int x2, int y2) {

        int res = this->sum(x2 + 1, y2 + 1);
        add(res, -sum(x1, y2 + 1));
        add(res, -sum(x2 + 1, y1));
        add(res, sum(x1, y1));

        return res;
    }
};



const int MAX = 2e3 + 10;
int N, M;
binary_indexed_tree_2d_by_mod<MOD> bit;

int main(void) {
    std::cin >> N >> M;
    std::vector<int> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }
    std::vector<int> T(M);
    for (int i = 0; i < M; i++) {
        std::cin >> T[i];
    }
    bit = binary_indexed_tree_2d_by_mod<MOD>(N + 1, M + 1);

    bit.add(0, 0, 1);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (S[i] == T[j]) {
                bit.add(i + 1, j + 1, bit.sum(0, 0, i, j));
            }
        }
    }

    std::cout << bit.sum(0, 0, N, M) << std::endl;
}


Measured memory_bytes: 16000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	dsu ua(n);
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		ua.merge(a,b);
	}
	a=0;
	for(i=0;i<n;i++){
		if(i==ua.leader(i))a++;
	}
	cout<<a-1<<endl;
}

Measured memory_bytes: 3772
#include <stdio.h>


int main() {
    long a, b, x, tmp,r;
    scanf("%ld %ld", &a, &b);
    x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  printf("%ld", x/b);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int p[101] = {};
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        p[a] = 1;
    }

    cout << accumulate(p + 1, p + 101, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
class Dice:
    """????????????????????????"""
    def __init__(self, s):
        self.s = [0 for _ in range(6)]
        self.s[0] = s[0]
        self.s[1] = s[1]
        self.s[2] = s[2]
        self.s[3] = s[3]
        self.s[4] = s[4]
        self.s[5] = s[5]

    def roll(self, direction):          # ???????????????????§??????¢????????¢
        temp = self.s[0]
        if direction == "E":
            self.s[0] = self.s[3]
            self.s[3] = self.s[5]
            self.s[5] = self.s[2]
            self.s[2] = temp
        elif direction == "N":
            self.s[0] = self.s[1]
            self.s[1] = self.s[5]
            self.s[5] = self.s[4]
            self.s[4] = temp
        elif direction == "S":
            self.s[0] = self.s[4]
            self.s[4] = self.s[5]
            self.s[5] = self.s[1]
            self.s[1] = temp
        elif direction == "W":
            self.s[0] = self.s[2]
            self.s[2] = self.s[5]
            self.s[5] = self.s[3]
            self.s[3] = temp

    def setposition(self, a, b):
        for _ in range(6):
            if self.s[0] == a:
                break
            self.roll("N")
            if self.s[0] == a:
                break
            self.roll("E")
        for _ in range(6):
            if self.s[1] == b:
                break
            self.roll("N")
            self.roll("E")
            self.roll("S")


s = list(map(int, input().split()))
dice1 = Dice(s)
s = list(map(int, input().split()))
dice2 = Dice(s)

answer = "No"
for _ in range(3):
    for _ in range(4):
        dice1.roll("N")
        dice1.roll("E")
        dice1.roll("S")
        if dice1.s == dice2.s:
            answer = "Yes"
    dice1.roll("N")
    for _ in range(4):
        dice1.roll("N")
        dice1.roll("E")
        dice1.roll("S")
        if dice1.s == dice2.s:
            answer = "Yes"
    dice1.roll("E")

print(answer)

Measured memory_bytes: 7920
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    ll s;
    cin >> s;
    int x, y;
    int v = 1e9;
    x = (v-s%v)%v;
    y = (s+x)/v;
 
    cout << "0 0 1000000000 1 " << x << " " << y  << endl;
    return 0;
}

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

int main() {
  int N = 0;
  cin >> N;
  
  int n1000 = N / 1000;
  int n100 = ( N - n1000 * 1000 ) / 100;
  int n10 = ( N - n1000 * 1000 - n100 * 100 ) / 10;
  int n1 = N % 10;

  if( n1000 == n100 && n100 == n10 || n100 == n10 && n10 == n1 )
	cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}


void solve(){
  char c;
  cin >> c;
  cout << (char)(c+1) << endl;
}


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


Measured memory_bytes: 764
#!/usr/bin/env python3
n = int(input())
a = int(n**0.5) + 1
ans = [0]*(n+1)
for x in range(1, a):
    for y in range(1, a):
        for z in range(1, a):
            s = x**2+y**2+z**2+x*y+y*z+z*x
            if s <= n:
                ans[s] += 1

for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 9524
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vector<pair<ll,ll>>pll(n);
  for(auto &a:pll)cin>>a.F>>a.S;
  ll ans=llINF;
  if(n==1){cout<<1<<endl;return 0;}
  sort(ALL(pll));
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ll cnt=1;
      ll x=pll[j].F-pll[i].F,y=pll[j].S-pll[i].S;
      ll nx=pll[j].F,ny=pll[j].S;
      for(int k=0;k<n;k++)
	for(int l=k+1;l<n;l++)
	  if(pll[l].F-pll[k].F==x && pll[l].S-pll[k].S==y)cnt++;
      ans=min(ans,n-cnt);
    }
  }

  sort(ALL(pll),greater<pair<ll,ll>>());
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ll cnt=1;
      ll x=pll[j].F-pll[i].F,y=pll[j].S-pll[i].S;
      ll nx=pll[j].F,ny=pll[j].S;
      for(int k=0;k<n;k++)
	for(int l=k+1;l<n;l++)
	  if(pll[l].F-pll[k].F==x && pll[l].S-pll[k].S==y)cnt++;
      ans=min(ans,n-cnt);
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

bool check(string S){
  if (S[0] != 'A') return false;
  int cnt = 0;  //大文字のCがいくつあるか
  for (int i = 2; i < S.size() - 1; i++){
    if (S[i] == 'C') cnt ++;
  }
  if (cnt != 1) return false;
  int upper = 0;  //大文字の個数
  rep(i, S.size()){
    if (S[i] >= 'A' && S[i] <= 'Z') upper ++;
  }
  if (upper != 2) return false;
  return true;
}

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

  if (check(S)){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
}


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

void cut(std::vector<int>&v, int p, int c){

	std::vector<int>vv(c);

	for (int i = 0, j = p - 1; i < vv.size(); i++, j++){
		vv[i] = v[j];
	}

	for (int i = p - 2; i >= 0; i--){
		v[i + c] = v[i];
	}

	for (int i = 0; i < c; i++){
		v[i] = vv[i];
	}

}

int main(){

	int n, r;

	while (std::cin >> n >> r){
		if (n == 0 && r == 0)break;
		std::vector<int>v(n);

		for (int i = v.size() - 1; i >= 0; i--)v[i] = v.size() - i;

		for (int i = 0; i < r; i++){
			int p, c;
			std::cin >> p >> c;
			cut(v, p, c);
		}

		std::cout << v[0] << std::endl;

	}
	return 0;
}

Measured memory_bytes: 1200
N = int(input())
books = [input().split(" ") for i in range(N)]
Q = int(input())
query = [input().split(" ") for i in range(Q)]
dates = []
for _, _, date in books:
    dates.append(list(map(int, date.split("/"))))


def search_Q_title(Q_title, books):
    if (Q_title=="*"):
        return (1<<(N+1))-1
    else:
        ret = 0
        for i, book in enumerate(books):
            if (Q_title in book[0]):
                ret |= 1<<i
        return ret

def search_Q_author(Q_author, books):
    if (Q_author=="*"):
        return (1<<(N+1))-1
    else:
        ret = 0
        for i, book in enumerate(books):
            if (Q_author in book[1]):
                ret |= 1<<i
        return ret

def search_Q_date_from(Q_date_from, dates):
    if (Q_date_from=="*"):
        return (1<<(N+1))-1
    else:
        ret = 0
        Q_year, Q_month, Q_day = list(map(int, Q_date_from.split("/")))
        for i, date in enumerate(dates):
            year, month, day = date
            if (year > Q_year):
                ret |= 1<<i
            elif (year == Q_year):
                if (month > Q_month):
                    ret |= 1<<i
                elif (month == Q_month):
                    if (day >= Q_day):
                        ret |= 1<<i
        return ret


def search_Q_date_t0(Q_date_to, dates):
    if (Q_date_to=="*"):
        return (1<<(N+1))-1
    else:
        ret = 0
        Q_year, Q_month, Q_day = list(map(int, Q_date_to.split("/")))
        for i, date in enumerate(dates):
            year, month, day = date
            if (year < Q_year):
                ret |= 1<<i
            elif (year == Q_year):
                if (month < Q_month):
                    ret |= 1<<i
                elif (month == Q_month):
                    if (day <= Q_day):
                        ret |= 1<<i
        return ret
        

for i, Quer in enumerate(query):
    Q_title, Q_author, Q_date_from, Q_date_to = Quer
    bit = search_Q_title(Q_title, books) & search_Q_author(Q_author, books) & search_Q_date_from(Q_date_from, dates) & search_Q_date_t0(Q_date_to, dates)
    for j in range(N):
        if (bit & 1):
            print(books[j][0])
        bit >>= 1
    if (i != Q-1):
        print()


Measured memory_bytes: 5760
k = int(input())
s = input()

mod = 10**9 + 7

ans = 0

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(2*10**6+10)

for i in range(k+1):
    ans += pow(25, k-i, mod) * pow(26, i, mod) * comb(len(s)+k-i-1, len(s)-1)
    ans %= mod

print(ans)


Measured memory_bytes: 217592
n = gets.to_i
l = gets.split.map(&:to_i)

ans = 0
n.times{|i|
  (i+1...n).each{|j|
    (j+1...n).each{|k|
      if l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j] && l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]
        ans+=1
      end
    }
  }
}

puts ans

Measured memory_bytes: 14340
local day = io.read("*n")
local c = {}
for i = 1, 26 do
  c[i] = io.read("*n")
end
local s = {}
for id = 1, day do
  s[id] = {}
  for i = 1, 26 do
    s[id][i] = io.read("*n")
  end
end

local function solve(t, debug)
  local cur = 0
  local lastday = {}
  for i = 1, 26 do lastday[i] = 0 end
  for id = 1, day do
    local pid = t[id]
    cur = cur + s[id][pid]
    lastday[pid] = id
    for i = 1, 26 do
      cur = cur - c[i] * (id - lastday[i])
    end
    if debug then print(cur) end
  end
end
local t = {}
for i = 1, day do
  t[i] = io.read("*n")
end
solve(t, true)


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

using namespace std;

int main () {
	
	int n , m;
	cin >> n >> m;
	if (abs(n)>abs(m)){
		if (n > 0&&m > 0) {
			cout<<(n-m)+2<<endl;
		}
		else if(n > 0){
			cout<<(n-abs(m))+1<<endl;
		}
		else if(m > 0){
			cout<<(abs(n)-m)+1<<endl;
		}
		else{
			cout<<abs(n)-abs(m)<<endl;
		}
	}
	else{
		if (n >= 0&&m >= 0) {
			cout<<(m-n)<<endl;
		}
		else if(n >= 0){
			cout<<(abs(m)-n)+1<<endl;
		}
		else if(m >= 0){
			cout<<(m-abs(n))+1<<endl;
		}
		else{
			cout<<(abs(m)-abs(n))+2<<endl;
		}	
	}

return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>
#define ff first
#define ss second
#define szof(x) ((int)x.size())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
mt19937 tw(9450189);
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }


void solve() {
	string s;
	cin >> s;
	vector<int> have = {0, 0};
	ll ans = 0;
	for (int i = 0; i < szof(s); ++i) {
		int cur = s[i] == 'W' ? 0 : 1;
		if (cur == 0) {
			ans += have[1];
		}
		have[cur]++;
	}

	cout << ans << "\n";
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


Measured memory_bytes: 720
# include <bits/stdc++.h>
using namespace std;
# define FOR(i, a, b) for (int i = a; i <= b; ++i)
# define FDR(i, a, b) for (int i = a; i >= b; --i)
# define mp make_pair
# define pb push_back
# define lch p<<1, l, mid
# define rch p<<1|1, mid + 1, r
# define mem(a, b) memset(a, b, sizeof(a))
# define fi first
# define se second
# define MOD 1000000007
# define INF 1000000000
typedef long long i64;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<int, int> PII;
const int N = 200005;

int a[N];
i64 sum[N], suc[N], b[10];

int main ()
{
    int n;
    i64 ans = 1e18;
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", a + i), sum[i] = sum[i - 1] + a[i];
    FDR(i, n, 1) suc[i] = suc[i + 1] + a[i];
    FOR(i, 2, n - 2) {
        i64 s = sum[i] / 2, tmp = 1e18;
        int l = 0, r = i + 1, mid;
        while (l < r) {
            mid = (l + r) >> 1;
            if (l == mid) break;
            if (sum[mid] <= s) l = mid;
            else r = mid;
        }
        if (l >= 1 && l < i) {
            if (tmp > abs(sum[i] - sum[l] - sum[l])) {
                tmp = abs(sum[i] - sum[l] - sum[l]);
                b[1] = sum[l]; b[2] = sum[i] - sum[l];
            }
        }
        //cout << l << endl;
        l = 0; r = i + 1;
        while (l < r) {
            mid = (l + r) >> 1;
            if (l == mid) break;
            if (sum[mid] >= s) r = mid;
            else l = mid;
        }
        //cout << r << endl;
        if (r < i && r >= 1) {
            if (tmp > abs(sum[i] - sum[r] - sum[r])) {
                tmp = abs(sum[i] - sum[r] - sum[r]);
                b[1] = sum[r]; b[2] = sum[i] - sum[r];
            }
        }

        s = suc[i + 1] / 2; tmp = 1e18;
        l = 0; r = n - i + 1;
        while (l < r) {
            mid = (l + r) >> 1;
            if (l == mid) break;
            if (suc[n + 1 - mid] <= s) l = mid;
            else r = mid;
        }
        if (l && l < n - i) {
            if (tmp > abs(suc[i + 1] - suc[n + 1 - l] - suc[n + 1 - l])) {
                tmp = abs(suc[i + 1] - suc[n + 1 - l] - suc[n + 1 - l]);
                b[3] = suc[n + 1 - l]; b[4] = suc[i + 1] - suc[n + 1 - l];
            }
        }
        l = 0; r = n - i + 1;
        while (l < r) {
            mid = (l + r) >> 1;
            if (l == mid) break;
            if (suc[n + 1 - mid] >= s) r = mid;
            else l = mid;
        }
        if (r && r < n - i) {
            if (tmp > abs(suc[i + 1] - suc[n + 1 - r] - suc[n + 1 - r])) {
                tmp = abs(suc[i + 1] - suc[n + 1 - r] - suc[n + 1 - r]);
                b[3] = suc[n + 1 - r]; b[4] = suc[i + 1] - suc[n + 1 - r];
            }
        }
        sort(b + 1, b + 5);
        //cout << i << endl;
        //FOR(i, 1, 4) cout << b[i] << ' ';
        //cout << endl;
        ans = min(ans, b[4] - b[1]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int MOD = 1000000033, N = 6e5 + 5;

ll bp(ll a, ll p) {
    ll r = 1;
    while (p > 0) {
        if (p & 1)
            r = r * a % MOD;
        a = a * a % MOD;
        p >>= 1;
    }
    return r;
}

ll inv_X[6], X[6];

vector<ll> a[N], b[N];

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

    mt19937 rnd(time(0));

    for (int i = 0; i < 6; i++) {
        X[i] = rnd() % 1000000 + 1000000;
        inv_X[i] = bp(X[i], MOD - 2);
    }

    int n;
    string s;
    cin >> n >> s;

    vector<ll> h(6, 0);

    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '>') {
            for (int j = 0; j < 6; j++) {
                h[j] = h[j] * X[j] % MOD;
            }
        }
        else if (s[i] == '<') {
            for (int j = 0; j < 6; j++) {
                h[j] = h[j] * inv_X[j] % MOD;
            }
        }
        else if (s[i] == '+') {
            for (ll &x : h)
                x = (x + 1) % MOD;
        }
        else {
            for (ll &x : h)
                x = (x - 1 + MOD) % MOD;
        }
    }

    map<vector<ll>, int> mp;

    ll ans = 0;

    a[n] = vector<ll>(6, 1);
    b[n] = vector<ll>(6, 0);

    for (int i = n - 1; i >= 0; i--) {
        mp[b[i + 1]]++;

        a[i] = a[i + 1];
        b[i] = b[i + 1];

        if (s[i] == '>') {
            for (int j = 0; j < 6; j++) {
                a[i][j] = a[i][j] * inv_X[j] % MOD;
            }
        }
        else if (s[i] == '<') {
            for (int j = 0; j < 6; j++) {
                a[i][j] = a[i][j] * X[j] % MOD;
            }
        }
        else if (s[i] == '+') {
            for (int j = 0; j < 6; j++) {
                b[i][j] = (b[i][j] - a[i][j] + MOD) % MOD;
            }
        }
        else {
            for (int j = 0; j < 6; j++) {
                b[i][j] = (b[i][j] + a[i][j]) % MOD;
            }
        }

        vector<ll> qr;
        for (int j = 0; j < 6; j++) {
            qr.push_back((a[i][j] * h[j] + b[i][j]) % MOD);
        }

        ans += mp[qr];
    }
    
    cout << ans << "\n";

    return 0;   
}

Measured memory_bytes: 130196
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
atoe = [a, b, c, d, e]
atoe_strip = [math.ceil(i/10)*10 for i in atoe]
diff = [abs(i-j) for i, j in zip(atoe, atoe_strip)]

print(sum(atoe_strip)-max(diff))

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

int main() {
	string S;
	cin >> S;
	reverse(S.begin(),S.end());
	vector<string>vS = { "maerd","remaerd","esare","resare" };
	while (S.size()>0) {
		bool b = false;
		for (int i = 0;i<4;++i) {
			if (0 == S.find(vS[i])) {
				b = true;
				S = S.substr(vS[i].size());
			}
		}
		if (!b) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}



Measured memory_bytes: 3728
def solve(n, y)
  for a in 0 .. n
    for b in 0 .. n - a
      c = n - a - b
      if (a*10000 + b*5000 + c*1000) == y
        return [a, b, c]
      end
    end
  end
  return [-1, -1, -1]
end

n, y = gets.split.map(&:to_i)
ans  = solve(n, y)
puts ans.map(&:to_s).join(" ")


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B>C+D) {
    cout << "Left" << endl;
  }
  else if (A+B==C+D) {
    cout << "Balanced" <<endl;
  }
  else {
    cout << "Right" <<endl;
  }
}
   

Measured memory_bytes: 256
import collections

S=[input() for _ in range(3)]
#print(S)

S=list(map(lambda x: x.replace("a","0").replace("b","1").replace("c","2"),S))
#print(S)

S=list(map(lambda x: collections.deque(list(x)),S))
#print(S)

i=0
while 1:
  if len(S[i])==0:
    break
  i=int(S[i].popleft())
  #print(S,i)
print(chr(i+65))

Measured memory_bytes: 3316
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int get(int x, int k) {
  return x / k;
}

void solve() {
  ll a, b, n; cin >> a >> b >> n;
  ll ans = 0;
  for(ll i = 1; i <= 100; i++) {
    ans = max(ans, (a * i) / b - (a * (i / b)));
    //cout << (a * i) / b - (a * (i / b)) << '\n';
  }
  ll cur = min(n, b - 1);
  cout << (a * cur) / b - (a * ((cur) / b)) << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

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

int main() {
    int m, f, r;

    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) {
            break;
        }
        if (m == -1 || f == -1) {
            cout << "F" << endl;
        } else {
            int sum = m + f;
            if (sum >= 80) {
                cout << "A" << endl;
            } else if (sum >= 65) {
                cout << "B" << endl;
            } else if (sum >= 50) {
                cout << "C" << endl;
            } else if (sum >= 30) {
                if (r >= 50) {
                    cout << "C" << endl;
                } else {
                    cout << "D" << endl;
                }
            } else {
                cout << "F" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main(){
	int a, b;
	scanf("%d%d",&a,&b);
	if (a + b == 15){
		printf("+");
	}
	else if (a*b == 15){
		printf("*");
	}
	else{
		printf("x");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define N 100001
typedef long long ll;

int a[N], top[N];
int main()
{
    ll sum = 0;
    int n, q, b, c;

    scanf("%d", &n);
    for(int i = 0; i < n; i++) 
    {
        scanf("%d", &a[i]);
        sum += a[i];
        top[a[i]]++;
    }

    scanf("%d", &q);
    for(int i = 0; i < q; i++) 
    {
        scanf("%d%d", &b, &c);
        top[c] += top[b];
        sum += top[b]*(c - b);
        top[b] = 0;
        printf("%lld\n", sum);
    }

    return 0;
}

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

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

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

  int ans = 0;
  if (s.size() == t.size()) {
    int tmp = 0;
    rep(j, t.size()) {
      if (s[ j] == t[j]) {
        tmp++;
      }
    }
    cout << s.size() - tmp << '\n';

    return 0;
  }
  rep(i, s.size() - t.size()) {
    int counter = 0;
    rep(j, t.size()) {
      if (s[i + j] == t[j]) {
        counter++;
      }
    }
    ans = max(ans, counter);
  }
  ans = t.size() - ans;
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        a: f64,
        b: f64,
        n: f64,
    }

    let ans = if n >= b {
            floor_funtion(a, b, b-1.0)
        } else {
            floor_funtion(a, b, n)
        };
    
        println!("{}", ans as u64);

}

fn floor_funtion(a: f64, b: f64, x: f64) -> f64 {
    return (a*x/b).floor() - a * (x/b).floor();
} 


Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int i,j;
    for(i=0;i<s.size();i++){
        for(j=i+1;j<s.size();j++){
            if(s.at(i)==s.at(j)){
                cout << "no"<<endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;
ll A[100100];
std::map<int, int> cnt;

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

    std::cin >> N >> M;

    for(int i=1;i<=N;++i){
        std::cin >> A[i];
        A[i] += A[i - 1];
    }

    for(int i=0;i<=N;++i){
        cnt[A[i] % M] += 1;
    }

    ll c = 0;
    
    for(auto &p : cnt){
        ll n = p.second;
        c += n * (n - 1) / 2;
    }

    std::cout << c << std::endl;
}


Measured memory_bytes: 3968
#include<stdio.h>

int main(){
  int N;
  int A[101];
  int i,j,k,key;

  /*load the N*/
  scanf("%d",&N);
  /*load number*/
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
  }

  /*algorithm*/
  for(j=1;j<=N;j++){
    key=A[j];
    i=j-1;
    while(i>=0 && A[i]>key){
      A[i+1]=A[i];
      i--;
    }
    A[i+1]=key;

    /*print*/
    for(k=1;k<=N;k++){
      printf("%d",A[k]);
      if(k!=N)printf(" ");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define P pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}


int main()
{
	string s;
	cin >> s;
	int num[4];
	for (int i = 0;i < 4;i++) num[i] = ctoi(s[i]);
	for (int s = 0;s<(1 << 3);s++) {
		int cou=num[0];
		for (int i = 0;i < 3;i++) {
			if (s>>i&1) {
				cou += num[i+1];
			}
			else {
				cou -= num[i+1];
			}
		}
		if (cou == 7) {
			cout << num[0];
			for (int i = 0;i < 3;i++) {
				if (s >> i & 1) {
					cout << "+";
				}
				else {
					cout << "-";
				}
				cout << num[i + 1];
			}
			cout << "=";
			cout << 7 << endl;
			return 0;
		}
	}
}


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

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

  while (1) {
    if (k % 2 == 0 && k % n == 0) {
      cout << k << endl;
      return 0;
    }
    k++;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    string s[3] = { "delicious", "safe", "dangerous" };
    int k = -a + b;

    cout << s[(k > 0) + (k > x)] << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
def resolve():
    N,A,B,C = map(int,input().split())
    Nlist = []
    YesOrNo = True
    ABC = str(input())
    for i in range(N):
        ABC_old = ABC
        if i < N-1:
            ABC = str(input())

        if ABC_old == "AB":
            if ABC == "AC":
                add1 = np.sign(B - A + 0.1)
            else:
                add1 = np.sign(B - A - 0.1)

            if add1 < 0:
                Nlist.append("B")
            else:
                Nlist.append("A")
            A = A + add1
            B = B - add1
            if A < 0 or B < 0:
                YesOrNo = False
                print('No')
                break
        
        if ABC_old == "AC":
            if ABC == "AB":
                add1 = np.sign(C - A + 0.1)
            else:
                add1 = np.sign(C - A - 0.1)

            if add1 < 0:
                Nlist.append("C")
            else:
                Nlist.append("A")
            A = A + add1
            C = C - add1
            if A < 0 or C < 0:
                YesOrNo = False
                print('No')
                break
        
        if ABC_old == "BC":
            if ABC == "AB":
                add1 = np.sign(C - B + 0.1)
            else:
                add1 = np.sign(C - B - 0.1)

            if add1 < 0:
                Nlist.append("C")
            else:
                Nlist.append("B")
            B = B + add1
            C = C - add1
            if B < 0 or C < 0:
                YesOrNo = False
                print('No')
                break

    if YesOrNo:
        print("Yes")
        s_Nlist = '\n'.join(Nlist)
        print(s_Nlist)
resolve()

Measured memory_bytes: 27924
H,W=map(int,input().split())
a=""
s=list()
for r in range(H):
        s+=(list(input()))

ans="Yes"

def field(s,h,d):
        try:
                if(s[h+d]=="#"):
                        return True
                else:
                        return False
        except:
                return False

lens=len(s)
for r in range(lens):
        if(s[r]=="#"):
                if(field(s,r,1) or field(s,r,-1) or field(s,r,H) or field(s,r,-H)):
                        pass
                else:
                        ans="No"
                        break
print(ans)

   

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<int> ts(string s)
{
	vector<int> res;
	map<char,int>m;
	int c=0;
	for(int i=0;i<s.size();i++)
	{
		if(m[s[i]]==0)
		{
			m[s[i]]=c++;
		}
		res.push_back(m[s[i]]);
	}
	return res;
}

bool ch(vector<int>a,vector<int>b)
{
	if(a.size()!=b.size())return false;
	for(int i=0;i<a.size();i++)
		if(a[i]!=b[i])
			return false;
	return true;
}

int main()
{
	string S,T;
	cin>>S>>T;
	auto a=ts(S),b=ts(T);
	puts(ch(a,b)?"Yes":"No");
}


Measured memory_bytes: 4152
#include<stdio.h>
 
int thw(int,int);
void chng(char*,int*,int,int);
 
int thw(int s,int b)
{
    for(int i=1;i<s;i++) b = b * 10;
    return b;
}
 
void chng(char *box,int *A,int s,int cnt)
{
    int tmp,bt=0;
    for(int i=s-1;i>=0;i--)
    {
        tmp = box[i]-'0';
        bt += thw(s-i,tmp);
    }
    A[cnt] = bt;
}
 
int main()
{
    char box[10],tmp;
    int A[101],s=0,cnt=0,flg=0;
    while((tmp = getchar()) != EOF)
    {
        if('0' <= tmp && tmp <= '9'){
            box[s] = tmp;
            s += 1;
            flg=0;
        }else {
            switch(tmp){
                case '+':
                    cnt -=1;
                    A[cnt-1]=A[cnt-1]+A[cnt];
                    flg = 1;
                    break;
                case '-':
                    cnt -=1;
                    A[cnt-1]=A[cnt-1]-A[cnt];
                    flg = 1;
                    break;
                case '*':
                    cnt -=1;
                     A[cnt-1]=A[cnt-1]*A[cnt];
                    flg = 1;
                    break;
                case '/':                    cnt -=1;
                     A[cnt-1]=A[cnt-1]/A[cnt];
                    flg = 1;
                    break;
                default :
                if(flg == 0){
                    chng(box,A,s,cnt);
                    break;
                }
            }
            if(flg == 0)    cnt +=1;
            s = 0;
            }
        }
    printf("%d\n",A[0]);
}



Measured memory_bytes: 2088
using System;

class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        string[] a = Console.ReadLine().Split(' ');
        string[] b = Console.ReadLine().Split(' ');
        string[] c = Console.ReadLine().Split(' ');

        int s = 0;
        for (int i = 0; i < n; i++)
        {
            s += int.Parse(b[int.Parse(a[i]) - 1]);

            if (i != (n -1))
            {
                if ((int.Parse(a[i]) + 1) == int.Parse(a[i + 1]))
                {
                    s += int.Parse(c[int.Parse(a[i]) - 1]);
                }
            }
        }
        Console.WriteLine(s);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    int h,w,n,x;
    cin>>h>>w;
    cin>>n;
    int a[h][w], i=0, j=0, col = 1;
    while(n--){
        cin>>x;
        while(x--){
            a[i][j] = col;
            if(i%2 == 0)j++;
            else j--;
            if(j == w){
                j = w-1;
                i++;
            }else if(j == -1){
                j = 0;
                i++;
            }
        }
        col++;
    }
    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  int N, P[110][20], F[110];

  void init() {
    cin >> N;
    bool f;
    rep(i, N) rep(j, 10) {
      cin >> f;
      F[i] |= (f << j);
    }
    rep(i, N) repc(j, 10) {
      cin >> P[i][j];
    }
  }

  void solve() {
    int a = 0;
    ll maxv = -LINF;
    REP(k, 1, 1<<10) {
      ll acc = 0;
      rep(i, N) {
        acc += P[i][__builtin_popcount(k & F[i])];
      }
      maxv = max(maxv, acc);
    }
    cout << maxv << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

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

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

int main() {
  int n;
  cin >> n;
  int a[n];
  int tmp;
  map<int, int> rate;
  rep(i, 9) {
    rate[i] = 0;
  }
  rep (i, n) {
    cin >> tmp;
    if (tmp >= 3200) rate[8]++;
    else rate[tmp/400]++;
  }
  int min = 0;
  int max = 0;
  int nonPlayer = 0;
  rep (i, 8) {
    if (rate[i] > 0) {
      min++;
      max++;
    } else {
      nonPlayer++;
    }
  }
  if (min == 0) min++;
  cout << min << " " << max + rate[8] << endl;
  return 0;
}

Measured memory_bytes: 256
/*\
 * ...
 * ......
 * In the name of ALLAH
 * ......
 * ...
 */

#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
#define LD_OUT setprecision(12) << fixed
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10 , MN = 1e5 + 10 , MOD = 1e9 + 7;

int n , arr[MN] , p[MN] , fact[MN] , lfact[MN];

int bpw(int a,int b)
{
	if(!b) return 1;
	int t = bpw(a , b/2) ;
	t = 1ll * t * t % MOD;
	if(b&1) return 1ll * t * a % MOD;
	return t;
}

int C(int a,int b)
{
	if(a < b) return 0;
	return 1ll * fact[a] * lfact[b] % MOD * lfact[a-b] % MOD;
}

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	cin >> n;++n;
	int l , r;
	memset(p , -1 , sizeof p);
	for(int i=0;i<n;++i){
		cin >> arr[i];
		if(~p[arr[i]]) l = p[arr[i]] , r = i;
		else p[arr[i]] = i;
	}
	fact[0] = lfact[0] = 1;
	for(int i=1;i<MN;++i)
		fact[i] = 1ll * fact[i-1] * i % MOD , lfact[i] = bpw(fact[i] , MOD-2);
	for(int i=1;i<=n;++i)
		cout << (1ll * C(n , i) - C(n-(r-l+1) , i-1) + MOD)%MOD << '\n';
	return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 211111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int f[MAXN] , in[MAXN] ;

int main() {
    int n , k , a , count = 0 ;
    vector < int > ans ;
    scanf("%d %d" ,&n,&k) ;
    for(int i =0;i<n ;i++) {
        scanf("%d" ,&a) ;
        if(!in[a]){
            count++;
            in[a] =1;
        }
        f[a]++ ;
    }
    for(int i = 0 ; i<MAXN; i++) 
        if(f[i])ans.pb(f[i]) ;

    if(count<=k)cout <<'0' << endl ;
    else {
        sort(ans.begin() , ans.end()) ;
        a = count - k ;
        count = 0 ;
        for(int i = 0 ;i<a ;i++)
            count+=ans[i];
        cout << count << endl ;
    }

    return 0 ;
}

Measured memory_bytes: 2936