akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            var diff = long.MaxValue;
            for (var i = 0; i < N - 2; ++i)
                diff = Min(diff, Abs(753 - long.Parse(S.Substring(i, 3))));
            WriteLine(diff);
        }

        static long Mod = (long)1e9 + 7;
        private static int pl;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27484
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int open=0;
    int close=0;
    int left=0;
    int right=0;
    for (int i=0; i<n; i++){
        if (s[i]=='('){
            open++;
        }
        else {
            if(open>=1){
                open--;
            }
            else {
                left++;
            }
        }
    }
    if (open>=1){
        right=open;
    }
    string ans="";
    for (int i=0; i<left; i++){
        ans+='(';
    }
    ans+=s;
    for (int i=0; i<right; i++){
        ans+=')';
    }
    cout << ans;
}

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

typedef long long ll;
const int MOD = 1000000007;

int main(){
    int N;
    std::cin >> N;
    std::vector<std::vector<int> > aff(N, std::vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            std::cin >> aff.at(i).at(j);
        }
    }
    std::vector<ll> dpt(1<<N, 0);
    dpt.at(0) = 1;

    for (int status = 1; status <= (1<<N) - 1; status++) {
        int m = __builtin_popcount(status);
        for (int f = 0; f < N; f++) {
            if (((1<<f) & status) && (aff.at(m-1).at(f))) {
                dpt.at(status) = (dpt.at(status) + dpt.at(status^(1<<f))) % MOD;
            }
        }
    }

    std::cout << dpt.at((1<<N)-1);
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> V(N, 0);
    for(int i=0; i<N; ++i) cin >> V[i];

    int res = -1001001001;
    for(int l=0; l <= min(K, N); ++l) {
        for(int r=0; l + r <= min(K, N); ++r) {
            priority_queue<int, vector<int>, greater<int>> Q;
            for(int i=0; i<l; ++i) Q.push(V[i]);
            for(int i=0; i<r; ++i) Q.push(V[N - 1 - i]);
            int k = K - l - r;
            while(k > 0 && !Q.empty()) {
                if(Q.top() > 0) break;
                Q.pop();
                --k;
            }
            int tmp = 0;
            while(!Q.empty()) {
                tmp += Q.top();
                Q.pop();
            }
            res = max(res, tmp);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, K, D;
    cin >> X >> K >> D;
    if(X < 0) {
        X = -X;
    }
    ll cnt = X / D;
    if(cnt >= K) {
        cout << X - D * K << endl;
    } else {
        ll nokori = K - cnt;
        if(nokori % 2 == 0) {
            cout << X - D * cnt << endl;
        } else {
            ll tmp = X - D * cnt;
            ll ans = llabs(D - tmp);
            cout << ans << endl;
        }
    }
}

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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

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;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];

//
int main(){
	ll a;cin >> a;

	ll t = 100;

	int cnt = 0;
	while(t < a){
		t += (ll)t/100;
		cnt ++ ;
		// cout << cnt << "\t" << t << endl;
	}

	cout << cnt << endl;	

	return 0;
}
 



Measured memory_bytes: 3596
s=input()
l=len(s)
a=[0,0,0,0]
for i in range(l):
  if(s[i]=='N'):
    a[0]=1
  elif(s[i]=='W'):
    a[1]=1
  elif(s[i]=='S'):
    a[2]=1
  else:
    a[3]=1
if(a[0]*a[2]==0 and a[0]+a[2]!=0 or a[1]*a[3]==0 and a[1]+a[3]!=0):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const line = Number(inputs[0].split(' ')[0]);
  const x = Number(inputs[0].split(' ')[1]);
  const y = Number(inputs[0].split(' ')[2]);
  let distance: number[] = new Array(line).fill(0);

  for (let i = 1; i <= line; i++) {
    for (let j = i + 1; j <= line; j++) {
      // XとYの間の辺を通らない距離
      let ans1 = j - i;
      // XとYの間の辺を通る距離
      let ans2 = 0;

      if (x < i) {
        ans2 += i - x;
      } else {
        ans2 += x - i;
      }

      if (y < j) {
        ans2 += j - y;
      } else {
        ans2 += y - j;
      }

      distance[Math.min(ans1, ans2 + 1)]++;
    }
  }

  for (let i = 1; i < line; i++) {
    console.log(distance[i]);
  }
}


