akhauriyash/Code-Regression huggingface dataset:
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); cin >> a;
  map<ll, ll> cnt;
  each(x, a) cnt[x]++;
  function<bool(ll,ll)> check = [&](ll x0, ll x1) {
    vector<ll> val(n);
    val[0] = x0;
    val[1] = x1;
    rep(i, 2, n) val[i] = val[i-1] ^ val[i-2];
    rep(i, n) if ((val[i] ^ val[(i+2)%n]) != val[(i+1)%n]) return false;
    map<ll, ll> cnt2;
    each(x, val) cnt2[x]++;
    each(p, cnt2) if (cnt[p.first] != p.second) return false;
    return true;
  };
  if (cnt.size() == 1) {
    bool ans = (a[0] ^ a[0]) == a[0];
    cout << ans << endl;
  }
  else if (cnt.size() == 2) {
    vector<ll> v;
    each(p, cnt) v.pb(p.first);
    bool ans = check(v[0], v[1]);
    cout << ans << endl;
  }
  else if (cnt.size() == 3) {
    vector<ll> v;
    each(p, cnt) v.pb(p.first);
    bool ans = (check(v[0], v[1]) || check(v[1], v[2]) || check(v[2], v[0]));
    cout << ans << endl;
  }
  else {
    cout << false << endl;
  }
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<ll> score(n,k-q);
    vector<int> a(q);
    rep(i,q) {
        cin >> a[i];
        score[a[i]-1]++;
    }
    rep(i,n) {
        if(score[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 4288
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] array = s.split("");
        
        int start = 0;
        int end = 0;
        for(int i = 0; i < s.length(); i++){
            String a = array[i];
            if(a.equals("A")){
                start = i;
                break;
            }
        }
        for(int i = start; i < s.length(); i++){
            String b = array[i];
            if(b.equals("Z")){
                end = i;
            }
        }

        System.out.println(end-start+1);
        
    }
}

Measured memory_bytes: 52744
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

