akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
#include <limits>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;
ll Pow2(ll n){
    ll sum = 1;
    REP(i,n){
        sum *= 2;
    }
    return sum;
}

ll A,B;

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B;
    ll digitA = ceil(log2(A));
    ll digitB = ceil(log2(B));
    ll digit = max(digitA,digitB);
    int Aarr[digit],Barr[digit];
    REP(i,digit+1){
        Aarr[i] = 0;Barr[i] = 0; 
    }
    ll tmp;
    REP(i,digit+1){
        tmp = Pow2(i+1);
        if(A%tmp >= tmp/2){
            if(A%tmp % 2 == 0){
                Aarr[i] = 1;
            }else{
                Aarr[i] = 5;
            }
        }else{
            Aarr[i] = 0;
        }
    }
     REP(i,digit+1){
        tmp = Pow2(i+1);
        if(B%tmp >= tmp/2){
            if(B%tmp % 2 == 0){
                Barr[i] = 1;
            }else{
                Barr[i] = 5;
            }
        }else{
            Barr[i] = 0;
        }
    }
    ll ans=0;
    REPP(i,1,digit+1){
        tmp = Pow2(i);
        if(Aarr[i] == 0){
            if(Barr[i] == 1){
                ans += tmp;
            }
        }else if(Aarr[i] == 1){
            if(Barr[i] == 1){
                ans += tmp;
            }
        }else{
            if(Barr[i] == 0 || Barr[i] == 5){
                ans += tmp;
            }
        }
    }
    tmp = B - A;
    if(B%2 == 1){
        if(tmp%4 == 0 || tmp%4 == 1){
            ans+=1;
        }
    }else{
        if(tmp%4 == 1 || tmp%4 == 2){
            ans+=1;
        }
    }

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

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

vector<int>adj[100010];
int n,m,from,to;
int memo[100010];

int go(int v)
{
    if(memo[v]!=-1) return memo[v];
    if(adj[v].size() == 0) return 0;

    int ret = 0;

    for(int i = 0;i<adj[v].size();i++){
        ret = max(ret,1+go(adj[v][i]));
    }
    return memo[v] = ret;

}


int main()
{
    cin>>n>>m;
    for(int i = 0;i<m;i++){
        cin>>from>>to;
        adj[from].push_back(to);
    }

    memset(memo,-1,sizeof memo);

    int ans = 0;
    for(int i = 1;i<=n;i++){
        ans = max(ans,go(i));
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 8192
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

int n;
string s;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
cin >> s;
if(n & 1){
	cout << "No" << endl;
	return 0;
}
for(int i = 0 ; i < n / 2 ; ++i){
	if(s[i] != s[i + n / 2]){
		cout << "No" << endl;
		return 0;
	}
}
cout << "Yes" << endl;

return 0;
}



Measured memory_bytes: 256
N = int(input())

points_pp = []
points_pn = []
points_np = []
points_nn = []
for _ in range(N):
  x, y = map(int, input().split())
  points_pp.append(x+y)
  points_nn.append(-x-y)
  
  points_pn.append(x-y)
  points_np.append(-x+y)
  
ans_pp = max(points_pp) - min(points_pp)  
ans_pn = max(points_pn) - min(points_pn)  
ans_np = max(points_np) - min(points_np)  
ans_nn = max(points_nn) - min(points_nn)
print(max(ans_pp, ans_pn, ans_np, ans_nn))

Measured memory_bytes: 122888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s; cin >> s;
    if(s.size()>=4&&s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')yn;
    return 0;
}
 
 


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	l := scanInts(n)

	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if l[i] == l[j] || l[j] == l[k] || l[k] == l[i] {
					continue
				}
				if l[i]+l[j] > l[k] && l[j]+l[k] > l[i] && l[k]+l[i] > l[j] {
					ans++
				}
			}
		}
	}
	fmt.Fprintln(wr, ans)
}


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

bool isn(char c){ return c >= '0' && c <= '9'; }

string cmp(string a,string b){
	int i = 0 , j = 0;
	while(a[i]=='0')i++;
	while(b[j]=='0')j++;
	if(i == a.size() && j == b.size() ) return "0";
	if(i == a.size() ) return b;
	if(j == b.size() ) return a;
	a = a.substr(i);
	b = b.substr(j);
	if(a.size() == b.size() ) return a < b ? b : a;
	else return a.size() < b.size() ? b : a;
}