Measured memory_bytes: 9288
def hikaku():
    y = 0
    for x in h :
        if y <= x - 1 :
            y = x - 1
        elif y <= x :
            y = x
        else :
            return 'No'

    return 'Yes'




n = int(input())
h = [int(x) for x in input().split(' ')]

print(hikaku())

Measured memory_bytes: 14396
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
#define sz(x) int(x.size())
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int K;
    cin >> K;
    repeat(i, K) {
        cout << "ACL";
        if (i == K - 1) cout << endl;
    }
    return 0;
}

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

int h, w;
char s[50][50];
string ans = "Yes";
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void updateAns(int y, int x) {
    bool canCreate = false;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (nx == -1 || nx == w || ny == -1 || ny == h) continue;
        if (s[ny][nx] == '#') canCreate = true;
    }
    if (!canCreate) ans = "No";
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                updateAns(i, j);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heappop
from heapq import heappush
from heapq import heappushpop

N,K=map(int,input().split())

a=[list(map(int,input().split()))[::-1] for i in range(N) ]
a.sort(reverse=True)

l=[]
dic1={}
dic2={}

for i in range(K):
    [d,t]=a[i]
    if t in dic1:
        if d>dic2[t]:
            heappush(l,dic2[t])
            dic2[t]=d
        else: heappush(l,d)

    else: 
        dic1[t]=1
        dic2[t]=d


s=sum(l)+sum(dic2.values())
x=len(dic1)
ans=s+x**2

for i in range(K,N):
    if l==[]: break
        
    [d,t]=a[i]
    if not t in dic1:
        dic1[t]=1
        s+=d-heappop(l)
        x+=1
        ans=max(ans,s+x**2) 

    

print(ans)
        

Measured memory_bytes: 29024
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e6+5;
const int mod=1e9+7;
int n,inv[N],ans;
int main(){
	scanf("%d",&n);inv[1]=1;inv[3]=333333336;
	for(int i=2;i<=n;++i)
		inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for(int i=1,j=inv[3];i<=n;++i,j=1ll*j*inv[3]%mod)
		ans=(ans+1ll*j*inv[n]%mod*inv[n-i+1])%mod;
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)
#define int long long

const int inf = 1 << 25;
const ll INF = 1LL << 55;

typedef vector< vector<int> > Graph;

bool warshallfloyd(Graph& graph)
{
  for(int i = 0; i < graph.size(); i++){
    for(int j = 0; j < graph.size(); j++){
      for(int k = 0; k < graph.size(); k++){
	graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
      }
      if(graph[j][j] < 0) return false;
    }
  }
  return true;
}

