akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int ret = 0;
	REP(r, N / R + 1){
		REP(g, N / G + 1){
			int tmp = N - (r * R + g * G);
			if(0 <= tmp && tmp % B == 0) ret++;
		}
	}

	cout << ret << endl;

	return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<ll> v(100000+1,0);

  ll ans = 0;  
  for(int i = 0; i < N; i++){
    ll tmp1,tmp2;
    cin >> tmp1 >> tmp2;

    ans += tmp2 - tmp1 + 1;
  }
  cout << ans<< endl;

}


Measured memory_bytes: 1024
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
#
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;

int main() {
	int n;
	ci(n);
	int i;
	vl h;
	fo(i,n){
		ll temp;
		ci(temp);
		temp-=(i+1);
		h.pb(temp);
	};
	sort(h.begin(),h.end());
	ll sum=0;
	fo(i,n){
		sum+=abs(h[i]-h[n/2]);
	};
	co(sum);
	
	return 0;
}





Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

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

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m; cin >> n >> m;
    UnionFind tree(n);
    int usefulop = 0;
    for(int i = 0; i < m; i++){
        int x,y,z; cin >> x >> y >> z;
        if(!tree.same(x-1,y-1)){
            tree.unite(x-1,y-1);
            usefulop++;
        }
    }
    cout << n - usefulop << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll lucas_core(const int n, const ll a, const ll b) {
  if(n <= 0) {
    return a;
  } else if(n == 1) {
    return b;
  } else {
    return lucas_core(n - 1, b, a + b);
  }
}

ll lucas(const int n) {
  return lucas_core(n, 2, 1);
}

