akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

void make_string(char* string, char* half_left, char* half_right, int len_left, int len_right, int flag) {
  if(flag == -1) {
    reverse(half_right, len_right);
    printf("%s%s", half_right, half_left);
  } else {
    reverse(half_left, len_left);
    printf("%s%s", half_left, half_right);
  }
}

int main(void) {
  char s[100001];
  char half_left[200001];
  char half_right[300001];
  char str_q[7];
  int q;
  int i, flag;
  int len_left, len_right;
  char str_query[6];
  char query;
  len_left = len_right = 0;
  
  scanf("%s", half_right);
  len_right += strlen(half_right);
  scanf("%s", str_q);
  q = atoi(str_q);
  flag=1;
  
  for(i=0; i<q; i++) {
    scanf("%s", str_query);
    if(str_query[0] == '1') {
      flag *= -1;
    } else {
      scanf("%s", str_query);
      if((str_query[0] == '1' && flag==1) || (str_query[0] == '2' && flag == -1)) {
        scanf("%s", str_query);
        half_left[len_left] = str_query[0];
        len_left += 1;
      } else {
        scanf("%s", str_query);
        half_right[len_right] = str_query[0];
        len_right += 1;
      }
    }
  }
  
  make_string(s, half_left, half_right, len_left, len_right, flag);
  return 0;
}
   