signed main()
{
  int V, E;
  cin >> V >> E;
  Graph graph(V, vector<int>(V, INF));
  rep(i, V) graph[i][i] = 0;
  while(E--) {
    int s, t, d;
    cin >> s >> t >> d;
    graph[s][t] = d;
  }
  if(!warshallfloyd(graph)) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  rep(i, V) {
    rep(j, V) {
      if(j) cout << " ";
      if(graph[i][j] > (2e10)) cout << "INF";
      else cout << graph[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;

int n, k;
std::vector<long long> w;

int check(long long p) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		long long s = 0;
		while (s + w[i] <= p) {
			s += w[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

int main() {
	std::cin >> n >> k;
	int a;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		w.emplace_back(a);
	}
	long long left = 0;
	long long right = 100000 * 10000;
	long long mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n)right = mid;
		else left = mid;
	}
	std::cout << right << std::endl;
}

Measured memory_bytes: 3936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int n = Integer.parseInt(str[0]);
            int a = Integer.parseInt(str[1]);
            int b = Integer.parseInt(str[2]);
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                String s = String.valueOf(i);
                int sum = 0;
                for (int j = 0; j < s.length(); j++) {
                    int temp = Integer.parseInt(s.substring(j, j + 1));
                    sum += temp;
                }
                if (sum >= a && sum <= b) {
                    ans += i;
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 24020
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int[][] gas = new int[n][n];
		int[][] counts = new int[n][n];
		for (int i = 0; i < n; i++) {
		    Arrays.fill(gas[i], l + 1);
		    Arrays.fill(counts[i], Integer.MAX_VALUE / 10);
		    gas[i][i] = 0; 
		    counts[i][i] = 0;
		}
		for (int i = 0; i < m; i++) {
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    int c = sc.nextInt();
		    gas[a][b] = c;
		    gas[b][a] = c;
		}
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j < n; j++) {
		        for (int k = 0; k < n; k++) {
		            gas[j][k] = Math.min(gas[j][k], gas[j][i] + gas[i][k]);
		        }
		    }
		}
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                if (gas[i][j] <= l) {
                    counts[i][j] = 1;
                }
            }
        }
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j < n; j++) {
		        for (int k = 0; k < n; k++) {
		            counts[j][k] = Math.min(counts[j][k], counts[j][i] + counts[i][k]);
		        }
		    }
		}
		int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int s = sc.nextInt() - 1;
		    int t = sc.nextInt() - 1;
		    if (counts[s][t] >= Integer.MAX_VALUE / 10) {
		        sb.append(-1);
		    } else {
		        sb.append(counts[s][t] - 1);
		    }
		    sb.append("\n");
		}
	    System.out.print(sb);
    }
}


Measured memory_bytes: 60232
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        a :i64,
    }
    println!("{}", if a % 1000 != 0 { 1000 - a % 1000 } else { 0 });
}


Measured memory_bytes: 2200
#include <iostream>

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

int main(void){
    int n, z, w; scanf("%d%d%d\n", &n, &z, &w);
    int ans;
    if(n == 1){
        int a; scanf("%d", &a);
        ans = abs(a-w);
    }
    else{
        int N = n - 2, v0, v1;
        REP(i, N) while(getchar() != ' ');
        scanf("%d%d", &v0, &v1);
        ans = std::max(abs(v0-v1), abs(v1-w));
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/arc091/tasks/arc091_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

vector<ll> solve(){
    ll N,A,B; cin >> N >> A >> B;
    if(A + B > N + 1) return vector<ll>{-1};
    if(A*B < N) return vector<ll>{-1};
    vector<ll> res;
    ll tA = N - A;
    ll now = N;
    for(int i = 0; i < A;i++){
        ll num = min(B-1,tA)+1;
        tA -= num - 1;
        for(int j = 0; j < num;j++) res.push_back(now-num+1+j);
        now -= num;
    }
    reverse(res.begin(),res.end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 6256
N,K = map(int,input().split())
V = list(map(int,input().split()))
ans = 0
for i in range(1,min(N,K)+1):#i個とる
    for j in range(-i,1):
        lis = []
        for k in range(i):
            lis.append(V[j+k])
            #print(i,j,k,j+k)
        lis.sort(reverse=True)
        cnt = 0
        while (len(lis) != 0 and i+cnt < K and lis[-1] < 0):
            del lis[-1]
            cnt += 1
        ans = max(ans,sum(lis))
print(ans)


Measured memory_bytes: 68436
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

template <typename T>
using vec = vector<T>;

template <typename T>
using vec2 = vector<vector<T>>;

template <typename T>
using vec3 = vector<vector<vector<T>>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s.insert(a);
    }

    int ans1, ans2;
    ans1 = x;
    ans2 = x;
    while (s.count(ans1) == 1 && s.count(ans2) == 1) {
        ans1--;
        ans2++;
    }

    if (s.count(ans1) == 1) {
        cout << ans2 << endl;
    } else {
        cout << ans1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#CF16A
A=[chr(ord('A') + i) for i in range(26)]
H,W=map(int,input().split())
S=[list(map(str,input().split())) for _ in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w]=='snuke':
            print(A[w]+str(h+1))

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

int main(){
	int i=1;
	int x,y;
		while(1){
			cin>>x>>y;
				if(x==0&&y==0)break;
			if (x<y){
				cout<<x<<" "<<y<<endl;
			} else {
				cout<<y<<" "<<x<<endl;
				}
		i++;
		}


return 0;
}


Measured memory_bytes: 3056
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(a: usize, b: usize);

    let mut count = 0;
    let mut mouth = 1;
    loop {
        if mouth >= b {
            break;
        }
        mouth += a - 1;
        count += 1;
    }

    println!("{}", count);
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, k;
    while(cin>>n>>k){
        ll ans=0;
        if(k==1){
            cout<<0<<endl;
        }
        else{
            cout<<n-k<<endl;
        }

    }
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
  int X;
  cin >> X;
  
  int64_t happiness = 0;
  if(X>=500){
    happiness = (X / 500) * 1000;
    X = X % 500;
  }
  if(X>=5){
    happiness += (X/5) * 5;
    X = X % 5;
  }

  cout << happiness << endl;
}


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

using namespace std;

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	long long d = c - a - b;
	if (d > 0 && d * d > 4LL * a * b)
		puts("Yes");
	else 
		puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin>>n;
  double x,s=0;
  string u;
  for(int i=0; i<n; i++){
    cin>>x>>u;
    if(u=="JPY") s+=x;
    else s+=380000*x;
  }
  printf("%-10.5lf\n",s);
}

Measured memory_bytes: 3812
N,M,C = [int(i) for i in input().split()]

B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for i in range(N)]

rez = [0]*N

for i in range(M):
  for j in range(N):
    rez[j] += B[i]*A[j][i]

count = 0
for i in rez:
  if i+C>0:
    count+=1
print(count)

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, M;
    cin >> N >> M;
    cout << (N == M ? "Yes": "No") << endl;
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S.size() == 1) { std::cout << NO << endl; return;}

    string hi = "hi";
    for(int i = 0; i < S.size(); i+=2) {
        if(S[i] != hi[0]) {
            std::cout << NO << endl;
            return;
        }
        if(S[i+1] != hi[1]) {
            std::cout << NO << endl;
            return;
        }
    }

    std::cout << YES << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include <stdio.h>
