akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
using LL = long long;

#define IN(v) LL v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(N);
  IN(A); IN(B); IN(C); IN(D); IN(E);
  LL d = min(A, min(B, min(C, min(D, E))));
  OUT((N+d-1) / d+4);


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        System.Diagnostics.Debug.WriteLine("-----TextFile1");
        System.Diagnostics.Debug.WriteLine(process("../TextFile1.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile2");
        System.Diagnostics.Debug.WriteLine(process("../TextFile2.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile3");
        System.Diagnostics.Debug.WriteLine(process("../TextFile3.txt"));
#endif

#if !DEBUG
        String ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static string process(string filePath) {
        using (var input = new System.IO.StreamReader(filePath)) {
            if(input.EndOfStream) return "NO PROC";
            return process(input);
        }
    }

    static string process(System.IO.TextReader input) {
        int n     = int.Parse(input.ReadLine());

        int ans = 0;

        for(int i=1; i<=n; i++) {
            int keta = i.ToString().Length;
            if (keta % 2 == 1) ans++;
        }
        return ans.ToString();
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int W = Integer.parseInt(scan.next());
		int H = Integer.parseInt(scan.next());
		int x = Integer.parseInt(scan.next());
		int y = Integer.parseInt(scan.next());
		int r = Integer.parseInt(scan.next());
		
		// ?????????????????????????????§????????¨??????Yes???????????°No
		if ((x-r >= 0) && (x+r <= W) && (y+r <= H) && (y-r >= 0)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main(){
	int n; cin >> n;
	int ans = 0;

	if (n > 0) ans += min(n, 9) - 0;
	if (n > 99) ans += min(n, 999) - 99;
	if (n > 9999) ans += min(n, 99999) - 9999;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]
v = [[] for i in range(4)]
standard = wv[0][0]

for wi, vi in wv:
    plus = wi - standard
    v[plus].append(vi)

for i in range(4):
    v[i].sort(reverse=True)
    for j in range(len(v[i])-1):
        v[i][j+1] = v[i][j] + v[i][j+1]
    v[i].insert(0, 0)

ans = 0
for a in range(len(v[0])):
    for b in range(len(v[1])):
        for c in range(len(v[2])):
            for d in range(len(v[3])):
                if standard*a + (standard+1)*b + (standard+2)*c + (standard+3)*d > W:
                    continue
                else:
                    ans = max(ans, v[0][a]+v[1][b]+v[2][c]+v[3][d])
print(ans)


Measured memory_bytes: 3064
//28
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
  int h[10];
  for(int i=0;i<10;i++){
    cin>>h[i];
  }
  sort(h,h+10,greater<int>());
  for(int i=0;i<3;i++){
    cout<<h[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        TreeMap<String, Integer> map = new TreeMap<>();
        int max = 0;
        while (n-- > 0) {
            String cur = sc.next();
            map.put(cur, map.getOrDefault(cur, 0) + 1);
            max = Math.max(max, map.get(cur));
        }
        for (String s : map.keySet())
            if (map.get(s)==max) out.println(s);
        out.flush();
        out.close();
    }


    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        boolean ready() throws IOException {
            return br.ready();
        }


        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}

Measured memory_bytes: 51644
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
a, b = map(int, input().split())

x = ""
y = ""

for _ in range(b) :
  x += str(a)
for _ in range(a) :
  y += str(b)

if int(x) >= int(y) :
  print (int(x))
else :
  print (int(y))


Measured memory_bytes: 38384
#include <stdio.h>
#include <string.h>

void reverse(char *str){
	int len = strlen(str);
	for(int i=0; i < len / 2; i++) {
		char temp = str[i];
		str[i] = str[len-1-i];
		str[len-1-i] = temp;
	}
}

int main(void){
	int len, beAble;
	char str[100001];

	char cands[4][8] = {
		{"dream"},
		{"dreamer"},
		{"erase"},
		{"eraser"},
	};

	scanf("%s", str);

	reverse(str);
	for(int i=0; i < 4; i++) {
		reverse(cands[i]);
	}

	len = strlen(str);
	for(int i=0; i < len;) {
		beAble = 0;
		for(int j=0; j < 4; j++) {
			if(!strncmp(str+i, cands[j], strlen(cands[j]))) {
				beAble = 1;
				i += strlen(cands[j]);
				break;
			}
		}
		if(!beAble) {
			printf("NO");
			return 0;
		}
	}
	printf("YES");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,i=0,j,c=0,w;
    string s;
    cin >> s;
    if(s.at(0)=='7' || s.at(1)=='7' || s[2]=='7')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;

}


Measured memory_bytes: 3604
#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 <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, b, c;
ll a[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans+=a[i]/2;
        if(a[i]%2==1&&i!=n-1&&a[i+1]!=0){
            ans+=1;
            a[i+1]--;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
//This code is written by Shammi Anand
#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define Max(a,b,c)      max(a,max(b,c))
#define Min(a,b,c)      min(a,min(b,c))
#define pb              push_back
#define mp              make_pair
#define f               first
#define s               second
#define mod             1000000007
#define nl              "\n"
#define w(x)            int x; cin>>x; while(x--)

void shammi() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main() {
	shammi();
	int N, D; cin >> N >> D;
	int count  = 0;
	for (int i = 0; i < N; i++) {
		double x, y; cin >> x >> y;
		if (sqrt(pow(x, 2) + pow(y, 2)) <= D) count++;
	}
	cout << count << nl;
	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;
const int inf=1000000000;
const int np=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int h1,h2,k1,k2,a,b,c,d;
	cin>>h1>>h2;
	cin>>k1>>k2;
	cin>>a>>b>>c>>d;
	int p1=0;
	int p2=0;
	p1=h1*a+(h1/10)*c+h2*b+(h2/20)*d;
	p2=k1*a+(k1/10)*c+k2*b+(k2/20)*d;

	if(p1>p2)cout<<"hiroshi"<<endl;
	if(p1<p2)cout<<"kenjiro"<<endl;
	if(p1==p2)cout<<"even"<<endl;

	return 0;
}



Measured memory_bytes: 3096
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<long long> dis(n, 0);
    vector<vector<pair<int,int>>> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        graph[u].emplace_back(v, w);
        graph[v].emplace_back(u, w);
    }
    int rt = 0;
    queue<int> que;
    que.emplace(rt);
    vector<int> pars(n, -1);
    while (!que.empty()) {
        int u = que.front();
        que.pop();

        for (auto& e : graph[u]) {
            int v = e.first;
            long long w = e.second;
            if (v == pars[u]) {
                continue;
            }
            pars[v] = u;
            dis[v] = dis[u] + w;
            que.emplace(v);
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << (dis[i] & 1) << "\n";
    }

    return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<iomanip>

using std::cout;
using std::cin;
using std::endl;

int main(void){
  double a, b, x;
  double deg;
  cin >> a >> b >> x;
  if (a * a * b / 2 > x){
  	deg = a * b * b / 2 / x;
  }
  else{
	deg = 2 * ( a*a * b - x) /a/a/a;
  }
  deg = atan(deg) * 180 / M_PI;
  printf("%.10f\n",deg);
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int N, M;
map<int, set<int>> G;

int solve1() {
    int cnt = 0;

    vi V(N);
    rep(i, N) V[i] = i;

    do {
        bool ok = true;
        if (V[0] != 0) continue;

        for (int i = 0; i < N - 1; i++) {
            if (!G[V[i]].count(V[i + 1])) {
                ok = false;
                break;
            }
        }
        if (ok) cnt++;
    } while (next_permutation(V.begin(), V.end()));

    return cnt;
}

int main() {
    cin >> N >> M;

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].insert(y);
        G[y].insert(x);
    }

    cout << solve1() << endl;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

string s;
int k;

int main (int argc, char const *argv[])
{
  cin >> s >> k;
  set<string> slist;

  for (size_t l = 0; l < s.size(); l++) {
    string fifth;
    if(slist.size()==5) {
      fifth = *(slist.rbegin());
      if(fifth < s.substr(l,1)) continue;
    }
    for (size_t r = l+1; r < s.size()+1; r++) {
      string ss = s.substr(l, r-l);
      if(slist.size()<5) {
        slist.insert(ss);
        fifth = *(slist.rbegin());
        continue;
      }
      if(slist.count(ss)) continue;
      if(ss<fifth){
        slist.insert(ss);
        slist.erase(fifth);
        fifth = *(slist.rbegin());
      } else {
        break;
      }
    }
  }

  string ans;
  int i = 1;
  for (auto &&ss:slist) {
    if(i==k)
      ans = ss;
    i++;
  }

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


Measured memory_bytes: 256
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();

    if (a < 10 && b < 10) {
      System.out.println(a * b);
    } else {
      System.out.println(-1);
    }
  }
}

Measured memory_bytes: 23764
def resolve():
    '''
    code here
    '''
    S = input()
    N = len(S)
    res = 0
    for i in range(N//2):
        a = S[:i]
        b = S[i:2*i]
        if a == b:
            res = max(i,res)

        # print(a, b)

    print(res*2)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  rep(i,n){
    cin >> p.at(i);
    q.at(i) =p.at(i);
  }
  sort(ALL(q));
  int count = 0;
  rep(i,n){
    if(p.at(i)!=q.at(i)) count++;
  }
  if(count==2||count==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


double ternary_search(
        const std::function<double(double)> &fn,
        double lo=0., double hi=1e9) {
    for (int iter = 0; iter < 100; iter++) {
        double midl = lo + (hi - lo) / 3;
        double midr = lo + 2*(hi - lo) / 3;
        if (fn(midl) < fn(midr)) hi = midr;
        else lo = midl;
    }
    return lo;
}

constexpr double EPS = 1e-12;

double binary_search_left(
        const std::function<double(double)> &fn,
        double t, double lo = 0., double hi = 1e9) {
    hi = t;
    double targ = fn(t);
    for (int iter = 0; iter < 1000; iter++) {
        double mid = lo + (hi - lo)/2;
        if (std::abs(fn(mid) - targ) < EPS) hi = mid;
        else lo = mid;
    }
    return lo;
}

double binary_search_right(
    const std::function<double(double)> &fn,
    double t, double lo = 0., double hi = 1e9) {
    lo = t;
    double targ = fn(t);
    for (int iter = 0; iter < 1000; iter++) {
        double mid = lo + (hi - lo) / 2;
        if (std::abs(fn(mid) - targ) < EPS) lo = mid;
        else hi = mid;
    }
    return lo;
}

int main() {
    int n; std::cin >> n;
    std::vector<double> x(n), y(n);
    std::vector<double> dx(n), dy(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i] >> y[i];
        char c; std::cin >> c;
        if (c == 'R') dx[i] = 1;
        if (c == 'L') dx[i] = -1;
        if (c == 'U') dy[i] = 1;
        if (c == 'D') dy[i] = -1;
    }
    auto fxmax = [&](double t) {
        double ret = -1e9;
        for (int i = 0; i < n; i++) {
            ret = std::max(ret, x[i] + t*dx[i]);
        }
        return ret;
    };
    auto fxmin = [&](double t) {
        double ret = 1e9;
        for (int i = 0; i < n; i++) {
            ret = std::min(ret, x[i] + t*dx[i]);
        }
        return -ret;
    };
    auto fymax = [&](double t) {
        double ret = -1e9;
        for (int i = 0; i < n; i++) {
            ret = std::max(ret, y[i] + t*dy[i]);
        }
        return ret;
    };
    auto fymin = [&](double t) {
        double ret = 1e9;
        for (int i = 0; i < n; i++) {
            ret = std::min(ret, y[i] + t*dy[i]);
        }
        return -ret;
    };

    std::vector<double> cand;
    auto push = [&](const auto& fn) {
        double t = ternary_search(fn);
        cand.push_back(binary_search_left(fn, t));
        cand.push_back(binary_search_right(fn, t));
    };
    push(fxmax);
    push(fxmin);
    push(fymax);
    push(fymin);

    double ans = 2e18;
    for (double t : cand) {
        ans = std::min(ans, (fxmax(t) + fxmin(t))*(fymax(t) + fymin(t)));
    }
    printf("%.14f\n", ans);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

ld sqrt_(ld d) {
	assert(d >= 0.0);
	ld l = 0.0, r = 300000.0;
	rep(q, 30) {
		ld m = (l + r) / 2.0;
		if (m * m >= d)
			r = m;
		else
			l = m;
	}
	return l;
}

int main() {
	int N, K;
	vd x, y, c;
	cin >> N >> K;
	x.resize(N);
	y.resize(N);
	c.resize(N);
	rep(i, N)
		cin >> x[i] >> y[i] >> c[i];
	ld L = 0.0, R = 150000.0;
	rep(q, 37) {
		ld t = (L + R) / 2.0;
		bool can = false;
		rep(i, N) {
			rep(j, N) {
				vd X(2), Y(2);
				if (i == j) {
					// 円の中心
					X[0] = x[i];
					Y[0] = y[i];
					X[1] = x[i];
					Y[1] = y[i];
				}
				else if (i > j) {
					// 円の交点
					ld A = (t / c[i]) * (t / c[i]);
					ld B = (t / c[j]) * (t / c[j]);
					ld C = (x[i] * x[i] - x[j] * x[j]) + (y[i] * y[i] - y[j] * y[j]) - (A - B);
					ld D = 2.0 * (x[i] - x[j]);
					ld E = 2.0 * (y[i] - y[j]);
					if (D == 0.0) {
						Y[0] = C / E;
						Y[1] = C / E;
						ld AY = A - (Y[0] - y[i]) * (Y[0] - y[i]);
						if (AY < 0.0)
							continue;
						ld sAY = sqrt_(AY);
						X[0] = sAY + x[i];
						X[1] = -sAY + x[i];
					}
					else {
						ld F = C / D;
						ld G = E / D;
						ld H = F - x[i];
						ld a_ = G * G + 1.0;
						ld b_ = -1.0 * (G * H + y[i]);
						ld c_ = H * H + y[i] * y[i] - A;
						if (b_ * b_ - a_ * c_ < 0.0)
							continue;
						ld sbbac = sqrt_(b_ * b_ - a_ * c_);
						Y[0] = (-b_ + sbbac) / a_;
						Y[1] = (-b_ + -sbbac) / a_;
						X[0] = F - G * Y[0];
						X[1] = F - G * Y[1];
					}
				}
				else continue;

				ld t2 = t * t + 0.0000000001;

				rep(p, 2) {
					int k = 0;
					rep(n, N) {
						ld ttmp2 = c[n] * c[n] * ((X[p] - x[n]) * (X[p] - x[n]) + (Y[p] - y[n]) * (Y[p] - y[n]));
						if (ttmp2 <= t2)
							k++;
						if ((N - n) <= (K - k))
							break;
					}
					if (k >= K) {
						can = true;
						break;
					}
				}
				if (can)
					break;
			}
			if (can)
				break;
		}
		if (can)
			R = t;
		else
			L = t;
	}
	db ans = L;
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 3836
#include<iostream>
using namespace std;
int main(){
    int H, W;
    while(1){
        cin>>H>>W;
        if(H==0 && W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((i+j)%2==0){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using static System.Console;

class Program
{
    static void Main()
    {
        var n = NextInt();
        var k = NextInt();

        var ans = 1;

        for (var i = 0; i < n; i++)
        {
            ans *= k - ((i == 0) ? 0 : 1);
        }
        WriteLine(ans);
    }

    static int NextInt()
    {
        return int.Parse(NextString());
    }

    static string NextString()
    {
        var result = new List<char>();
        while (true)
        {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}


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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 1e4 + 9;
const int mod = 1e9 + 7, inf = 1e9;

int dp[N][1010], w[N], c[N];
int yo (int h, int n)
{
    if(h <= 0) return 0;
    if(n == -1) return inf;
    int &ret = dp[h][n];
    if(ret != -1) return ret;
    ret = yo(h, n - 1);
    ret = min(ret, yo(h - w[n], n - 1) + c[n]);
    ret = min(ret, yo(h - w[n], n) + c[n]);
    return ret;
}
int32_t main()
{
    int h = in(), n = in();
    for(int i = 0; i < n; i++) w[i] = in(), c[i]= in();
    memset(dp, -1, sizeof dp);
    cout << yo(h, n-1) << nl;
    return 0;
}


Measured memory_bytes: 40320
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N, ans = 0;
	string S;

	cin >> N >> S;

	for(long long i = 0; i < N; i++){
		if(S[i] == '.') ans++;
 	}

	long long t;

	t = ans;
	for(long long i=0; i < N; i++){
		if(S[i] == '.') {
			t--;
		} else {
			t++;
		}
		ans = min(t, ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int a[29];

int main() {
  int n, m, c;
  scanf("%d %d %d", &n, &m, &c);
  for (int i = 0; i < m; ++i) {
    scanf("%d", a + i);
  }
  int ans = 0;
  while (n--) {
    int sum = c;
    for (int i = 0; i < m; ++i) {
      int x;
      scanf("%d", &x);
      sum += a[i] * x;
    }
    if (sum > 0) {
      ++ans;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut infos = BTreeMap::new();
    for i in 0..n {
        let s = read_vec::<String>();
        let k = s[0].clone();
        infos
            .entry(k)
            .or_insert(vec![])
            .push((s[1].parse::<i64>().unwrap(), i + 1));
    }

    for elements in infos.values() {
        let mut a = elements.clone();
        a.sort();
        a.reverse();
        for (_, num) in a {
            println!("{}", num);
        }
    }
}

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

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


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

int a,b,c,d,y,m,k,ol[200000],cl[200000];
double al=0.5,ks,ans,n;
string s;

int  main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ol[i]=i+1;
    }

    for(int i=0;i<n;i++){
        int zc=i+1,op=0;
        while(zc<k){
            zc*=2;op++;
        }
        cl[i]=op;
    }


    for(int i=0;i<n;i++){
            al=0.5;
        for(int u=0;u<cl[i];u++){
            al*=0.5;
        }ans+=al;
    }
    printf("%.12lf",((double)ans/n)*2);



}


Measured memory_bytes: 1024
//18-3 幹線道路
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#define LL long long
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main(){
    int H,W;
    cin >> H >> W;
    int A[25][25];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> A[j][i];
        }
    }

    LL ans = LL_MAX;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            LL tmp = 0;
            for(int k=0; k<H; k++){
                for(int l=0; l<W; l++){
                    //j,iを幹線道路にしたときの(l,k)の人々のコスト
                    tmp += min(abs(i-k),abs(j-l)) * A[l][k];
                }
            }
            ans = min(ans,tmp);
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=n=0);Z[n];a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)
const LL mod = LL(1e9) + 7;
char dom[2][53];

void solve()
{
    int N;
    cin >> N;
    REP0 (i, 2)
    {
        REP0 (j, N)
        {
            cin >> dom[i][j];
        }
    }

    int i = 0;
    LL ans = 1;
    while (i < N)
    {
        if (i + 1 < N and dom[0][i] == dom[0][i + 1])
        {
            if (i == 0)
            {
                ans *= 6;
            }
            else
            {
                if (dom[0][i - 1] == dom[1][i - 1])
                {
                    ans *= 2;
                }
                else
                {
                    ans *= 3;
                }
            }
            ans %= mod;
            i += 2;
        }
        else
        {
            if (i == 0)
            {
                ans *= 3;
            }
            else
            {
                if (dom[0][i - 1] == dom[1][i - 1])
                {
                    ans *= 2;
                }
                // else ans *= 1;
                // 横積みのあとの縦ドミノは横積みドミノの色が決まれば確定
            }
            ans %= mod;
            i++;
        }
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}

ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}

int main(void) {
	int a,b,n,s,f;
	cin >> a >> b;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> s >> f;
		if ((a<f && f<b) || (a<s && s<b) || (s<=a && b<=f)) {
			ans = 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3084
def main():
  n = int(input())
  a = list(map(int, input().split()))
  a.sort()
  
  r = 0
  c = a[-1] / 2
  for i in range(n-1):
    if abs(c-r) > abs(c-a[i]):
      r = a[i]
  ans = "{} {}".format(a[-1], r)
  print(ans)

  
if __name__ == "__main__":
  main()


Measured memory_bytes: 14052
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string text,key,temp;
	for(;;)
	{
		text=key="";
		while(getline(cin,text)&&text.empty())
			;
		if(cin.eof())return 0;
		while(getline(cin,temp)&&!temp.empty())
			text+=temp;
		if(cin.eof())return 0;
		while(getline(cin,key)&&key.empty())
			;
		if(cin.eof())return 0;


		int minLen=1e9,minIndex=1e9,minCount=0;
		int i,head,tail;
		int kind=0,curKind;
		bool f[256]={};
		int a[256]={};
		for(i=0;i<key.size();++i)
			if(!f[key[i]]++)
				++kind;
		text+="\0";
		head=tail=curKind=0;
		for(;tail<text.size();)
		{
			for(; head<text.size(); ++head)
			{
				char c=text[head];
				if(f[c]&&!a[c]++)
				{
					if(++curKind==kind)
					{
						++head;
						break;
					}
				}
			}
			for(; tail<text.size(); ++tail)
			{
				char c=text[tail];
				if(f[c]&&!--a[c])
				{
					if(curKind--==kind)
					{
						if(minLen>head-tail)
						{
							minLen=head-tail;
							minIndex=tail;
							minCount=1;
						}
						else if(minLen==head-tail)
							++minCount;
						++tail;
						break;
					}
				}
			}
		}
		cout<<minCount<<endl<<endl;
		if(minLen!=1e9)
		{
			temp = text.substr(minIndex,minLen);
			for(i=0;i<temp.size();++i)
			{
				cout<<temp[i];
				if(i!=temp.size()-1&&i%72==71)cout<<endl;
			}
			cout<<endl<<endl;
		}
	}
}

Measured memory_bytes: 0
import sys
import math

input = sys.stdin.readline

def main():
    _is_found = False
    n = int(input())
    for x in range(n+1):
        if math.floor(x * 1.08) == n:
            print(x)
            _is_found = True
            break
    if not _is_found:
        print(':(')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import Counter

class union_find():
    def __init__(self,n):
        self.n=n
        ##親要素のノード番号を格納。par[x]==xのときそのノードは根
        ##親とはその上にノードなし！！　
        self.par=[-1 for i in range(n)]
        self.rank=[0]*(n)

    def find(self,x):
        if self.par[x]<0:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            
            return self.par[x]

    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)

        ##木の高さを比較し、低い方から高い方へ辺をはる
        if x==y:
          return

        if self.par[x]>self.par[y]:
          x,y=y,x
          
        self.par[x]+=self.par[y]
        self.par[y]=x

    def same(self,x,y):
        return self.find(x) == self.find(y)
    
    def size(self,x):
      return -self.par[self.find(x)]
      
    def members(self,x):
      root=self.find(x)
      return [i for i in range(self.n) if self.find(i)==root]
    
    def roots(self):
      return [i for i, x in enumerate(self.par) if x<0]
    
    def all_group_member(self):
      return {r:self.members(r) for r in self.roots()}
      
n,m,k=map(int,input().split())
uf=union_find(n)
good=[0 for _ in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  uf.union(a-1,b-1)
  good[a-1]+=1
  good[b-1]+=1
  
  
ans=[0  for _ in range(n)]
    
    
bad=[0 for _ in range(n)]
for _ in range(k):
  p,q=map(int,input().split())
  if uf.same(p-1,q-1):
    
    bad[p-1]+=1
    bad[q-1]+=1


ans1=[]
for u in range(n):
  C=uf.size(u)
  
  ans1.append(str(C-1-bad[u]-good[u]))
  
print(' '.join(ans1))

Measured memory_bytes: 94608
#include<stdio.h>


int main()
{
	int k, i;
	char S[101];
	scanf("%d",&k);
	scanf("%s", S);
	i = strlen(S) ;
	if (i<=k)
		printf("%s",S);
	else
	{
		for(i=0;i<k;i++)
			printf("%c",S[i]);
		printf("...");
	}
	return 0;
	
}

Measured memory_bytes: 1736
#include <iostream>
using namespace std;
typedef long long ll;
ll GCD(ll a, ll b) {
    return a == 0 ? b : GCD(b%a, a);
} 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, gcd, lcm;
    while (cin >> a >> b) {
        gcd = GCD(a, b);
        lcm = a * b / gcd;
        cout << gcd << " " << lcm << "\n";
    }

    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  vector<vector<int>> G(4 * K, vector<int>(4 * K, 0));
  rep(i, N) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    if (c == 'W') y += K;
    y %= (2 * K);
    x %= (2 * K);
    rep(j, 2) {
      rep(k, 2) {
        int ty = y + (j * (2 * K));
        int tx = x + (k * (2 * K));
        G[ty][tx]++;
      }
    }
  }

  vector<vector<int>> CSUM(4 * K + 1, vector<int>(4 * K + 1, 0));
  rep(y, 4 * K) {
    rep(x, 4 * K) {
      CSUM[y + 1][x + 1] = CSUM[y + 1][x] + CSUM[y][x + 1] - CSUM[y][x];
      CSUM[y + 1][x + 1] += G[y][x];
    }
  }

  int answer = 0;
  rep(y, 2 * K) {
    rep(x, 2 * K) {
      int tmp_ans = 0;
      tmp_ans +=
          CSUM[y + K][x + K] - CSUM[y + K][x] - CSUM[y][x + K] + CSUM[y][x];
      tmp_ans += CSUM[y + 2 * K][x + 2 * K] - CSUM[y + 2 * K][x + K] -
                 CSUM[y + K][x + 2 * K] + CSUM[y + K][x + K];
      answer = max(answer, tmp_ans);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 128640
#include<stdio.h>
int searching(long int a[], long int key, int n)
{
    int left, right, mid;

    left=0;right=n;

    while(left<right)
    {
        mid=(left+right)/2;
        if(a[mid]==key) return 1;
        else if(a[mid]>key) right=mid;
        else left=mid+1;
    }
    return 0;
}
int main()
{
    int n, q, sum=0, i  ;

    long int s[100000], t;

    scanf("%d", &n);
    for(i=0;i<n;i++)
        scanf("%ld", &s[i]);

    scanf("%d", &q);
    for(i=0;i<q;i++)
    {
        scanf("%ld", &t);
        if(searching(s, t, n)) sum++;
    }

    printf("%d\n", sum);

    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

struct data{
  ll x, y;
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    ll a,b;
    vector<data> d;
    d.push_back({0,0});
    rep(i,n-1){
      cin >> a >> b;
      if(b == 0){
        d.push_back({d[a].x-1,d[a].y});
      }
      if(b == 1){
        d.push_back({d[a].x,d[a].y-1});
      }
      if(b == 2){
        d.push_back({d[a].x+1,d[a].y});
      }
      if(b == 3){
        d.push_back({d[a].x,d[a].y+1});
      }
    }
    ll l = inf,r = -inf,u = -inf,bo = inf;
    rep(i,n){
      l = min(l,d[i].x);
      r = max(r,d[i].x);
      u = max(u,d[i].y);
      bo = min(bo,d[i].y);
    }
    cout << r-l+1 << " " << u-bo+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3100
from collections import deque
n = int(input())
li = deque()
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        li.appendleft(command[1])
    elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.popleft()
    else:
        li.pop()
print(*li)

Measured memory_bytes: 71940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int ar[n];
    for(int i=0;i<n;++i){cin>>ar[i];}
    bool dp[k+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<k+1;++i)
    {
        for(int j=0;j<n;++j)
        {
            if(ar[j]>i || dp[i]==1){break;}
            dp[i]=max(dp[i],bool(1-dp[i-ar[j]]));
        }
        //cout<<dp[i]<<" ";
    }
    if(dp[k]==1){cout<<"First";return 0;}
    cout<<"Second";
}

Measured memory_bytes: 3724
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

ll N, res = 0;

void dfs(ll sum, int dep, int flag)
{
    if (dep > 10)
        return;
    if (sum <= N && flag == 7)
    {
        res++;
    }
    dfs(sum * 10 + 3, dep + 1, flag | 1);
    dfs(sum * 10 + 5, dep + 1, flag | 2);
    dfs(sum * 10 + 7, dep + 1, flag | 4);
}

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

    cin >> N;
    dfs(0, 0, 0);
    cout << res << endl;
}


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

int arr[100000],N,c=0,k;
int main(){
  cin >> N >> k;
  for (int i=0;i<N;i++){
    cin >> arr[i];
    if (arr[i] >= k){
      c += 1;
    }
  }
  cout << c;
  return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		char[] X = sc.next().toCharArray();
		int S = 0;
		int ans = 0;
		for (char c : X) {
			if (c == 'S') {
				++S;
			} else {
				if (S > 0) {
					--S;
				} else {
					++ans;
				}
			}
		}
		System.out.println(ans + S);
	}

}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 1000010;

bool neg[MN]; 

int main() {
	int N;
	string S, T;
	cin >> N >> S >> T;
	if (S == T) {
		puts("0");
		return 0;
	}

	int la = N;

	deque<int> deq;

	int h = 0;
	int pre = N + 1;

	for (int i = N-1; i >= 0; --i) {
		la = min(la, i);
		while (la >= 0 && S[la] != T[i]) {
			--la;
		}
		if (la == -1) {
			puts("-1");
			return 0;
		}
		if (pre == la) continue;
		pre = la;

		deq.push_back(la);
		while (!deq.empty() && deq[0] >= i + (int)deq.size() - 1) {
			deq.pop_front();
		}
		h = max(h, (int)deq.size());
	}

	cout << h << endl;

	return 0;
}

Measured memory_bytes: 6280
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include <utility>
#include<cstdlib>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<functional>
#include<algorithm>
#define ms0(a) memset(a,0,sizeof(a))
#define ms1(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
using namespace std;
typedef long long  ll;
//typedef __int64  ll;
const double Eps = (double)0.5;
const int M = 1e9 + 7;
const int N = 2e5+ 5 ;
const double PI = acos(-1.0);

char a[N];

int main()
{
    cin>>a;
    int l = strlen(a);
    int i = 0;
    int j;
    int x;
    int y;
    int asr = 0;
    x = 0;
    y = 0;
    while(i < l)
    {
        for(j = i; j < l; j++)
        {
            if(a[j] == 'S')
                break;
        }
        while( j < l && a[j] == 'S')
        {
            x++;
            j++;
        }
        if(j == l)
            break;
        while( j < l && a[j] == 'T')
        {
            y++;
            j++;
        }
        asr += min(x, y)*2;
        if(x > y)
            x -= y;
        else
            x = 0;
        y = 0;
        i = j;
    }
    cout<< l - asr <<endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,z;
    cin >> n >> x >> y >> z;
    ll dp[n+1][1<<(x+y+z)];
    memset(dp,0,sizeof(dp));
    a=(1<<(x+y+z))-1;
    b=(1<<x-1)|(1<<x+y-1)|(1<<x+y+z-1);
    ll ans=0;
    dp[0][0]=1;
    for(int i=0; i<n; i++){
        for(int state=0; state<=a; state++){
            for(int j=1; j<=10; j++){
                c=state<<j|(1<<j-1);
                c&=a;
                if((c&b)!=b){dp[i+1][c]+=dp[i][state];dp[i+1][c]%=mod;}
            }
        }
    }
    c=0;
    for(int i=0; i<=a; i++){
        c+=dp[n][i];
        c%=mod;
    }
    cout << (binpow(10,n,mod)-c+mod)%mod << el;
    
    return 0;
}


Measured memory_bytes: 42240
#include <bits/stdc++.h>
#define int long long
const int MAXN = 1e6 + 10;
using namespace std;
int prime[MAXN];
int Mark[MAXN];
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a%b);
}
bool isPrime(int n) 
{ 


    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  

    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int32_t main() {
	int a, b;cin >> a >> b;
	int res=gcd(a,b);
	int ans=0;

	int orires=res;
	for(int i=2;i<=sqrt(orires);i++){
		if(res%i==0){
			ans++;
			while(res%i==0)res/=i;
		}
	}
	if(res>2)ans++;
	cout<<ans+1<<endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

#define MAX (10000 + 1)

int S[MAX];

int search(int *S, int n, int key)
{
	int i = 0;
	S[n] = key;
	while (S[i] != key) i++;

	return i != n;
}

int main(int argc, char *argv[])
{
	int n, q, i, key, same = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &S[i]);

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &key);
		if (search(S, n, key)) same++;
	}
	
	printf("%d\n", same);

	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>


using namespace std;

int main()
{
	int n, b;
	vector<int> v;
	vector<int> c;
	vector<int> a;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b;
		v.push_back(b);
	}

	for (int i = 0; i < n; i++) {
		cin >> b;
		c.push_back(b);
	}

	for (int i = 0; i < n; i++) {
		a.push_back(v[i] - c[i]);
	}

	sort(a.rbegin(), a.rend());

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < 1) {
			break;
		}
		ans += a[i];
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
cin >> n;
int w[n];
int sum = 0;
REP(i,n) {
  cin >> w[i];
  sum += w[i];
}
int s_min = INF;
int temp = 0;
REP(i,n-1) {
  temp += w[i];
  s_min = min(s_min,abs(sum-2*temp));
}
cout << s_min << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int mod = 1000000007;

int main() {
    string a;
    cin >> a;
    int n = a.length();
    
    int cnt[26];
    for (int i = 0; i < 26; i++) cnt[i] = 0;
    
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        int c = a[i] - 'a';
        for (int j = 0; j < 26; j++) {
            if (j == c) continue;
            ans += cnt[j];
        }
        cnt[c]++;
    }

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

Measured memory_bytes: 640