Measured memory_bytes: 2676
def isPalindrome(sentence):
    for i in range((len(sentence))//2):
        if sentence[i] != sentence[-i-1]:
            return False
    return True


S = input()
N = len(S)
print("Yes" if isPalindrome(S) and isPalindrome(
    S[:(N-1)//2]) and isPalindrome(S[(N+1)//2:]) else "No")

Measured memory_bytes: 3060
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
# from copy import deepcopy, copy

import queue
from collections import deque




def main():
    high, width, num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    ans_list = defaultdict(int)
    move_dic = [-2, -1, 0]
    for i in range(num):
        a, b = data[i]
        a -= 1
        b -= 1
        for move_a in move_dic:
            for move_b in move_dic:
                now_a = a + move_a
                now_b = b + move_b
                if 0 <= now_a < high - 2 and 0 <= now_b < width - 2:
                    ans_list[(now_a, now_b)] += 1
        # print(ans_list)

    ans = Counter(list(ans_list.values()))
    print((high - 2) * (width - 2) - sum(list(ans.values())))
    for i in range(1, 10):
        print(ans[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 172280
#include <bits/stdc++.h>
using namespace std;
int H, W, A, B;

int main() {
    cin >> H >> W >> A >> B;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            bool x = (i < B) ^ (j < A);
            putchar(x + '0');
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1280
// 20:17 WA

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int N, H;
  int a[100005];
  int b[100005];
  int cnt = 0;

  cin >> N >> H;
  int work = H;
  for(int i = 0; i < N; i++){
    cin >> a[i] >> b[i];
  }
  sort(a, a+N);
  reverse(a, a+N);
  sort(b, b+N);
  reverse(b, b+N);

  for(int i = 0; i < N; i++){
    if(b[i] <= a[0]) break;
    work -= b[i];
    cnt++;
    if(work <= 0) break;
  }
  while(true){
    if(work > 0){
      work -= a[0];
      cnt++;
    }
    else break;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner don = new Scanner(System.in);
		String[] an,bn;
		String as,bs;
		as = don.next();
		boolean ak = true;
		for(int i=0;i<as.length();i++){
			if(String.valueOf(as.charAt(as.length()-i-1)).equals("d")&&String.valueOf(as.charAt(i)).equals("b")){
			}else if(String.valueOf(as.charAt(as.length()-i-1)).equals("b")&&String.valueOf(as.charAt(i)).equals("d")){
			}else if(String.valueOf(as.charAt(as.length()-i-1)).equals("p")&&String.valueOf(as.charAt(i)).equals("q")){
			}else if(String.valueOf(as.charAt(as.length()-i-1)).equals("q")&&String.valueOf(as.charAt(i)).equals("p")){
			}else{
				ak = false;
			}
		}
		if(ak){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 28024
//#include<iostream>
//#include<algorithm>
//
//using namespace std;
//
//
//int main() {
//
//	int n, x, y;
//
//	cin >> n >> x >> y;
//
//
//	int ans[2005] = { 0 };
//
//	for (int i = 0; i < n; i++) {
//		for (int j = i; j < n; j++) {
//			int min1 = min(abs(i - x), abs(i - y));
//			int min2 = min(abs(j - x), abs(j - y));
//			int min3 = min(abs(j - i),abs(min1 + 1 + min2));
//			ans[min3]++;
//		}
//
//
//	}
//
//	for (int i = 1; i < n; i++) {
//		cout << ans[i] << endl;
//	}
//}


#include<iostream>
#include<algorithm>

using namespace std;

int ans[2005];

int main() {

	int n, x, y;

	cin >> n >> x >> y;

	for (int i = 1; i < n ; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (j <= x) {
				ans[j - i]++;
			}
			else if (i >= y) {
				ans[j - i]++;
			}
			else {
				int a = min(j - i, abs(i - x) + 1 + abs(j - y));
				ans[a]++;
			}
		}
	}

	for (int i = 1; i <= n - 1; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int Adj[100][100] = { 0 };
int Que[101] = { -1 }, d[100] = { -1 };
int main(){
    int n, u, k, v;
    int i, j;
    int id = 0, qin = 0, qout = 0, aid;
     
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &u);
        scanf("%d", &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            Adj[u - 1][j] = v;
        }
    }
    for (i = 0; i < 101; i++) {
        Que[i] = -1;
        d[i] = -1;
    }
     
    Que[qin++] = id;
    d[id] = 0;
    while (id != -1) {
        qout++;
        for (i = 0; Adj[id][i] != 0; i++) {
            aid = Adj[id][i] - 1;
            if (d[aid] == -1) {
                Que[qin++] = aid;
                d[aid] = d[id] + 1;
            }
        }
        id = Que[qout];
    }
     
    for (i = 0; i < n; i++) {
        printf("%d %d\n", i + 1, d[i]);
    }
    return 0;
}

Measured memory_bytes: 636
N = int(input())
n = N

limit = int(N ** 0.5)
A = []
for i in range(2, limit + 1):
    while n % i == 0:
        A.append(i)
        n //= i

if not n == 1:
    A.append(n)

A.sort()
print(f'{N}: {" ".join(map(str, A))}')


Measured memory_bytes: 5648
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//string alp = "abcdefghijklmnopqrstuvwxyz";
using namespace std;
int main(){
  string s;
  cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  int N; cin >> N;

  vector<ll> v[3];
  for(int i = 0;i < N;i++){
    ll x,y,h; cin >> x >> y >> h;
    v[0].push_back(x);
    v[1].push_back(y);
    v[2].push_back(h);
  }

  for(ll Cx = 0;Cx <= 100;Cx++){
    for(ll Cy = 0;Cy <= 100;Cy++){
      ll H = 0;
      int index = 0;
      bool flag = true;
      for(int k = 0;k < N;k++){
        if(v[2][k] != 0){
          ll abs_x = max(Cx-v[0][k],v[0][k]-Cx);
          ll abs_y = max(Cy-v[1][k],v[1][k]-Cy);
          H = abs_x + abs_y + v[2][k];
          break;
        }
      }

      for(int k = 0;k < N;k++){
        ll abs_x = max(Cx-v[0][k],v[0][k]-Cx);
        ll abs_y = max(Cy-v[1][k],v[1][k]-Cy);
        ll hantei_h = abs_x + abs_y + v[2][k];
        if(v[2][k] != 0 && hantei_h != H){
          flag = false;
          break;
        }
        else if(v[2][k] == 0 && hantei_h < H){
          flag = false;
          break;
        }
      }

      if(!flag)continue;
      else{
        cout << Cx << ' ' << Cy << ' ' << H << endl;
        return 0;
      }

    }
  }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n;
        String s;
        n=nextInt();
        s = next();
        int x;
        for(int i=0;i<s.length();i++){
            x=s.charAt(i)-'A';
            x=(x+n)%26;
            System.out.printf("%c",x+'A');
        }
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}

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

ll p(ll a,ll b){
	ll sum=1,cnt=0;
	for(ll i=a;cnt<b;i--){
		sum*=i;
		cnt++;
	}
	return sum;
}

ll c(ll a,ll b){
	ll r=1;
	for(ll i=1;i<=b;i++){
		r*=i;
	}
	return a/r;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<ll,ll>mp;
	ll n,a;
	cin>>n;
	vector<ll>v(200001);
	vector<ll>vv(200001);
	for(ll i=0;i<n;i++){
		cin>>a;
		mp[a]++;
		v[i]=a;
		vv[a]++;
	}
	ll sum=0;
	vector<ll>vvv(200001);
	for(ll i=0;i<200001;i++){
		vvv[v[i]]=c(p(mp[v[i]],2),2);
		if(vv[i]==0)continue;
		sum+=c(p(mp[i],2),2);
	}
	for(ll i=0;i<n;i++){
		cout<<sum-vvv[v[i]]+c(p(mp[v[i]]-1,2),2)<<endl;
	}
	return 0;
}



Measured memory_bytes: 15824
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

int dp[60][60][2600];

void solve(long long n, long long k){
    dp[0][0][0] = 1;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= i; ++j) {
            for(int l = 0; l <= n * n; ++l) {
                dp[i + 1][j + 1][l + 2 * (j + 1)] += dp[i][j][l];
                dp[i + 1][j + 1][l + 2 * (j + 1)] %= MOD;

                dp[i + 1][j][l + 2 * j] += dp[i][j][l] * (2 * j + 1) % MOD;
                dp[i + 1][j][l + 2 * j] %= MOD;

                if (j > 0) {
                    dp[i + 1][j - 1][l + 2 * (j - 1)] += dp[i][j][l] * (j * j % MOD);
                    dp[i + 1][j - 1][l + 2 * (j - 1)] %= MOD;
                }
            }
        }
    }
    cout << dp[n][0][k] << endl;
}

signed main(){
    long long n;
    scanf("%lld",&n);
    long long k;
    scanf("%lld",&k);
    solve(n, k);
    return 0;
}


Measured memory_bytes: 61696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll f(ll x){
    if(x==3) return 6;
    else if(x==2) return 6;
    else if(x==1) return 3;
}


int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    map<ll,ll> mp;
    ll cnt0 = 0;
    rep(i,n){
        ll p;
        cin >> p;
        if(p==0) cnt0++; 
        mp[p]++;
        if(mp[p]>3){cout << 0 << endl;return 0;}
        if(p>=1){
            ans *= mp[p-1];
            mp[p-1]--;
            ans %= mod;
        }
    }

    cout << (ans*f(cnt0))%mod;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);

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

  sort(h.begin(), h.end());

  int ans = 1000000000;
  for (int i = 0; i < N - K + 1; i++)
  {
    int diff = h[i + K - 1] - h[i];
    if (ans > diff)
    {
      ans = diff;
    }
  }

  cout << ans;
}

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

int main(){
  int N;
  cin >> N;
  map<int64_t,int> m;
  int64_t ans=0;
  for(int i=0;i<N;i++){
    int64_t a;
    cin >> a;
    if(!m.count(a)){
      m[a]=1;
      ans++;
    }else{
      m.erase(a);
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        vll A(4);
        rep(i, 0, 4) {
                char c;
                cin >> c;
                A[i] = c - '0';
        }
        if (A[0] + A[1] + A[2] + A[3] == 7) {
                cout << A[0] << "+" << A[1] << "+" << A[2] << "+" << A[3] << "=7" << endl;
        }
        else if (A[0] + A[1] + A[2] - A[3] == 7) {
                cout << A[0] << "+" << A[1] << "+" << A[2] << "-" << A[3] << "=7" << endl;
        }
        else if (A[0] + A[1] - A[2] + A[3] == 7) {
                cout << A[0] << "+" << A[1] << "-" << A[2] << "+" << A[3] << "=7" << endl;
        }
        else if (A[0] + A[1] - A[2] - A[3] == 7) {
                cout << A[0] << "+" << A[1] << "-" << A[2] << "-" << A[3] << "=7" << endl;
        }
        else if (A[0] - A[1] + A[2] + A[3] == 7) {
                cout << A[0] << "-" << A[1] << "+" << A[2] << "+" << A[3] << "=7" << endl;
        }
        else if (A[0] - A[1] + A[2] - A[3] == 7) {
                cout << A[0] << "-" << A[1] << "+" << A[2] << "-" << A[3] << "=7" << endl;
        }
        else if (A[0] - A[1] - A[2] + A[3] == 7) {
                cout << A[0] << "-" << A[1] << "-" << A[2] << "+" << A[3] << "=7" << endl;
        }
        else if (A[0] - A[1] - A[2] - A[3] == 7) {
                cout << A[0] << "-" << A[1] << "-" << A[2] << "-" << A[3] << "=7" << endl;
        }

}







Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXN = 5e3 + 1;

string s;
int n;


int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	cin >> s;
	n = SZ(s);
	
	if (n & 1)
	{
		int d = n/2 + 1;
		FOR(i, n/2, n)
			if (s[i] != s[n / 2])
			{
				d = i - n / 2;
				break;
			}
		int ans = n / 2 + d;
		reverse(ALL(s));
		FOR(i, n / 2, n)
			if (s[i] != s[n / 2])
			{
				d = i - n / 2;
				break;
			}
		ans = min(ans, n / 2 + d);
		cout << ans;
	}
	else
	{
		int ans = 0;

		if (s[n / 2] != s[n / 2 - 1])
			ans = n / 2;
		else
		{
			int d = n/2;
			FOR(i, n / 2, n)
				if (s[i] != s[n / 2])
				{
					d = i - n / 2;
					break;
				}

			ans = n / 2 + d;
			reverse(ALL(s));
			FOR(i, n / 2, n)
				if (s[i] != s[n / 2])
				{
					d = i - n / 2;
					break;
				}
			ans = min(ans, n / 2 + d);
		}

		cout << ans;
	}

	cin>>n;
	return 0;
}

Measured memory_bytes: 512
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int X = sc.nextInt();
		sc.close();
		for(int i=X-K+1;i<X+K;i++) {
			if(i!=X+K-1) {
				System.out.print(i+" ");
			} else {
				System.out.print(i);
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 21844
from math import sqrt

def readinput():
    n=int(input())
    return n

def main(n):
    f=[0]*n
    for i in range(1,n+1):
        sqrt2n=int(sqrt(2*i))+1
        #print(i,sqrt2n)
        for x in range(1,sqrt2n):
            for y in range(1,sqrt2n-x+1):
                if (x+y)**2>2*i:
                    break
                for z in range(1,sqrt2n-x+1):
                    v=(x+y)**2+(y+z)**2+(z+x)**2
                    if v>2*i:
                        break
                    #print(v)
                    if v==2*i:
                        f[i-1]+=1
                        #print('found')
                        #print(x,y,z,i)
    return f

def F(x,y,z):
    return ((x+y)**2+(y+z)**2+(z+x)**2)//2

def main2(n):
    sqrt2n=int(sqrt(2*n))+1
    cntbl=[0]*(10**4+1)
    for x in range(1,sqrt2n):
        for y in range(1,sqrt2n):
            for z in range(1,sqrt2n):
                v=F(x,y,z)
                if v>n:
                    break
                cntbl[v]+=1
    return cntbl


if __name__=='__main__':
    n=readinput()
    ans=main2(n)
    for i in range(1,n+1):
        print(ans[i])


Measured memory_bytes: 9316
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b;
  cin >> a >> b;
  if(a<=5)cout << 0 << endl;
  else if(a>=13) cout << b << endl;
  else cout << b/2 << endl;
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    if(x>=a && y>=b) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Char
import Data.Maybe
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
    n <- fst . fromJust . BS8.readInteger <$> BS8.getLine
    i <- unfoldr (BS8.readInteger . BS8.dropWhile isSpace) <$> BS8.getLine
    let a = [1 / (toRational x) | x <- i]

    print $ fromRational (1 / (foldr (+) 0 a))


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,k,t,summ = 0,res = 0;
	cin >> n;
	cin >> k;
	vector<int> a;
	for (int i = 0; i < k; ++i)
	{
		cin >> t;
		a.push_back(t);
		summ += t;
	}
	res = n - summ;
	if (res < 0) {
		cout << -1;
	} else {
		cout << res;
	}
}

Measured memory_bytes: 3676
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0: break
    count = 0
    for i in range(1,n - 1):
        for j in range(i + 1 ,n):
            if i + j + j + 1 > x: break
            for k in range(j + 1 ,n + 1):
                if i + j + k == x:
                    count += 1
                    break
    print(count)

Measured memory_bytes: 7684
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;

int main() {
	
	int n;
	ll T;
	cin >> n >> T;
	vector<ll> t(n);
	FOR(i, n)cin >> t[i];

	ll x = T;
	FOR1(i, n)x += min(T, t[i] - t[i - 1]);
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main()
{
    int n;
    cin >> n;
    int w[n];
    int all_w = 0, ans = 1000000000;
    REP(i, n)
    {
        cin >> w[i];
        all_w += w[i];
    }
    int s1 = 0, s2 = all_w;
    REP(i, n)
    {
        s1 += w[i];
        s2 -= w[i];
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> vi;
 
int main(){
  int n, t[55], c[55];
  pair<int,int> s[55];
  while(scanf("%d",&n),n){
    rep(i,n)scanf("%d%d",&s[i].first,&s[i].second);
    sort(s,s+n);
    rep(i,n){
      t[i] = s[i].first;
      c[i] = s[i].second;
    }
    
    vi q[2];
    rep(i,n)q[0].push_back(i);
     
    int ans = 0;
    while(q[0].size() || q[1].size()){
      vi g[2];
      int nxt = 1000;
      rep(x,2){
	if(q[x].size())nxt = min(nxt, t[q[x][0]]);
      }
      ans += nxt;

      rep(x,2){
	rep(i,q[x].size()){
	  t[q[x][i]] -= nxt;
	  if(i>0 && t[q[x][i-1]] > t[q[x][i]])t[q[x][i]] = t[q[x][i-1]];
	}
	while(q[x].size()){
	  if(t[q[x][0]])break;
	  g[x].push_back(q[x][0]);
	  q[x].erase(q[x].begin());
	}
      }
       
      sort(all(g[0])); sort(all(g[1]));
      for(int id : g[0]){
	q[1].push_back(id);
	t[id] = s[id].first;
      }
      for(int id : g[1]){
	if(--c[id]){
	  q[0].push_back(id);
	  t[id] = s[id].first;
	}
      }
    }
    cout << ans << endl;
  }
}

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

void print(string &str)//str???a???????????????b??????????????§?????????
{
	int a, b;
	cin >> a >> b;
	
	string copy_str;
	for(int i = a; i <= b; i++){
		copy_str += str[i];
	}
	cout << copy_str << endl;
}
string reverse(string &str)//str???a???????????????b??????????????§??????????????????
{
	int a, b;
	cin >> a >> b;
	
	string copy_str = str;
	for(int i = 0; i <= b - a; i++){
		copy_str[i + a] = str[b - i];
	}
	return copy_str;
}
string replace(string &str)//str???a???????????????b??????????????§???p??????????????????
{
	int a, b;
	cin >> a >> b;
	
	string p;
	cin >> p;
	
	for(int i = a; i <= b; i++){
		str[i] = p[i - a];
	}
	return str;
}
int main(void)
{
	string str;
	cin >> str;
	
	int q;//???????????°
	cin >> q;
	
	for(int i = 0; i < q; i++){
		
		string command;//?????????
		cin >> command;
		
		if(command == "print"){
			print(str);
		}
		else if(command == "reverse"){
			str =reverse(str);
		}
		else{
			str =replace(str);
		}
	}
	return 0;
}

Measured memory_bytes: 3232
n = int(input())
NUM_STR = input()

print(NUM_STR)

NUM_LIST = list(map(int, NUM_STR.split()))

for i in range(1, len(NUM_LIST)):
    v = NUM_LIST[i]
    j = i - 1
    while NUM_LIST[j] > v and j >= 0:
        NUM_LIST[j+1] =NUM_LIST[j]
        j -= 1
    NUM_LIST[j+1] = v
    STR = list(map(str, NUM_LIST))
    print(" ".join(STR))


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

int main()
{
  vector<int> x(5);
  for(int i = 0; i < 5; i++)
  {
    cin >> x.at(i);
  }
  for(int i = 0; i < 5; i++)
  {
    if(x.at(i) == 0)
    {
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3544
#include<cstdio>
#include<algorithm>
#define N_ 201000
using namespace std;
int R[N_];
struct point {
	int x, num;
	bool operator<(const point &p)const {
		return x<p.x;
	}
}w[N_];
int main() {
	int i, n;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i].x);
		w[i].num = i;
	}
	sort(w + 1, w + n + 1);
	for (i = 1; i <= n / 2; i++)R[w[i].num] = w[n / 2 + 1].x;
	for (i = n / 2 + 1; i <= n; i++)R[w[i].num] = w[n / 2].x;
	for (i = 1; i <= n; i++)printf("%d\n", R[i]);
}

Measured memory_bytes: 4480
#include<iostream>
using namespace std;
string a,b,c;
int i,j,k,f;
main(){
    cin>>a>>b>>c;
    while(1){
        if(f==0){
            if(i==a.size()){
                cout<<'A'<<endl;
                return 0;
            }
            if(a[i]=='a')f=0;
            if(a[i]=='b')f=1;
            if(a[i]=='c')f=2;
            i++;
        }
        if(f==1){
            if(j==b.size()){
                cout<<'B'<<endl;
                return 0;
            }
            if(b[j]=='a')f=0;
            if(b[j]=='b')f=1;
            if(b[j]=='c')f=2;
            j++;
        }
        if(f==2){
            if(k==c.size()){
                cout<<'C'<<endl;
                return 0;
            }
            if(c[k]=='a')f=0;
            if(c[k]=='b')f=1;
            if(c[k]=='c')f=2;
            k++;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
ll lcm(ll c,ll b){
    return c*b/gcd(c,b);
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
typedef pair<ll,pair<ll,ll>> P;
bool pc(const P& f,const P& s){
    return f.second.second>s.second.second;
}

int main(){
    ll n;
    cin>>n;
    vec(a,n);
    vec(t,n);
    rep(i,n){
        cin>>t[i]>>a[i];
    }
    rep(i,n-1){
        if(((float)t[i+1]/t[i])<=((float)a[i+1]/a[i])){
            if(t[i+1]<t[i]){
                //op((t[i]%t[i+1]?t[i]/t[i+1]+1:t[i]/t[i+1]));
                ll tmp=(t[i]%t[i+1]>0?t[i]/t[i+1]+1:t[i]/t[i+1]);
                t[i+1]=t[i+1]*tmp;
                a[i+1]=a[i+1]*tmp;
               
            }
        }else{
            if(a[i+1]<a[i]){
                //op((a[i]%a[i+1]?a[i]/a[i+1]+1:a[i]/a[i+1]));
                ll tmp=(a[i]%a[i+1]>0?a[i]/a[i+1]+1:a[i]/a[i+1]);
                t[i+1]=t[i+1]*tmp;
                a[i+1]=a[i+1]*tmp;
                }
        }
        //cout<<t[i+1]<<" "<<a[i+1]<<endl;
            
    }
    op(a[n-1]+t[n-1]);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int cnum,i,j=0,count[26]={0};
  char ch[1200];
  char alp[26]="abcdefghijklmnopqrstuvwxyz";
  while(scanf("%c",&ch[j])!=EOF){
    j++;
  }
  for(i=0;i<j;i++){
    if('a'<=ch[i]&&ch[i]<='z'){
      cnum=ch[i]-'a';
      count[cnum]++;
    }
    if('A'<=ch[i]&&ch[i]<='Z'){
      cnum=ch[i]-'A';
      count[cnum]++;
    }
  }
  for(i=0;i<26;i++){
    printf("%c : %d\n",alp[i],count[i]);
  }
  return 0;
}
  
  
   


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

int main()
{
   int n,m,x,s=0;
   cin>>n>>m;
   while(n--)
   {
       cin>>x;
       if(x>=m)s++;
   }
cout<<s<<endl;
    return 0;

}


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

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = w * h / 2;
    int ans = 0;
    if (2 * x == w & 2 * y == h) ans = 1;
    cout << s << ' ' << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;
	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

template <typename T>
inline string to_strangebin_str(T n){
    string str;
    while (n != 0) {
        str.push_back('0' + (n & 1));
        n >>= 1;
        n = -n;
    }
    reverse(str.begin(), str.end());
    return str;
}

int main(){
	int N;
	cin >> N;
	if(N == 0){
		cout << "0" << endl;
		return 0;
	}
	string ret = to_strangebin_str(N);
	cout << ret << endl;
	return 0;
}

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

using namespace std;

bool a , b , c , d;

int main() {
	
	register string s;
	
	cin >> s;
	
	register int len = s.size();
	
	for(register int i=0; i<len; i++) {
		if(s[i] == 'N' && !a)	a = true;
		if(s[i] == 'S' && !b)	b = true;
		if(s[i] == 'E' && !c)	c = true;
		if(s[i] == 'W' && !d)	d = true;
	}
	
	if( (a && !b) || (!a && b) || (c && !d) || (!c && d) )	puts("No");
	else	puts("Yes");
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 210
#define mod 1000000007
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge
{
	int u,v,next;
}vs[N<<1];
int n,m,k,st[N],ee,sta[N],top,las;
int bl[N],dfn[N],low[N],tot,Ans=1,c[N][N];
inline int qpow(int bas,int pw)
{
	int ret=1; for(;pw;pw>>=1,bas=1ll*bas*bas%mod)
		if(pw&1) ret=1ll*bas*ret%mod; return ret;
}
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline int polya(int n)
{
	int ret=0; 
		for(int i=1;i<=n;i++) 
			ret=(ret+qpow(k,__gcd(i,n)))%mod;
	return 1ll*ret*qpow(n,mod-2)%mod;
}
inline void calc(int x,int y)
{
	//cerr << x << " " << y << endl;
	int cnt=1,bcnt=0;
	bl[x]=++tot; while(sta[top]!=y)
		bl[sta[top]]=tot,top--,cnt++;
	top--; bl[y]=tot; cnt++; 
	if(cnt==2) {Ans=1ll*Ans*k%mod; return ;}
	for(int i=1;i<=n;i++) if(bl[i]==tot)
		for(int j=st[i];j;j=vs[j].next)
			if(bl[vs[j].v]==tot) bcnt++;
	bcnt>>=1;
	if(bcnt==cnt) Ans=1ll*Ans*polya(cnt)%mod;
	else Ans=1ll*Ans*c[bcnt+k-1][k-1]%mod;
}
inline void dfs(int rt,int pr)
{
	dfn[rt]=low[rt]=++las; sta[++top]=rt;
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
 		if(!dfn[vs[i].v])
		{
			dfs(vs[i].v,rt);low[rt]=min(low[rt],low[vs[i].v]);
			if(low[vs[i].v]>=dfn[rt]) calc(rt,vs[i].v);
		}
		else low[rt]=min(low[rt],dfn[vs[i].v]);
	}
}
int main()
{
	c[0][0]=1; for(int i=1;i<=200;i++)
	{
		c[i][0]=1; for(int j=1;j<=200;j++)
			c[i][j]=(1ll*c[i-1][j]+1ll*c[i-1][j-1])%mod;
	}
	n=read(); m=read(); k=read();
	for(int i=1;i<=m;i++)
	{
		int u=read(), v=read();
		addedge(u,v); addedge(v,u);
	}
	for(int i=1;i<=n;i++) if(!dfn[i]) dfs(i,0);
	cout << Ans << endl;
	return 0 ;
}

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

int main() 
{
    int n,l,sum=0;
    cin >> n >> l;
    vector<int> v;
    vector<int> w;
    for (int i=1; i<=n; i++)
    {
        v.push_back(abs(l+i-1));
        w.push_back(l+i-1);
    }
    int minIndex = min_element(v.begin(), v.end()) - v.begin();
    w.erase(w.begin() + minIndex);
    for (int i=0; i<n-1; i++)
        sum += w[i];
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int Q1, B, C1, C2, Q2;
	while(cin >> Q1 >> B >> C1 >> C2 >> Q2, Q1){
	
		int ans1 = -1, ans2;
		for(int i = 1; i <= Q2; i++){
			int common = (B - i*C1)/C2;
			if(B - i*C1 < 0) break;
			if(i + common >= Q1) ans1 = i, ans2 = common;
			//printf("%d, %d\n", i, common);
		}
		if(ans1 == -1) puts("NA");
		else printf("%d %d\n", ans1, ans2);
	}
	return 0;
}

Measured memory_bytes: 1148
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}
	void solve() {
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int[] p = new int[30];
			for (int j = 0; j < 30; j++) p[j] = sc.nextInt();
			ans = 8;
			search(p, 0);
			System.out.println(ans);
		}
	}
	int ans;
	void search(int[] p, int depth) {
		if (goal(p)) {
			ans = Math.min(ans, depth);
			return;
		}
		if (depth + 1 >= ans) return;
		for (int i = 0; i < 4; i++) {
			f(p, op[i]);
			search(p, depth + 1);
			f(p, op[i]);
		}
	}

	void f(int[] p, int[][] o) {
		for (int i = 0; i < o.length; i++) {
			int a = o[i][0];
			int b = o[i][1];
			int t = p[a];
			p[a] = p[b];
			p[b] = t;
		}
	}

	boolean goal(int[] a) {
		int[][] is = {
			{0,1,2,3,4,5,6,7,8},
			{9,10,11},
			{12,13,14},
			{15,16,17},
			{18,19,20},
			{21,22,23,24,25,26,27,28,29}
		};
		for (int[] sub : is) {
			for (int i = 0; i < sub.length; i++) {
				if (a[sub[i]] != a[sub[0]]) return false;
			}
		}
		return true;
	}
	int[][][] op = {
		{{0,27},{1,28},{2,29},{14,15},{20,18}},
		{{0,23},{3,26},{6,29},{9,20},{15,17}},
		{{6,21},{7,22},{8,23},{12,17},{9,11}},
		{{2,21},{5,24},{8,27},{12,14},{11,18}},
	};

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 59748
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n, ans=1;
    cin >> n;
    while(true){
        if(1000*ans >= n) break;
        ans++;
    }
    cout << 1000*ans - n << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			int count = 1;
			if (b != a) {
				count++;
			}
			if (c != b && c != a) {
				count++;
			}

			System.out.println(count);

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 23124
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.size();
  vector<int> next[256];
  for(char c = 'a'; c <= 'z'; c++) {
    next[c].resize(n + 1);
    next[c][n] = n;
    for(int i = n - 1; i >= 0; i--) {
      if(s[i] == c) {
        next[c][i] = i;
      } else {
        next[c][i] = next[c][i + 1];
      }
    }
  }
  ll ans = 0;
  ll now = 0;
  for(auto c : t) {
    if(next[c][now] == n) now = 0, ans = (ans / n + 1) * n;
    if(next[c][now] == n) {
      cout << -1 << endl;
      return 0;
    }
    ans += 1 + next[c][now] - now;
    now = next[c][now] + 1;
    if(now == n) now = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10832
using System;
class Program
{
	static void Main(string[] args)
	{			string s = Console.ReadLine();
			string[] sl = s.Split(' ');
			int A = int.Parse(sl[0]);
			int B = int.Parse(sl[1]);
			int K = int.Parse(sl[2]);
			for (int i = A; i <= B; i++)
			{
				if (i == A + K)
				{
					if (i < B - K + 1) i = B - K + 1;
				}
				Console.WriteLine(i);
			}
	}
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n;
  cin >> n;

  vector<ll> p(n);
  for (ll i = 0; i < n; ++i) {
    cin >> p[i];
  }

  ll c = 0;
  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    if (p[i] == i+1) {
      ++c;
      if (c == 2) {
        ++ans;
        c = 0;
      }
    } else {
      ans += c;
      c = 0;
    }
  }
  ans += c;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int n,p[100]={0},a=0,b=0,c=0,d=0,e=0,f=0;
    cin>>n;
    for(int i=2;i<=n;i++){
        int m=i,l=2;
        while(m>1){
            if(m%l==0){
                p[l]++;
                m/=l;
            }else{
                l++;
            }
        }
        
    }
    
    for(int i=2;i<100;i++){
        if(p[i]>=2)a++;
        if(p[i]>=4)b++;
        if(p[i]>=14)c++;
        if(p[i]>=24)d++;
        if(p[i]>=74)e++;
        /*
        if(p[i]>0){
            cout<<i<<":"<<p[i]<<endl;
        }
        */
    }
    f+=e;
    f+=c*(b-1);
    f+=d*(a-1);
    f+=b*(b-1)*(a-2)/2;
    cout<<f<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }

        boolean fin = true;
        int count = 0;
        int i = 1;
        int index = 0;
        while(i <= N){
            int j = index;
            while(j < N){
                if(a[j] == 1){
                    fin = false;
                }
                if(a[j] == i){
                    count++;
                    index = j + 1;
                    break;
                }
                j++;
            }
            if(fin){
                System.out.println("-1");
                return;
            }
            if(j >= N) break;
            i++;
        }

        System.out.println(N - count);
    }
}

Measured memory_bytes: 79240
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// solution 
//
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        X: usize,
        x: [usize; N],
    }
    x.push(X);
    x.sort();
    let ans = (1..x.len()).map(|ind| x[ind] - x[ind-1]).fold(0, |acc, a| gcd(acc, a));
    println!("{}", ans);
}

fn gcd(a: usize, b: usize) -> usize {
    if a == 0 {
        b
    } else if a < b {
        gcd(b % a, a)
    } else {
        gcd(a % b, b)
    }
}


Measured memory_bytes: 6396
#include<stdio.h>
int main(){
    int n,i;
    long ans = 0;
    scanf("%d",&n);
    
    for(i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0 && i % 15 != 0) ans += i;
    }
    printf("%ld\n",ans);
    return 0;
}


Measured memory_bytes: 1728
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll Q,M,K,P,A,B,N,X;

    long double x;

    string s;
    char aaa;
    ll ans=0;
   
  

    vector<char> S, bb, hh, ff;
    ll a,b;
    
    ll d;


    cin >>N;
    

    ll temp = 1;
    ll count = 0;
    N -=0;
    while(1){
        if(N>pow(26,temp)){
            N -=pow(26,temp);
            S.push_back('a');
            count++;
            temp++;
        }else{
            break;
        }
        
    }
    S.push_back('a');
   
    //cout<<N<<'q'<<count<<endl;
    N -=1;
    
    
    // rep(i,S.size()){
    //     cout<<S[i];
    // }
    //cout<<endl;


    for(i=count;i>=0;i--){
        
        j = ll(N/pow(26,i));
        N -= pow(26,i)*j;
        S[S.size()-1-i] += j;
    }
   
    rep(i,S.size()){
        cout<<S[i];
    }
    //char xxx ='a'+26;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3544