map<int, int> m;
ll sol;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        m[x]++;
    }
    for (auto p : m)
    {
        int a = p.first;
        int b = p.second;
        if (a != b)
        {
            if (b > a)
                sol += min(b - a, b);
            else
                sol += b;
        }
    }
    cout << sol;
}


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	string s;
	cin >> s;
	ll ans(0);
	rep(i, s.size()) {
		ll a;
		ans += ll(s[i])-48;
		//ans %= 9;
	}
	//cout << ans;
	if (ans % 9 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

int n, a[105], ans = 1e9;

int calc(int x) {
    int ret = 0;
    for (int i = 1; i <= n; i++) ret += (a[i] - x) * (a[i] - x);
    return ret;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = -100; i <= 100; i++)
        ans = min(ans, calc(i));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
int n;
vector<int> edge[d5];
int fd[d5], cd[d5];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    fill(fd, fd + d5, inf);
    fill(cd, cd + d5, inf);
    for (int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    queue<int> Q;
    Q.push(0);
    fd[0] = 0;
    while (!Q.empty())
    {
        int now = Q.front();
        Q.pop();
        for (auto it : edge[now])
        {
            if(fd[it]==inf){
                fd[it] = fd[now] + 1;
                Q.push(it);
            }
        }
    }
    Q.push(n - 1);
    cd[n - 1] = 0;
    while (!Q.empty())
    {
        int now = Q.front();
        Q.pop();
        for (auto it : edge[now])
        {
            if(cd[it]==inf){
                cd[it] = cd[now] + 1;
                Q.push(it);
            }
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if(fd[i]<=cd[i]){
            cnt++;
        }
    }
    if (cnt > n - cnt)
    {
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}

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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var L = vals[1];

        var min = int.MaxValue;
        var apple = new int[N];
        for (int i = 0; i < N; i++)
        {
            apple[i] = L + i;
            if(Math.Abs(apple[i]) < Math.Abs(min))
            {
                min = apple[i];
            }
        }

        var sum = apple.Sum() - min;
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11348
N, x = map(int, input().split())
A = list(map(int, input().split()))

min_time = [a for a in A]
ans = 10**15
for t in range(N):
  time = t*x
  for i in range(N):
    j = (i - t) % N
    min_time[i] = min(min_time[i], A[j])
    time += min_time[i]
  ans = min(ans, time)

print(ans)

Measured memory_bytes: 41820
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#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 <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, k, q;
    cin >> n >> k >> q;
    int p[SIZE] = {};

    for( int i = 0; i < q; ++i ) {
        int a;
        cin >> a;
        p[a]++;

    }

    for( int i = 1; i <= n; ++i ) {
        if( k - q + p[i] <= 0 ) cout << "No";
        else cout << "Yes";
        cout << endl;

    }

    return 0;
}



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

using namespace std;
typedef long long ll;

// #define DEBUG
class Point;
void printpoint(Point a);

class Point
{
    int x;
    int y;

public:

    Point()
    {
        x = 0;
        y = 0;
    }
    Point(int xi, int yi)
    {
        x = xi;
        y = yi;
    }
    int get_x();
    int get_y();
    void set_x(int xin);
    void set_y(int yin);
};

int Point::get_x() { return x; }
int Point::get_y() { return y; }
void Point::set_x(int xin) { x = xin; }
void Point::set_y(int yin) { y = yin; }

class Segment
{
    Point a;
    Point b;
    Point c;

public:
    Segment(Point ai, Point bi)
    {
        a = ai;
        b = bi;
        c.set_x(ai.get_x() - bi.get_x());
        c.set_y(ai.get_y() - bi.get_y());   
    }

    Point get_a();
    Point get_b();
    Point get_c();

};

Point Segment::get_a() { return a; }
Point Segment::get_b() { return b; }
Point Segment::get_c() { return c; }



void printpoint(Point a){
    cout << a.get_x() << " " << a.get_y() << endl;
}

void printsegment(Segment p){
    printpoint(p.get_a());
    printpoint(p.get_b());
    printpoint(p.get_c());
}
void relation_between_two_segment(Segment p, Segment q)
{
    Point pc = p.get_c();
    Point qc = q.get_c();
    int pcx, pcy, qcx, qcy;
    pcx = pc.get_x(), pcy = pc.get_y(), qcx = qc.get_x(), qcy = qc.get_y();
    if (pcx * qcx + pcy * qcy == 0)
        cout << 1 << endl;
    else if (pcx == 0 && qcx == 0)
        cout << 2 << endl;
    else if (pcy == 0 && qcy == 0)
        cout << 2 << endl;
    else if (pcx != 0 && pcy != 0 && qcx != 0 && qcy != 0 && pcx * qcy == pcy * qcx)
        cout << 2 << endl;
    else
        cout << 0 << endl;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, ax, ay, bx, by;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> ax >> ay >> bx >> by;
        Point a(ax, ay);
        Point b(bx, by);
        Segment p(a, b);
        cin >> ax >> ay >> bx >> by;

        Point c(ax, ay);
        Point d(bx, by);
        Segment q(c, d);
        relation_between_two_segment(p, q);
    }
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


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

public class Main {
    
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        int N = Integer.parseInt(in1[0]);
        int M = Integer.parseInt(in1[1]);
        String S = br.readLine();
        br.close();

        List<Character> T = new ArrayList<>();
        for(int i = S.length() - 1; i >= 0; i--){
            T.add(S.charAt(i));
        }

        List<Integer> ans = new ArrayList<>();
        
        int cont_1 = 0;
        int max_cont_1 = 0;
        for(int i = 0; i <= N; i++){
            if(T.get(i) == '1'){
                cont_1++;
            }else{
                cont_1 = 0;
            }
            max_cont_1 = Math.max(max_cont_1, cont_1);
        }
        if(max_cont_1 >= M){
            System.out.println(-1);
            System.exit(0);
        }

        int position = 0;
        while(position < N){
            int step = M;
            if(position + step > N) step = N - position;

            while(T.get(position + step) == '1'){
                step--;
            }

            ans.add(step);
            position += step;
        }

        for(int i = ans.size() - 1; i >= 0; i--){
            System.out.println(ans.get(i));
        }
    }

    static List<Integer> calc_greedy_path(int len, int M){

        List<Integer> result = new ArrayList<>();

        while(len > M){
            result.add(M);
            len -= M;
        }
        result.add(len);

        return result;
    }
}

Measured memory_bytes: 38144
#include <bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define mod 1000000007

ll arr[3005][3005] = {};
ll n,m;
void test(){
    for(ll i=1; i<=n; i++){
        for(ll ii=1; ii<=m; ii++){
            cout << arr[i][ii] << " ";
        }
        cout << endl;
    }
}

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


    string s1,s2; cin >> s1 >> s2;
    string out = "";
    n = s1.length(); m = s2.length();

    for(ll i=1; i<=s1.length(); i++){
        for(ll ii=1; ii<=s2.length(); ii++){
            if(s1[i-1] == s2[ii-1]){
                arr[i][ii] = arr[i-1][ii-1] + 1;
            }else{
                arr[i][ii] = max(arr[i-1][ii], arr[i][ii-1]);
            }
        }
    }


    ll i = n, ii = m;

    while(i && ii){
        if(arr[i-1][ii-1] < arr[i][ii] && arr[i-1][ii] < arr[i][ii] && arr[i][ii-1] < arr[i][ii]){

            out += s1[i-1];
            i--;
            ii--;
            continue;
        }else{
            if(arr[i-1][ii] > arr[i][ii-1]){
                i--;
            }else{
                ii--;
            }
        }
    }



    for(ll i=out.length()-1; i>=0; i--) cout << out[i];




    return 0;
}

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