int main() {
  int n; cin >> n;
  cout << lucas(n) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  if (a == b) cout << "Draw";
  else if (a > b) {
    if (b == 1) cout << "Bob";
    else cout << "Alice";
  } else if (a == 1) {
    cout << "Alice";
  } else {
    cout << "Bob";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
def solve():
  n = int(input())
  query = []
  for i in range(n-1):
    c,s,f = (int(i) for i in input().split())
    query.append((c,s,f))

  ans = []
  for i in range(n-1):
    time = 0
    for j in range(i,n-1):
      c,s,f = query[j]
      time = max(s,time)
      if not time%f == 0:
        time += f-time%f
      time += c
    ans.append(time)
  for i in ans:
    print(i)
  print(0)
solve()

Measured memory_bytes: 3188
fun main(args:Array<String>) {
    val s = readLine()!!
    val k = readLine()!!.toInt()
    val target = mutableSetOf<String>()
    for(i in s.indices) {
        for(j in (i until Math.min(i+5, s.length))) {
            target.add(s.substring(i..j))
        }
    }
    val ans = target.sorted()[k-1]
    println(ans)
}

Measured memory_bytes: 42248
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    multimap<int, int> timelimitToIndex;
    vector<int> taskTime(N);

    rep(i, N) {
        int A, B;
        cin >> A >> B;
        taskTime[i] = A;
        timelimitToIndex.insert({B, i});
    }

    int elapsed = 0;
    for (auto it: timelimitToIndex) {
        int timelimit = it.first;
        int index = it.second;
        elapsed += taskTime[index];
        if (timelimit < elapsed) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

	#define MAX 1000000

	typedef struct dd{
		char name[100];
		int time;
	}data;

	data Q[MAX+1];
	int head = 1,tail = 1,n;


	void enquence(data x){
		Q[tail] = x;
		if(tail+1 == MAX){
			tail=0;
		}

		else {
			tail++;
		}

	}

	data dequene(){
		data a;
		a = Q[head];
		if(head+1==MAX){
			head=0;
		}
		else {
			head++;
		}

		return a;
	}


	int main(){

	int i,answer=0,c=0,q,count=0;

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

	for(i=1;i<=n;i++){

		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].time);
		enquence(Q[i]);
	}

	while(1){
		c++;
		if(n==count)break;
		if(Q[c].time - q > 0){
			answer+=q;
			Q[c].time -= q;
			enquence(Q[c]);
		}

	else {
		answer += Q[c].time;
		printf("%s %d\n",Q[c].name,answer);
		count++;
		Q[c]= dequene();
	}
	}
	return 0;

	}

Measured memory_bytes: 21068
#include <iostream>

using namespace std;

const int NIL = -1;

struct Node{
    int id, parent, bro, num_childs, child, depth;
};

void setDepth(Node* tree, int id, int d)
{
    tree[id].depth = d;
    if(tree[id].child != NIL) setDepth(tree, tree[id].child, d+1);
    if(tree[id].bro != NIL) setDepth(tree, tree[id].bro, d);
}

int main()
{
    int n, id, c, k, bro;
    Node tree[200000];
    cin >> n;
    for(int i=0;i<n;++i)
    {
        tree[i].parent = tree[i].child = tree[i].bro = NIL;
        tree[i].depth = 0;
    }
    for(int i=0;i<n;++i)
    {
        cin >> id >> k;
        tree[id].num_childs = k;
        tree[id].id = id;
        for(int j=0;j<k;++j)
        {
            cin >> c;
            tree[c].parent = id;
            if(j){
                tree[bro].bro = c;
            }
            else{
                tree[id].child = c;
            }
            bro = c;
        }
    }

    int root = 0;
    for(int i=0;i<n;++i){
        if(tree[i].parent == NIL) 
        {
            root = i;
            break;
        }
    }
    setDepth(tree, root, 0);

    for(int i=0;i<n;++i)
    {
        cout << "node " << i << ": parent = " << tree[i].parent << ", depth = " << tree[i].depth << ", ";
        if(tree[i].parent == -1) cout << "root, ";
        else if(tree[i].num_childs == 0) cout << "leaf, ";
        else cout << "internal node, ";
        cout << "[";
        c = tree[i].child;
        for(int j=0;j<tree[i].num_childs;++j)
        {
            if(j) cout << ", ";
            cout << tree[c].id;
            c = tree[c].bro;
        }
        cout << "]" << endl;
    }
}



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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		long[] A = nextLongs();
		long[] B = nextLongs();
		long[] C = new long[N];
		long sum=0;
		for(int i=0;i<N;i++){
			C[i]=A[i]-B[i];
			sum+=C[i];
		}
		if(sum<0){
			System.out.println(-1);
			return;
		}

		Arrays.sort(C);
		long ans=0;
		int i=0;
		int t=N-1;
		long rem=0;
		while(C[i]<0){
			rem+=C[i];
			ans++;
			i++;
			while(rem<0){
				rem+=C[t];
				ans++;
				t--;
			}
		}
		System.out.println(ans);

	}

	public static long[] disassemblyAlph(String s) {
		long[] alph = new long['z' - 'a' + 1];
		Arrays.fill(alph, 0);
		for (int i = 0; i < s.length(); i++) {
			alph[s.charAt(i) - 'a']++;
		}
		return alph;
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

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

using namespace std;

int main()
{
   int l,r,d;
   cin>>l>>r>>d;
   
   int count=0;
   count=r/d-l/d;
   
   
   if(l%d==0)
   count++;
   if(l==r&&l%d==0)
   count=1;
   cout<<count;
   
   
   return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

 for(int i = 0;i < q;i++) {
   string X,Y;
   cin >> X >> Y;
   int x = X.size(),y = Y.size();

   int dp[x+1][y+1];
   for(int i = 0;i <= x;i++) {
     dp[i][0] = 0;
   }
   for(int i = 0;i <= y;i++) {
     dp[0][i] = 0;
   }

   for(int i = 1;i<=x;i++) {
     for(int j = 1;j <= y;j++) {
       if(X.at(i-1) == Y.at(j-1)) dp[i][j] = dp[i-1][j-1] + 1;
       else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
     }
   }

   cout << dp[x][y] << endl;

 }

  
}





Measured memory_bytes: 7068
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 5050;
int a[MAXN], cnt[MAXN];

int n, k;

void add(int& x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

void sub(int& x, int y) {
    x -= y;
    if (x < 0) x += MOD;
}

int main() {
    GI(n); GI(k);

    FOR1(i, n) GI(a[i]);
    
    memset(cnt, 0, sizeof cnt); cnt[0] = 1;

    FOR1(i, n-1) {
        FORD(j, MAXN) {
            if (j - a[i] >= 0) {
                add(cnt[j], cnt[j - a[i]]);
            }
        }
    }

    int res = 0;

    for (int i = n; i >= 1; i--) {
        bool useless = true;

        for (int j = max(0, k - a[i]); j <= k - 1; j++) {
            if (cnt[j] != 0) {
                useless = false;
                break;
            }
        }

        res += useless;

        FORN(j, MAXN) {
            if (j - a[i-1] >= 0) {
                sub(cnt[j], cnt[j - a[i-1]]);
            }
        }

        FORD(j, MAXN) {
            if (j - a[i] >= 0) {
                add(cnt[j], cnt[j - a[i]]);
            }
        }
    }

    cout << res << "\n";

    return 0;
}

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

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
typedef long long LL;
template<class T> int maxx(T a, T b) { return a > b ? a : b; }
template<class T> int minn(T a, T b) { return a < b ? a : b; }
template<class T> int abss(T a) { return a > 0 ? a : -a; }
#define max maxx
#define min minn
#define abs abss
const int maxn = 100010;

int n, m;
priority_queue<int, vector<int>, less<int> >Q;

int main()
{
    scanf("%d%d", &n, &m);
    REP(i, 1, n) { int x; scanf("%d", &x); Q.push(x); }
    REP(i, 1, m)
    {
        int u = Q.top(); Q.pop();
        u /= 2;
        Q.push(u);
    }
    LL ans = 0;
    REP(i, 1, n) { ans += Q.top(); Q.pop(); }
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, a[100010], mu = 0, rin = 0;
vector<int> ta;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = n - 2; i >= 0; i--) {
		if (a[i + 1] == a[i] && a[i + 2] != a[i]) {
			ta.push_back(a[i]);
		}
		if (i <= n - 4 && a[i] == a[i + 1] && a[i] == a[i + 2] && a[i] == a[i + 3]) {
			mu = a[i];
		}
		if (ta.size() == 2) {
			rin = ta[0] * ta[1];
			cout << max(mu*mu, rin) << endl;
			getchar(); getchar();
			return 0;
		}
	}
	cout << mu*mu << endl;
	getchar(); getchar();
	return 0;
}

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

const int N = 100005;

int arr[N];

int main() {
  int n, cnt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++) scanf("%d", &arr[i]);
  for (int i = 1; i <= n; i ++)
    if (arr[i] == i) {
      if (i == 1) swap(arr[i], arr[i + 1]);
      else if (i == n) swap(arr[i - 1], arr[i]);
      else {
	if (arr[i + 1] == i + 1) swap(arr[i], arr[i + 1]);
	else swap(arr[i - 1], arr[i]);
      }
      cnt ++;
    }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 640
use proconio::input;

fn main() {
    input!(n: usize, a: [usize; n]);

    const AMAX: usize = 1_000_000;

    let mut cnt = vec![0; AMAX + 1];
    for &a in &a {
        cnt[a] += 1;
    }

    let mut seen = vec![false; AMAX + 1];
    let mut max_csum = 0;
    for i in 2..=AMAX {
        if seen[i] {
            continue;
        }
        let mut csum = 0;
        for j in 1..=AMAX / i {
            seen[i * j] = true;
            csum += cnt[i * j];
        }
        max_csum = max_csum.max(csum);
    }

    let pairwise = max_csum <= 1;
    let setwise = max_csum < n;

    println!(
        "{}",
        if pairwise {
            "pairwise coprime"
        } else if setwise {
            "setwise coprime"
        } else {
            "not coprime"
        }
    );
}


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

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

int main() {
  
  int K;
  cin >> K;
  
  int64_t sumN = 0;
  
  for (int a = 0; a < K; a++) {
    for (int b = 0; b < K; b++) {
      for (int c = 0; c < K; c++) {
        sumN = sumN + gcd(a+1, gcd(b+1, c+1));
      }
    
    }
    
  }
  
  cout << sumN << endl;
  

}

Measured memory_bytes: 3636
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;cin>>k;
  cout<<vec[k-1]<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(b==1){
    cout<<0<<endl;
    return 0;
  }
  int ans=1;
  for(int i=a;i<b;i+=a-1){
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int a,b;
	cin >> a >>b;
	int num=b;
	if(b<=9){num+=10*a;}
	else if(b==100){num+=1000*a;}
	else{
		num+=100*a;
	}
	
	for(int i=0; i<num; i++){
		if(i*i==num){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
K = int(input())
#a1= 7 mod K
#a2= a1*10+7 mod K
#a3= a2*10+7 mod K
a = 0
count = -1
for i in range(K):
    a = (7 + a*10) % K
    if a  == 0:
        count=i+1
        break
print(count)

Measured memory_bytes: 63136
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep4(i, a, b, c) for (int i = int(a), i##__b = int(b), i##__c = int(c); i < i##__b; i += i##__c)
#define rep1(n) rep4(i, 0, n, 1)
#define rep2(i, n) rep4(i, 0, n, 1)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define REP(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep3(i, a, b) for (int i = int(b) - 1, i##__a = int(a); i >= i##__a; i--)
#define rrep1(n) rrep3(i, 0, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep4(i, a, b, c) for (int i = int(a + (b - a - 1) / c * c), i##__a = int(a), i##__c = int(c); i >= i##__a; i -= i##__c)
#define RREP(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define FOREACH(i, x) for (auto &i : x)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define print(x) cout << x << endl;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
template <class T> using vv = vector<vector<T>>;
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;}
// clang-format on

int main() {
    ll N;
    cin >> N;
    vll keta_flag_kazu(60);
    REP(_, N) {
        ll A;
        cin >> A;
        REP(i, 60) {
            keta_flag_kazu[i] += A >> i & 1;
        }
    }
    ll ans = 0;
    REP(i, 60) {
        ll k = keta_flag_kazu[i] * (N - keta_flag_kazu[i]) % MOD;
        ll b = (1ll << i) % MOD;
        ans += k * b;
        ans %= MOD;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

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

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> k;
    vector<ll> A(n);
    for(auto &x : A) {
        cin >> x;
    }
    ll cnt = 0, now = 0;
    vector<ll> used(n, -1);
    used[0] = 0;
    for(i = 0; i < n; i++) {
        now = A[now] - 1;
        cnt++;
        if(used[now] >= 0) break;
        used[now] = i + 1;
        if(cnt==k){
            cout << now+1 << endl;
            return 0;
        }
    }
    // now が 始点
    ll ch = 0, s = 0;
    if(now != 0) {
        for(i = 0; i < n; i++) {
            ch = A[ch] - 1;
            s++;
            if(ch == now) break;
        }
    }
    vector<ll> loop;
    ch = now;
    do {
        loop.push_back(ch);
        ch = A[ch] - 1;
    } while(ch != now);
    ll c = (k - s) % (cnt - s);
    cout << loop[c] + 1 << endl;
    return 0;
}

Measured memory_bytes: 8496
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		HashMap<String,Integer> map=new HashMap<>();
		for(String t:strs(gInt()))
			map.merge(t,1,Integer::sum);

		int max=map.values().stream().mapToInt(i->i).max().getAsInt();
		map.entrySet().stream().filter(o->o.getValue()==max)
				.map(o->o.getKey()).sorted()
				.forEach(System.out::println);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int t;
	Supplier<T> supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 87640
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
  
  int r,c;

  cin >> r >> c;
  
  int **A = new int* [r+1];
  for(int i=0; i<r+1; i++){
    A[i] = new int [c+1];
  }

  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      cin >> A[i][j];
    }
  }

  for(int i=0; i<r; i++){
    A[i][c]=0;
    for(int j=0; j<c; j++){
      A[i][c] += A[i][j];
    }
  }

  for(int j=0; j<=c; j++){
    A[r][j]=0;
    for(int i=0; i<r; i++){
      A[r][j] += A[i][j];
    }
  }

  for(int i=0; i<=r; i++){
    for(int j=0; j<=c; j++){
      cout << A[i][j];
      if(j!=c){
        cout << " ";
      }
    }
    cout << endl;
  }

  return(0);
}

Measured memory_bytes: 1228
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    for(signed i=0;i<n;i++,cout<<"\n")
        for(signed j=i+1;j<n;j++)
            cout<<__builtin_ctz(i^j)+1<<" ";
}


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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef long long int lli; 
 
int main(){
    
	lli s,w;
  cin>>s>>w;
  if(s<=w){
    cout<<"unsafe";
  }  
  else{
  	cout<<"safe";
  }
    return 0;
}

Measured memory_bytes: 3532
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int n, a[100005];
bool flag;
int sum;
int main(){
	scanf("%d", &n);
	sum = 1;
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int ans = 1;
	do{
		if(a[ans + 1] > a[ans]) flag = 0;
		else if(a[ans + 1] < a[ans])flag = 1;
		ans++;
	}while(a[ans - 1] == a[ans] && ans < n);
	for(int i = ans - 1; i < n; i++){
		if(!flag){
			if(a[i + 1] < a[i]){
				sum++;
				int cnt = i;
				do{
					cnt++;
					i = cnt;
					if(a[cnt + 1] > a[cnt]) flag = 0;
					else flag = 1;
				}while(a[cnt] == a[cnt + 1] && cnt < n);
			}
		}
		else{
			if(a[i + 1] > a[i]){
				sum++;
				int cnt = i;
				do{
					cnt++;
					i = cnt;
					if(a[cnt + 1] > a[cnt]) flag = 0;
					else flag = 1;
				}while(a[cnt] == a[cnt + 1] && cnt < n);
			}
		}
	}
	printf("%d\n", sum);
}




Measured memory_bytes: 512
#include <stdio.h>
#include <stdint.h>

#define STR_MAX    (100000)

#define FAST_TRIAL  (1)

int main(void)
{
    uint64_t n;
    uint64_t k;
    char s[STR_MAX+1];

    scanf("%ld %ld", &n, &k);
    scanf("%s", s);

    uint64_t ptr = 0;
    char curC;
    char nxtC;

    uint64_t serialNum[STR_MAX+2];
    uint64_t indx   = 0;
    uint64_t head1  = 0;
    uint64_t max    = 0;
    uint64_t cntK   = 0;
    uint64_t curSum = 0;

    curC = s[ptr++];
    /* serialNumは 1 の数 -> 0の数としたいので0ならindxを送る */
    if ( curC == '0' ) {
        indx++;
    }

#ifdef FAST_TRIAL
    while ( (curC != '\0') && (cntK < k) ) {
        /* nxtCを得る */
        nxtC = s[ptr++];

        serialNum[indx]++;

        /* どうやら次は別の文字のようだ */
        if ( curC !=  nxtC ) {
            curSum += serialNum[indx++];

            if ( curC == '0' ) {
                /* 逆立ちできる人たちが増える */
                cntK++;
            }

            /* ここまでで今回のserialNumによるcurSumが決定するので最大値更新 */
            max = ( curSum >= max ) ? curSum : max;
        }

        curC = nxtC;
    }
#endif

    while ( curC != '\0' ) {
        /* nxtCを得る */
        nxtC = s[ptr++];

        serialNum[indx]++;

//        uint64_t dbgIndx = indx;

        /* どうやら次は別の文字のようだ */
        if ( curC !=  nxtC ) {
            curSum += serialNum[indx++];

            /* 0の連続が終わったときは昔の0を捨てる場合がある */
            if ( curC == '0' ) {
#ifdef FAST_TRIAL
                curSum -= (serialNum[head1] + serialNum[head1+1]);
                head1 += 2;
#else
                /* 逆立ちできる人たちが増える */
                cntK++;

                /* 逆立ちできる人たちがK人より多いとき */
                if ( cntK > k ) {
                    /* 
                     * 1Grp -> 0Grp -> 1Grp -> 0Grp ... 1Grp -> NEW 0Grp
                     * となるので先頭の0Grpと1Grp分を引いて, 0Grpのheadを移動させる
                     */
                    curSum -= (serialNum[head1] + serialNum[head1+1]);
                    head1 += 2;
                }
#endif
            }

            /* ここまでで今回のserialNumによるcurSumが決定するので最大値更新 */
            max = ( curSum >= max ) ? curSum : max;
        }

//        printf("%c : cntK=%ld, curSum=%ld, serialNum=%ld, head1=%ld, max=%ld\n", curC, cntK, curSum, serialNum[dbgIndx], head1, max);

        curC = nxtC;
    }

    printf("%ld\n", max);

    return 0;
}



Measured memory_bytes: 1024
N = int(input())
S = str(input())

suu = []
s_count = S.count('.')
k_count = 0
suu.append(s_count + k_count)
for i in range(N):
    if S[i] == "#":
        k_count += 1
    else:
        s_count -= 1
    suu.append(k_count + s_count)

print(min(suu))


Measured memory_bytes: 11368
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
  int n;
  while(cin>>n,n){
    int s=0;
    for(int i=1;i<=(int)sqrt(n)&&i!=n;++i){
    	if(n%i==0){
	    	s+=(n/i!=n)?n/i:0;
	    	s+=(n/i!=i)?i:0;
    	}
    }
    if(n>s) cout<<"deficient number"<<endl;
    else if(n==s) cout<<"perfect number"<<endl;
    else if(n<s) cout<<"abundant number"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
N,K=map(int,input().split())
import numpy as np
hights=np.array(list(map(int,input().split())))
steps=np.array([10**10]*N)
steps[0]=0
for i in range(N-1):
    gaps=hights[i+1:i+K+1]-hights[i]
    gaps=np.abs(gaps)
    gaps+=steps[i]
    steps[i+1:i+K+1]=np.minimum(steps[i+1:i+K+1],gaps)
print(steps[-1])

Measured memory_bytes: 23092
function main(input) {
  const inputChars = input.split("");
  const upper = parseInt(inputChars[0] + inputChars[1]);
  const lower = parseInt(inputChars[2] + inputChars[3]);
  var YYMM = false;
  var MMYY = false;

  const d1 = new Date(upper + 2000, lower - 1, 1);
  if (d1.getFullYear() == upper + 2000 && d1.getMonth() == lower - 1) {
    YYMM = true;
  }

  const d2 = new Date(lower + 2000, upper - 1, 1);
  if (d2.getFullYear() == lower + 2000 && d2.getMonth() == upper - 1) {
    MMYY = true;
  }

  if (YYMM && MMYY) {
    console.log("AMBIGUOUS");
    return
  }
  if (YYMM) {
    console.log("YYMM");
    return
  }
  if (MMYY) {
    console.log("MMYY");
    return
  }
  console.log("NA");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11464
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define int ll
const int mod = 1e9 + 7;
int32_t main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    static int p[1 << 20];
    int n;
    IOS;
    fi>>n;
    static int was[1 << 20];
    for (int i = 1;i <= n;++i)
        was[i] = 1;
    for (int i = 1;i <= n;++i)
        fi>>p[i],was[p[i]] = 0;
    static int t[1 << 20];
    static int f[1 << 20];
    f[0] = f[1] = 1;
    for (int i = 2;i <= 1e6 + 5;++i)
        f[i] = (1ll * i * f[i - 1]) % mod;
    auto U = [&](int i)
    {
        for (;i <= n;i += i&(-i))
            t[i] ++;
    };
    auto Q = [&](int i)
    {
        int ans = 0;
        for (;i;i -= i&(-i))
            ans += t[i];
        return ans;
    };
    const int sum = accumulate(was + 1,was + 1 + n,0) % mod;
    int ans = 0;
    int S = 0;
    was[0] = 0;
    for (int i = 1;i <= n;++i)
        if (was[i])
            S += i - 1;
    S %= mod;
    for (int i = 1;i <= n;++i)
        was[i] += was[i - 1];
    static int sums[1 << 20];
    for (int i = 1;i <= n;++i)
        sums[i] = sums[i - 1] + (p[i] == 0);
    int w = 0;
    for (int i = 1;i <= n;++i)
    {
        if (p[i])
        {
            int now = 0;
            ans = (ans + (f[n - i] * (p[i] - 1) % mod) * f[sum]) % mod;
            now = Q(p[i]) * f[n - i] % mod;
            now = now * f[sum] % mod;
            (ans += mod - now) %= mod;
            now = 0;
            now = sums[i] * was[p[i]] % mod;
            now = now * f[sum - 1] % mod;
            now = now * f[n - i] % mod;
            (ans += mod - now) %= mod;
            w += sum - was[p[i]];
            w %= mod;
            U(p[i]);
        }
        else
        {
            ans = (ans + (f[n - i] * S % mod) * f[sum - 1]) % mod;
            int now = w * f[sum - 1] % mod;
            now = now * f[n - i] % mod;
            (ans += mod - now) %= mod;
            if (sum >= 2)
            {
                now = (sum * (sum - 1) / 2) % mod;
                now = (now * sums[i - 1]) % mod;
                now = (now * f[sum - 2]) % mod;
                now = (now * f[n - i]) % mod;
                (ans += mod - now) %= mod;
            }
        }
    }
    (ans += f[sum]) %= mod;
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

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

int main()
{
    int64_t X, A, B;
    cin >> X >> A >> B;
    if (A >= B)
    {
        cout << "delicious" << endl;
    }
    else if (B - A <= X)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  string s = to_string(n);
  int m = 0;
  rep(i,s.size()){
    int tmp = s.at(i) - '0';
    m += tmp;
  }
  cout << (n % m == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  l=LI()

  sm=sum(l)
  if n<sm:
    return -1
  return n-sm

# main()
print(main())


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

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

    switch (N % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 3128
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 15 August 2020 01:47:47 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;

int fact(int x){
    if(x == 0){
        return 1;
    }
    if(x == 1){
        return 1;
    }
    return x*fact(x-1);
}
    

int nC3(int x){
    return ((x*(x-1)*(x-2))/6);
}

void solve(){
    int n;
    cin>>n;
    string t;
    cin>>t;
    set < string >  s;
    for(int i=0; i<10; ++i){
        for(int j=0; j<10; ++j){
            for(int k=0; k<10; ++k){
                string  p = "";
                p += (i+'0');
                p += (j+'0');
                p += (k+'0');
                s.insert(p);
            }
        }
    }


    int ans = 0;
    for(auto x: s){
        int j = 0;
        bool found = false;
        for(int i=0; i<n; ++i){
            if(x[j] == t[i]){
                ++j;
            }
            if( j == 3 ){
                found = true;
                break;
            }
        }
        if(found) ++ans;
    }
    cout<<ans<<endl;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n==0) break;
    unsigned long psum = 0;
    for(int i=0; i<n; i++){
      int p;
      cin >> p;
      psum += p;
    }
    vector<int> j(n-1);
    for(int i=0; i<n-1; i++) cin >> j[i];
    sort(j.rbegin(),j.rend());
    int num = n;
    for(int i=0; i<n-1; i++){
      if(psum * num >= (psum + j[i]) * (num - 1)) break;
      psum += j[i];
      num--;
    }
    cout << psum * num << endl;
  }
  return 0;
}

Measured memory_bytes: 1448
#include <stdio.h>
int main(void){
    int a[5]={0},b=0,i=0;
    for(i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    if(a[0]>a[1]){
        b=a[0];
        a[0]=a[1];
        a[1]=b;
    }
     if(a[1]>a[2]){
        b=a[1];
        a[1]=a[2];
        a[2]=b;
    }
     if(a[0]>a[1]){
        b=a[0];
        a[0]=a[1];
        a[1]=b;
    }
    if(a[3]>a[4]){
        b=a[3];
        a[3]=a[4];
        a[4]=b;
    }
    printf("%d\n",a[0]+a[3]-50);


    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli A[100000] = {};
lli L[100000] = {};
lli R[100000] = {};

int main(void) {

	lli N;
	cin >> N;

	for (int i = 0; i < N; i++)
		cin >> A[i];

	L[0] = A[0];

	for (int i = 1; i < N; i++) {
		lli x, y;
		L[i] = extgcd<lli>(L[i - 1], A[i], x, y);
	}

	R[N - 1] = A[N - 1];

	for (int i = N - 2; i >= 0; i--) {
		lli x, y;
		R[i] = extgcd<lli>(R[i + 1], A[i], x, y);
	}

	lli ans = 0;

	for (int i = 0; i < N; i++) {
		lli x, y;
		lli t;
		if (i == 0)
			t = R[i + 1];
		if (i == N - 1)
			t = L[i - 1];
		else
			t = extgcd(L[i - 1], R[i + 1], x, y);

		CHMAX(ans,t);
	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if (A + B >= C - 1) {
			System.out.println(B + C);
		} else {
			System.out.println(B + A + B + 1);
		}
		
		sc.close();
	}
}


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

using namespace std;

// Graph template
template <class... Args> struct Edge {
  int from, to;
  tuple<Args...> values;
  Edge(int from, int to, Args... values)
      : from(from), to(to), values(values...) {}
};
template <class E> auto operator<(const E &e, const E &f) {
  return e.values > f.values;
}

template <class... Args> class Graph {
  using Edges = vector<Edge<Args...>>;
  vector<Edges> graph_;

public:
  Graph(int n) : graph_(n) {}
  size_t size() { return graph_.size(); };
  size_t size() const { return graph_.size(); };
  auto &operator[](unsigned int x) { return graph_[x]; }
  const auto &operator[](unsigned int x) const { return graph_[x]; }
  void AddEdge(int s, int t, Args... v) { graph_[s].emplace_back(s, t, v...); }
};

int dp(int now, const Graph<> &g) {
  vector<int> v;
  for (const auto &x : g[now]) {
    int c = dp(x.to, g);
    v.push_back(c);
  }
  sort(v.rbegin(), v.rend());
  int ret = 0;
  for (int i = 1; i <= (int)v.size(); ++i) {
    ret = max(ret, v[i - 1] + i);
  }
  return ret;
};

int main() {
  int n;
  cin >> n;
  Graph<> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int u;
    cin >> u;
    g.AddEdge(u - 1, i + 1);
  }
  cout << dp(0, g) << endl;
}

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

data = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')

print(data[n-1])


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        long k = Long.parseLong(br.readLine());

        int x = 0;
        long now = 100;
        while(true){
            x++;
            long rishi = now / 100;
            now += rishi;
            if(k <= now){
                break;
            }
        }

        System.out.println(x);
    }


}


Measured memory_bytes: 25368
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;

const int maxn=55;
int a[maxn];
int n,k,ans;

bool cmp(const int x,const int y) {
	return x>y;
}

int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++) 
		cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=k;i++)
		ans+=a[i];
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    int N; cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++){
        cin >> S[i];
    }

    map<string, int> M;
    for(int i=0; i<N; i++){
        M[S[i]]++;
    }

    cout << M.size() << endl;

    return 0;
}

