akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		short[] a = new short[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextShort();
		}
		for (int i = 0; i < 3; i++) {
			for (int j = i + 1; j < 3; j++) {
				if (a[i] > a[j]) {
					short b = a[i];
					a[i] = a[j];
					a[j] = b;
				}
			}
		}
		System.out.println(a[0] + " " + a[1] + " " + a[2]);
		sc.close();
	}

}


Measured memory_bytes: 26148
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int gcd(vector<int> v)
{
    int ret = v[0];
    for (int i = 0; i < v.size(); i++)
    {
        ret = __gcd(ret, v[i]);
    }
    return ret;
}


int main(){
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    rep(i, N) cin >> x[i];

    rep(i, N){
        x[i] = abs(x[i] - X);
    }
    cout << gcd(x) << endl;
    return 0;


}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	long long n, i, s1, s2, m, min,sum=0;
	long long *arr;
	scanf("%lld", &n);
	arr = (long long*)malloc(sizeof(long long)*n);
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &arr[i]);
		sum += arr[i];
	}
	for (i = 0,s1=0; i < n - 1; i++)
	{
		s1 += arr[i];
		s2 = sum - s1;
		if (s1 > s2)m = s1 - s2;
		else m = s2 - s1;
		if (i == 0)min = m;
		if (min > m)min = m;
	}
	printf("%lld", min);
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;


