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

class Solver {

    private final int N;

    Solver(Scanner in) {
        N = in.nextInt();
    }

    void solve() {
        int[] primes = new int[N];
        for (int i = 2; i <= N; i++) {
            int j = 2;
            int x = i;
            for (; j * j <= x; j++) {
                while (x % j == 0) {
                    primes[j - 1]++;
                    x /= j;
                }
            }
            if (x != 1) primes[x - 1]++;
        }
        System.out.println(Arrays.stream(primes).mapToLong(i -> i + 1).reduce(1, (a, b) -> a * b % 1000000007));
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 27732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            List<Integer> a = new ArrayList<>();
            for (int i = 0; i < n; ++i) {
                a.add(in.nextInt());
            }
            List<Integer> res = new ArrayList<>();
            outer:
            while (!a.isEmpty()) {
                for (int i = a.size() - 1; i >= 0; --i)
                    if (a.get(i) == i + 1) {
                        res.add(i + 1);
                        a.remove(i);
                        continue outer;
                    }
                out.println(-1);
                return;
            }
            Collections.reverse(res);
            for (int x : res) {
                out.println(x);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int main() {
  int64_t N;
  cin >> N;
  int64_t mod = pow(10, 9) + 7;
  vector<int64_t> A(N);
  int64_t S=0, T=0;
  for (int i=0; i<N; i++) {
    cin >> A[i];
    S += (A[i]-A[i]/mod*mod);
    S -= S/mod*mod; 
    T += (A[i]-A[i]/mod*mod)*(A[i]-A[i]/mod*mod);
    T -= T/mod*mod; 
  }
  int64_t SS=S*S;
  SS = SS - SS/mod*mod;
  int64_t M = SS - T;
  if (M<0) {
    M += mod;
  }
  if (M-M/2*2==1) {
    M += mod;
  }
  M/=2;
  
  cout << M << endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    string s; cin >> s; s = "<" + s;

    ll dp[N+1][N+1]; REP(i,N+1)REP(j,N+1) dp[i][j] = 0;

    dp[0][N] = 1;
    REP(i,N){
        ll sum = 0;
        if(s[i] == '<'){
            REP(j,N){
                sum += dp[i][N-j];
                (dp[i+1][N-j-1] += sum) %= MOD;
            }
        }
        else{
            REP(j,N-i){
                sum += dp[i][j];
                (dp[i+1][j] += sum) %= MOD;
            }
        }
    }

    ll ans = dp[N][0];
    cout << ans << en;
    return 0;
}

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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
   int r;
   cin >> r;
   cout << 2*r*acos(-1) << endl;
return 0;}

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

using namespace std;

const int M = 18;
int S, T, nr, N0, N, K, a[60], cnt[(1 << M) + 10];
long long c[60][60], atMostK[60];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d %d", &N0, &K, &S, &T);
if ((T & S) != S)
{
    printf ("0\n");
    return 0;
}
for (int i=0; i<=N0; i++)
{
    c[i][0] = 1;
    for (int j=1; j<=i; j++)
        c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
}
for (int i=0; i<M; i++)
    nr += (((S ^ T) >> i) & 1);
for (int i=1; i<=N0; i++)
{
    int a0;
    scanf ("%d", &a0);
    if ((a0 & S) == S && (a0 | T) == T)
    {
        int a1 = 0, pos = 0;
        for (int j=0; j<M; j++)
            if ((S ^ T) & (1 << j))
            {
                if (a0 & (1 << j))
                    a1 |= 1 << pos;
                pos ++;
            }
        a[++N] = a1;
    }
}
for (int i=0; i<=N; i++)
    for (int j=1; j<=K && j<=i; j++)
        atMostK[i] += c[i][j];
///I want to choose between 1 and K elements in a s.t. their or is 1 << nr - 1 and their and is 0
long long ans = 0;
for (int msk = 0; msk < (1 << nr); msk ++)
{
    int sg = 0;
    for (int i=0; i<M; i++)
        if (msk & (1 << i))
            sg ^= 1;
    long long curr = 0;
    for (int i=1; i<=N; i++)
    {
        curr -= atMostK[cnt[a[i] & msk]];
        cnt[a[i] & msk] ++;
        curr += atMostK[cnt[a[i] & msk]];
    }
    if (sg)
        ans -= curr;
    else
        ans += curr;
    for (int i=1; i<=N; i++)
        cnt[a[i] & msk] = 0;
}
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 4880
N = int(input())
A = [[int(_) for _ in input().split()] for i in range(N)]

dp = [[0] * ((1 << 21) + 10) for _ in range(N + 1)]
dp[0][0] = 1
MOD = 10**9+7
for i in range(N):
    # i 番目の男性に着目
    for s in range(1 << N):  # sのbit が立っている女子はマッチ済み
        if dp[i][s] == 0: continue

        for j in range(N):
            jb = 1 << j
            if not (s & jb) and A[i][j]:
                # i, j をマッチさせる
                dp[i + 1][s | jb] += dp[i][s] % MOD
print(dp[N][(1 << N) - 1] % MOD)


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

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

    char alp;
    cin >> alp ;

    if(alp<'a')
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'a' << endl;
    }
    