using namespace std;
 
int main(){
  int W,H,x,y,r;

  cin >> W >> H >> x >> y >> r;

  if((x-r)<0 || (y-r)<0){
    cout << "No" << endl;
  }
  else if(W < x+r || H < y+r){
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }  

  return 0;		 
}


Measured memory_bytes: 3116
n=int(input())

def divisions(n):
  divisors=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      divisors.append(i)
      if i!=n//i:
        divisors.append(n//i)
  return divisors
divisors=divisions(n)
if len(divisors)%2==1:
  print((divisors[-1]-1)*2)
else:
  print(divisors[-1]+divisors[-2]-2)
  






Measured memory_bytes: 3384
#include <stdio.h>
#include <math.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main()
{
	int hills[10];
	int i;
	int N1 = 0;
	int N2 = 0;
	int N3 = 0;
	for (i = 0; i < 10; ++i) {
		scanf("%d", &hills[i]);
	}

	for (i = 0; i < 10; ++i) {
		if (N3 < hills[i] && N2 < hills[i] && N1 < hills[i]) {
			N3 = N2;
			N2 = N1;
			N1 = hills[i];
		} else if (N3 < hills[i] && N2 < hills[i]) {
			N3 = N2;
			N2 = hills[i];
		} else if (N3 < hills[i]) {
			N3 = hills[i];
		}
	}
	printf("%d\n%d\n%d\n", N1, N2, N3);
	
	return 0;
}

Measured memory_bytes: 600
function Main(input) {
  input = input.split(' ')
  var D = parseInt(input[0])
  var N = parseInt(input[1])

  if (N === 100) {
    N++
  }

  answer = D === 0 ? N : Math.pow(100, D) * N
  console.log(answer)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))