int main(){
 
 int A,B,C;cin>>A>>B>>C;
 int ans = B/A;
 cout<<min(ans,C)<<endl;



  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=101;
int n,x,a[N];
int main(){
    int last=0,ans=0;
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        if(last<=x) ++ans;
        last+=a[i];
    }
    if(last<=x) ++ans;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
read s

if [ ${s:0:1} != 'A' ] ; then
    echo "WA" && exit
fi

flag=0

for (( i = 2; i < ${#s}-1; i++ )) do
    if [ ${s:$i:1} == 'C' ] ; then
        flag=1
    fi
done

if [ $flag != 1 ] ; then
    echo "WA" && exit
fi

count=0

for (( i = 0; i < ${#s}; i++ )) do
    if [ $(echo ${s:$i:1} | awk '/[A-Z]/') ] ; then
        count=$((count+=1))
    fi
done

if [ $count != 2 ] ; then
    echo "WA"
else
    echo "AC"
fi

Measured memory_bytes: 4172
from collections import deque
k=int(input())

qu=deque(list(range(1,10)))
count=0
while True:
  x=qu.popleft()
  count+=1
  if count==k:
    print(x)
    break
  if str(x)[-1]!="0":
    qu.append(int(str(x)+str(int(str(x)[-1])-1)))
  qu.append(int(str(x)+str(x)[-1]))
  if str(x)[-1]!="9":
    qu.append(int(str(x)+str(int(str(x)[-1])+1)))
    

Measured memory_bytes: 16588
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

double minkowski (int n, int x[], int y[], int p) {
    double sum = 0.0;
    if (p < 4) {
        for (int i = 0; i < n; i++) {
            sum += pow(abs(x[i] - y[i]), p);
        }
        return pow(sum, (double)1/p);
    } else {
        for (int i = 0; i < n; i++) {
            sum = fmax(sum, abs(x[i] - y[i]));
        }
        return sum;
    }
}

int main(void){
    int n, x[100], y[100];

    scanf("%d\n", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &x[i]);
    for (int i = 0; i < n; i++)
        scanf("%d", &y[i]);

    printf("%lf\n", minkowski(n, x, y, 1));
    printf("%lf\n", minkowski(n, x, y, 2));
    printf("%lf\n", minkowski(n, x, y, 3));
    printf("%lf\n", minkowski(n, x, y, (int)INFINITY));

    return 0;
}


Measured memory_bytes: 2148
N=int(input())
lis=[0]*(N+1)
Mcnt=0
Mi=1

for i in range(1,N+1):
  lis[i]=i
  cnt=0
  while lis[i]%2==0:
    lis[i]//=2
    cnt+=1
    
  if Mcnt<cnt:
    Mcnt=cnt
    Mi=i
    
print(Mi)

Measured memory_bytes: 9088
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

fun IntArray2D(i: Int, j: Int, defaultValue: () -> Int) = Array(i) { IntArray(j) { defaultValue() } }
fun LongArray2D(i: Int, j: Int) = Array(i) { LongArray(j) }

fun Array<LongArray>.updateMax(i: Int, j: Int, v: Long): Long {
    if (this[i][j] < v) this[i][j] = v
    return this[i][j]
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val W = sc.next().toInt()
        val WV = IntArray2D(N, 2) { sc.next().toInt() }
        val dp = LongArray2D(N + 1, W + 1)
        for (i in 1..N) {
            val w = WV[i - 1][0]
            val v = WV[i - 1][1]
            for (j in 1..W) {
                dp.updateMax(i, j, dp[i - 1][j])
                if (j >= w) dp.updateMax(i, j, dp[i - 1][j - w] + v) // 入れる
            }
        }
        pw.println(dp[N][W])
    }
}


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

int main() {
  int N,ans,B,C,D;
  ans=1;
  cin >>N;
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  sort(S.begin(),S.end());
    for(int i=1;i<N;i++){
      if(S[i]==S[i-1]){
        continue;
      }
      ans++;
  }
  cout <<ans<< endl;
}


Measured memory_bytes: 9596
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
int main() {
	vector<pair<int,string>> x(1000);
	string a;
	int j=1,s=0,m=0;
	while(cin >> a) {
		for (int i = 0; i <j ; i++) {
			if (x[i].second == a) {
				x[i].first++;
				break;
			}
			if (i == j - 1) {
				x[i].second = a;
				x[i].first = 1;
				j++;
				break;
			}
		}
	}
	sort(x.begin(), x.end(), greater<pair<int, string>>());
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() > s) {
			s = x[i].second.size();
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first > m) {
			m = x[i].first;
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first == m) {
			cout << x[i].second << ' ';
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() == s) {
			cout << x[i].second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Modulo Summation
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    sum += ai - 1;
  }

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 21:57:09
*/

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


int main(){
    vector<int> a(5);
    rep(i,5) cin >> a[i];
    int k;
    cin >> k;
    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            if( abs(a[j]-a[i]) > k ){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 3608
s = list(input())
n = len(s)

ans = 'Yes'
for i in range((n-1)//2):
    if s[i] != s[n-i-1]:
        ans = 'No'
for i in range((n-1)//2):
    if s[i] != s[(n-1)//2-i-1]:
        ans = 'No'
s_inv = s[::-1]
for i in range((n-1)//2):
    if s_inv[i] != s_inv[(n-1)//2-i-1]:
        ans = 'No'
print(ans)

Measured memory_bytes: 3064
S = input()
A = int(S[:2])
B = int(S[2:])

if 1<=A<=12 and 1<=B<=12:
  print("AMBIGUOUS")
elif 1<=A<=12:
  print("MMYY")
elif 1<=B<=12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 9056
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int a[1000][1000];
int main() {
	scanf("%d", &n);
	int l = 1, r = 2 * n, m = -1;
	while(l <= r) {
		int mid = (l + r) / 2;
		if(mid > sqrt(2 * n))r = mid - 1;
		else if(mid * (mid + 1) == 2 * n) {
			m = mid;
			break;
		}
		else if(mid * (mid + 1) < 2 * n)l = mid + 1;
		else r = mid - 1;
	}
	if(m == -1)printf("No\n");
	else {
		printf("Yes\n%d\n", m + 1);
		int l = 1;
		int x = 0;
		for(int i = 1; i <= m; i++) {
			for(int j = l; j <= m; j++) a[i][j] = ++x;
			int y = x + 1;
			for(int j = m + 1; j >= l + 1; j--) a[j][i] = --y;
			l++;
		}
		for(int i = 1; i <= m + 1; i++) {
			printf("%d", m);
			for(int j = 1; j <= m; j++) printf(" %d", a[i][j]);
			printf("\n");
		}
	}
}

Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[100100];

int solve() {
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        m[a[i]]++;
    }

    int res = 0;
    for (auto v : m) {
        int p = v.first, q = v.second;
        if (p > q) {
            res += q;
        } else {
            res += q - p;
        }
    }
    return res;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k;cin>>k;
  queue<ll> q;rep(i,9) q.push(i+1);
  for(ll cnt=1;cnt<k;++cnt) {
    ll v=q.front(),w=v%10;q.pop();
    if(w!=0) q.push(v*10+w-1);
    q.push(v*10+w);
    if(w!=9) q.push(v*10+w+1);
  }
  print(q.front());
  return 0;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


int main() {
    unsigned long long n, k;
    cin >> n >> k;

    unsigned long long x1;
    x1 = n - (unsigned long long)(n / k) * k;
    unsigned long long x2;
    x2 = k - x1;

    cout << min(x1, x2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

using Graph = vector<vector<int>>;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;


int main()
{
    //累積わ
    //スライディング最大値
    int p = 0;

    int N, K;
    cin >> N >> K;
    ll sum_m = 0;
    ll isum = 0;
    vector <int> a(N);
    
    REP(i,N)
    {
        cin >> a[i];
    }

    for(int i = 0; i < K; ++i)
    {
        isum += a[i];
    }
    sum_m = isum;

    for(int i = K; i < N; ++i)
    {
        isum += a[i];
        isum -= a[i-K];

        if(sum_m < isum)
        {
            sum_m = isum;
            p = i+1 - K;
        }
    }

    double res = 0;

    for(int i = p; i < p + K; ++i)
    {
        res += (double)(1.0 + a[i])/ double(2.0);
        //cout << a[i] <<endl;
    }


    printf("%.12f\n", res);


    return 0;
}

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

int main()
{
    string tmp;
    vector<string> str;
    for(int i=0; i<3; i++){
        cin >> tmp;
        str.push_back(tmp);
    }
    for(int i=0; i<3; i++){
        cout << str[i][i];
    } cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = [0 for i in range(a[n-1]+2)]
for i in a:
    ans[i] += 1
    ans[i+1] += 1
    if i-1 > 0:
        ans[i-1] += 1
ans.sort()
print(ans[len(ans)-1])


Measured memory_bytes: 14008
n = int(input())
count = 0
flag = 0
for i in range(n):
  x, y = map(int, input().split())
  if(x == y):
    count += 1
  else:
    count = 0
  if count == 3:
    flag = 1
if(flag == 1):
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <list>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <assert.h>
typedef long long ll;
typedef long double ld;
using namespace std;

const int SZ = 1e5 + 10;
const int INF = 1e9;

vector<int> win[SZ];

int dfs(int h) {
	vector<int> d;
	for (int i : win[h])
		d.push_back(dfs(i));
	sort(d.rbegin(), d.rend());
	int mx = 1, p = 1;
	for (int i : d) {
		mx = max(mx, i + p);
		p++;
	}
	return mx;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int x;
		cin >> x;
		win[x - 1].push_back(i);
	}
	cout << dfs(0) - 1;

	return 0;
}

Measured memory_bytes: 15104
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
vector<vector<ll>> matrixmul(int l, int m, int n, vector<vector<ll>> a, vector<vector<ll>> b){
	vector<vector<ll>> c;
	for(int i=0; i<l; i++){
		vector<ll> v;
		for(int j=0; j<n; j++){
			ll x=0;
			for(int k=0; k<m; k++){
				x+=(a[i][k]*b[k][j]);
				x%=MOD;
			}
			v.push_back(x);
		}
		c.push_back(v);
	}
	return c;
}
vector<vector<ll>> matrixpow(int n, vector<vector<ll>> a, ll k){
	vector<vector<ll>> ap=a, ans;
	for(int i=0; i<n; i++){
		vector<ll> v;
		for(int j=0; j<n; j++){
			if(i==j){
				v.push_back(1);
			}else{
				v.push_back(0);
			}
		}
		ans.push_back(v);
	}
	while(k){
		if(k&1) ans=matrixmul(n, n, n, ap, ans);
		ap=matrixmul(n, n, n, ap, ap);
		k>>=1;
	}
	return ans;
}
int main()
{
	int n; ll k;
	cin>>n>>k;
	vector<vector<ll>> a;
	for(int i=0; i<n; i++){
		vector<ll> ai;
		for(int j=0; j<n; j++){
			ll aij; cin>>aij;
			ai.push_back(aij);
		}
      a.push_back(ai);
	}
	vector<vector<ll>> a0=matrixpow(n, a, k);
	ll ans=0;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			ans+=a0[i][j];
			ans%=MOD;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {

	long long int n,sum; cin>>n;
	for(long long  int i=sqrt(n);i>=1;i--) {
		if(n%i==0) {
			sum=i+(n/i)-2;
			break;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,n - 1)
#define rep1(i,n) repU(i,1,n)
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) ((a) & 1 == (b) & 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;


ll N,M,A,B,C,D,K,a[100100],b[100100];
string S,T;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> S;
	int len = S.size();
	if(len & 1){
		if(S[0] == S[len - 1]) esc("Second");
	}else{
		if(S[0] != S[len - 1]) esc("Second");
	}
	esc("First");
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll a, b;
    	ll v, w, t;
	cin >> a >> v;
	cin >> b >> w >> t;

	ll dis = abs(b - a);
	ll soutai = v - w;
	if (soutai <= 0)
	{
		cout << "NO" << endl;
	}
	else
	{
		if ((dis + soutai - 1) / soutai <= t)
			cout << "YES" << endl;
		else
		{
			cout << "NO" << endl;
		}
	}


	return 0;
}

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

int main(){
  string a = "",res = "NO";
  cin >> a;
  if(a.substr(0,7) =="keyence"){
    res = "YES";
  }
  if(a.substr((a.length()-7),7) == "keyence"){
    res = "YES";
  }
  for(int i = 0;i < 7;i++){
    string c = (a.substr(0,i) + (a. substr((a.length()-(7-i)),(7-i))));
    if(c == "keyence"){
      res = "YES";
      break;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
const main = (input: string) => {
  const lines = input.trim().split("\n")
  const N = parseInt(lines[0])
  const [p, q] = lines.slice(1).map(line => line.split(" ").map(str => parseInt(str)))
  let [pOrder, qOrder] = [0, 0]
  const sequence = []
  for (let i = 1; i <= N; i++) {
    sequence.push(i)
  }

  const getPermutation = ({result, pre, post, n}: {
    result: number[][], pre: number[], post: number[], n: number
  }) => {
    if (n > 0) {
      post.forEach((_, i) => {
        const rest = [...post];
        const elem = rest.splice(i, 1);
        getPermutation({ result, pre: [...pre, ...elem], post: rest, n: n - 1});
      });
    } else {
      result.push(pre);
    }
    return result;
  }

  const permutation = getPermutation({ result: [], pre: [], post: sequence, n: N })

  for (let i = 0; i < permutation.length; i++) {
    if(JSON.stringify(permutation[i]) === JSON.stringify(p)) {
      pOrder = i + 1
    }
    if(JSON.stringify(permutation[i]) === JSON.stringify(q)) {
      qOrder = i + 1 
    }
  }

  console.log(Math.abs(pOrder - qOrder));
}

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


Measured memory_bytes: 29772
use std::io::*;
use std::io;
use std::str::FromStr;
fn read(s: &mut StdinLock) -> u32 {
    s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as u32 + a * 10)
}

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| String::from_str(n).unwrap());
    let s = it.next().unwrap();
    println!(
        "{}{}{}",
        s.chars().nth(0).unwrap(),
        s.len() - 2,
        s.chars().nth(s.len() - 1).unwrap()
    );

}


Measured memory_bytes: 4352
/**
*    author:  y_takano
*    created: 18.06.2020 16:57:58
**/

#include <bits/stdc++.h>

using namespace std;

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

  int i, j, k, cnt = 0;
  cin >> i >> j >> k;

  for (i; i < j + 1 ; i++)
  {
      if (k % i == 0)
      {
          cnt++;
      }
  }
  
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
    int n;
    cin>>n;
    int a[200000];
    rep(i,0,n) cin>>a[i];
    map<int,int> mpl,mpr;

    int sl[200000],sr[200000];
    rep(i,0,n){
      int s=i+a[i];
      sl[i]=s;
      //まだ無かったらmapに追加
      if(mpl.find(s)==mpl.end()) mpl[s]=1;
      //すでにmapにあったら増やす
      else mpl[s]++;

      s=i-a[i];
      sr[i]=s;
      if(mpr.find(s)==mpr.end()) mpr[s]=1;
      else mpr[s]++;
    }

    ll ans=0;
    rep(i,0,n){
      int tmp=sl[i];
      //ans+=(mpl[tmp]*mpr[tmp]);
      //mpl[tmp]=0;
      ans+=mpr[tmp];
    }

    cout<<ans<<endl;


}

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

constexpr int N = 100009, INF = 100005;
int n, m, dp[N];
vector<int> idx[N];
string s;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  fill(dp, dp + N, INF);
  cin >> n >> m >> s;
  dp[n] = 0;
  idx[0].push_back(n);
  multiset<int> ms{0};
  for(int i = n - 1; i >= 0; --i) {
    if(s[i] == '0') dp[i] = min(dp[i], *ms.begin() + 1);
    if(ms.size() == m) ms.erase(ms.find(dp[i + m]));
    ms.insert(dp[i]);
    idx[dp[i]].push_back(i);
  }
  for(int i = 0; i < N; ++i) { 
    reverse(idx[i].begin(), idx[i].end());
  }
  if(dp[0] >= INF) return cout << -1 << '\n', 0;
  for(int i = 0; i < n; ) {
    int j = *upper_bound(idx[dp[i] - 1].begin(), idx[dp[i] - 1].end(), i); 
    cout << j - i << ' ';
    i = j;
  }
}


Measured memory_bytes: 8060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[101][SIZE];

int main(){
  int n, k;

  scanf("%d%d", &n, &k);

  dp[0][0] = 1;

  for(int i=0;i<n;i++){
    int a;
    scanf("%d", &a);

    ll sum = 0;
    for(int j=0;j<=k;j++){
      sum = (sum + dp[i][j]) % mod;
      dp[i+1][j] = (dp[i+1][j] + sum)%mod;
      if(j >= a) sum = (sum + mod - dp[i][j-a]) % mod;
    }
  }

  cout << dp[n][k] << endl;

  return 0;
}


Measured memory_bytes: 156416
N= int(input())
X = list(map(int, input().split()))
xlim = sum(X) // N
x1 = 0
x2 = 0
for i in range(len(X)):
  x1 += (X[i]-xlim)**2
  x2 += (X[i]- xlim - 1)** 2
print(min(x1,x2))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
 
int main(){
    IOS;
   int t;
    int n;
    int k;

    
    cin>>n>>k;
    ll a[n+2];
    ll dp[n+2];
    loop(n)cin>>a[i+1];
    dp[0]=0;
    dp[1]=0;
    ll  x,y;
    for(int i=2;i<=n;i++){
      dp[i]=2e31;
      for(int j=1;j<=min(i-1,k);j++)
      {
        x=dp[i-j]+abs(a[i]-a[i-j]);
        dp[i]=min(dp[i],x);
      }
     
    }
    cout<<dp[n]<<endl;
}

 



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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  int n;
  int64_t t, tmp_a, tmp_b, ans = 0;

  cin >> n >> t;
  for (int i = 0; i < n; i++)
  {
    cin >> tmp_b;
    if (i == 0)
    {
      tmp_a = tmp_b;
      continue;
    }
    ans += min(t, tmp_b - tmp_a);
    tmp_a = tmp_b;
  }
  ans += t;
  cout << ans << endl;
}

Measured memory_bytes: 256
S = str(input())
if len(S) % 4 == 1:
    m = len(S) // 4
    for i in range(m):
        if (S[i] != S[2 * m - i - 1] or
            S[2 * m - i - 1] != S[2 * m + 1 + i] or
            S[2 * m + 1 + i] != S[4 * m - i]):
            print('No')
            exit()    
else:
    m = len(S) // 4 + 1
    for i in range(m - 1):
        if (S[i] != S[2 * m - i - 2] or
            S[2 * m - i - 2] != S[2 * m + i] or
            S[2 * m + i] != S[4 * m - i - 2]):
            print('No')
            exit()
    if S[m - 1] != S[3 * m - 1]:
        print('No')
        exit()
print('Yes')

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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

void printV(vector<int> &v);
void printVV(vector<vector<int>> &vv);


int main() {
  int N, K;
  cin >> N >> K;




  vector<int> sample;
  for(int i = 0; i <= 20; i++) {
    int s = pow(2, i);
    sample.push_back(s);
    // if(s >= K) break;
  }

  double sum = 0;
  for(int i = 1; i <= N; i++) {
    if(i >= K) {
      sum += (double)1/N;
      continue;
    }

    int num = K / i;
    int r = K % i;
    if(r != 0) num++;
    auto lt = lower_bound(sample.begin(), sample.end(), num) - sample.begin();

    // cout << lt << endl;
    sum = sum + (double)1 / (N * sample.at(lt));
  }

  cout << fixed;
  cout << setprecision(12) << sum << endl;
}


// ベクターの中身を全部出力
void printV(vector<int> &v) {
  cout << "  [ ";
  for(int i = 0; i < (int)v.size(); i++) {
    cout << v.at(i) << " ";
  }
  cout << "]" << endl;
}

void printVV(vector<vector<int>> &vv) {
  cout << "{" << endl;
  for(int i = 0; i < (int)vv.size(); i++) {
    cout << "  [ ";
    for(int j = 0; j < (int)vv.at(i).size(); j++) {
      cout << vv.at(i).at(j) << " ";
    }
    cout << "]," << endl;
  }
  cout << "}" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a, b, x;
  cin >> x >> a >> b;
  int expiration_date = a-b;
  string status;
  if(expiration_date<0){
    if(expiration_date*-1>=x+1){
      status = "dangerous";
    }else{
      status = "safe";
    }
  }else{
    status = "delicious";
  }
  cout << status << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include<algorithm>
using namespace std;
const long long INF = 1LL << 60;

int N;
long long h[110000];
long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];
    for (int i = 0; i < 110000; ++i) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine.toArray.map(_ - '0')

  def rec(acc:Int ,cnt:Int, init:Int):Int = {
    if(cnt == s.size) acc
    else {
      if(cnt % 2 == 0) {
        debug(cnt, s(cnt), init, s(cnt) != init)
        if(s(cnt) == init) rec(acc+1, cnt+1, init)
        else rec(acc, cnt+1, init)
      }
      else {
        debug(cnt, s(cnt), init, s(cnt) != init)
        if(s(cnt) != init) rec(acc+1, cnt+1, init)
        else rec(acc, cnt+1, init)
      }
    }
  }

  val res1 = rec(0,0,0)
  val res2 = rec(0,0,1)
  debug(res1, res2)
  val ans = if(s.size == 1) 0 else res1 min res2
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString != "class Main$")
      println(any.mkString(" "))
  }
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    vvi data(n, vi(m));
    rep(i, n) {
        rep(j, m) {
            cin >> data[i][j];
        }
    }

    vector<pair<pii, pii>> output;
    rep(i, n-1) {
        rep(j, m-1) {
            if (data[i][j] % 2) {
                data[i][j]--;
                data[i][j+1]++;
                output.pb({{i+1, j+1}, {i+1, j+1+1}});
            }
        }
        if (data[i][m-1] % 2) {
            data[i][m-1]--;
            data[i+1][m-1]++;
            output.pb({{i+1, m-1+1}, {i+1+1, m-1+1}});
        }
    }

    rep(j, m-1) {
        if (data[n-1][j] % 2) {
            data[n-1][j]--;
            data[n-1][j+1]++;
            output.pb({{n-1+1, j+1}, {n-1+1, j+1+1}});
        }
    }

    std::cout << output.size() << std::endl;
    rep(i, output.size()) {
        std::cout << output[i].ffir << " " << output[i].fsec << " "
            << output[i].sfir << " " << output[i].ssec << std::endl;
    }

    return 0;
}






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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll A,B,C;
    cin >> A >> B >> C;
    Yes((B > C && A < C) || (A > C && B < C));
}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int H=gi();
	    int W=gi();

        for(int i=0;i<W+2; i++) {
        	System.out.print("#");
	    }
        System.out.println();
	    for(int i=0;i<H; i++) {
	    	System.out.print("#");
	    	System.out.print(gs());
	    	System.out.println("#");
	    }
	    for(int i=0;i<W+2; i++) {
        	System.out.print("#");
	    }
        //System.out.println((H-h)*(W-w));
//        if (flg) {
//        	System.out.print("YES");
//        }else {
//        	System.out.print("NO");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 37388
using System;
using System.IO;
using System.Collections.Generic;

namespace ARC085C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var M = ss.Next(int.Parse);

            sw.WriteLine((M * 1900 + (N - M) * 100) * (1 << M));
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

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

	int X; cin >> X;
	if (X < 600) cout << 8;
	else if (X < 800) cout << 7;
	else if (X < 1000) cout << 6;
	else if (X < 1200) cout << 5;
	else if (X < 1400) cout << 4;
	else if (X < 1600) cout << 3;
	else if (X < 1800) cout << 2;
	else if (X < 2000) cout << 1;
	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();
    var cash = Integer.parseInt(str);

    while (1000 < cash) {
      cash = cash - 1000;
    }

    var ans = 1000 - cash;

    System.out.println(ans);
    scan.close();
  }
}


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

template<int MOD> struct modint{
    int val;
    constexpr modint(int v): val(v % MOD){
        if(val < 0) val += MOD;
    }
    constexpr int getmod(){
        return MOD;
    }
    constexpr modint operator-(){
        return val? MOD - val : 0; 
    }

    constexpr modint operator+(const modint& r){
        return modint(*this) += r;
    }
    constexpr modint operator-(const modint& r){
        return modint(*this) -= r;
    }
    constexpr modint operator*(const modint& r){
        return modint(*this) *= r;
    }
    constexpr modint operator/(const modint& r){
        return modint(*this) /= r;
    }


    constexpr modint& operator+=(const modint &r){
        val += r.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    constexpr modint& operator-=(const modint& r){
        val -= r.val;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr modint& operator*=(const modint& r){
        val = (val * r.val) % MOD;
        return *this;
    }
    constexpr modint& operator/=(const modint& r){
        // ax + bz = a, ay + bw = b からスタートして
        // 右辺について互除法して係数を変えていく
        // (x, y) -> (y, x-y*(a/b)), (z, w) -> (w, z-w*(a/b))
        // 最終的に ax + bz = gcd(a, b) となるので a, b が互いに素なら x が逆元
        // z と w を覚えておく必要はない
        int a = r.val, b = MOD, x = 1, y = 0;
        while(b){
            x -= y * (a/b); swap(x, y);
            a -= b * (a/b); swap(a, b);
        }
        val = (val * x) % MOD;
        if(val < 0) val += MOD;
        return *this;
    }

    constexpr bool operator==(const modint& r){
        return val == r.val;
    }
    constexpr bool operator!=(const modint& r){
        return val != r.val;
    }

    constexpr modint modpow(int e){
        modint ans = 1, n = *this;
        while(e){
            if(e & 1) ans *= n;
            n *= n;
            e /= 2;
        }
        return ans;
    }

    friend constexpr ostream& operator<<(ostream &os, const modint<MOD>& x){
        return os << x.val;
    }
};

const int MOD = 998244353;
using mint = modint<MOD>;

signed main(){
    // cout << fixed << setprecision(10) << flush;


    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    vector<vector<mint>> dp(n+1, vector<mint>(s+1, 0));
    dp[0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=s; j++){
            dp[i+1][j] = dp[i][j] * 2;
        }
        for(int j=a[i]; j<=s; j++){
            dp[i+1][j] += dp[i][j-a[i]];
        }
    }

    cout << dp[n][s] << endl;


    return 0;
}

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

int main(){
  long long a = 0;
  string s, t; cin >> s >> t; s += s;
  vector<vector<int>> m(26), v(26, vector<int>((int)s.size(), -1));
  rep(i, s.size()) m[s[i]-'a'].push_back(i);
  rep(i, 26){
    if(m[i].size() == 0) continue;
    else rep(j, (int)s.size()/2) v[i][j] = m[i][upper_bound(m[i].begin(), m[i].end(), j)-m[i].begin()]-j;
  }
  rep(i, t.size()){
    if(m[t[i]-'a'].size() == 0){
      a = -2; break;
    }
    else if(i == 0 && s[0] == t[i]) continue;
    else a += v[t[i]-'a'][a % ((int)s.size()/2)];
  }
  cout << a+1 << "\n";
  return 0;
}

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


int main() {
    const int MAX_N = 3100;
    double dp[MAX_N], p;
    fill(dp, dp+MAX_N, 0.0);
    dp[0] = 1.0;
    int N;
    cin >> N;
    for (int i = 0; i < N ; ++i){
        cin >> p;
        for (int j = N; j > 0; j--){
            dp[j] = dp[j-1] * p + dp[j] * (1.0 - p);
        }
        dp[0] = dp[0] * (1-p);
    }
    
    double ans = 0.0;
    for (int i = (N+1)/2; i <= N; ++i){
        ans += dp[i];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int GCD(int a, int b)
{
    return b ? GCD(b, a%b) : a;
}

void PrintVector(const vector<int> &vec)
{
    for (auto val : vec)
        cout << val << " ";
    cout << endl;
}

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

    vector<int> left(n + 1, 0), right(n + 1, 0);
    rep(i, n) left[i + 1] = GCD(left[i], a[i]);
    RRep(i, n - 1, -1) right[i] = GCD(right[i + 1], a[i]);

    int ans = 0;
    //PrintVector(left);
    //rep(i, right.size()) cout << i << " " << right[i] << endl;
    rep(i, n)
    {
        int l = left[i];
        int r = right[i + 1];

        chmax(ans, GCD(l, r));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
N = int(input())
A = list(map(int, input().split(' ')))

approved = True
for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            approved = False
if approved:
    print('APPROVED')
else:
    print('DENIED')

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

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

const int INF = 1001001001;

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

  if (d > t * s) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }


  return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int n,a[100000],b[100000],cnt=1;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    int i=a[0]-1;
    while(1){
        //cout<<"___"<<i<<"___"<<cnt<<endl;
        if(i==1){
            cout<<cnt<<endl;
            break;
        }else{
            i=a[i]-1;
            b[cnt]=a[i]-1;
            cnt++;
            if(cnt>n){
                cout<<-1<<endl;
                goto fin;
            }
        }

    }
fin:
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 123;

int n, m;
int h[N];
vector <int> g[N];
int used[N];

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> h[i];
	for(int i = 1; i <= m; i++)
	{
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}
	memset(used, -1, sizeof used);
	for(int i = 1; i <= n; i++)
	{
		if(used[i] != -1) continue;
		bool ok = 1;
		for(auto to : g[i]) if(h[i] <= h[to]) ok = 0;
		if(ok) 
		{
			for(auto to : g[i]) used[to] = 0;
			used[i] = 1;
		}
		else used[i] = 0;
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) if(used[i]) cnt++;
	cout << cnt;
}      

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    for(auto c : s){
        if(c == '1') cout << '9';
        else cout << '1';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256