Measured memory_bytes: 25116
#ifndef _WIN32
#include<iostream>
#endif 
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<bitset>
using namespace std;

typedef long long LL;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
template<typename T> bool chmax(T &l, T r) {
	bool res = l < r;
	if (res) l = r;
	return res;
}
template<typename T> istream& operator>>(istream &is, vector<T> &v) {
	for (auto &it : v)is >> it;
	return is;
}

struct cww {
	cww() {
		cout << fixed;
		cout << setprecision(10);
	}
}star;
int N;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<string> Vs;
typedef vector<Vs> VVs;
VV G;
V B;
int bitdp[1 << 20];
bool input() {
	cin >> N;
	if (N == 0)return false;
	G.assign(N, V(N, 0));
	B.assign(N, 0);
	map<string, int> memo;
	Vs A(N);
	VVs D(N);
	REP(i, N) {
		cin >> A[i]>>B[i];
		int C;
		cin >> C;
		REP(j, C) {
			string s; cin >> s;
			D[i].push_back(s);
		}
		memo[A[i]] = i;
	}
	REP(i, N) for(auto &it:D[i]){
		int j = memo[it];
		G[i][j] = 1;
	}
	return true;
}
void sync(int n) {
	int sz = 1 << n;

	REP(bit, sz) {
		REP(i, n)
			if (bit&(1 << i));
			else chmax(bitdp[bit | (1 << i)],bitdp[bit]);
	}
}