Measured memory_bytes: 11468
#include <stdio.h>
#define abs(x) ((x) > 0 ? (x) : -(x))
#define max(x, y) ((x) > (y) ? (x) : (y))

int
main(int argc, char *argv[])
{
  int n, k, ans;
  scanf("%d%d", &n, &k);
  int a, b = -1; int x[100005] = {}; int c = 0, minus = 0;
  for(int i = 0; i < n; i++){
    scanf("%1d", &a);
    if(b - a != 0) c++;
    if(a == 1) x[c]++;
    if(a == 0){
      x[c]--;
    }
    b = a;
  }
  x[0] = 0;
  x[++c] = 0;
  int sum[100005] = {};
  sum[0] = 0;
  for(int i = 1; i <= c; i++){
    sum[i] = sum[i - 1] + abs(x[i]);
    if(x[i] < 0) minus++;
  }
 

  if(minus <= k) ans = n;
  else{
    int t; ans = 0;
    if(x[1] < 0) t = 1;
    if(x[2] < 0) t = 2;
    while(t + 2 * (k - 1) < c){
      ans = max(ans, sum[t + 2 * (k - 1) + 1] - sum[max(t - 2, 0)]);
      t += 2;
    }
  }
  printf("%d\n", ans);
  return 0;
}
    
    


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 1000000007;


int main()
{
	ll N;
	cin >> N;
	vector<ll> a(N), b(N), c(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<ll>> dp(3, vector<ll>(100000, 0));
	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];
	for (ll i = 1; i < N; i++)
	{
		dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
		dp[1][i] = max(dp[2][i - 1], dp[0][i - 1]) + b[i];
		dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i];
	}
	cout << max(dp[0][N - 1], max(dp[1][N - 1], dp[2][N - 1])) << endl;
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,n) for(i=0;i<n;i++)in(v[i]);
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define cf(n) printf("%I64d\n",n)
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
typedef long long int ll;
#define N 2000005
int main()
{
    int n,i,a;
    in(n);
    vector<int> v(n),c(n);
    read(v,n);
    read(c,n);
    a=0;
    for(i=0;i<n;i++)
        if(v[i]>c[i])a+=(v[i]-c[i]);
    out(a);
}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

const int mod = 1e9 + 7;
const int NMAX = 10005;

int N, K;
int fct[NMAX], ifct[NMAX], p2[NMAX];

int power(int x, int y)
{
    if(y <= 0)  return 1;
    int ans = power( (1LL * x * x) % mod, y >> 1 );
    if(y & 1) ans = (1LL * ans * x) % mod;
    return ans;
}

int pw2(int x) { if(x < 0) return 1; return p2[x]; }

int C(int N, int K)
{
    if(N < K)   return 0;
    int ans = (1LL * fct[N] * ifct[K]) % mod;
    ans = (1LL * ans * ifct[N - K]) % mod;
    return ans;
}

void pre(int N)
{
    fct[0] = 1;
    for(int i = 1; i <= N; i++) fct[i] = (1LL * fct[i - 1] * i) % mod;

    ifct[N] = power(fct[N], mod - 2);
    for(int i = N - 1; i >= 0; i--) ifct[i] = (1LL * ifct[i + 1] * (i + 1)) % mod;

    p2[0] = 1;
    for(int i = 1; i <= N; i++) p2[i] = (2LL * p2[i - 1]) % mod;
}

