akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node* u, int k)
{
    while(u != NIL && k != u->key) {
        if (k < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }
    return u;
}

void insert(int k)
{
    Node *y = NIL;  // yをNIL(zの親候補)
    Node *x = root;  // xをrootとする(現在の節点)
    Node *z;  // これから挿入するつもりの節点

    // zのメモリ領域を確保し，key, left, rightを設定する
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    // x(現在の節点)に関する処理
    // xがleafになるまで続ける
    while(x != NIL) {
        y = x;  // zの親としてxをyに代入
        if (z->key < x->key) {
            // xをxの左の子とする
            x = x->left;
        } else {
            // xをxの右の子とする
            x = x->right;
        }
    }

    // y(zの親候補)に関する処理
    z->parent = y;  // zの親をyとする
    if (y == NIL) {  // yがNIL(xがNIL)ならばrootはz
        root = z;
    } else {  // そうでないとき
        if (z->key < y->key) {
            // yの左の子をzとする
            y->left = z;
        } else {
            // yの右の子をzとする
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    // 中間順巡回
    if (u == NIL) {
        return;
    }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    // 先行順巡回
    if (u == NIL) {
        return;
    }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, i, x;
    string com;
    
    scanf("%d", &n);

    for (i = 0;i < n; i++) {
        cin >> com;
        if (com[0] == 'f') {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        } else if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 22044
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<malloc.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, a[200200];
pii b[200200];

int bit[200200];

int sum(int i){
    int s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x){
    while(i <= N + 1){
        bit[i] += x;
        i += i & -i;
    }
}

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        b[i] = mk(-a[i], i);
    }
    sort(b, b + N);
    for(int i = 0; i < N; i++){
        a[b[i].second] = i + 1;
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += sum(a[i]);
        add(a[i], 1);
    }
    cout << ans << endl;

    return 0;
}

/*

*/


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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    int nu = n*(n-1)/2;
    int mu = m*(m-1)/2;
    if(n == 0)nu = 0;
    if(m == 0)mu = 0;
    cout << nu + mu << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
 
    int x = 1, i = 1;
    while(1){
        scanf("%d", &x);
        if(x != 0){
            printf("Case %d: %d\n", i, x);
            i++;
        }
         
        if(x == 0){
            break;
        }
    }
 
    return 0;
}

Measured memory_bytes: 600
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/



#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ll n;
    cin >> n;
    n = n%10;
    if(n==2 || n==4 ||n==5 ||n==7 || n==9 )
        cout << "hon"<< endl;
    else if(n==3)
        cout << "bon"<< endl;
    else 
        cout << "pon"<< endl;

}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
bool visited[200005];
int towhere[200005];
int main() {
    int n;
    long long k;
    scanf("%d %lld",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",towhere+i);
    }
    int cur=1;
    long long cntcl=0;
    while(not visited[cur]){
        visited[cur]=true;
        cur=towhere[cur];
        cntcl++;
    }
    int head=1;
    long long cnthd=0;
    while(head!=cur){
        head=towhere[head];
        cnthd++;
    }
    cntcl-=cnthd;
    if(k>cnthd){
        k-=cnthd;
        k%=cntcl;
        k+=cnthd;
    }
    int ans=1;
    for(int i=0;i<k;i++){
        ans=towhere[ans];
    }
    printf("%d",ans);
}

Measured memory_bytes: 4788
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long M = 1000000007L;

	void solve() {
		StringBuffer sb = new StringBuffer();
		int n = ni();
		int k = ni();
		out.println(k == 1 ? 0 : n - k);
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

string s;
int k;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s >> k;
	set<string> st;
	FOR(i, s.size()) {
		for (int j = 1; i+j <= s.size() && j <= k; j++) {
			string sub = s.substr(i, j);
			st.insert(sub);
		}
	}
	int cnt = 0;
	string ans;
	FORR(x, st) {
		cnt++;
		if (cnt == k) {
			ans = x;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

    long double ans = 0;
    for (int i = 1; i <= N ; i++){
        long double I = i;
        long double a = K / I;
        if (a < 1){
            ans += 1;
        } else {
            long double x = log2(a);
            int y = x;
            if (x != y)y++;
            long double Y = y;
            ans += pow(0.5,Y);
        }
    }

    ans /= N;

    cout << fixed;
    cout << setprecision(11) << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    sp(6);
    int n;cin>>n;
    double res=0;
    rep(i,n){
        double x;string s;cin>>x>>s;
        if(s=="BTC")x*=380000;
        res+=x;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();

        sc.close();

        int dx = tx - sx;
        int dy = ty - sy;

        for(int i=0; i<dy; i++) System.out.print('U');
        for(int i=0; i<dx; i++) System.out.print('R');

        for(int i=0; i<dy; i++) System.out.print('D');
        for(int i=0; i<dx; i++) System.out.print('L');

        System.out.print('L');
        for(int i=0; i<dy+1; i++) System.out.print('U');
        for(int i=0; i<dx+1; i++) System.out.print('R');
        System.out.print('D');

        System.out.print('R');
        for(int i=0; i<dy+1; i++) System.out.print('D');
        for(int i=0; i<dx+1; i++) System.out.print('L');
        System.out.print('U');
    }
}

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

bool ok(int, int, int);

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

  vector<int> v(N);
  rep(i,0,N-1) {
    cin >> v[i];
  }

  int ans = 0;
  for (int i = 0; i < v.size(); ++i) {
    for (int j = i + 1; j < v.size(); ++j) {
      for (int k = j + 1; k < v.size(); ++k) {
        if (ok(v[i], v[j], v[k])) {
          ans += 1;
        }
      }
    }
  }

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

bool ok(int i, int j, int k)
{
  if (i == j || j == k || k == i)
    return false;
  if (k < i + j && i < j + k && j < i + k)
    return true;
  return false;
}


Measured memory_bytes: 3632
#ifndef _WIN32
#include<iostream>
#endif

using namespace std;
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<iomanip>
#include<stack>
#include<set>
#include<functional>
#include<map>
#include<complex>
#include<tuple>
typedef double D;
typedef bool B;
typedef complex<D> P;
typedef vector<P> Poly;
typedef pair<P, P> L;
typedef L LS;
#define X real()
#define Y imag()

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DCl(a,b,l) P(a),(b);tie(a,b)=l;
const int dr[] = { 0, 1, 0, -1 };
const int dc[] = { 1, 0, -1, 0 };
const D EPS = 1e-9;

struct cww{
	cww(){
		cin.tie();
		ios::sync_with_stdio(false);
		cout << fixed;
		cout << setprecision(10);
	}
}star;
D dot(P a, P b){
	return a.X*b.X + a.Y*b.Y;
}
D cross(P a, P b){
	return a.X*b.Y - a.Y*b.X;
}
D ccw(P a, P b, P c){
	return cross(b - a, c - a);
}
int sgn(P a, P b, P c){
	if (cross(b - a, c - a) > EPS)return 1;
	if (cross(b - a, c - a) < -EPS)return -1;
	if (dot(b - a, c - a) > -EPS)return 2;
	if (dot(a - b, c - b) > -EPS)return -2;
	return 0;
}


D signed_distance_P_L(P p,L l){
	DCl(a, b, l);
	return ccw(a, b, p) / abs(b - a);
}

B is_LS_LS(LS p,LS q){
	DCl(a, b, p);
	DCl(c, d, q);
	return sgn(a, b, c)*sgn(a, b, d) <= 0
	&& sgn(c, d, a)*sgn(c, d, b) <= 0;
}
P cross_L_L(LS p,LS q){
	DCl(a, b, p);
	D d1 = signed_distance_P_L(a, q);
	D d2 = signed_distance_P_L(b, q);
	return (a*d2 - b*d1) / (d2 - d1);
}


P input(){
	double x, y;
	cin >> x >> y;
	return P(x, y);
}
int main(){
	int T; cin >> T;
	while(T--){
		P A = input();
		P B = input();
		int N;
		cin >> N;
		vector<pair<LS,int>> M, O;
		REP(i, N){
			LS in = LS(input(), input());
			int type,pos; cin >> type>>pos;
			if (type)M.push_back({ in, pos });
			else O.push_back({ in, 1-pos });
		}
		map<D, int> m;
		for (auto ls : M)if (is_LS_LS({ A, B }, ls.first))m[abs(A-cross_L_L({ A, B }, ls.first))] = ls.second;
		for (auto ls : O)if (is_LS_LS({ A, B }, ls.first))m[abs(A - cross_L_L({ A, B }, ls.first))] = ls.second;
		if (m.size()){
			int res = 0;
			int prv = m.begin()->second;
			for (auto &it : m){
				if (prv != it.second)res++;
				prv = it.second;
			}
			cout << res << endl;
		}
		else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>
int main(void){
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
         scanf("%d",&a[i]);
    }
    for(i=n-1;0<=i;i--){
        if(i!=0){
            printf("%d ",a[i]);
        }
        else{
            printf("%d\n",a[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n;
    cin>>n;
    loop(i,0,n+1){
        // print(i*1.08);
        if((ll)(i*1.08) == n){
            print(i);
            ret;
        }
    }
    print(":(");
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

def main():
    cumsum = accumulate([0] + A)
    counter = Counter(cumsum)
    for v in counter.values():
        if v > 1:
            yield v*(v-1)//2


print(sum(main()))

Measured memory_bytes: 40552
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(H);
    Cini(W);
    Cini(N);
    int maxLen = max(H,W);
    cout << (N+maxLen-1)/maxLen << nn;
    return 0;
}

Measured memory_bytes: 256
a,b = list(map(int, input().split()))
max = a
if max < b:
  max = b
p = 1
for i in range(b, 1, -1):
  if a % i == 0 and b % i == 0:
    a = a // i
    b = b // i
    p = i
    break
print(a * b * p)

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	m := nextInt()
	kl := make([]int, m)
	s := make([][]int, m)
	for i := 0; i < m; i++ {
		kl[i] = nextInt()
		tmp := make([]int, kl[i])
		for j := 0; j < kl[i]; j++ {
			tmp[j] = nextInt()
		}
		s[i] = tmp
	}

	pl := make([]int, m)
	for i := 0; i < m; i++ {
		pl[i] = nextInt()
	}

	cnt := 0
	for bit := 0; bit < (1 << n); bit++ {

		var setlist []int
		for j := 0; j < n; j++ {
			if bit&(1<<j) != 0 { // 今回ヒットした場合
				setlist = append(setlist, j+1)
			}
		}

		// 表示
		//fmt.Println(setlist)

		// 電球mごとに全て点灯したかをカウント
		allLightFlag := true
		for i := 0; i < m; i++ {

			// 電球mにつながっているスイッチのうちONの個数をカウント
			cntmon := 0
			for j := 0; j < kl[i]; j++ {
				tmp := s[i]
				f, _ := hasX(tmp[j], setlist)
				if f == true { // ON
					cntmon++
				}
			}
			if cntmon%2 != pl[i] {
				allLightFlag = false //少なくとも１つ消えている
				break
			}
		}
		if allLightFlag == true {
			cnt++
		}
	}

	fmt.Println(cnt)
}
func hasX(x int, plist []int) (bool, int) {
	for i, p := range plist {
		if x == p {
			return true, i
		}
	}
	return false, -1
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1888
n = int(input())
a_l = list(map(int, input().split()))

ans = 0
i = 0
j = 0
while i < n:
    if a_l[i] == j+1:
        j += 1
        i += 1
        continue
    ans += 1
    i += 1
if ans > n-1:
    print('-1')
else:
    print(ans)

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll INF = 1LL << 60;
int N, M;
ll dis[1010][1010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  fill((ll*)dis, (ll*)(dis + 1010), INF);
  for (int i = 0; i < N; i++) dis[i][i] = 0;
  for (int i = 0; i < M; i++) {
    int a, b; ll c;
    cin >> a >> b >> c;
    a--, b--;
    dis[a][b] = -c;
  }
  for (int k = 0; k < N; k++) for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
    dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  }
  for (int i = 0; i < N; i++) {
    if (dis[i][i] < 0 && dis[0][i] < 1000000000000000LL && dis[i][N - 1] < 1000000000000000LL) {
      cout << "inf" << endl;
      return 0;
    }
  }
  cout << -dis[0][N - 1] << endl;

  return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main() {
    int k,x;
    cin >> k >> x;
    vector <int> v(2*k-1);
    for(int i=0;i<2*k-1;++i) {
        v[i]=x-k+i+1;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<2*k-1;++i) cout << v[i] << endl;
}



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

typedef long long ll;

const ll MOD = ((ll)1e9) + 7;

const int MAXN = 2002;

bool field[MAXN][MAXN];
int wh[MAXN][MAXN], ht[MAXN][MAXN];

int main() {
	ios_base::sync_with_stdio(0);
	
	int h, w;
	cin >> h >> w;
	for(int y = 1; y <= h; y++) {
		string s;
		cin >> s;
		for(int x = 1; x <= w; x++) {
			field[y][x] = (s[x-1] == '.');
		}
	}
	
	int ans = 0;
	
	for(int y = 1; y <= h; y++) {
		int len = 0;
		int px = 0;
		for(int x = 1; x <= w+1; x++) {
			if(!field[y][x]) {
				for(int xx = px; xx < x; xx++) {
					wh[y][xx] = len;
				}
				len = 0;
				px = x+1;
			} else len++;
		}
	}
	for(int x = 1; x <= w; x++) {
		int len = 0;
		int py = 0;
		for(int y = 1; y <= h+1; y++) {
			if(!field[y][x]) {
				for(int yy = py; yy < y; yy++) {
					ht[yy][x] = len;
				}
				len = 0;
				py = y+1;
			} else len++;
		}
	}
	
	
	for(int y = 1; y <= h; y++) {
		for(int x = 1; x <= w; x++) {
			if(!field[y][x]) continue;
			ans = max(ans, ht[y][x]+wh[y][x] - 1);
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 35456
def division(a, b):
   return float(a / b)

def div_rest(a, b):
    return a % b

def div_result(a, b):
    return a//b

a, b = map(int, input().split())

result = div_result(a,b)
rest = div_rest(a,b)
x = division(a,b)
print(result, rest, '%.10f' % x)



Measured memory_bytes: 5612
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        o: Chars,
        e: Chars,
    };
    let mut oi = o.iter();
    let mut ei = e.iter();
    let mut s = "".to_owned();
    while let Some(oc) = oi.next() {
        s.push(*oc);
        if let Some(ec) = ei.next() {
            s.push(*ec);
        }
    }
    println!("{}", s);
}


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

a = list(map(int,input().split()))

index = 1

ans = 0

while index < n:
    ans += 1
    if a[index-1] < a[index]:
        flag = True
    elif a[index-1] > a[index]:
        flag = False
    else:
        flag3 = True
        for i in range(index,n):
            if a[index] != a[i]:
                flag3 = False
                if a[index] < a[i]:
                    flag = True
                    break
                else:
                    flag = False
                    break
        if flag3:
            break
    flag2 = True
    for i in range(index,n):
        if flag and a[i] < a[i-1]:
            index = i+1
            flag2 = False
            break
        elif a[i] > a[i-1] and flag == False:
            index = i+1
            flag2 = False
            break
    if flag2:
        break
if index == n:
    ans += 1
print(ans)

Measured memory_bytes: 62704
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int dp[201][201] = {0};

int main(){
    int d,n;
    memset(dp,0,sizeof(dp));
    cin >> d >> n;
    vector<int> t(d);
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    REP(i,d){
	cin >> t[i];
    }
    REP(i,n){
	cin >> a[i] >> b[i] >> c[i];
    }

    FOR(i,2,d+2){
	REP(j,n){
	    REP(k,n){
		int tt = t[i-1];
		int pt = t[i-2];
		if(a[k] <= tt && tt <= b[k] && a[j] <= pt && pt <= b[j]){
		    dp[i][k] = max(dp[i][k],dp[i-1][j] + abs(c[j]-c[k]) );
		}
	    }
	}
    }
    int ans = 0;
    REP(i,n) {
	ans = max(ans,dp[d][i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1360
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 62) - 1;

int main(void)
{
    int bingo[3][3];
    static bool open[3][3];
    int n;
    int b;
    int i, j, k;
    bool flag = false;

    rep(i, 0, 3)
    {
        rep(j, 0, 3)
        {
            cin >> bingo[i][j];
        }
    }

    cin >> n;

    rep(k, 0, n)
    {
        cin >> b;
        rep(i, 0, 3)
        {
            rep(j, 0, 3)
            {
                if (bingo[i][j] == b)
                {
                    open[i][j] = true;
                }
            }
        }
    }

    rep(i, 0, 3)
    {
        if (open[0][i] == true && open[1][i] == true && open[2][i] == true)
        {
            flag = true;
        }
    }

    rep(i, 0, 3)
    {
        if (open[i][0] == true && open[i][1] == true && open[i][2] == true)
        {
            flag = true;
        }
    }

    if (open[0][0] == true && open[1][1] == true && open[2][2] == true)
    {
        flag = true;
    }

    if (open[0][2] == true && open[1][1] == true && open[2][0] == true)
    {
        flag = true;
    }

    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int L,R,D;
  cin >> L >> R >> D;
  int l = L - 1;
  int a = (l - l % D) / D;
  int b = (R - R % D) / D;
  cout << b - a << endl;
}

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

int main(){
  int n,d;
  cin >> n >> d;
  vector<vector<int>>x(n,vector<int>(d));
  int ans=0;
  
  for(int i=0; i<n; i++){
    for(int j=0; j<d; j++){
      cin >> x[i][j];
    }
  }
  
  for(int i=0;i<n; i++){
    for(int j=i+1;j<n; j++){
      int b=0;
      for(int k=0;k<d; k++){
        int a=abs(x[i][k]-x[j][k]);
        b+=a*a;
      }
      for(int k=0; k<=b; k++){
        if(k*k==b){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  
   

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    ll n,a,b;cin >> n >> a >> b;
    vec<ll> h(n);
    rep(i,n)cin >> h[i];
    a-=b;
    /*
    毎回bだけダメージが入る
    k回の攻撃でb*kは減る
    あと何回aの攻撃が必要か？を見て和を取る
    k以下なら〇
    そうでないなら×
    */
    function<ll(ll,ll)> ans = [&](ll l,ll r){
        if(r-l==1)return r;
        ll k=(l+r)/2;
        ll cnt=0;
        rep(i,n){
            cnt+=(max((h[i]-b*k),0)+a-1)/a;
        }
        if(cnt<=k)return ans(l,k);
        else return ans(k,r);
        return 0LL;
    };
    cout << ans(0,10000000000LL) << endl;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	printf("%d",a[n/2+1]-a[n/2]);
}

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

using ll=long long; 

ll mod=1e9+7;

void solve(){
	ll n;
	cin>>n;
	map<char, ll> cnt;
	string s;
	cin>>s;
	for(char c='a'; c<='z'; c=char(c+1)){
		cnt[c]=1;
	}
	for(int i=0; i<s.size(); i++){
		cnt[s[i]]++;
	}
	ll ans=1;
	for(char c='a'; c<='z'; c=char(c+1)){
		ans*=cnt[c];
		ans%=mod;
	}
	cout<<ans-1<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
long long r = 0;
cin>>n>>m;
if(n==1&&m==1)
    cout<<1;
else if(n==1&&m!=1)
    cout<<m-2;
else if(n!=1&&m==1)
    cout<<n-2;
    else{
       r = 1ll*(n-2)*1ll*(m-2)*1ll;
       cout<<max(0ll,r);
}}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
	cin >> n >> m >> k;
	if(m-k+1>n+k-1){
		FOR(i,n,n+k) {
			cout << i << endl;
		}
		FOR(i,m-k+1,m+1) {
			cout << i << endl;
		}
	}else{
		FOR(i,n,m+1) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll n, k, a[200005] = {}, visitedTurn[200005];
	cin >> n >> k;
	for (ll i = 1; i <= n; i++)
	{
		cin >> a[i];
		visitedTurn[i] = -1;
	}
	visitedTurn[1] = 0;
	ll townNumber = 1, loopNumber = 1, teleportNumber = 0, previousTown = 1;
	while (true)
	{
		previousTown = townNumber;
		townNumber = a[townNumber];
		teleportNumber++;
		if (teleportNumber==k)
		{
			cout << townNumber << endl;
			return 0;
		}
		if (visitedTurn[townNumber] != -1)
		{
			break;
		}
		visitedTurn[townNumber] = teleportNumber;
	}
	k -= visitedTurn[townNumber];
	ll needTeleportNumber = k % (visitedTurn[previousTown]-visitedTurn[townNumber]+1);
	for (ll i = 0; i < needTeleportNumber; i++)
	{
		townNumber = a[townNumber];
	}
	cout << townNumber << endl;
	return 0;
}


Measured memory_bytes: 6716
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const double EPS=1e-10;
int sig(double r){return (r<-EPS)?-1:(r>EPS)?1:0;}

struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y) : x(x),y(y) {}
	Pt operator+(const Pt &a) const {return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt &a) const {return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt &a) const {return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator-() const {return Pt(-x,-y);}
	Pt operator*(const double &k) const {return Pt(x*k,y*k);}
	Pt operator/(const double &k) const {return Pt(x/k,y/k);}
	double abs() const {return sqrt(x*x+y*y);}
	double abs2()const{return x*x+y*y;}
	double arg()const{return atan2(y,x);}
	double dot(const Pt&a)const{return x*a.x+y*a.y;}
	double det(const Pt&a)const{return x*a.y-y*a.x;}
	bool operator<(const Pt &a)const{return (x!=a.x)?(x<a.x):(y<a.y);}
	bool operator==(const Pt&a)const{return (sig(x-a.x)==0&&sig(y-a.y)==0);}
};
ostream &operator<<(ostream &os,const Pt &a){os<<"("<<a.x<<","<<a.y<<")";return os;}
double tri(Pt a, Pt b, Pt c){return (b-a).det(c-a);}
bool iLS(Pt a,Pt b,Pt c,Pt d){
	return (sig(tri(a,b,c))*sig(tri(a,b,d))<=0);
}
int main() {
	Pt a,b,c,x;
	for(;~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&x.x,&x.y);){
		if(iLS(a,b,c,x)||iLS(a,c,b,x)||iLS(b,c,a,x)){
			puts("NO");
		}else{
			puts("YES");
		}
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,h,m; cin>>a>>b>>h>>m;
	long double H=h*30+0.5*m,M=m*6;
	cout<<fixed<<setprecision(10)<<sqrt(a*a+b*b-2*a*b*cos((M-H)*M_PI/180))<<"\n"s;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100, MAX_K = 100000;
int n,k;
int a[MAX_N];
bool memo[MAX_K+1];
bool vis[MAX_K+1];


bool win(int k) {
  if (vis[k]) return memo[k];

  bool res = false;
  forn (i,n) {
    if (k >= a[i]) // k=0 -> ok
      res |= !win(k - a[i]);
  }

  vis[k] = true;
  return memo[k] = res;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> k;
  forn(i,n) cin >> a[i];

  if (win(k))
    cout << "First\n";
  else
    cout << "Second\n";

  return 0;
}


Measured memory_bytes: 5120
n=int(input())
abc=[[int(i) for i in input().split()]for _ in range(n)]
dp=[[0]*3 for _ in range(n)]
dp[0]=abc[0]
for i in range(1,n):
    for j in range(3):
        a=(j+1)%3
        b=(j+2)%3
        dp[i][j]=max(dp[i-1][a]+abc[i][j],dp[i-1][b]+abc[i][j])
print(max(dp[-1]))

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

int main(){
        int n;
        cin >> n;
        for(int i = 0; i < n; i++){
        int high = 0,low = 0;
                int m;
                cin >> m;
                int input[2];
                cin >> input[0];
                for(int j = 0; j < m-1; j++){
                        cin >> input[1];
                        if(input[0] - input[1] < 0){
                                if(high > input[0] - input[1]){
                                        high = input[0] - input[1];
                                }
                        }else if(input[0] - input[1] > 0){
                                if(low < input[0] - input[1]){
                                        low = input[0] - input[1];
                                }
                        }
                        input[0] = input[1];
                }
        cout << high*-1 << " " << low << endl;
        }
}

Measured memory_bytes: 1160
#include <stdio.h>

void maxHeapify(int *,int);
void buildMaxHeap(int *);

int n,A[500000];

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=n/2;i>=1;i--){
    maxHeapify(A,i);
  }
  for(j=1;j<=n;j++){
    printf(" %d",A[j]);
  }
   printf("\n");
  return 0;
}
void maxHeapify(int *A,int i){
  int l,r,largest,m;
  l=2*i;
  r=2*i+1;

  if(l<=n && A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=n && A[r]>A[largest])
    largest=r;
  if(largest!=i){
    m=A[i];
    A[i]=A[largest];
    A[largest]=m;
    maxHeapify(A,largest);
  }
}

    
  



Measured memory_bytes: 3688
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

d = {num for num in range(1, n + 1)}
for i in range(m):
    if h[ab[i][0] - 1] > h[ab[i][1] - 1]:
        d.discard(ab[i][1])
    elif h[ab[i][0] - 1] < h[ab[i][1] - 1]:
        d.discard(ab[i][0])
    elif h[ab[i][0] - 1] == h[ab[i][1] - 1]:
        d.discard(ab[i][1])
        d.discard(ab[i][0])

print(len(d))

Measured memory_bytes: 107028
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if(x&1) {
			cout << "first";
			exit(0);
		}
	}
	cout << "second";
	return 0;
}


Measured memory_bytes: 256
M, D = map(int, input().split())
count = 0

for i in range(1, M+1):
    for j in range(22, D+1):
        s = str(j)
        if int(s[1]) >= 2 and int(s[0]) * int(s[1]) == i:
            count += 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define F first
#define S second
typedef pair<int,int> pii;
typedef long long ll;


void A(){
	/**ios_base::sync_with_stdio(0); cin.tie(0);
	int x, y, z;
	cin>>x>>y>>z;
	cout<<min({x+y, x+z, y+z})<<endl;*/
}
int main(){
	int n; cin>>n;
	int arr[n]; cin>>arr[0];
	for(int i=1; i<n; i++){
		cin>>arr[i];
		arr[i]+=arr[i-1];
	}
	int ans = 1e6;
	for(int i=0; i<n-1; i++){
		ans=min(ans, abs(arr[i] - (arr[n-1]-arr[i])));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3608
// #pragma GCC optimize ("O2")
// #pragma GCC target("avx2")
#include "bits/stdc++.h"
	
#define PI 3.141592653589793L
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// Use for file I/O;
#define FIN string _fname = "convention2"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define gsize(x) (int)((x).size())

using namespace std;

const char nl = '\n';

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
 
const ll inf = 1e9;
const ll inf2 = 1e18 + 99LL;
const ld inf3 = 1e14;
const ll mod = 1e9 + 7;
const ld eps = 1e-6;
 
const int logn = 19, maxn = 2e3+5, maxm = 1e5 + 5;

int main() {
	FAST;
	int x;
	cin >> x;
	cout << 1 - x;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	n--;
	cout << n*(n+1)/2 << endl;
}


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

using namespace std;

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

const int PS = 50001;
int prime[PS];
int set_prime(){
	rep(i,PS)prime[i]=1;
	prime[0]=prime[1]=0;
	rep(i,PS){
		if(prime[i]==0)continue;
		for(int j=i*2;j<PS;j+=i)prime[j]=0;
	}
}


int main(){
	set_prime();
	vector<int> s;
	rep(i,PS)if(prime[i]==1)s.push_back(i);
	
	int n;
	for(;cin>>n;){
		if(n==0)break;
		
		int sum = 0;
		rep(i,s.size()){
			if(n-s[i]>=0 && s[i]*2<=n && prime[n-s[i]]==1){
				sum++;
			}
		}
		int sum2 = 0;
		for(int i=2;i*2<=n;i++){
			if(prime[i]&&prime[n-i])sum2++;
		}
		//if(sum!=sum2)printf("%d  (%d-%d)\n",n,sum,sum2);
		printf("%d\n",sum2);
	}
}

Measured memory_bytes: 1444
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

// ACL template
int main() {
    ll N, M;
    cin >> N >> M;
    vc<string> S(N);
    rep(i, N) cin >> S[i];

    ll s = N * M, t = N * M + 1;
    mf_graph<ll> mf(N * M + 2);

    // 辺を貼る
    rep(i, N) rep(j, M) {   // 横向きの辺
        if ((i + j) % 2 == 1) continue;
        if (j > 0)      mf.add_edge(i * M + j, i * M + j - 1, 1);
        if (j < M - 1)  mf.add_edge(i * M + j, i * M + j + 1, 1);
    }
    rep(j, M) rep(i, N) {   // 縦向きの辺
        if ((i + j) % 2 == 1) continue;
        if (i > 0)      mf.add_edge(i * M + j, (i - 1) * M + j, 1);
        if (i < N - 1)  mf.add_edge(i * M + j, (i + 1) * M + j, 1);
    }
    rep(i, N) rep(j, M){    // sからの辺、tへの辺
        if((i + j) % 2 == 0)
            mf.add_edge(s, i * M + j, S[i][j] == '.');
        else
            mf.add_edge(i * M + j, t, S[i][j] == '.');
    }

    // 流す
    ll ans = mf.flow(s, t);

    auto T = S;

    // 横の辺で流れたか
    ll ycnt = N * (M - 1);
    rep(i, N) rep(j, M - 1){
        auto e = mf.get_edge(i * (M - 1) + j);

        if(e.flow > 0) T[i][j] = '>', T[i][j + 1] = '<';
    }
    // 縦の辺で流れたか
    rep(j, M) rep(i, N - 1){
        auto e = mf.get_edge(j * (N - 1) + i + ycnt);

        if(e.flow > 0) T[i][j] = 'v', T[i + 1][j] = '^';
    }


    cout << ans << '\n';
    rep(i, N) cout << T[i] << '\n';
}

Measured memory_bytes: 5724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

ll N, M;

int main(void){
    
    scanf("%lld %lld", &N, &M);
    
    if(N == 1 || M == 1) printf("%lld\n", (N == 1 && M == 1) ? 1 : N * M - 2);
    else if(N == 2 || M == 2) printf("0\n");
    else printf("%lld\n", N * M - (N + N + M + M - 4));
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int n,t;
    int minc=INF;
    int ans;
    cin>>n>>t;
    rep(i,n)
    {
        int c,ti;
        cin>>c>>ti;
        if(minc>c && ti<=t)
        {
            minc=c;
        }
    }
    if(minc==INF)
    {
        cout<<"TLE"<<endl;
    }
    else
    {
        cout<<minc<<endl;
    }
    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<string> W(N);
  for(int i=0;i<N;i++){
    cin >> W.at(i);
  }

  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(W.at(i)==W.at(j)){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  for(int i=1;i<N;i++){
    string a=W.at(i-1);
    string b=W.at(i);
    reverse(a.begin(),a.end());
    if(a.at(0)!=b.at(0)){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256