int main(){
	int H , W;
	string table[70];
	while(cin >> W >> H && W){
		string dp[70][70];
		for(int i = 0 ; i < H ; i++) cin >> table[i];
		for(int i = 0 ; i < H ; i++)
			for(int j = 0 ; j < W ; j++)
				if( isn(table[i][j]) ) dp[i][j] = string(1,table[i][j]);
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j ++){
				if(isn(table[i][j])){
					if(i && isn(table[i-1][j]) ) dp[i][j] = cmp(dp[i][j] , dp[i-1][j]+string(1,table[i][j]));
					if(j && isn(table[i][j-1]) ) dp[i][j] = cmp(dp[i][j] , dp[i][j-1]+string(1,table[i][j]));
				}
			}
		}
		string mx = "";
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j++){
				mx = cmp(mx,dp[i][j]);
			}
		}
		cout << mx << endl;
	}
}

Measured memory_bytes: 1040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace _20180502_pra
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int averagea = (int)a.Average();
            int averageaplus = averagea + 1;

            int sum = 0;
            int sump = 0;

            foreach (var item in a)
            {
                sum += (item - averagea) * (item - averagea);
            }
            foreach (var item in a)
            {
                sump += (item - averageaplus) * (item - averageaplus);
            }

            if(sum>sump)
            Console.WriteLine(sump);
            else
                Console.WriteLine(sum);


        
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

ll dp[1100][11000];

int main() {
    ll h, n; cin >> h >> n;
    rep(i, 1100) rep(j, 11000) {
        if(j == 0) dp[i][j] = 0;
        else dp[i][j] = INF;
    }
    rep(i, n) {
        ll a, b; cin >> a >> b;
        rep(j, h+1) {
            chmin(dp[i+1][j], dp[i][j]);
            if(j <= a) chmin(dp[i+1][j], b);
            else chmin(dp[i+1][j], dp[i+1][j-a] + b);
        }
    }
    cout << dp[n][h] << endl;
}


Measured memory_bytes: 98160
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<cctype>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
const int N=110;
int n,a[N],x,cnt;
int main()
{
	n=read();x=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	if(x>=a[i])x-=a[i],cnt++;
	if(cnt==n&&x)cnt--;
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 256
N = input()
if N[-1:] == "2" or N[-1:] == "4" or N[-1:] == "5" or N[-1:] == "7" or N[-1:] == "9":
    print('hon')
elif N[-1:] == "0" or N[-1:] == "1" or N[-1:] == "6" or N[-1:] == "8":
    print('pon')
else:
    print("bon")

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

using namespace std;

int main(void) {
    long n;
    cin >> n;

    vector<vector<long>> G(n);
    for(int i=0; i<n-1; i++) {
        long a,b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    long m;
    cin >> m;
    vector<pair<long,long>> uv(m);
    for(auto &e: uv) cin >> e.first >> e.second;
    for(auto &e: uv) e.first--, e.second--;

    vector<long> par(n);
    {
        auto dfs = [&](auto dfs, long cur, long prev) -> void {
            for(auto &v: G[cur]) {
                if(v == prev) continue;
                par[v] = cur;
                dfs(dfs, v, cur);
            }
        };
        dfs(dfs, 0, -1);
    }

    vector<long> k(n);
    {
        for(int i=0; i<m; i++) {
            long u = uv[i].first;
            long v = uv[i].second;

            {
                long mask = 0;
                long cur = u;
                while(cur != 0)
                    mask |= (1ULL << cur), cur = par[cur];
                mask |= 1;

                cur = v;
                while(!((1ULL << cur) & mask))
                    k[cur] |= (1ULL << i), cur = par[cur];
            }
            swap(u, v);
            {
                long mask = 0;
                long cur = u;
                while(cur != 0)
                    mask |= (1ULL << cur), cur = par[cur];
                mask |= 1;

                cur = v;
                while(!((1ULL << cur) & mask))
                    k[cur] |= (1ULL << i), cur = par[cur];
            }
            swap(u, v);
        }
    }

    /* for(int i=0; i<n; i++) */
    /*     cout << k[i] << endl; */

    vector<vector<long>> dp(n+1, vector<long>(1ULL << m));

    dp[0][0] += 1;
    for(int i=1; i<n; i++)
        for(long t=0; t < (1ULL << m); t++) {
            dp[i][t | k[i]] += dp[i-1][t];
            dp[i][t] += dp[i-1][t];
        }

    cout << dp[n-1][((1ULL<<m)-1)] << endl;

}


Measured memory_bytes: 426496
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if( a==b && b==c && a%2==0){
		cout<<-1<<endl;
		return 0;
	}
	else{
		ll cnt=0;
		while( a%2 == 0 && b%2==0 && c%2==0){
			ll na,nb,nc;
			na = (b+c)/2;
			nb = (a+c)/2;
			nc = (a+b)/2;
			cnt++;
			a=na;b=nb;c=nc;
		}
		cout<<cnt<<endl;
		return 0;
	}
	return 0;
}

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

using namespace std;

const int N = 101;

int n, ans;
int a[N];

bool check(int i, int j, int k) {
    if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) return false;
    return (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]);
}

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

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (int i = 1; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k <= n; k++) {
                ans += (check(i, j, k));
            }
        }
    }

    cout << ans;

    return 0;
}



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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int s=y+z;
  int ans=(x-z)/s;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let _n = input[0];
    let k = input[1];
    let input = read_vec::<usize>();
    let r = input[0];
    let s = input[1];
    let p = input[2];
    let t = read::<String>();

    let mut groups: Vec<Vec<char>> = vec![];
    for _ in 0..k {
        groups.push(vec![]);
    }
    for (i, c) in t.chars().enumerate() {
        groups[i%k].push(c);
    }

    let mut ans: usize = 0;

    for group in groups {
        let mut prev: char = '.';
        for c in group {
            if c != prev {
                match c {
                    'r' => {
                        ans += p;
                        prev = 'r';
                    },
                    's' => {
                        ans += r;
                        prev = 's';
                    },
                    'p' => {
                        ans += s;
                        prev = 'p';
                    },
                    _ => {}
                }
            } else {
                prev = '.';
            }
        }
    }

    println!("{}", ans);

}