int getNumberOfWays(int N, int M)
{
    if(N == 0)  return 1;
    M++;
    if(N == 1)  return M;
    int ans = (1LL * fct[M + 2 * N - 1] * ifct[M + N]) % mod;
    ans = (1LL * ans * M) % mod;
    ans = (1LL * ans * ifct[N]) % mod;
    return ans;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    pre(10000);

    scanf("%d%d", &N, &K);
    if(N == K)
    {
        printf("%d\n", getNumberOfWays(N - 1, 0));
        return 0;
    }

    int ans = 0;
    for(int i = 0; i < K; i++)
    {
        int sol = getNumberOfWays(i, K - 1 - i);
        sol = (1LL * sol * C(N - 2 - i, K - 1 - i)) % mod;
        ans = (ans + sol) % mod;
    }
    ans = (1LL * ans * pw2(N - K - 1)) % mod;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>

using namespace std;

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

int k;
int main(){
    scanf("%d", &k);
    long long ans = 0;
    for (int i = 1; i <= k; i++){
        for (int j = 1; j <= k; j++){
            for (int l = 1; l <= k; l++){
                ans += gcd(gcd(i,j),l);
            }
        }
    }
    printf("%lld", ans);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    while(cin>>ch)
    {
        if(ch>='A' && ch<='Z')
        {
            cout<<"A"<<endl;
        }
        else
        {
            cout<<"a"<<endl;
        }
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    string s, t;
    cin >> s >> t;
    rep(i, s.size()){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int C = sc.nextInt();
		//角度をラジアンとして数値にする
		//Math.PI→円周率
		double Cc = C * Math.PI / 180;

		double L = a + b + Math.sqrt((a * a) + (b * b) - 2 * a * b * Math.cos(Cc));
		double h = b * Math.sin(Cc);
		double S = a * (b * Math.sin(Cc)) / 2;

		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}
}


Measured memory_bytes: 26464
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}


*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;
 
int main() {
	// 入力
    int H, W;
    cin >> H >> W;
    string line[H];
    for (int i = 0; i < H; ++i) cin >> line[i];
    
    
    
    string C[H+2][W+2];
    for (int i = 0; i < H+2; ++i){
    	for (int j = 0; j < W+2; ++j) C[i][j] = ".";
    }
    
    //for (int i = 0; i < H; ++i) cout << line[i] <<endl;
    
    for (int i = 1; i <= H; ++i){
    	for (int j = 1; j <= W; ++j) C[i][j] = line[i-1][j-1];
    }
 
    //for (int i = 0; i < H+2; ++i){
    //	for (int j = 0; j < W+2; ++j) cout << C[i][j];
    //	cout << endl;
    //}
    
    string ans = "Yes";
    for (int i = 1; i <= H; ++i){
        for (int j = 1; j <= W; ++j){
            if (C[i][j]!="." 
    	    && C[i-1][j]=="." 
    	    && C[i+1][j]=="." 
    	    && C[i][j-1]=="." 
    	    && C[i][j+1]==".") ans = "No";
        }
    		
    }
    
	//出力
    //if (H==1 && W==1) ans = 'No';
    cout << ans << endl;
}
 


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a = A[i]
        for j in range(19):
            if a <= 10**j:
                m = j
                break
        for k in range(19):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 19):
            print(-1)
            break
        elif(ans*a == 10**18):
            ans = ans*a
        elif(ans*a > 10**18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)