#define MOD 1000000007

typedef long long ll;

int N;
int X[5];
ll all;
ll dp[50][1 << 17];
ll bace;

ll F(ll n,ll bit)
{

    if(dp[n][bit] != -1)return dp[n][bit];
    //printf("F log  // %d  ",n);
    //for(int i = 0; i < 17; i++)printf("%d ",(((bit) & (1 << i)) > 0));printf("\n");


    if(((bit >> X[0] + X[1] + X[2] - 1) & 1) &&
       ((bit >> X[1] + X[2] - 1) & 1) &&
       ((bit >> X[2] - 1) & 1))return dp[n][bit] = 0;


    if(n == N)return dp[n][bit] = 1;

    ll res = 0;

    for(int i = 0; i < 10; i++)res = (res + F(n + 1,((bit << (i + 1)) | (1 << i)) & bace)) % MOD;

    res = (res + MOD) % MOD;

    return dp[n][bit] = res;
}

int main()
{
    all = 1;
    memset(dp,-1,sizeof(dp));
    scanf("%d%d%d%d",&N,&X[0],&X[1],&X[2]);
    for(int i = 0; i < N; i++)all = all * 10 % MOD;
    bace = (1 << X[0] + X[1] + X[2]) - 1;
    printf("%lld\n",(all - F(0,0) + MOD) % MOD);
    return 0;
}





Measured memory_bytes: 51456
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

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

	int cnt = 0;
	int br[3];
	for(int i=1; i+1<n; i++){
		br[0] = ar[i-1];
		br[1] = ar[i];
		br[2] = ar[i+1];
		sort(br, br+3);
		if(br[1] == ar[i] && br[1] != br[2]){
			cnt++;
		}
		else if(br[1] == br[2] && br[0] == ar[i] && br[0] != br[1]){
			cnt++;
		}
	}

	cout<< cnt<< endl;

	return 0;
}

Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
A.sort()
size = A[0]
r = 1
ans = 0
for l in range(N):
    if l == r:
        r += 1
        size += A[l]
    while r < N and size * 2 >= A[r]:
        size += A[r]
        r += 1
    if r == N:
        ans += 1