    return 0;
}



Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	if (x % y == 0)printf("-1\n");
	else printf("%d\n", x);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,s,i,x;
    cin>>n>>k>>s;
    n = n-k;
    for(i=0;i<k;i++)
        cout<<s<<" ";
    x = 1e9;
    if(s == x)
        x = 1;
    for(i=0;i<n;i++)
        cout<<x<<" ";    
    return 0;
}


Measured memory_bytes: 1280
x, y = gets.chomp.split.map(&:to_i)

test1 = 4 * x - y
test2 = y - 2 * x

result = "No"
result = "Yes" if test1 % 2 == 0 && test1 >= 0 && test2 % 2 == 0 && test2 >= 0

puts result

Measured memory_bytes: 14428
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  init();
  std::cout << (n==m?pp(pp(fac[n],fac[n]), 2):(abs(n-m)>1?0:pp(fac[n], fac[m]))) << '\n';
}


Measured memory_bytes: 47104
#include<iostream>
#include<cstdio>
using namespace std;
int k[15],p[15],s[15][15];
int main ()
{
	int n,m,i,j,k1;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
	{
		scanf("%d",&k[i]);
		for(j=1;j<=k[i];++j)
		  scanf("%d",&s[i][j]);
	}
	for(i=1;i<=m;++i)
	  for(j=1;j<=k[i];++j) s[i][j]--;
	for(i=1;i<=m;++i) scanf("%d",&p[i]);
	int ans=0;
	for(i=0;i<(1<<n);++i)
	{
		int b1=0;
		for(j=1;j<=m;++j)
		{
			int sum=0;
			for(k1=1;k1<=k[j];++k1)
			  if(((i>>s[j][k1])&1)==1) sum++;
			sum%=2;
			if(sum!=p[j]) 
			{
				b1=1;
				break;
			} 
		}
		if(b1==0) ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	char s[1001];
	int w;
	scanf("%s%d", s, &w);
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		if (i % w == 0) {
			printf("%c", s[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int n;
    long long int a[100010];
    long long int prod = 1;

    scanf("%d",&n);


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

            if(a[i]==0){
                printf("0\n");
                return 0;
            }
    }


    for(int i=0;i<n;i++){
        if(a[i]<=1000000000000000000/prod){ // oq essa linha faz??
            prod*=a[i];
    }else{
        printf("-1\n");
        return 0;
        }
    }



    printf("%lld\n",prod);

    return 0;

}


Measured memory_bytes: 2484
#include <stdio.h>
#include <stdlib.h>
#define max_size 51

int main(){
	int i, j, N, M, f;
	char *S2 = (char *)malloc(sizeof(char) * max_size);
	char *T = (char *)malloc(sizeof(char) * max_size);
	scanf("%s", S2);
	scanf("%s", T);
	for(i = 0; S2[i] != '\0'; i++){}
	N = i;
	for(j = 0; T[j] != '\0'; j++){}
	M = j;
	for(i = N - M; i >= 0; i--){
		f = 1;
		for(j = 0; j < M; j++){
			if(S2[i + j] != '?' && S2[i + j] != T[j]){
				f = 0;
			}
		}
		if(f == 1){
			for(j = 0; j < M; j++){
				S2[i + j] = T[j];
			}
			for(i = 0; i < N; i++){
				if(S2[i] == '?'){
					S2[i] = 'a';
				}
			}
			printf("%s\n", S2);
			return 0;
		}
	}
	printf("UNRESTORABLE\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	int a, b;
	cin >> a >> b;
	if(b % a == 0) cout << a+b << endl;
	else cout << b-a << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner
var out *bufio.Writer

const INF = 1 << 30

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N, X, Y := nextInt3()
	G := make([][]int, N+1)
	for i := 1; i < N; i++ {
		G[i] = append(G[i], i+1)
		G[i+1] = append(G[i+1], i)
	}
	G[X] = append(G[X], Y)
	G[Y] = append(G[Y], X)

	d := make([]int, N)
	for i := 1; i < len(G); i++ {
		u, qu := i, []int{i}
		dist := make([]int, N+1)
		for j := 1; j < len(dist); j++ {
			if j != i {
				dist[j] = -1
			}
		}
		for len(qu) > 0 {
			u, qu = qu[0], qu[1:]
			for v := 0; v < len(G[u]); v++ {
				next := G[u][v]
				if dist[next] == -1 {
					dist[next] = dist[u] + 1
					qu = append(qu, next)
					d[dist[next]]++
				}
			}
		}
	}
	for i := 1; i < N; i++ {
		fmt.Fprintln(out, d[i]/2)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInt2() (int, int)      { return nextInt(), nextInt() }
func nextInt3() (int, int, int) { return nextInt(), nextInt(), nextInt() }
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func cond(condition bool, t, f int) int {
	if condition {
		return t
	}
	return f
}
func abs(a int) int { return cond(a < 0, -a, a) }
func min(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		chmin(&ret, a[i])
	}
	return ret
}
func max(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		chmax(&ret, a[i])
	}
	return ret
}
func chmin(a *int, b int) { *a = cond(*a < b, *a, b) }
func chmax(a *int, b int) { *a = cond(*a > b, *a, b) }


Measured memory_bytes: 13056
S = input()
T = input()
check = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}
alll = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
alfa = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
count_s = set()
count_t = set()
nums = 0
numt = 0
for s in range(len(S)):
    if count_s == alfa:
        break
    if S[s] in check:
        continue
    count_s.add(S[s])
    S = S.replace(S[s],str(alll[nums]))
    nums += 1
for t in range(len(T)):
    if count_t == alfa:
        break
    if T[t] in check:
        continue
    count_t.add(T[t])
    T = T.replace(T[t],str(alll[numt]))
    numt += 1
if S == T:
    print('Yes')
else:print('No')

Measured memory_bytes: 3888
#include <stdio.h>

int selectionSort (int A[], int N)
{
   int i, j, minj, s, count;

   count = 0;

   for (i = 0; i < N-1; i++) {
      minj = i;
      for (j = i; j < N; j++) { 
         if (A[j] < A[minj]) {
            minj = j;
         }
      }

      s = A[i];
      A[i] = A[minj];
      A[minj] = s;

      if (i != minj) {
         count++;
      }
   }

   return count;
}
      

int main ()
{
   int N, A[100];
   int minj, i, c;

   scanf("%d", &N);
   for (i = 0; i < N; i++) {
      scanf("%d", &A[i]);
   }

   c = selectionSort(A, N);

   for (i = 0; i < N; i++) {
      if (i == 0) {
         printf("%d", A[i]);
      } else {
         printf(" %d", A[i]);
      }
   }

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

   return 0;
}

         

Measured memory_bytes: 604
import java.io.*;
import java.util.ArrayList;

public class Main {
    private static ArrayList<House> houses = new ArrayList<>();

    public static void main(String[] args) {
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            int n,m;
            String[] temp = in.readLine().split(" ");
            n = Integer.parseInt(temp[0]);
            m = Integer.parseInt(temp[1]);
            for (int i = 0;i < n;i ++) {
                houses.add(new House(i+1));
            }
            for(int i = 0;i < m;i ++) {
                temp = in.readLine().split(" ");
                houses.get(Integer.parseInt(temp[0]) - 1).connectedHouse
                        .add(houses.get(Integer.parseInt(temp[1]) - 1));
                houses.get(Integer.parseInt(temp[1]) - 1).connectedHouse
                        .add(houses.get(Integer.parseInt(temp[0]) - 1));
            }
            ArrayList<House> a = new ArrayList<>();
            ArrayList<House> b = new ArrayList<>();
            ArrayList<House> c;
            a.add(houses.get(0));
            while(true) {
                c = b;
                b = a;
                a = c;
                a.clear();
                for(House house : b) {
                    for(House house1 : house.connectedHouse) {
                        if (house1.lastHouse == null) {
                            house1.lastHouse = house;
                            a.add(house1);
                        }
                    }
                }
                if(a.isEmpty()) break;
            }
            houses.remove(0);
            boolean isDone = true;
            for(House house : houses) {
                if (house.lastHouse == null) {
                    isDone = false;
                }
            }
            if(isDone) {
                System.out.println("Yes");
                for(int i = 0;i < houses.size();i ++) {
                    if(i < houses.size() - 1) {
                        System.out.println(houses.get(i).lastHouse.num);
                    } else {
                        System.out.print(houses.get(i).lastHouse.num);
                    }
                }
            } else {
                System.out.print("No");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class House {
    House lastHouse;
    ArrayList<House> connectedHouse = new ArrayList<>();
    int num;
    public House(int num) {
        this.num = num;
    }
}


Measured memory_bytes: 77280
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

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

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<int> like(M, 0);
  for(int i = 0; i < N; i++){
    int K; cin >> K;
    for(int j = 0; j < K; j++){
      int a; cin >> a;
      a--;
      like[a]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < M; i++){
    if(like[i] == N) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

int n, h[100002], k;
int dp[100002];  // dp[i] = min cost to get to i

int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	
	cin >> n >> k;
	for(int i = 1; i <= n; ++i)
		cin >> h[i];
	for(int i = 1; i <= n; ++i)
		dp[i] = (1<<30);
	dp[1] = 0;
	for(int i = 1; i < n; ++i)
		for(int nxt = i+1; nxt <= i+k; ++nxt)
			if(nxt <= n && dp[i] + abs(h[i] - h[nxt]) < dp[nxt])
				dp[nxt] = dp[i] + abs(h[i] - h[nxt]);
	cout << dp[n];
    return 0;
}


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

const int MAX_N = 50;

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

    int F[MAX_N];
    F[0] = F[1] = 1;
    rep(i, 2, n+1) F[i] = F[i-1] + F[i-2];

    cout << F[n] <<endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int main() {
	// your code goes here
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	while(cin>>n){
	vector<int>cost(n);
	for(int i=0;i<n;i++)cin>>cost[i];
	vector<unsigned long long>dp(n);
	dp[0]=0;
	dp[1] = abs(cost[1]-cost[0]);
	for(int i=2;i<n;i++)
	dp[i] = min(dp[i-1]+abs(cost[i]-cost[i-1]),dp[i-2]+abs(cost[i]-cost[i-2]));
	
	
	cout<<dp[n-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4528
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    int ans = 0;
    string nows = "", nowt = "";
    rep(i, min(s.size(), t.size())){
        nows = s[s.size()-1-i] + nows;
        nowt += t[i];
        if(nows == nowt)ans = i+1;
    }
    ans = t.size()+s.size()-ans;
    cout << max(n, ans);
}      

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


n, k = map(int, input().split())

# Store data
sushis = []
neta_set = set()
for i in range(n):
    t, d = map(int, input().split())
    sushis.append((t,d))
    neta_set.add(t)


# Formatting
sushis.sort(key=lambda i:i[1])
tMax = len(neta_set)


# Select sushi set as maximum oishisa point
sel_sushis = []
neta_set = set()
sum_oishisa = 0
for i in range(k):
    t, d = sushis.pop()
    if t in neta_set:
        sel_sushis.append((t,d))
    else:
        neta_set.add(t)
    sum_oishisa += d

sel_sushis.sort(key=lambda i:i[1], reverse=True)
tMin = len(neta_set)
max_score = tMin**2 + sum_oishisa

for nNeta in range(tMin+1, tMax + 1, 1):

    # Find sushi having minimum oishisa and being not unique for neta
    if len(sel_sushis) == 0:
        break
    t1, d1 = sel_sushis.pop()
    sum_oishisa -= d1

    # Find sushi having maximum oishisa and unique for neta
    while True:
        t2, d2 = sushis.pop()
        if not t2 in neta_set:
            break

    sum_oishisa += d2
    neta_set.add(t2)

    score = nNeta**2 + sum_oishisa
    if score > max_score:
        max_score = score

print(max_score)

Measured memory_bytes: 22116
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll arr[100001];

int main() {
	// your code goes here
	ll N;
	cin >> N;
	map<ll,ll>cmap;
	for (ll i = 0; i < N; i++)
	    cin >> arr[i];
	for (ll i = 0; i < N; i++) {
	    cmap[arr[i]]++;
	}
	map<ll,ll>::iterator it;
	ll ans = 0;
	for (it = cmap.begin(); it != cmap.end(); it++) {
	    ll x = it->first;
	    ll y = it->second;
	    if (x == y)
	       continue;
	    else if (y < x) {
	        ans += y ;
	    }
	    else {
	        ans += (y-x);
	    }
	}
	cout << ans << endl;
	return 0;
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N;

ll i, j, k;

int main(){
    scanf("%lld", &N);
    printf("%lld\n", 10 - N / 200);
    return 0;
}

Measured memory_bytes: 3828
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b, c;

int main(){
    INIT;
    cin >> a >> b >> c;
    cout << (a * c <= b ? c : b / a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll r,c;
const int maxn=5005;
ll k;
ll dp[maxn][maxn][4];
ll g[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>r>>c>>k;
	rep(i,k)
	{
		ll x,y,v;
		cin>>x>>y>>v;
		g[x][y]=v;
	}
	for(ll i=1;i<=r;i++)
	{
		for(ll j=1;j<=c;j++)
		{
			for(ll k=0;k<=3;k++)
			{
				dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
				dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+g[i][j]);
				dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
			}
			for(ll k=1;k<=3;k++)
			{
				dp[i][j][k]=max(dp[i][j][k],g[i][j]+dp[i][j-1][k-1]);
			}		
		}
	}
	ll ans=0;
	rep(k,4) ans=max(ans,dp[r][c][k]);
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 376788
//06
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cout<<"Case "<<i<<":"<<endl;
    int s;
    cin>>s;
    for(int j=0;j<10;j++){
      s=s*s%1000000/100;
      cout<<s<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
    int length[10];
    int num;
    int maxNum = 0;
    int maxIdx;
    int sumNums = 0;
    int i;

    scanf("%d", &num);
    for(i = 0; i < num; i++){
        scanf("%d", &length[i]);
        sumNums += length[i];
    }

    for(i = 0; i < num; i++){
        if(length[i] > maxNum){
            maxNum = length[i];
            maxIdx = i;
        }
    }

    if(length[maxIdx] < sumNums - length[maxIdx]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int N,i,j,key;
  int A[1000];
  scanf("%d",&N);

  for(j=0;j<N;j++){
    scanf("%d",&A[j]);
  }
  for(j=0;j<N-1;j++){
    printf("%d ",A[j]);
  }
  printf("%d",A[N-1]);
  printf("\n");
  
  for(i=1;i<N;i++){
    
    key=A[i];
    j=i-1;
    
    while(j>=0&&A[j]>key){
      A[j+1]=A[j];
      j--;
     
      A[j+1]=key;
      
    }
    for(j=0;j<N-1;j++){
      printf("%d ",A[j]);
    }
    printf("%d",A[N-1]);
    
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2068
N=int(input())
D,X=list(map(int,input().split()))

#aは任意の人が食べた個数を記録するリスト
a=[]
for i in range(N):
    x=int(input())
    num=(D-1)//x
    a.append(num+1)
print(sum(a)+X)


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

using namespace std;
typedef long long ll;

const int N=200005;
vector<ll> tree(4*N,0);

void update(int idx,int l,int r,int pos,ll val)
{
    if(l==r) tree[idx]=val;
    else
    {
        int m=(l+r)/2;
        if(pos<=m) update(2*idx,l,m,pos,val);
        else update(2*idx+1,m+1,r,pos,val);
        tree[idx]=max(tree[2*idx],tree[2*idx+1]);
    }
}

ll query(int idx,int l,int r,int ql,int qr)
{
    if(ql>qr) return 0;
    if(l==ql&&r==qr) return tree[idx];
    int m=(l+r)/2;
    return max(query(2*idx,l,m,ql,min(qr,m)),query(2*idx+1,m+1,r,max(ql,m+1),qr));
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n);
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> h[i];
    for(int i=0;i<n;i++) cin >> a[i];
    ll res=0;
    for(int i=0;i<n;i++)
    {
        ll now=query(1,1,n,1,h[i]-1)+a[i];
        res=max(res,now);
        update(1,1,n,h[i],now);
    }
    cout << res << "\n";
    return 0;
}


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

#define ll long long

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

	ll n, x;
	ll sum = 0, cnt = 1;
	scanf("%lld %lld", &n, &x);
	for (int i = 0; i < n; ++i)
	{
		int v;
		scanf("%d", &v);
		sum += v;
		if (sum <= x)
		{
			cnt++;
		}
	}
	printf("%lld\n", cnt);
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  ll ans=0;
  FOR(i,1,n-1){
    ll a=A[i-1]+A[i]+A[i+1];
    a-=max({A[i-1],A[i],A[i+1]});
    a-=min({A[i-1],A[i],A[i+1]});
    if(A[i]==a) ans++;
  }
  co(ans)
}

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


int main(void) {
    long int N,ans=0,A,B;
    cin >> N;
    long int s[N];
        rep(i,N){
       cin >> s[i];
    }
    sort(s,s+N);
    forr(i,0,N-1){
        if(s[i]==s[i+1]){
            cout << "NO" << "\n";
            return 0;
        }
    }


      
    
      cout << "YES" << "\n";
  

  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

public class HelloWorld
{
    static public void Main ()
    {
        var S = long.Parse(Console.ReadLine());
        
        var Y3 =((S-1)/1000000000)+1;
        var X3 = 1000000000*Y3 - S;
        
        
        Console.WriteLine(0+" "+0+" "+1000000000+" "+1+" "+X3+" "+Y3);
        
     }            
}


Measured memory_bytes: 27308
n,m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
lang = [[] for i in range(m+1)]
graph = [[] for i in range(n+1)]
for i in range(n):
    for j in range(1,a[i][0]+1):
        lang[a[i][j]].append(i+1)
for i in range(m+1):
    if len(lang[i]) > 1:
        for j in range(len(lang[i])-1):
            graph[lang[i][j+1]].append(lang[i][j])
            graph[lang[i][j]].append(lang[i][j+1])
stack = [1]
visited = [0]*(n+1)
while stack:
    x = stack.pop()
    visited[x] = 1
    for y in graph[x]:
        if visited[y] == 1:
            continue
        stack.append(y)
if 0 not in visited[1:]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 44112
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define iterator IT
#define SIZ(V) V.size()
#define FS(a) fixed<<setprecision(a)
using namespace std;
namespace STARTER {
	int MAX(int a,int b) {
		return a>b?a:b;
	}
	int MIN(int a,int b) {
		return a<b?a:b;
	}
	int ABS(int a) {
		return a<0?-a:a;
	}
	int GCD(int a,int b) {
		return !b?a:GCD(b,a%b);
	}
	int LCM(int a,int b) {
		return a/GCD(a,b)*b;
	}
	int QSM(int a,int b,int p) {
		int ret=1;
		while (b) {
			if (b&1)
				ret=ret*a%p;
			a=a*a%p;
			b>>=1;
		}
		return ret;
	}
	int ROUND(double a) {
		return a+0.5;
	}
}
using STARTER::MAX;
using STARTER::MIN;
using STARTER::ABS;
using STARTER::GCD;
using STARTER::LCM;
using STARTER::QSM;
using STARTER::ROUND;
const int maxN=15;
int n,a[4][4],b[maxN];
bool flag[4][4];
int main() {
	for (int i=1;i<=3;i++)
		for (int j=1;j<=3;j++)
			cin>>a[i][j];
	cin>>n;
	for (int i=1;i<=n;i++) {
		cin>>b[i];
		for (int j=1;j<=3;j++)
			for (int k=1;k<=3;k++)
				if (a[j][k]==b[i])
					flag[j][k]=true;	
	}
	if ((flag[1][1]&&flag[1][2]&&flag[1][3])||(flag[2][1]&&flag[2][2]&&flag[2][3])||(flag[3][1]&&flag[3][2]&&flag[3][3])||(flag[1][1]&&flag[2][1]&&flag[3][1])||(flag[1][2]&&flag[2][2]&&flag[3][2])||(flag[1][3]&&flag[2][3]&&flag[3][3])||(flag[1][1]&&flag[2][2]&&flag[3][3])||(flag[1][3]&&flag[2][2]&&flag[3][1]))
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    cin >> n;
    // ll a;
    vector<ll> a(n);
    int64_t ans = 1;
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, n)
    {
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, n)
    {
        if (a[i] > (1000000000000000000 / abs(ans)))
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            ans *= a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var D = int.Parse(Console.ReadLine());
            var C = RL<long>();
            var Co = Enumerable.Repeat(0, 26).ToArray();
            var S = new List<long>[D];
            for (var i = 0; i < D; i++) S[i] = RL<long>().ToList();
            for (var i = 0; i < D; i++) {
                var tmp = new int[26];
                Array.Copy(Co, tmp, Co.Length);
                long ans = 0;
                var T = 0;
                for (var t = 0; t < 26; t++) {
                    Array.Copy(tmp, Co, tmp.Length);
                    long m = 0;
                    for (var a = 0; a < 26; a++) {
                        if (t == a) {
                            Co[a] = 0;
                            continue;
                        }
                        Co[a]++;
                    }
                    for (var a = 0; a < 26; a++) {
                        m += Co[a] * C[a];
                    }
                    if(S[i][t] - m > ans) {
                        T = t;
                        ans = S[i][t] - m;
                    }
                }
                Co = tmp;
                for (var a = 0; a < 26; a++) {
                    if (T == a) {
                        Co[a] = 0;
                        continue;
                    }
                    Co[a]++;
                }
                Console.WriteLine(T + 1);
            }
        }

        static T[] RL<T>() where T : IComparable {
            if (typeof(T) == typeof(int)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            }
            if (typeof(T) == typeof(long)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            }
            if (typeof(T) == typeof(double)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            }
            if (typeof(T) == typeof(decimal)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
            }
            return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
        }
    }
}


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

typedef long long ll;

ll search(vector<ll> &a,ll val)
{
	// cout<<" vector ";
	// for(int i=0;i<a.size();i++)
	// 	cout<<a[i]<<" ";
	// cout<<endl;
	ll low=0,high=a.size()-1;
	if(val>=a.back())
		val=-1;
	while(low<high)
	{
		ll mid=(low+high)>>1;
		if(a[mid]<=val)
			low=mid+1;
		else
			high=mid;
	}
	return a[low];
}

int main()
{
	string s,t;
	cin>>s>>t;
	vector<vector<ll> > ms(26),mt(26);
	for(int i=0;i<s.length();i++)
		ms[s[i]-'a'].push_back(i);
	for(int i=0;i<t.length();i++)
		mt[t[i]-'a'].push_back(i);
	// for(int i=0;i<26;i++)
	// {
	// 	if(ms[i].size()>0)
	// 	{
	// 		cout<<char(i+'a')<<" -< ";
	// 		for(int j=0;j<ms[i].size();j++)
	// 			cout<<ms[i][j]<<" ";
	// 		cout<<endl;
	// 	}
	// }
	for(int i=0;i<26;i++)
	{
		if(mt[i].size()>0&&ms[i].size()==0)
		{
			cout<<-1;
			return 0;
		}
	}
	ll ans=0;
	ll curr=-1;
	for(int i=0;i<t.length();i++)
	{
		ll z=search(ms[t[i]-'a'],curr);
		// cout<<z<<endl;
		if(z<=curr)
			ans++;
		curr=z;
	}
	cout<<ans*s.length()+curr+1;
}

Measured memory_bytes: 2872
#include <bits/stdc++.h>
using namespace std;
int a,b;
int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int main()
{
	a=read();
	b=read();
	cout<<a+b;
	puts("");
} 

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

int main() {
  vector<int> fibo(50, -1);
  fibo[0] = fibo[1] = 1;
  for (int i = 2; i <= 44; i++) {
    fibo[i] = fibo[i-1] + fibo[i-2];
  }
  int p; cin >> p;
  cout << fibo[p] << endl;
}




Measured memory_bytes: 3120
# 072b
class Atc_072b:
    def __init__(self, s: str) -> str:
        self.s = s

    def odd(self):
        s_odd = ""
        for i in range(0, len(self.s)):
            if i % 2 == 0:
                s_odd += self.s[i]
        return s_odd
    

s_input = input()
print(Atc_072b(s_input).odd())

Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1000000007;
int vis[100000+5]={0};
ll poww(ll n,ll m)
{
    ll ans=1,base=n;
    while(m!=0)
    {
        if(m&1!=0)
            ans=ans*base%mod;
        base=base*base%mod;
        m>>=1;
    }
    return ans;
}
int main()
{
    int n;
    cin>>n;

   int sum=n;
   for(int i=0;i<n;i++)
   {
       int t;
       cin>>t;
      vis[t]++;
   }
   for(int i=1-n%2;i<=n-1;i+=2)
   {
       if(vis[i]==2)
        sum-=2;
   }
   if(n%2==1)
   {
       if(vis[0]==1)
        sum--;
   }
   if(sum!=0)
   {
       cout<<0<<endl;
   }
   else
   {//cout<<sum<<endl;
       int tot=n/2;
        cout<<poww(2,tot)%mod<<endl;
        //cout<<tot<<endl;
   }
}


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

long long C0,C1,C2,C3,N;
string S;

int main() {
	cin>>N;
	
	for (long long i = 0; i<N; i++){
		cin>>S;
		
		if (S == "AC"){
			C0++;
		} else if (S == "WA"){
			C1++;
		} else if (S == "TLE"){
			C2++;
		} else if(S == "RE") {
			C3++;
		}
	}
	
	cout<<"AC x "<<C0<<endl;
	cout<<"WA x "<<C1<<endl;
	cout<<"TLE x "<<C2<<endl;
	cout<<"RE x "<<C3<<endl;
	return 0;
}

Measured memory_bytes: 3624
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  s = to_string(n);
  ll siz = Size(s);
  if (siz == 1) {
    Cout(n);
    return 0;
  }
  rrep(i, 1, n + 1) {
    ll cou = 0;
    s = to_string(i);
    char be, af;
    be = s[Size(s) - 1], af = s[0];
    if (be == '0') continue;
    if (be == af) {
      tmp = (be - '0');
      if (tmp <= n) ans++, cou++;
    }
    cnt = 1;
    ll tmpp;
    rep(k, 15) {
      tmpp = k;
      if (k + 2 == siz) break;
      ans += cnt;
      cou += cnt;
      cnt *= 10;
    }
    string co = "";
    co += be;
    rep(z, tmpp) co += "0";
    co += af;
    tmp = (ll)stoi(co);
    if (tmp > n) continue;
    s = to_string(n);
    if (Size(s) <= 1) continue;
    if (Size(s) == 2) {
      ans++;
      cou++;
      continue;
    }
    s = to_string(n);
    if (s[0] == be) {
      string co = "";
      rrep(z, 1, siz - 1) co += s[z];
      tmp = (ll)stoi(co);
      ll add = tmp + 1;
      if ((s[Size(s) - 1] - '0') >= (af - '0')) {
        ans += add;
        cou += add;
      } else {
        ans += max(add - 1, 0LL);
        cou += add - 1;
      }
    } else {
      cnt = 1;
      rep(z, siz - 2) cnt *= 10;
      ans += cnt;
      cou += cnt;
    }
    // Cout(cou);
  }
  Cout(ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	while(1){
	int n,m;
	scanf("%d %d",&n,&m);
	if(!n) break;
	int maxi[51]={};
	int date[105]={};
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		for(int j=0;j<a;j++){
			int e;
			scanf("%d",&e);
			date[e]++;
		}
	}
	int ma=0,ans=0;
	for(int i=100;i>=1;i--){
		if(date[i]>=ma){
			ans=i;
			ma=date[i];
		}
	}
	if(ma<m){
		ans=0;
	}
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 1028
N = int(input())
S = [input() for _ in range(N)]
ans = 0
ba, __a, b__ = 0, 0, 0
for i in range(N):
  ans += S[i].count("AB")
  if S[i][0] != "B" and S[i][-1] == "A":
    __a += 1
  elif S[i][0] == "B" and S[i][-1] == "A":
    ba += 1
  elif S[i][0] == "B" and S[i][-1] != "A":
    b__ += 1
if ba > 0:
  ans += ba - 1
  if __a > 0:
    ans += 1
    __a -= 1
  if b__ > 0:
    ans += 1
    b__ -= 1
ans += min(b__, __a)
print(ans)

Measured memory_bytes: 3700