Measured memory_bytes: 21808
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include<string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
	if(k>a&&k<=a+b) cout<<a;
	if(k>a+b&&k<=a+b+c) cout<<a-(k-a-b); 
    if(k>a+b+c) cout<<a-c;

}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int i;
	ll k;
	string s;
	cin >> s;
	cin >> k; --k;
	while(k && s[i]=='1'){
		--k;
		++i;
	}
	cout << s[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e9+7;
int main() {
    int N;
    cin >> N;
    vector<int> C(N-1);
    vector<int> S(N-1);
    vector<int> F(N-1);
    rep(i, N-1) cin >> C[i] >> S[i] >> F[i];
    rep(i, N) {
        int t = 0;
        for ( int j = i; j < N - 1; ++j ) {
            if ( t < S[j] ) {
                t = S[j];
            }
            else if ( t % F[j] != 0 ) {
                t = t + F[j] - t % F[j];
            }
            t += C[j];
        }
        printf("%d\n", t);
    }
    return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<ll> a(n), bit(60);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    for(int i = n - 1; i > 0; i--) {
        for(int j = 0; a[i] > 0; j++) {
            bit[j] += a[i] % 2;
            a[i] >>= 1;
            //cout << bit[j];
        }
        //cout << endl;
        ll buff = a[i - 1];
        for(int j = 0; j < 60; j++) {
            if(!((buff >> j) % 2))
                ans += bit[j] * ((1ll << j) % MOD) % MOD;
            else
                ans += (n - i - bit[j]) * ((1ll << j) % MOD) % MOD;
            //bit[j] * ((1ll << j) % MOD) % MOD
            ans %= MOD;
            //cout << j << "a" << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 2560
import collections

N = int(input())
names = [input() for s in range(N)]

c = collections.Counter(names)

max_value = max(c.values())

output_list = []
for k, v in c.items():
    if v == max_value:
        output_list.append(k)

for name in sorted(output_list):
    print(name)

Measured memory_bytes: 35572
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

if a<40:
    a=40
if b<40:
    b=40
if c<40:
    c=40
if d<40:
    d=40
if e<40:
    e=40

f=a+b+c+d+e
g=int(f/5)

print(g)


Measured memory_bytes: 5588
import os, sys, re, math

S = input()

s1 = int(S[:2])
s2 = int(S[2:])
mr = range(1, 13)

if s1 in mr and s2 in mr:
    print('AMBIGUOUS')
elif s1 in mr:
    print('MMYY')
elif s2 in mr:
    print('YYMM')
else:
    print('NA')

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

int main () {
  int N; cin >> N;
  
  int t=N, c=0;
  while (t>0) {
    c += t%10;
    t /= 10;
  }  
  if (N%c == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

char shi['Z'+10];
string bo['z'+10];

int main() {
    shi['T']='a';
    shi['L']='i';
    shi['U']='u';
    shi['R']='e';
    shi['D']='o';

    bo['1']="";
    bo['2']="k";
    bo['3']="s";
    bo['4']="t";
    bo['5']="n";
    bo['6']="h";
    bo['7']="m";
    bo['8']="y";
    bo['9']="r";
    bo['0']="w";
    string s;
    cin>>s;
    string ans="";
    rep(i,s.size()) {
        if(i%2==0) {
            ans+=bo[s[i]];
        }
        else ans+=shi[s[i]];
    }
    rep(i,ans.size()) {
        if(!i) continue;
        if(ans[i-1]=='w'&&ans[i]=='u'){
            ans[i-1]=ans[i]='n';
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1200
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f
inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
int x,y,z;
signed main() {
  IO;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;


void Main()
{
	std::string s, t;
	std::cin >> s >> t;
	std::array<std::vector<std::int64_t>, 26> indexes{};
	for (auto i : boost::irange<std::int64_t>(0, s.size()))
	{
		indexes[s[i] - 'a'].emplace_back(i);
	}
	std::int64_t last = -1, loop = 0;
	if (indexes[t[0] - 'a'].size() == 0)
	{
		std::cout << -1 << std::endl;
		return;
	}
	last = indexes[t[0] - 'a'][0];
	for (auto index : boost::irange<index_t>(1, t.size()))
	{
		int i = t[index] - 'a';
		if (indexes[i].size() == 0)
		{
			std::cout << -1 << std::endl;
			return;
		}
		else
		{
			auto ite = boost::upper_bound(indexes[i], last % s.size());
			if (ite == indexes[i].end())
			{
				++loop;
				last = indexes[i][0] + s.size() * loop;
			}
			else
			{
				last = *ite + s.size() * loop;
			}
		}
	}
	std::cout << last + 1 << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 1736
#!/usr/bin/env python3
#ABC143 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
l = LI()
l.sort()
ans = 0
for i in range(n):
    for j in range(i+1,n):
        r = bl(l,l[i]+l[j])
        ans += (r-(j+1))
print(ans)

Measured memory_bytes: 44816
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think('sippuu'), 'Yes')

    def test_2(self):
        self.assertEqual(think('iphone'), 'No')

    def test_3(self):
        self.assertEqual(think('coffee'), 'Yes')


def solve():
    s = read()
    result = think(s)
    write(result)


def read():
    return read_line()


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    return 'Yes' if data[2] == data[3] and data[4] == data[5] else 'No'


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 51312
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n),dp(n,1e9);
    for(int i=0;i<n;i++)
        cin>>v[i];
    dp[0]=0;
    for(int i=1;i<n;i++)
        for(int j=1;j<=k;j++)
            if(i-j>=0) dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
    cout<<dp[n-1]<<'\n';
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back
#define UNIQ(a) a.erase(unique(all(a)), end(a))

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;
constexpr int mod = TEN(9) + 7;

int N, L, Q;
int to[100010][25];

signed main()
{
	cin >> N;

	vi x(N);
	rep(i, N) cin >> x[i];

	cin >> L >> Q;

	rep(i, N) rep(j, 20) to[i][j] = N + 1;

	rep(i, N) {
		int idx = upper_bound(all(x), x[i] + L) - begin(x) - 1;
		to[i][0] = idx;
	}

	range(j, 1, 20) {
		rep(i, N) {
			to[i][j] = to[to[i][j - 1]][j - 1];
		}
	}

	rep(_, Q) {
		int a, b; cin >> a >> b;
		--a, --b;
		if (a > b) swap(a, b);

		int ans = 0;

		int cur = a;

		rrep(i, 20) {
			if (b > to[cur][i]) {
				cur = to[cur][i];
				ans += 1ll << i;
			}
		}

		ans++;

		printf("%lld\n", ans);
	}
}




Measured memory_bytes: 23584
#include <cstdio>
#include <vector>
#include <queue>
#include <tuple>

const int P = 1000000007;

using namespace std;

vector<pair<int, int> > g[100001];
long long d[2][100001];
int c[2][100001];
int v[100001];

void f(int n, int x, long long d[], int c[]) {
	priority_queue<tuple<long long, int, int> > pq;
	int i;
	for (i = 1; i <= n; i++) v[i] = 0;
	c[0] = 1;
	pq.emplace(0LL, x, 0);
	while (!pq.empty()) {
		auto p = pq.top();
		pq.pop();
		if (v[get<1>(p)]) {
			if (d[get<1>(p)] == -get<0>(p)) {
				c[get<1>(p)] += c[get<2>(p)];
				if (c[get<1>(p)] >= P) c[get<1>(p)] -= P;
			}
			continue;
		}
		v[get<1>(p)] = 1;
		d[get<1>(p)] = -get<0>(p);
		c[get<1>(p)] = c[get<2>(p)];
		for (auto q : g[get<1>(p)]) pq.emplace(get<0>(p) - q.second, q.first, get<1>(p));
	}
}

int main() {
	int i, j, k, n, m, p, q, r = 0;
	scanf("%d%d%d%d", &n, &m, &p, &q);
	while (m--) {
		scanf("%d%d%d", &i, &j, &k);
		g[i].emplace_back(j, k);
		g[j].emplace_back(i, k);
	}
	f(n, p, d[0], c[0]);
	f(n, q, d[1], c[1]);
	r = (long long)c[0][q] * c[0][q] % P;
	for (i = 1; i <= n; i++) {
		if (i != p && i != q && (d[0][i] << 1) == d[0][q] && (d[1][i] << 1) == d[0][q]) {
			int tt = (long long)c[0][i] * c[1][i] % P;
			r -= (long long)tt * tt % P;
			if (r < 0) r += P;
		}
		for (auto t : g[i]) if ((d[0][i] << 1) < d[0][q] && (d[0][i] + t.second << 1) > d[0][q] && d[0][i] + d[1][t.first] + t.second == d[0][q]) {
			int tt = (long long)c[0][i] * c[1][t.first] % P;
			r -= (long long)tt * tt % P;
			if (r < 0) r += P;
		}
	}
	printf("%d\n", r);
	return 0;
}


Measured memory_bytes: 18764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int d, n;
	cin >> d >> n;
	ll ans = 1;
	while(1){
		ll temp = ans;
		int count = 0;
		while(temp % 100 == 0){
			temp /= 100;
			count++;
		}
		if(count == d){
			n--;
		}
		if(n == 0){
			cout << ans << endl;
			return 0;
		}
		ans++;
	}
	return 0;
}

Measured memory_bytes: 384