Measured memory_bytes: 10232
s = gets.chomp
c = s.size

until c == 0
  if s[c-5, 5] == 'erase' || s[c-5, 5] == 'dream'
    c -= 5
  elsif s[c-6, 6] == 'eraser'
    c -= 6
  elsif s[c-7, 7] == 'dreamer'
    c -= 7
  else
    puts 'NO'
    exit
  end
end

puts 'YES'


Measured memory_bytes: 1916
n,a,b=map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    if n-b >= a-1:
        ans = a-1
        ans += (b-a-1)//2
        print(ans+1)
    else:
        ans = n-b
        ans += (b-a-1)//2
        print(ans+1)

Measured memory_bytes: 38384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = INT_MAX/10;

int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};
char dd[] = {'N', 'E', 'S', 'W'};

typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	ll H, W, L;
	while(cin >> H >> W >> L, H) {
		vs field(H);
		REP(i, H) {
			cin >> field[i];
		}

		int cx, cy, cd;
		REP(i, H) {
			REP(j, W) {
				if(field[i][j] != '.' && field[i][j] != '#') {
					cx = j;
					cy = i;
					switch(field[i][j]) {
					case 'N':
						cd = 0;
						break;
					case 'E':
						cd = 1;
						break;
					case 'S':
						cd = 2;
						break;
					case 'W':
						cd = 3;
						break;
					}
					break;
				}
			}
		}

		vector<vvl> turn(H, vvl(W, vl(4)));
		bool looped = false;
		for(ll t = 0; t < L; t++) {
			if(!looped && turn[cy][cx][cd] != 0) {
				looped = true;
				ll cycle = (t-turn[cy][cx][cd]);
				t += ((L-t)/cycle)*cycle;
				if(t == L) {
					t -= cycle;
				}
			}

			int nx = cx+dx[cd];
			int ny = cy+dy[cd];

			if(ny<0 || H<=ny || nx<0 || W<=nx || field[ny][nx]=='#') {
				cd = (cd+1)%4;
				t--;
				continue;
			}

			turn[cy][cx][cd] = t;
			cy = ny;
			cx = nx;
		}

		cout << cy+1 << " " << cx+1 << " " << dd[cd] << endl;
	}

	return 0;
}

Measured memory_bytes: 1968
N,M,X = list(map(int, input().split()))

A = []
for n in range(N):
    a = list(map(int, input().split()))
    A.append(a)

ans = 10**7
notFound = True
Nall = 2**N
idx = [0]*N
for num in range(Nall):
    T = num
    for n in range(N):
        idx[n] = T%2
        T = T //2
        
    S = [0]*M
    cost = 0
    for n1 in range(N):
        if idx[n1] == 1:
            a = A[n1]
            cost += A[n1][0]
            for m in range(M):
                S[m] += a[m+1]
            OK = True
            for m in range(M):
                if S[m] < X:
                    OK = False
            if OK:
                ans = min(ans, cost)
                notFound = False
                
                
if notFound:
    print(-1)
else:
    print(ans)

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