int main() {
	while (input()) {
		int m = N/2;
		int n = N -m;
		int res = 0;
		REP(bit, (1<<n))bitdp[bit] = 0;
		const int mask = (1 << n) - 1;
		V x(n,0);
		V y(m,0);
		V z(m, mask);
		REP(i, n) {
			REP(j, n)if (i != j&&G[i][j] == 1)x[i] |= (1 << j);
		}
		REP(i, m) {
			REP(j, m)if (i != j&&G[i+n][j+n] == 1)y[i] |= (1 << j);
		}
		REP(i, m) {
			REP(j, n)if (G[i + n][j])z[i] -= (1 << j);
		}
		REP(bit, (1 << n))if(bit&1) {
			bool flag = true;
			int cost = 0;
			REP(i,n)
				if (bit&(1 << i)) {
					cost += B[i];
					if (bit&x[i]) {
						flag = false;
						break;
					}
				}
			if (flag) {
				bitdp[bit] = cost;
				chmax(res, cost);
			}
		}
		sync(n);

		REP(bit, (1 << m)) {
			bool flag = true;
			int cost = 0;
			int ans = mask;
			REP(i, m) {
				if (bit&(1 << i)) {
					cost += B[i + n];
					if (bit&y[i]) {
						flag = false; break;
					}
					ans &= z[i];
				}
			}
			if (flag)if(ans&1) {
				chmax(res, cost + bitdp[ans]);
			}
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 7384