print(ans)

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


int main() {
    long long N;
  	cin >> N;
  	double T = sqrt(N);
  	long long fact = floor(T);
  	long long X = 1;
  
  for(int i = fact; i>0; i--){
  	if(N%i == 0){
    	X = i;
      	break;
    }
  }
  
  long long Ans = N/X + X - 2;
  
  cout << Ans << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
	int n, m,j=1;
	cin >> n >> m;
	int t1, t2, t3;
	t1 = (n - m) * 100;
	t2 = m * 1900;
	rep(i, m) {
		j *= 2;
	}
	int ans = j * (t1 + t2);
	cout << ans << endl;

    return 0;
}



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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
      cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end(), greater<int>());
  int res = 0;
  for(int i = 0; i < K; i++){
  	res += vec.at(i);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


class Chemical{
    int typeA;
    int typeB;
    int cost;
    public Chemical(int a, int b, int c){
        typeA = a;
        typeB = b;
        cost = c;
    }
}

public class Main {
    static void possible(){
        System.out.println("Yes");
        System.exit(0);
    }
    static void impossible(){
        System.out.println("-1");
        System.exit(0);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Ma = sc.nextInt();
        int Mb = sc.nextInt();
        Chemical[] chemical = new Chemical[N];
        for(int n=0; n<N; n++) chemical[n] = new Chemical(sc.nextInt(),sc.nextInt(),sc.nextInt());

        int[][] dp = new int[500][500];
        for(int a=0; a<500; a++)for(int b=0; b<500; b++) dp[a][b]=1_000_000_000;
        dp[0][0] = 0;
        for(int n=0; n<N; n++){
            int[][] next = new int[500][500];
            for(int a=0; a<500; a++)for(int b=0; b<500; b++) next[a][b]=dp[a][b];
            for(int a=0; a<500; a++)for(int b=0; b<500; b++){
                int na = a+chemical[n].typeA;
                int nb = b+chemical[n].typeB;
                if(na <500 && nb <500){
                    next[na][nb] = Math.min(next[na][nb], dp[a][b]+chemical[n].cost);
                }
            }
            dp = next;
        }


        int ans = 1_000_000_000;
        for(int x=1; Ma*x<500&&Mb*x<500; x++) ans = Math.min(ans, dp[Ma*x][Mb*x]);
        if(ans >= 1_000_000_000) impossible();
        else System.out.println(ans);
    }
}


Measured memory_bytes: 44980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype (i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype (i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
string a,b;
int n,m,f[100005][26],pos;vector<int> oc[26];ll ans;
int main()
{
    fastio;
    cin>>a>>b;n=a.size();m=b.size();
    rap(i,0,n) oc[a[i]-97].pb(i),oc[a[i]-97].pb(i+n);
    rep(i,0,25) sort(oc[i].begin(),oc[i].end());
    rap(i,0,n) rep(j,0,25){
        f[i][j]=inf;
        int pos=upper_bound(oc[j].begin(),oc[j].end(),i)-oc[j].begin();
        if(pos>=oc[j].size()) continue;
        f[i][j]=oc[j][pos]-i;
    }
    if(oc[b[0]-97].size()==0){cout<<"-1";return 0;}
    pos=oc[b[0]-97][0];ans=pos+1;
    rap(i,1,m){
        int num=b[i]-97;
        if(f[pos][num]==inf){cout<<"-1";return 0;}
        ans+=f[pos][num];pos=(pos+f[pos][num])%n;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 11600
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}


signed main()
{
    hello();
    
    int n, d;
    cin >> n >> d;
    int res = 0;
    for (int i = 0; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d)
        {
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ? 2e18:1e9+10;
int main(){
	int n;
	while(cin>>n,n){
		int co=0;
		loop(i,0,1010)loop(j,i+2,1010)if(j*(j+1)/2-i*(i+1)/2==n)co++;
		cout<<co<<endl;
	}
}


Measured memory_bytes: 2968
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
struct Sweet {
	int weight, price;
};
int main() {
	int s, d, m;
	while (std::cin >> s >> d >> m) {
		std::vector<int> max_weight(m + 1, 0);
		std::vector<std::vector<Sweet>> sweets(s);
		for (auto &sweet : sweets) {
			int k; std::cin >> k;
			for (auto i = 0; i < k; ++i) {
				Sweet sw; std::cin >> sw.weight >> sw.price;
				sweet.push_back(sw);
			}
		}
		for (auto _i = 0; _i < d; ++_i) {
			int f; std::cin >> f;
			for (auto sweet : sweets[f]) {
				for (int i = m - sweet.price; i >= 0; --i) {
					max_weight[i + sweet.price] = std::max(max_weight[i + sweet.price], max_weight[i] + sweet.weight);
				}
			}
		}
		std::cout << max_weight.back() << ' ' << std::distance(max_weight.begin(), std::lower_bound(max_weight.begin(), max_weight.end(), max_weight.back())) << '\n';
	}
}


Measured memory_bytes: 3132
import math

Q = int(input())
lr = [list(map(int, input().split())) for _ in range(Q)]

# 試し割り法(2以外の偶数は捨てる方法を追加)
def check_prime(n):
    flag = True

    # n:evenかつ2でないならば素数でない
    # n=1は素数でない,n=0も実装しやすいように入れておく
    if (n % 2 == 0 and n != 2) or n == 0 or n == 1:
        flag = False
        return(flag)

    # n:oddまたは2のときは考える
    else:
        # 2からrootnまでに約数は存在しうる
        for i in range(2, math.floor(math.sqrt(n))+1):
            if n % i == 0:
                flag = False
                break
        return(flag)

MAX = 10**5 - 1
prime = [0]*((MAX+1)//2 + 1)
cnt = 0
for i in range(1, len(prime)):
    if check_prime(2*i - 1) and check_prime(i):
        cnt += 1
    prime[i] = cnt

for i in range(Q):
    left = (lr[i][0] - 1) // 2
    right = (lr[i][1] + 1) // 2
    ans = prime[right] - prime[left]
    print(ans)





Measured memory_bytes: 28668
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=200009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int c[M+3];
int dp[M+4];
int nxt[M+4];
int last[M+3];
 main()

{
    fast
    int n;
    cin>>n;
    memset(last,-1,sizeof last);
    f(i,1,n)cin>>c[i];
    rf(i,n,1)
    {
        nxt[i]=last[c[i]];
        //cout<<nxt[i]<<" ";
        last[c[i]]=i;
    }
   // cout<<endl;
    dp[n]=1;
    rf(i,n-1,1)
    {
        if(nxt[i]==-1)
        {
            dp[i]=dp[i+1];
        }
        else if(nxt[i]==(i+1))
        {
            dp[i]=dp[i+1];
        }
        else
        {
            dp[i]=ad(dp[i+1],dp[nxt[i]]);
        }
    }
    cout<<dp[1]<<endl;
    return 0;

}













Measured memory_bytes: 6528
//c++ -std=gnu++14 a.cpp
#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>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int 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);
#define len(x) ((int)(x).size())

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

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){printf("%.9lf\n", A);}
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 = 2000010;
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;
}


ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


void solve(){
  int N;
  cin >> N;
  cout << 9 - (N - 399 + 199) / 200 << endl;
}

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


Measured memory_bytes: 3576
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve()
{
    int animals,legs;
    cin>>animals>>legs;
    rep(i,0,animals+1)
    {
        int turt=i;
        int crane=animals-i;
        if((turt*4)+(crane*2)==legs)
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m,i=0,j,c=0,h[100010],a[100010],b[100010],ans=1;
    double n;
    string s[200010];
    cin >> m;
    cout << fixed << setprecision(12);
    cout<< (double)m*m*m/27 << endl;
    return 0;

}


Measured memory_bytes: 9876
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

template<typename Weight>class PotentializedUnionFind{
public:
  vector<int> par,rnk,sz;
  vector<Weight> difweight;
  PotentializedUnionFind(int n):
    par(n,-1),rnk(n,0),sz(n,1),difweight(n,0){}

  int find(int x){
    if(par[x]<0){return x;}
    else{
      int r=find(par[x]);
      difweight[x]+=difweight[par[x]];
      return par[x]=r;
    }
  }
  Weight weight(int x){
    find(x);
    return difweight[x];
  }
  bool same(int x,int y){return find(x)==find(y);}

  bool unite(int x,int y,Weight w){
    w+=weight(x);w-=weight(y);
    x=find(x);y=find(y);
    if(x==y)return false;
    if(rnk[x]<rnk[y])swap(x,y),w=-w;
    if(rnk[x]==rnk[y])rnk[x]++;
    par[y]=x;
    difweight[y]=w;
    return true;
  }
  Weight diff(int x,int y){return weight(y)-weight(x);}
};

signed main(){
  int n,m;
  cin>>n>>m;
  PotentializedUnionFind<int> puf(100005);
  bool ans=true;
  rep(i,m){
    int l,r,d;
    cin>>l>>r>>d;
    if(puf.same(l,r)){
      if(puf.diff(l,r)!=d)ans=false;
    }else puf.unite(l,r,d);

  }
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>

int main(void){
	
	int input_num=0;
	int *input;
	int i;
	int right=0,left=0;
	int size;
	
	while(1){
		left = 0;
		right = 0;
		scanf("%d", &input_num);
		if(input_num==0){
			return 0;
		}
		size = input_num * 2;
		input = malloc(sizeof(int) * size);
		
		for(i=0 ; i<size ; i++){
			scanf("%d",&input[i]);
		}
	
		for(i=0 ; i<input_num ; i++){
			if(input[2*i]>input[2*i+1]){
				left+=input[2*i];
				left+=input[2*i+1];
			}
			else if(input[2*i]<input[2*i+1]){
				right+=input[2*i];
				right+=input[2*i+1];
			}
			else{
				left+=input[2*i];
				right+=input[2*i+1];
			}	
		}

		printf("%d %d\n",left,right);
		
		free(input);
	}
	
	return 0;
}

Measured memory_bytes: 676
# 貪欲法で得た解に対して、局所探索法(改良ver)

import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

D = I()
c = [0] + LI()
s = [0] + [[0] + LI() for _ in range(D)]

last = [[0]*27 for _ in range(D+1)]
t = [0]

for i in range(1,D+1):
    r = 0
    manzoku = 0
    for j in range(1,27):
        m = s[i][j]
        for k in range(1,27):
            if k != j:
                m -= c[k]*(i-last[i-1][k])
            else:
                continue
        if j == 1:
            r = 1
            manzoku = m
        else:
            if manzoku < m:
                manzoku = m
                r = j
    t.append(r)
    for j in range(1,27):
        if j == r:
            last[i][j] = i
        else:
            last[i][j] = last[i-1][j]


dq = []
for i in range(1,D+1):
    for j in range(1,27):
        dq.append([i,j])

from copy import deepcopy

for i in range(10):
    for d, q in dq:
        t0 = t[d]
        manzoku = s[d][q] - s[d][t0]
        for j in range(d, D + 1):
            if j == d:
                last[d][t0] = last[d - 1][t0]
                manzoku -= c[t0] * (d - last[d][t0])
                last[d][q] = d
                manzoku += c[q] * (d - last[d - 1][q])
            else:
                if last[j][t0] == d:
                    last[j][t0] = last[d - 1][t0]
                    manzoku -= c[t0] * (d - last[d][t0])
                if last[j][q] == last[d - 1][q]:
                    last[j][q] = d
                    manzoku += c[q] * (d - last[d - 1][q])
        if manzoku > 0:
            t[d] = q
        else:
            for j in range(d, D + 1):
                if j == d:
                    last[d][t0] = d
                    last[d][q] = last[d - 1][q]
                else:
                    if last[j][t0] == last[d - 1][t0]:
                        last[j][t0] = d
                    if last[j][q] == d:
                        last[j][q] = last[d - 1][q]

del t[0]

print(*t,sep='\n')

Measured memory_bytes: 77268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
void rle(string s,vector<char> &cha,vector<ll> &num){
    ll a=0,cnt=0;
    string t;char x=s[0];
    while(a<s.size()){
        if(x==s[a])cnt++;
        else{
            cha.pb(x);num.pb(cnt);
            x=s[a];cnt=1;
        }
        a++;
    }
    cha.pb(x);num.pb(cnt);
}
int main(){
    string s;cin >> s;
    ll d=1;
    rev(all(s));
    vvl dp(s.size(),vl(13,0));
    if(s[0]=='?')rep(i,10)dp[0][i]=1;
    else dp[0][s[0]-'0']=1;
    rep(i,s.size()-1){
        d*=10;
        d%=13;
        char c=s[i+1];
        if(c=='?'){
            rep(j,13){
                rep(k,10){
                    dp[i+1][(j+k*d)%13]+=dp[i][j]%MOD;
                    dp[i+1][(j+k*d)%13]%=MOD;
                }
            }
        }
        else{
            ll z=c-'0';
            rep(j,13){
                dp[i+1][(j+z*d)%13]+=dp[i][j]%MOD;
                dp[i+1][(j+z*d)%13]%=MOD;
            }
        }
    }
    cout << dp[s.size()-1][5]%MOD <<endl;
}

Measured memory_bytes: 13696
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main(){
  std::ios_base::sync_with_stdio(false);
  set<string> st;
  int n;
  cin >> n;
  while(n--){
    string BUFF,c;
    cin >> BUFF >> c;
    if(BUFF=="insert") st.insert(c);
    else cout << (st.find(c)!=st.end()?"yes":"no") << endl;
  }
}



Measured memory_bytes: 28996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M,Q;
  cin >> N >> M >> Q;
  vector<pair<int,int>> v;
  int l,r;
  int P[510][510]={0};
  for(int i=0;i<M;i++){
    cin >> l >> r;
    P[l][r-l]++;
  }
  for(int i=1;i<N;i++){
    for(int j=0;j<N;j++){
      P[i][j+1]=P[i][j]+P[i][j+1];
    }
  }
  int p,q;
  for(int i=0;i<Q;i++){
    cin >> p >> q;
    int ans=0;
    for(int j=p;j<=q;j++){
      ans+=P[j][q-j];
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int j = 0; j < W; j++) {
            cout << '#';
        }
        cout << endl;
        for (int i = 0; i < H-2; i++) {
            cout << '#';
            for (int j = 0; j < W-2; j++) {
                cout << '.';
            }
            cout << '#' << endl;
        }
        for (int j = 0; j < W; j++) {
            cout << '#';
        }
        cout << endl << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#pragma GCC optimize ("O3", "unroll-loops")
#pragma GCC target ("avx")
#include <stdio.h>
#include <algorithm>

constexpr unsigned int N = 2e6;
char buffer[N];
char *ptr = buffer;
constexpr unsigned int S = 5e5;
char Out[2 * S];
char *left = Out + S, *right = Out + S;

int main(void){
    setvbuf(stdout, NULL, _IONBF, S);
    fread(buffer, sizeof(char), N, stdin);
    while('a' <= *ptr) *(right++) = *(ptr++);
    unsigned int q = 0;
    while(*(++ptr) >= '0') q = 10 * q + *ptr - '0';
    bool flag = false;
    while(q--){
        if(*(++ptr) == '1') flag = not flag;
        else{
            if((*(ptr += 2) == '1') ^ flag) *(--left) = *(ptr += 2);
            else *(right++) = *(ptr += 2); 
        }
        ptr++;
    }
    if(flag) std::reverse(left, right);
    fwrite(left, sizeof(char), right - left, stdout);
    return 0;
}

Measured memory_bytes: 2048
#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>;

const int INF = 1001001001;

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> dp(h+1, INF);
  dp[0] = 0;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    rep(j,h) {
      int nj = min(j+a,h);
      dp[nj] = min(dp[nj], dp[j]+b);
    }
  }
  cout << dp[h] << endl;
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int m = cin.Int();

			var like = new int[m];
			for (int i = 0; i < n; i++) {
				int k = cin.Int();
				for (int j = 0; j < k; j++) {
					like[cin.Int() - 1]++;
				}
			}

			int ans = 0;
			for (int i = 0; i < m; i++) {
				if (like[i] == n) {
					ans++;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endk cout<<"\n";
typedef long long int ll;
typedef long int l;
#define l(i,a,b) for(i=a;i<b;i++)
#define lo(i,a,b) for(i=a;i>=b;i--)
#define s(v) sort(v.begin(),v.end());
#define pb push_back;
#define vll vector<ll>
#define vint vector<int>
#define test() ll t;cin>>t;while(t--){solve();};
#define test1() int t=1;while(t--){solve();};
bool isPrime(ll x)
{
    ll i,n;
    n=sqrt(x);
    if(x==1) return false;
    if(x==2 || x==3) return true;
    for(i=2;i<=n;i++)
    {
        if(!(x%i)) return false;
    }
    return true;
}
ll power(ll x,ll y)
{
	ll ans=1;
	while(y>0)
	{
		if(y&1) ans=ans*x;
		x=x*x;
		y=y>>1;
	}
	return ans;
}
int solve()
{
    string s,t;
    cin>>s>>t;
    int n,m,i,j,ans,tmp;
    n=s.length();
    m=t.length();
    ans=m;
    for(i=0;i<n-m+1;i++)
    {
        tmp=0;
        for(j=i;j<i+m;j++)
        {
            if(s[j]!=t[j-i])
            {
                tmp++;
            }
        }
        if(tmp<ans)
        {
            ans=tmp;
        }
    }
    cout<<ans;
    return 0;
}
int main()
{
    fst;
    test1();
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    vc<vc<int>> al(n);
    for(int i = 1; i < n; i ++){
        Cin(int, a); a --;
        al[a].push_back(i);
    }

    auto depth = [&](int i, auto self) -> int {
        vc<int> c;
        for(auto &j : al[i]){
            c.push_back(self(j, self));
        }
        DeSort(c);
        int ret = 0;
        For(i, (int)c.size()) Maxi(ret, c[i] + i+1);
        // Cout(i, " : ", ret);
        return ret;
    };
    
    Cout(depth(0, depth));
}




Measured memory_bytes: 13056
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main() {
    int N; cin >> N;
    vector<string> S(N);
    vector<int> P(N);
    for (int i = 0; i < N; ++i) cin >> S[i] >> P[i];

    vector<int> ord(N);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&](int x, int y) {
            if (S[x] == S[y]) return P[x] > P[y];
            else return S[x] < S[y];
        });
    for (auto e : ord) cout << e + 1 << endl;
}


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

func main(){
	var a int
	var b int
	var g int = 3
    fmt.Scanf("%d", &a)
    fmt.Scanf("%d", &b)
    if(a%g== 0 || b%g==0 || (a+b)%g==0){
        fmt.Println("Possible")
    }else{
        fmt.Println("Impossible")
    }
    
}

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

def Sieve_of_Eratosthenes(n):
  is_prime = [True] * (n+1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2, n+1, i):
      is_prime[j] = False
  return is_prime
  #return [i for i in range(n+1) if is_prime[i]]

is_prime = Sieve_of_Eratosthenes(55555)
ans = []
i = 0

while N:
  if is_prime[1+5*i]:
    ans.append(1+5*i)
    N -= 1
  i += 1

print(*ans)

Measured memory_bytes: 9296