int main(){
    int m,d,ans;
  	ans=0;
    cin >> m >> d;
    for(int i=1;i<=m;i++){
        for(int j=22;j<=d;j++){
          	if((j%10)<2)continue;
            if((j/10)*(j%10)==i){
              ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

string a;
int dp[200005], idp[200005];
vector <int> Adj[30];

signed main()
{
	Fastio();
	cin >> a;
	for(int i = 0; i <= 25; i++)
	{
		Adj[i].eb(0);
	}
	for(int i = 0; i < a.length(); i++)
	{
		Adj[a[i] - 'a'].eb(i + 1);
	}
	for(int i = 0; i <= 25; i++)
	{
		Adj[i].eb(a.length() + 1);
	}
	dp[0] = 0;
	for(int i = 1; i <= a.length() + 1; i++)
	{
		dp[i] = 9999999;
		for(int j = 0; j <= 25; j++)
		{
			int temp = lower_bound(Adj[j].begin(), Adj[j].end(), i) - Adj[j].begin();
			dp[i] = min(dp[i], dp[Adj[j][temp - 1]] + 1);
		}
	}
	idp[a.length() + 1] = 0;
	for(int i = a.length(); i >= 0; i--)
	{
		idp[i] = 9999999;
		for(int j = 0; j <= 25; j++)
		{
			int temp = upper_bound(Adj[j].begin(), Adj[j].end(), i) - Adj[j].begin();
			idp[i] = min(idp[i], idp[Adj[j][temp]] + 1);
		}
	}
	int pos = 0, t = 0;
	while(pos != a.length() + 1)
	{
		for(int i = 0; i < 26; i++)
		{
			int temp = upper_bound(Adj[i].begin(), Adj[i].end(), pos) - Adj[i].begin();
			if(dp[Adj[i][temp]] + idp[Adj[i][temp]] == idp[0] and dp[Adj[i][temp]] == t + 1)
			{
				t++;
				cout << char(i + 'a');
				pos = Adj[i][temp];
				break;
			}
		}
	}
}

Measured memory_bytes: 6056
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using llong = long long;

llong n;
vector<llong> a;
vector<pair<llong, llong>> p;

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    p.emplace_back(a[0], 1);
    for (int i = 1; i < n; i++) {
        if (p.back().first == a[i]) p.back().second++;
        else p.emplace_back(a[i], 1);
    }

    llong kougen, bonti, sanpuku, mine, kuboti;
    kougen = bonti = sanpuku = mine = kuboti = 0;

    for (int i = 1; i < (int)p.size() - 1; i++) {
        if (p[i - 1].first < p[i].first && p[i].first > p[i + 1].first) {
            if (p[i].second == 1) mine++;
            else kougen++;
        }
        else if (p[i - 1].first > p[i].first && p[i].first < p[i + 1].first) {
            if (p[i].second == 1) kuboti++;
            else bonti++;
        }
        else if (p[i].second > 1) {
            sanpuku++;
        }
    }

    printf("%lld %lld %lld %lld %lld\n", kougen, bonti, sanpuku, mine, kuboti);

    return 0;
}


Measured memory_bytes: 5704
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val dices = for{
      in <- Source.stdin.getLines.toList
    } yield in

    val targets = dices.tail.map(_.split(" ").toList.map(_.toInt)).combinations(2)
    val list = for{
      target <- targets
    } yield {
      val dice1 = new Dice(target.head)
      val dice2 = new Dice(target.last)
      dice1.isEqual(dice2)
    }

    println(if(!list.foldLeft(false)((a,b) => a || b)) "Yes" else "No")
  }
}

class Dice(sur: List[Int]){
  private val index: List[Int] = sur

  def findRight(list: List[Int]): Int={
    val dice = new Dice(index)
    val kindOfDices = List[Dice](dice, dice.rotN, dice.rotS, dice.rotW, dice.rotE, dice.rotN.rotN)
    val finddice = for{
      kindOfDice <- kindOfDices
    }yield kindOfDice match{
      case x if(x.getVal(0) == list(0) && x.getVal(1) == list(1)) => x.getVal(2)
      case x if(x.rotR.getVal(0) == list(0) && x.rotR.getVal(1) == list(1)) => x.rotR.getVal(2)
      case x if(x.rotR.rotR.getVal(0) == list(0) && x.rotR.rotR.getVal(1) == list(1)) => x.rotR.rotR.getVal(2)
      case x if(x.rotR.rotR.rotR.getVal(0) == list(0) && x.rotR.rotR.rotR.getVal(1) == list(1)) => x.rotR.rotR.rotR.getVal(2)
      case _ => 0
    }

    finddice.sum
  }

  def isEqual(dice2:Dice): Boolean={
    val dice = new Dice(index)
    val kindOfDices = List[Dice](dice, dice.rotN, dice.rotS, dice.rotW, dice.rotE, dice.rotN.rotN)

    val torf = for{
      kindOfDice <- kindOfDices
    } yield kindOfDice match{
      case x if(x.index == dice2.index) => true
      case x if(x.rotR.index == dice2.index) => true
      case x if(x.rotR.rotR.index == dice2.index) => true
      case x if(x.rotR.rotR.rotR.index == dice2.index) => true
      case _ => false
    }

    torf.foldLeft(false)((a,b) => a || b)
  }

  def getVal(i: Int): Int = index(i)

  def rotR(): Dice =
    new Dice(index).rotS.rotW.rotN

  def rotN(): Dice =
    new Dice(List[Int](index(1), index(5), index(2), index(3), index(0), index(4)))

  def rotS(): Dice =
    new Dice(List[Int](index(4), index(0), index(2), index(3), index(5), index(1)))

  def rotW(): Dice =
    new Dice(List[Int](index(2), index(1), index(5), index(0), index(4), index(3)))

  def rotE(): Dice =
    new Dice(List[Int](index(3), index(1), index(0), index(5), index(4), index(2)))
}

Measured memory_bytes: 228952
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int sum = 0;
    rep(i,n) sum += a[i];

    int const_m=m;
    rep(i,n){
        if(a[i]*(4*const_m)>=sum){
            m--;
            if(m==0){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

} // end of main

//実行は、Opt + Ctl + N

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <sstream>
#include <fstream>
#include <iterator>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdio>

using namespace std;
using namespace std::placeholders;

// namespace { struct NoSync { NoSync() { cin.tie(0); ios::sync_with_stdio(false); } } nosync; }

using ll = long long;
#define float double

constexpr ll INF = 999999999LL;
constexpr ll MOD = 1e9 + 7;

#define y0 Y0
#define y1 Y1
#define j0 J0
#define j1 J1
#define prev PREV
#define next NEXT

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i##_len = (n), i = (i##_len) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define permutations(v) sort(all(v));for(bool v##p = true; v##p; v##p=next_permutation(all(v)))
#define UNIQUE(v) (v).erase(unique(all(v)), (v).end())
#define REMOVE(v) (v).erase(remove(all(v)), (v).end())
#define ROTATE(v, n) rotate((v).begin(), (v).begin() + (n), (v).end())
#define TO_SUMS(v) partial_sum(all(v), (v).begin())
#define SUMS(srcv, dstv) partial_sum(all(srcv), (dstv).begin())
#define nth_bit(n) (1LL<<(n))

template <typename T> T high()  { return numeric_limits<T>::max(); }
template <typename T> T high(T) { return numeric_limits<T>::max(); }
template <typename T> T low()   { return numeric_limits<T>::lowest(); }
template <typename T> T low(T)  { return numeric_limits<T>::lowest(); }

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

// f には functional のオブジェクトが便利 (lambda 式も   [](int a){ return a / 2 }   みたいな)
template<class C, class F> inline C mapped(const C& c, F f){// mapっていうSTLがあるから...
    // ex: mapped(v, bind(plus<ll>(), _1, 2))   [v の各要素について x + 2]
    C r; r.reserve(c.size()); transform(all(c), back_inserter(r), f); return r;
}
template<class C, class F> inline C filtered(const C& c, F f){
    // ex: filtered(v, bind(equal_to<ll>(), bind(modulus<ll>(), _1, 2), 0)   [x mod 2 == 0 な x を取ってくる]
    C r; copy_if(all(c), back_inserter(r), f); return r;
}
template<class C, class I, class F> inline typename C::value_type foldl(const C& c, I i, F f){
    // ex: foldl(v, 1, multiplies<int>())   [v の総乗]
    return accumulate(all(c), static_cast<typename C::value_type>(i), f);
}

// 出力
template<class T> ostream& operator << (ostream &s, vector<T> v){
    rep(i, v.size()) { if (i != 0) { s << " "; } s << v[i]; } return s;
}


int main(){
    ll W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    cout << ((r <= x and x <= W - r and r <= y and y <= H - r)? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	ll n; cin>>n;
	rep(i,1,n+1){
		if(i%3==0){
			cout<<" "<<i;
			continue;
		}
		ll j=i;
		while(j){
			if(j%10==3){
				cout<<" "<<i;
				break;
			}
			j/=10;
		}
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 3128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;

int f[100005];

int main() {
	vector<int>r;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		r.push_back(x);
	}
	sort(r.begin(), r.end());
	int ans = 0;
	long long int w = 0;
	for (int i = 0; i < n-1; i++) {
		w += r[i];
		if (w * 2 < r[i + 1])ans = i + 1;
	}
	cout << n - ans << endl;

	return 0;

}


Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X,K,Q;
ll A,B,C,D;

ll ans;
bool F=false;
string S,T,U;
int main(){
    cin>>S;
    REP(i,S.size()){
        cout<<"x";
    }


    
}


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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    dd = [(1,0,0),(0,1,0),(0,0,1),(1,1,0),(1,0,1),(0,1,1),(1,1,1),(1,-1,0),(1,0,-1),(0,1,-1),(1,1,-1),(1,-1,1),(-1,1,1)]

    while True:
        n,m,p = LI()
        if n == 0 and m == 0 and p == 0:
            break

        a = [LI() for _ in range(p)]
        r = 'Draw'
        d = collections.defaultdict(int)
        for i in range(p):
            ci,cj = a[i]
            t = i % 2 + 1
            ck = 0
            for k in range(p):
                if d[(ci,cj,k)] == 0:
                    d[(ci,cj,k)] = t
                    ck = k
                    break
            ff = False
            for di,dj,dk in dd:
                if ff:
                    break
                for k in range(1-m,1):
                    f = True
                    for kk in range(k,k+m):
                        ni = ci + di*kk
                        nj = cj + dj*kk
                        nk = ck + dk*kk
                        if d[(ni,nj,nk)] != t:
                            f = False
                            break
                    if f:
                        ff = True
                        break
            if ff:
                if t == 1:
                    r = 'Black {}'.format(i+1)
                else:
                    r = 'White {}'.format(i+1)
                break

        rr.append(r)


    return '\n'.join(map(str, rr))


print(main())




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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;



int main(){
    ll k,n; cin>>k>>n;
    vector<ll> a(n);
    rep(i,n)    cin>>a[i];
    ll ans = a[n-1]-a[0];
    rep1(i,n-1){
        ans = min(ans,k-a[i]+a[i-1]);
    }
    cout<<ans<<endl;
}

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

int main() {
	int d;
	cin >> d;
	vector<int> c(30);
	vector<int> co(d+5);
	vector<int> ans(d + 5);
	int ans_c = 0;

	rep(i,26) {
		cin >> c[i];
	}

	vector<int> last(26);

	rep(i, 26) {
		last[i]=0;
	}

	vector<int> t(d + 5);
	int s[370][30];

	rep(j, d) {
		rep(i, 26) {
			cin >> s[j][i];
		}
	}

	int count = 0;
	
	rep(j, d) {

		int max=s[j][0];
		int max_d=0;

		rep(i, 26) {
			if (max <= s[j][i]) {
				max = s[j][i];
				max_d = i;
			}
		}

		last[max_d] = j+1;
		count += max;

		rep(i, 26) {
			count -= c[i] * (j+1-last[i]);
		}

		co[j] = max_d;
	}

	ans_c += count;
	count = 0;
//	cout << ans_c << endl;

	rep(j, d) {
		ans[j]=co[j];
	}

	rep(k, 100) {
		count = 0;
		rep(j, d) {
			ans[j] = rand()%26;
		}
		rep(i, 26) {
			last[i] = 0;
		}

		rep(j, d) {

			rep(i, 26) {
				if (ans[j] + 1 == i) {
					count += s[j][i];
				}
				else {
					count -= c[i] * (j + 1 - last[i]);
				}
			}
		}
	//	cout << count << endl;

		if (ans_c <= count) {
			ans_c = count;
			rep(j, d) {
				ans[j] = co[j];
			}
		}

	}


	rep(j, d) {
		cout << ans[j]+1<<endl;
	}

	return 0;
}

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

vector<vector<int>> g;
vector<int> dp;
void dfs(int u, int p) {
    int sum = 0, zero = 0;
    for (int v: g[u]) if (v != p) {
        dfs(v, u);
        sum += dp[v];
        zero += dp[v] == 0;
    }
    sum += max(0, zero - 1);
    dp[u] = sum;
}

int main() {
    int n; cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    int r = -1;
    for (int i = 0; i < n; i++) if (g[i].size() > 2) r = i;
    if (r == -1) return !(cout << 1 << endl);
    dp.resize(n);
    dfs(r, -1);
    cout << dp[r] << endl;
    return 0;
}


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

int main()
{
    char c;
    cin >> c;
    set<char> st = {'a', 'i', 'u', 'e', 'o'};
    if (st.find(c) != st.end()) cout << "vowel" << endl;
    else cout << "consonant" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a%3==0||b%3==0||(a+b)%3==0)
        printf("Possible\n");
    else
        printf("Impossible\n");
    return 0;
 }

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

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

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

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

    // gcd
    ll g = gcd(a,b);

    auto res = factorize(g);
    ll ans = res.size() + 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,c1=0,c2=0,c3=0,c4=0;
    cin>>a;
    string arr[a];
    for (int i=0;i<a;i++){
        cin>>arr[i];
    }
    for(int i=0;i<a;i++){
        if(arr[i]=="AC"){
            c1++;
        }
        if(arr[i]=="WA"){
            c2++;
        }
        if(arr[i]=="TLE"){
            c3++;
        }
        if(arr[i]=="RE"){
            c4++;
        }
    }
    cout<<"AC"<<' '<<'x'<<' '<<c1<<endl;
    cout<<"WA"<<' '<<'x'<<' '<<c2<<endl;
    cout<<"TLE"<<' '<<'x'<<' '<<c3<<endl;
    cout<<"RE"<<' '<<'x'<<' '<<c4<<endl;
}

Measured memory_bytes: 6760
#include <iostream>
#include <algorithm>
#include <set>
#include <tuple>
using namespace std;

int main()
{
    int n, w, d;
    while (cin>>n>>w>>d, w) {
        set<tuple<int, int, int>> a;
        int id=0;
        a.emplace(id, w, d);
        while (n--) {
            int p, s; cin>>p>>s;
            --p;
            auto i=begin(a);
            advance(i, p);

            tie(ignore, w, d)=*i;
            a.erase(i);
            s%=2*(w+d);

            ++id;
            if (s<w) {
                int k=w-s>s;
                a.emplace(id+k, w-s, d);
                a.emplace(id+(k^1), s, d);
            }
            else if (s<w+d) {
                s-=w;
                int k=d-s>s;
                a.emplace(id+k, w, d-s);
                a.emplace(id+(k^1), w, s);
            }
            else if (s<w+d+w) {
                s-=w+d;
                int k=w-s>s;
                a.emplace(id+k, w-s, d);
                a.emplace(id+(k^1), s, d);
            }
            else {
                s-=w+d+w;
                int k=d-s>s;
                a.emplace(id+k, w, d-s);
                a.emplace(id+(k^1), w, s);
            }
            ++id;
        }
        vector<int> res;
        for(auto& e: a) {
            tie(ignore, w, d)=e;
            res.push_back(w*d);
        }
        sort(begin(res), end(res));
        for(int i=0; i<res.size(); ++i)
            cout<<res[i]<<(i==res.size()-1 ? '\n' : ' ');
    }
}

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for (auto &s : S) cin >> s;
    
    int ans = 1e9;
    for (int bit = 0; bit < 1 << (H - 1); bit++) {
        int cut = 0;
        vector<int> div(H);
        for (int i = 0; i < H; i++) {
            div.at(i) = cut;
            if (bit >> i & 1) cut++;
        }
        vector<int> cnt(cut + 1);
        for (int w = 0; w < W; w++) {
            vector<int> tmp(cut + 1);
            bool add = false;
            for (int h = 0; h < H; h++) {
                int d = div.at(h);
                if (S.at(h).at(w) == '1') cnt.at(d)++, tmp.at(d)++;
                if (cnt.at(d) > K) add = true;
                if (tmp.at(d) > K) goto NG;
            }
            if (add) cut++, cnt = tmp;
        }
        ans = min(ans, cut);
        NG:;
    }
    cout << ans << "\n";
}

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

#define ll long long int
#define hell 1000000007
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

void solve()
{
    string s,t;
    cin>>s>>t;
    unordered_set <char> s1(begin(s),end(s));
    unordered_set <char> s2(begin(t),end(t));
    for(auto c:s2)
    {
        if(!s1.count(c))
        {
            cout<<-1;
            return;
        }
    }
    vector < vi > a(26);
    rep(i,0,s.length())
        a[s[i]-'a'].pb(i);
    ll c=-1;
    ll ans=0;
    ll p=-1;
    rep(i,0,t.length())
    {
        auto it=upper_bound(begin(a[t[i]-'a']),end(a[t[i]-'a']),c);
        if(it==a[t[i]-'a'].end())
        {
            ans+=s.length()-p-1;
            p=-1;
            c=a[t[i]-'a'][0];
            ans+=c-p;
            p=c;
        }
        else
        {
            c=*it;
            ans+=c-p;
            p=c;
        }
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


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

int N, A, B, C;
vector<int> L;
int INF = 1000000000;

int func(int i, int a, int b, int c) {
  if (i == N) {
    if (a == 0 || b == 0 || c == 0) return INF;
    return abs(a - A) + abs(b - B) + abs(c - C) - 30;
  }
  int res0 = func(i + 1, a, b, c);
  int res1 = func(i + 1, a + L.at(i), b, c) + 10;
  int res2 = func(i + 1, a, b + L.at(i), c) + 10;
  int res3 = func(i + 1, a, b, c + L.at(i)) + 10;
  vector<int> res = { res0, res1, res2, res3 };
  sort(res.begin(), res.end());
  return res.at(0);
}

int main() {
  cin >> N >> A >> B >> C;
  L.resize(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  cout << func(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_b
n, a, b = map(int, input().split())
s = input()

c = 0
abroad = 0
for i in range(n):
    if s[i] == 'c':
        print('No')
    elif s[i] == 'a' and c < a + b:
        print('Yes')
        c += 1
    elif s[i] == 'b' and c < a + b and abroad < b:
        print('Yes')
        abroad += 1
        c += 1
    else:
        print('No')

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

using namespace std;
typedef pair<int, int> pii;

pii field[200009];
int result[200009];

int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> field[i].first;
        field[i].second = i;
    }
    sort(field, field+n);
    for(int t=0; t<n/2; t++) {
        result[field[t].second] = field[n/2].first;
    }
    for(int t=n/2; t<n; t++) {
        result[field[t].second] = field[n/2-1].first;
    }
    for(int i=0; i<n; i++) {
        cout << result[i] << endl;
    }
}

Measured memory_bytes: 4480
from collections import Counter


def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    k = int(input())
    a = sorted(["".join(sorted(input())) for _ in range(k)])
    d = Counter(a)
    return int(sum(val*(val-1)/2 for val in d.values()))



print(main())

Measured memory_bytes: 25132
#include<iostream>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include <cstring>
#include <string>
#include <set>
using namespace std;
int per[200005];
int rank1[200005];
int find(int x)
{
   if(per[x]==x)
      return x;
   else
      return per[x]=find(per[x]);
}
void init(int n)
{
   for(int i=0;i<=n;i++)
   {
      per[i]=i;
      rank1[i]=0;
   }
}
void unite(int x,int y)
{
   x=find(x);
   y=find(y);
   if(x==y)
      return;
   else
   {
      if(rank1[x]>rank1[y]){
         per[y]=x;
         rank1[y]++;
      }
      else
      {
         per[x]=y;
         if(rank1[x]==rank1[y])
            rank1[x]++;
      }
   }
}
bool same(int x,int y)
{
   return find(x)==find(y);
}
int main()
{
   int n,m;cin>>n>>m;
   int loc[100005];
   for(int i=1;i<=n;i++)
      cin>>loc[i];
   init(n);
   for(int i=0;i<m;i++)
   {
      int x,y;cin>>x>>y;
      unite(x, y);
   }
   int ans=0;
   for(int i=1;i<=n;i++)
      if(same(i, loc[i]))
         ans++;
   cout<<ans;
}









//int cow[5005];
//int f[5005];
//int n,res;
//int cow_rev(int k)
//{
//   memset(f, 0, sizeof f);
//   int ans=0,sum;
//   for(int i=0;i+k<n;i++)
//   {
//
//   }
//   for(int i=n-k;i<n;i++)
//   {
//
//   }
//   return ans;
//}
//
//int main()
//{
//   cin>>n;
//   char c;
//   for(int i=0;i<n;i++)
//   {
//      cin>>c;
//      cow[i]=c=='F'?0:1;
//   }
//   for(int i=1;i<=n;i++)
//   {
//
//   }
//}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ll mx = max({a, b, c});
  ll sum = a+b+c;
  cout <<sum - mx << endl;
    return 0;
}


Measured memory_bytes: 3596
/*input
5 1
5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

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

vector<int> odd,even;
int a[maxn];
vector<int> ans;
int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	REP(i,m) cin>>a[i];

	REP(i,m){
		if(a[i]%2) odd.pb(a[i]);
		else even.pb(a[i]);
	}
	if(SZ(odd)>2){
		cout<<"Impossible\n";
		return 0;
	}

	if(SZ(odd)==0){
		REP(i,SZ(even)) cout<<even[i]<<" \n"[i==SZ(even)-1];
		ans.pb(1);
		REP(i,SZ(even)-1) ans.pb(even[i]);
		ans.pb(even.back()-1);
	}
	else if(SZ(odd)==1&&SZ(even)){
		cout<<odd[0];
		for(int i:even) cout<<' '<<i;
		cout<<'\n';
		ans.pb(odd[0]+1);
		REP(i,SZ(even)-1) ans.pb(even[i]);
		if(SZ(even)) ans.pb(even.back()-1);
	}
	else if(SZ(odd)==1){
		cout<<odd[0]<<'\n';
		if(odd[0]-1) ans.pb(odd[0]-1);
		ans.pb(1);
	}
	else{
		cout<<odd[0];
		for(int i:even) cout<<' '<<i;
		cout<<' '<<odd[1]<<'\n';

		ans.pb(odd[0]+1);
		for(int i:even) ans.pb(i);
		if(odd[1]-1) ans.pb(odd[1]-1);
	}
	cout<<SZ(ans)<<'\n';
	for(int i:ans) cout<<i<<' ';
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    string s;
    cin >> s;
    if(s[s.size()-1]=='s'){
        cout<<s+"es"<<endl;
    }else{
        cout<<s+'s'<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632