akhauriyash/Code-Regression huggingface dataset:
using System.Text;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var mask = new ulong[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var k = int.Parse(line[0]);
            var a = 0uL;
            for (int j = 0; j < k; j++)
            {
                var t = int.Parse(line[j + 1]);
                a |= 1uL << t;
            }
            mask[i] = a;
        }
        getAns(n, mask);
    }
    static void getAns(int n, ulong[] mask)
    {
        var sb = new StringBuilder();
        var q = int.Parse(Console.ReadLine().Trim());
        var c = 0;
        var a = 0uL;
        while (c++ < q)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[0] == "0")
            {
                var i = int.Parse(line[1]);
                sb.Append(((a >> i) & 1) == 1 ? "1\n" : "0\n");
            }
            else if (line[0] == "1")
            {
                var m = int.Parse(line[1]);
                a |= mask[m];
            }
            else if (line[0] == "2")
            {
                var m = int.Parse(line[1]);
                a &= ~mask[m];
            }
            else if (line[0] == "3")
            {
                var m = int.Parse(line[1]);
                a ^= mask[m];
            }
            else if (line[0] == "4")
            {
                var m = int.Parse(line[1]);
                sb.Append((a & mask[m]) == mask[m] ? "1\n" : "0\n");
            }
            else if (line[0] == "5")
            {
                var m = int.Parse(line[1]);
                sb.Append((a & mask[m]) > 0 ? "1\n" : "0\n");
            }
            else if (line[0] == "6")
            {
                var m = int.Parse(line[1]);
                sb.Append((a & mask[m]) == 0 ? "1\n" : "0\n");
            }
            else if (line[0] == "7")
            {
                var m = int.Parse(line[1]);
                var res = bitCount(a & mask[m]);
                sb.Append(res.ToString() + "\n");
            }
            else
            {
                var m = int.Parse(line[1]);
                var res = a & mask[m];
                sb.Append(res.ToString() + "\n");
            }
        }
        Console.Write(sb);
    }
    static int bitCount(ulong bits)
    {
        bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555);
        bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333);
        bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f);
        bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff);
        bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff);
        return (int)(bits & 0x00000000ffffffff) + (int)(bits >> 32);
    }
}



Measured memory_bytes: 23388
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>

#define N 1001

using namespace std;

int main() {
	int V, d;
	while ( scanf("%d%d", &V, &d) != EOF ) {
		vector<int> v(V);
		for (int i = 0; i < V; ++i) {
			if (i == 0) v[i] = 2;
			else if (i == 1) v[i] = 3;
			else v[i] = (v[i-1] + v[i-2]) % N;
		}

		vector< vector<int> > edge(V);
		for (int i = 0; i < V; ++i) for (int j = i+1; j < V; ++j) {
			if ( abs(v[i] - v[j]) < d ) {
				edge[i].push_back(j);
				edge[j].push_back(i);
			}
		}

		int ans = 0;
		vector<bool> f(V, false);
		for (int s = 0; s < V; ++s) {
			if (!f[s]) {
				++ans;

				queue<int> Q; Q.push(s);
				while ( !Q.empty() ) {
					int now = Q.front(); Q.pop();
					if (f[now]) continue;
					f[now] = true;

					for (int i = 0; i < edge[now].size(); ++i) {
						Q.push( edge[now][i] );
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3472
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define REP(i, n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;


class BYYMMOrMMYY {
public:
    void solve(std::istream& in, std::ostream& out) {
        string str;
        in >> str;
        int l = (str[0] - '0') * 10 + (str[1] - '0');
        int r = (str[2] - '0') * 10 + (str[3] - '0');
        if (f(l) && f(r)) out << "AMBIGUOUS" << endl;
        if (f(l) && !f(r)) out << "MMYY" << endl;
        if (!f(l) && f(r)) out << "YYMM" << endl;
        if (!f(l) && !f(r)) out << "NA" << endl;
    }

    bool f(int x) {
        if (1 <= x && x <= 12) return true;
        return false;
    }
};


int main() {
    BYYMMOrMMYY solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
N,L =list(map(int, input().split()))
n = list(range(1,N+1))
tasteA = list(map(lambda x: x + L -1, n))
tasteB = list(map(lambda x: abs(x), tasteA))
tasteC = sum(tasteA) - min(tasteB)
tasteD = sum(tasteA) + min(tasteB)
if abs(tasteC) < abs(tasteD):
    print(tasteC)
else:
    print(tasteD)


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.nextLine();
		//int count = sc.nextInt();
		//int nums[] = new int[count];
		/*int size = nums.length / 2;
		for(int i = 0; i < nums.length; i++) {
		}*/
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int num3 = 0;
		if(num2 < 10) num3 = num1*10 + num2;
		else if(num2 < 100) num3 = num1*100 + num2;
		else num3 = num1*1000 + num2;
		boolean flag = false;
		for(int i = 0; i < 316; i++) {
			if(num3 == i*i) { System.out.println("Yes"); flag = true;}
		}
		if(!flag) System.out.println("No");
	}
}

Measured memory_bytes: 20820
#include<iostream>
#include<string>
#include<stack>
using namespace std;
pair<int, int> dp[3005][3005];
string s1, s2;
int n, m, i, j;
stack<char>s;
void LCS(int a,int b) {
	if (a == 0 || b == 0)return;
	if (dp[a][b].second == 1)s.push(s1[a - 1]), LCS(a - 1, b - 1);
	if (dp[a][b].second == 2)LCS(a - 1, b);
	if (dp[a][b].second == 3)LCS(a, b - 1);
}
int main() {
	cin >> s1 >> s2;
	n = s1.size(), m = s2.size();
	for (i = 1;i <= n;++i)
		for (j = 1;j <= m;++j) {
			if (s1[i - 1] == s2[j - 1])dp[i][j].first = dp[i - 1][j - 1].first + 1, dp[i][j].second = 1;
			else if (dp[i - 1][j].first > dp[i][j - 1].first)dp[i][j].first = dp[i - 1][j].first, dp[i][j].second = 2;
			else dp[i][j].first = dp[i][j - 1].first, dp[i][j].second = 3;
		}
	LCS(n, m);
	while (s.size()) cout << s.top(), s.pop();
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
int main(){
	int s,c,d=0;
	cin >> s;
	c=s;
	for(int i=0;c>0;i++){
		d+=(c%10);
		c=c/10;
	}
	(s%d)?cout << "No":cout << "Yes";
}

Measured memory_bytes: 256
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int a , b , k;
		cin >>a>>b>>k;
		int aa = min(a,k);
		a-=aa;
		k-=aa;
		b-=min(b,k);
		cout<<max(0ll,a)<<" "<<max(0ll,b);
	
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

constexpr long long mod = 1000000007;

typedef pair<long long, long long> result; // true, false
#define T first
#define F second

struct parse_t {
	char c;
	result value;
	parse_t(char c_ = '#', const result &value_ = result()):c(c_), value(value_) {}
};

template<class T>
T take_back(vector<T> &vec) {
	const T res = vec.back();
	vec.pop_back();
	return res;
}

void push_value(vector<parse_t> &sta, const result &value) {
	if(!sta.empty() && sta.back().c == '~') {
		sta.pop_back();
		push_value(sta, result(value.F, value.T));
	}
	else {
		sta.emplace_back('v', value);
	}
}

result calculate_binary_operator(char ope, const result &a, const result &b) {
	switch(ope) {
	case '|': return result((a.T * (b.T + b.F) + a.F * b.T) % mod, a.F * b.F % mod);
	case '&': return result(a.T * b.T % mod, (a.F * (b.T + b.F) + a.T * b.F) % mod);
	default : assert(false);
	}
}

void evaluate_binary_operator(vector<parse_t> &sta) {
	const result b = take_back(sta).value;
	const char ope = take_back(sta).c;
	const result a = take_back(sta).value;
	push_value(sta, calculate_binary_operator(ope, a, b));
}

result parse(const string &expression) {
	vector<parse_t> sta;
	sta.reserve(10000);

	int priority[256] = {};
	priority['|'] = 2;
	priority['&'] = 3;
	priority['('] = 100;
	priority[')'] = 1;

	for(auto it = expression.cbegin(); it != expression.cend();) {
		if(*it == 'x') {
			++it; // x
			while(isdigit(*it)) ++it;
			push_value(sta, result(1, 1));
		}
		else if(*it == '~') {
			sta.emplace_back('~');
			++it;
		}
		else {
			while(sta.size() >= 3 && sta[sta.size() - 2].c != '('
				  && priority[sta[sta.size() - 2].c] >= priority[*it]) {
				evaluate_binary_operator(sta);
			}

			if(*it == ')') {
				const auto tmp = take_back(sta);
				sta.pop_back(); // (
				push_value(sta, tmp.value);
			}
			else {
				sta.emplace_back(*it);
			}

			++it;
		}
	}

	while(sta.size() >= 3) evaluate_binary_operator(sta);
	return sta.back().value;
}

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

	string expression;
	cin >> expression;
	cout << parse(expression).T << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 17964
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int imo[300000],ans,p;
vector<P>v[31],V[31];
int main(){
  int n;
  cin>>n>>p;
  while(n--){
    int s,t,c;
    cin>>s>>t>>c;c--;
    v[c].push_back(P(s,t));
  }
  r(i,30)v[i].push_back(P(100000000,1000000000));
  r(i,30)sort(v[i].begin(),v[i].end());
  r(i,30){
    int s=v[i][0].first;
    r(j,v[i].size()-1){
      if(v[i][j].second==v[i][j+1].first)continue;
      else{
        V[i].push_back(P(s,v[i][j].second));
        s=v[i][j+1].first;
      }
    }
    r(j,V[i].size()){
      imo[V[i][j].first*2-1]++;
      imo[V[i][j].second*2]--;
    }
  }
  int sum=0;
  for(int i=0;i<250000;i++){
    sum+=imo[i];
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		int[] ans = new int[n-1];

		for (int i=1; i<=n-1; i++){
			for (int j=i+1; j<=n; j++){
				int normal = j-i;
				int warp;
				warp = Math.abs(i-x) + 1 + Math.abs(j-y);
				int min = Math.min(normal, warp);
				ans[min -1]++;
			}
		}

		for (int i=0; i<ans.length; i++){
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

const int INF = 100'100'100;

class digraph
{
private:
    class edge;
    class vertex;
public:
    vec<vec<edge>> adjL;
    vec<vertex> verS;
public:
    void push_edge(int u,int v,int w);
    void push_edge(int u,int v);
    //void pop_edge(int &u, int &v);
public:
    void bfs(int index_of_start_vertex);
    //void dfs();
public:
    digraph(size_t V)
    {
        adjL.resize(V);
        verS.resize(V);
    }
    ~digraph()
    {}
};

class digraph::edge
{
public:
    int from;
    int to;
    int weight;
public:
    edge(int from,int to, int weight):from(from),to(to),weight(weight)
    {}
    ~edge()
    {}
};

class digraph::vertex
{
public:
    //0->white;1->black
    bool color;
    int distance;
    int predecessor;
public:
    vertex()
    {}
    ~vertex()
    {}
};

void digraph::push_edge(int u, int v, int w)
{
    edge new_edge = {u,v,w};
    adjL.at(u).push_back(new_edge);
};
void digraph::push_edge(int u, int v)
{
    push_edge(u,v,1);
};

void digraph::bfs(int index_of_start_vertex)
{
    for (auto &&vertex : verS)
    {
        vertex.color = false; // "white"
        vertex.distance = INF;
        vertex.predecessor = -1;
    }

    auto &s = index_of_start_vertex;
    //s->color = "gray";
    verS.at(s).distance = 0;
    verS.at(s).predecessor = -1;
    queue<int> Q;
    Q.push(s);
    while (!Q.empty())
    {
        int u = Q.front();
        Q.pop();

        for (auto &&Edge : adjL.at(u))
        {
            int v = Edge.to;
            if (verS.at(v).color == 0)
            {
                verS.at(v).color = 1;
                verS.at(v).distance = verS.at(u).distance + 1;
                verS.at(v).predecessor = u;
                Q.push(v);
            }
        }
        verS.at(u).color = 1;
    }
}

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

    digraph G(n);
    for (int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G.push_edge(a,b);
        G.push_edge(b,a);
    }
    
    G.bfs(0);
    bool flag = 1;
    for (auto &&v : G.verS)
    {
        if(v.color == 0)
        flag = 0;
    }
    
    if (flag)
    {
        cout << "Yes" << endl;
        for (size_t i = 1; i < n; i++)
        {
            cout << G.verS.at(i).predecessor + 1 << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 14752
#include<bits/stdc++.h>
#include<cstdio>
 
#define gc getchar
#define db double
#define ll long long int
#define ull unsigned long long int
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define pass cout<<"pass\n"
#define vi vector<int>
#define pb push_back
#define vec vector
#define vi vector<int>
#define el "\n"
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define f(i,x,y) for(int i=x;i<y;++i)
#define ff(i,x,y) for(int i=x;i<=y;++i)
#define MOD 1000000007
#define MAX2 1000001
#define MAX 103
#define pbb pair<bool,bool>

using namespace std;

int n;

int main() {
	sc(n); 
	ll ans =0LL;
	vec<int> ar(n);
	f(i,0,n) {
		sc(ar[i]);
		ans += ar[i];
	}
	cout << ans-n << el;
	ar.clear();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll a,b;
  cin>>a>>b;
ll ans;
  ans=(a*b+1)/2;
if(a==1)ans=1;
  if(b==1)ans=1;
cout<<ans<<endl;
  
  
}


Measured memory_bytes: 256
#!/user/bin/env pypy3
import sys
from functools import reduce


def fast_input():
    return sys.stdin.readline()[:-1]


def digit_sum(num: int) -> int:
    str_num = str(num)
    return reduce(
        lambda acc, n: acc + int(n),
        list(str_num),
        0
    )


def solve(n: int, a: int, b: int) -> int:
    num_sum = 0
    for num in range(1, n + 1):
        if a <= digit_sum(num) <= b:
            num_sum += num
    return num_sum


def main():
    [n, a, b] = list(map(int, fast_input().split()))
    result = solve(n, a, b)
    print(result)


main()


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 998244353;
const int N = 1e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

vector<ll> G[N];

ll n, mex[N], ps[N], cnt[4][N];
set<ll> st;
ll Solve(int idx){
	ll m;
	cin >> m;
	for(int i = 1; i <= n; i++) G[i].clear();
	//memset(mk, 0, sizeof mk);
	ll u, v;
	for(int i = 0; i < m; i++){
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	ll ans = 0;
	for(int i = n; i >= 1; i--){
		mex[i] = 0;
		st.clear();
		for(auto adj : G[i]) if(adj > i) st.insert(mex[adj]);
		for(auto x : st) if(x == mex[i]) mex[i] ++;
		(cnt[idx][mex[i]] += ps[i]) %= Mod;
	}
	return ans % Mod;
}
ll mul(ll a, ll b){
	return (a * b) % Mod;
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll X = 716070898;
	ps[0] = 1;
	for(int i = 1; i < N; i++) ps[i] = (ps[i - 1] * X) % Mod;
	cin >> n;
	ll res = 0;
	for(int i = 0; i < 3; i++) Solve(i);
	for(int i = 0; i < 1000; i++){
		for(int j = 0; j < 1000; j++) res += mul(cnt[0][i], mul(cnt[1][j], cnt[2][i ^ j]));

	}
cout << res % Mod << '\n';
	return 0;
}


Measured memory_bytes: 10752
#include<string.h>
int main()
{
    char s1[10],s2[10],s3[10];
    int i;
    scanf("%s %s %s",&s1,&s2,&s3);

    for(i=0;i<10;i++){
    if('a'<=s1[i] && s1[i]<='z' && 'a'<=s2[i] && s2[i]<='z' && 'a'<=s3[i] && s3[i]<='z'){
       continue;

    }
    }
    s1[0]=s1[0]-32;
    s2[0]=s2[0]-32;
    s3[0]=s3[0]-32;
    printf("%c%c%c",s1[0],s2[0],s3[0]);
    return 0;
}

Measured memory_bytes: 1708
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  while(b>=2){
    if (a%b==0) return false;
    b--;
  }
  return true;
}

int main(void){
  ll N, M, A, B, C, D, K, W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> A >> B >> C;
  cin >> K;
  ll max_abc = max(A, B);
  max_abc = max(max_abc, C);
  cout << max_abc*pow((ll)2, K)-max_abc+A+B+C << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n; cin >> n;
  int x; cin >> x;
  int distance = 0;
  int jumps = 1;
  for(int i=0; i<n; i++) {
    int increment; cin >> increment;
    distance += increment;
    if(x>=distance) {
      jumps++;
    }
  }
  cout << jumps << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<vector<int>> a(10);
  string s;
  cin >> s;
  rep(i, n) {
    int idx = s[i] - '0';
    a[idx].push_back(i);
  }

  ll ans = 0;

  for (int i = 0; i <= 999; i++) {
    int x = i / 100;
    int y = (i % 100) / 10;
    int z = i % 10;
    if (a[x].empty() || a[y].empty() || a[z].empty()) continue;
    int x_idx = a[x][0];
    int y_idx = -1;
    int z_idx = -1;
    for (auto& m : a[y]) {
      if (m > x_idx) {
        y_idx = m;
        break;
      }
    }
    if (y_idx == -1) continue;
    for (auto& m : a[z]) {
      if (m > y_idx) {
        z_idx = m;
        break;
      }
    }
    if (z_idx != -1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	vector<int> d(N);
	for (int i = 0; i < N; ++i)
		d[i] = i - A[i];
	ll res = 0;
	map<int, int> cnt;
	for (int i = N - 1; i >= 0; --i) {
		int S = i + A[i];
		res += cnt[S];
		++cnt[d[i]];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 21912
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n;

    cin >> n;

    int res = n;

    for (int i = 0; i <= n; i++)
    {
        int r = 0;
        int t = i;
        while (t > 0)
            r += t % 6, t /= 6;
        t = n - i;
        while (t > 0)
            r += t % 9, t /= 9;

        res = min(res, r);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){cout<< "Yes" <<endl;}
  else if(s.at(1)==s.at(2)&&s.at(2)==s.at(3)){cout<< "Yes" <<endl;}
  else{cout << "No" << endl;}
 
  return 0;
}

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

typedef long long int llint;

struct UF {
  vector<int> par, rank;
  UF(){}
  UF(int size) : par(size, -1), rank(size, -1) {
    for(int i = 0; i < size; i++) par[i] = i, rank[i] = 1;
  }

  int root(int x) {
    return par[x] == x ? par[x] : par[x] = root(par[x]);
  }
  
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);

    if(rank[x] > rank[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
};

int main()
{
  UF uf(100002);
  int p[100010];
  int n, m;
  cin>> n >> m;

  for(int i = 1; i <= n; i++) cin>> p[i];

  int x, y;
  for(int i = 0; i < m; i++) {
    cin>> x >> y;
    uf.unite(x, y);
  }

  int cnt = 0;

  for(int i = 1; i <= n; i++) {
    
    if(i == p[i]) {
      cnt++;
    } else if(uf.same(p[i], i)) {
      cnt++;
    }
 
  }

  cout<< cnt <<endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N,vector<int>(0));
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int INF = 1e9;
  vector<int> ans(N,-1);
  vector<int> dist(N,INF);
  queue<int> Q;
  Q.push(0);
  dist[0] = 0;
  while(Q.size()){
    int x = Q.front();
    Q.pop();
    for(int i=0; i<G[x].size(); i++){
      int y = G[x][i];
      if(dist[y] <= dist[x] + 1){
        continue;
      }
      else{
        dist[y] = dist[x]+1;
        ans[y] = x+1;
        Q.push(y);
      }
    }
  }
  
  bool flag = true;
  for(int i=1; i<N; i++){
    if(ans[i] == -1){
      flag = false;
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
    for(int i=1; i<N; i++){
      cout << ans[i] << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}
  




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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

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

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


  int main(){
    string S;
    cin >> S;
    string S2;
    REP(i, S.size()){
      S2 += S.at((S.size() - 1) - i);
    }
    int cnt = 0;
    REP(i, S.size()){
      if(S.at(i) != S2.at(i)) cnt++;
    }
    print(cnt / 2);
  }

Measured memory_bytes: 256
#include <stdio.h>
#define INF 1000000000
#define N 100
#define WHITE -1
#define GRAY 0
#define BLACK 1

int min_cost[N],Stamp[N],A[N][N],n;

void initialize(void){
  int i;
  for(i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      A[i][j] = INF;
    }
    Stamp[i] = WHITE;
    min_cost[i] = INF;
  }
}


void dijkstra(){
  int mincost,u;

  min_cost[0] = 0;
  Stamp[0] = GRAY;

  while(1){
    mincost = INF;
    for(int i = 0; i < n; i++){
      if(Stamp[i] != BLACK && min_cost[i] < mincost){
	mincost = min_cost[i];
	u = i;
      }
    }

    if(mincost == INF) break;

    Stamp[u] = BLACK;

    for(int v = 0; v < n; v++){
      if(Stamp[v] != BLACK && A[u][v] != INF){
	if((min_cost[u] + A[u][v]) < min_cost[v]){
	  min_cost[v] = min_cost[u] + A[u][v];
	  Stamp[v] = GRAY;
	}
      }
    }
  }

  for(int i = 0; i < n; i++){
    printf("%d %d\n",i,min_cost[i]);
  }
}

int main(){
  int i,j,u,k,c,v;

  initialize();

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d%d",&v,&c);
      A[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s,t;
    
    cin>>s;
    cin>>t;
    
    int flag=0;
    
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]){
            flag=1;
        }
    }
    if(s.size()+1!=t.size()){
        flag=1;
    }
    
    if(flag==0){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3604
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import string

def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))

a,b,c = get_tuple()
k = get_int()
ans = 0
while b<=a:
    ans += 1
    b *= 2

while c<=b:
    ans += 1
    c *= 2
if ans<=k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9984
/********** Raaghav Raaj (cf: raaghavraaj, cc: mothercoder27) *************/
#include<bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#pragma optimize("-O3")

// #ifndef ONLINE_JUDGE
// #include "../Codechef/trace.h"
// #else
// #define trace(args...)
// #endif

#define int long long
#define double long double
#define vi vector<int>
#define vc vector<char>
#define pi pair<int, int>
#define pii pair<pi,int>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sp " "
#define endl '\n'
#define all(v) v.begin(), v.end()
#define debug(data) for(auto it: data) cout<<it<<sp;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int sz = 1e10;

int gcd(int n, int m) {
	return __gcd(n, m);
}

int power(int a, int b) {
	a %= sz;
	int res = 1;
	while (b) {
		if (b & 1) res = (res * a) % sz;
		a = (a * a) % sz;
		b >>= 1;
	}
	return res;
}

int modInverse(int a) { //sz must be prime
	return power(a, sz - 2);
}

void solve() {
	int n; cin >> n;
	int x = n / 200;
	cout << 10 - x << endl;
}

int32_t main() {
	fast;
	int T = 1;
	// cin >> T;
	rep(i, 1, T + 1) {
		// cout << "Case #" << i << ": " << endl;
		solve();
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	int N, K;
	cin >> N >> K;
	cout << (N % K != 0) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
import copy
H,W,K=input().split()
H=int(H)
W=int(W)
K=int(K)
C= [list(input()) for i in range(H)]
counter=0
for j in range(1<<H+W):
    D=copy.deepcopy(C)
    for k in range(H+W):
        mask=1<<k
        if j&mask!=0:
            if k<W:
                for l in range(H):
                    D[l][k]='R'
            else:
                for m in range(W):
                    D[k-W][m]='R'
    black=sum(D,[]).count('#')
    if black==K:
        counter+=1
print(counter)

Measured memory_bytes: 9292
#include <stdio.h>
#include <math.h>
 
int dp[3005][3005];
 
int main(){
 
	int A,B,C,D,E,F;
 
	scanf("%d %d %d %d %d %d",&A,&B,&C,&D,&E,&F);
 
	int i,j;
 
	dp[0][0]=1;
 
	for(i=0;i<=3000;i++){
		for(j=0;j<=3000;j++){
			if(dp[i][j]==1){
				if(i+(100*A)+j<=F){
					dp[i+(100*A)][j]=1;
				}
				if(i+(100*B)+j<=F){
					dp[i+(100*B)][j]=1;
				}
				if(i+C+j<=F){
					dp[i][j+C]=1;
				}
				if(i+D+j<=F){
					dp[i][j+D]=1;
				}
			}
 
		}
	}
 
	double ratio=0;
 
	int water=0;
	int sugar=0;
 
	for(i=0;i<=3000;i++){
		for(j=0;j<=3000;j++){
			if(j<=(int)floor((double)i*E/100.0) && dp[i][j]==1 && i+j!=0){
				if(ratio<=100.0*(double)j/(double)(i+j)){
					ratio=100.0*(double)j/(double)(i+j);
					water=i;
					sugar=j;
				}
			}
		}
	}
 
	printf("%d %d\n",water+sugar,sugar);
 
	return 0;
}

Measured memory_bytes: 28800
/*
// 部分点解法
#include<iostream>
#define INF (1LL << 62)
#define MAX_N 2 * 100001
using namespace std;
typedef unsigned long long ll;

ll x[MAX_N];

ll calc_cost(ll i, ll a) {
    if (i == 1) return 5 * a;
    else return (2 * i + 1) * a;
}

int main() {
    ll N, X;
    cin >> N >> X;
    for (int i = 1; i <= N; i++) cin >> x[i];
    ll min_cost = INF;
    for (int k = 1; k <= N; k++) {
        ll now_cost = (N + k) * X;
        for (int i = 1; i <= N; i++) {
            now_cost += calc_cost((i + k - 1) / k, x[N - i + 1]);
        }
        min_cost = min(min_cost, now_cost);
    }
    cout << min_cost << endl;
    return 0;
}
*/

// 満点解法
#include<iostream>
#define MAX_N 2 * 2 * 100001
#define INF (1LL << 62)
using namespace std;
typedef long long ll;

ll x[MAX_N];

ll calc_cost(ll i, ll a) {
    if (i == 1) return 5 * a;
    else return (2 * i + 1) * a;
}

int main() {
    ll N, X;
    cin >> N >> X;
    x[N + 1] = 0;
    for (int i = N; i >= 1; i--) {
        cin >> x[i];
        x[i] += x[i + 1];
    }
    for (int i = N + 1; i <= 2 * N; i++) x[i] = 0;
    ll min_cost = INF;
    for (int k = 1; k <= N; k++) {
        ll now_cost = (N + k) * X;
        for (int i = 1; i <= (N + k - 1) / k; i++) {
            now_cost += calc_cost(i, x[k * (i - 1) + 1] - x[k * i + 1]);
            if (now_cost < 0) {
                now_cost = min_cost;
                break;
            }
        }
        min_cost = min(min_cost, now_cost);
    }
    cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    cin >> s;
    int n = s.length();
    int g = 0, p = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'g') ++g;
        else    ++p;
    }
    int ans = (g - p) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> t(n+1,0),x(n+1,0),y(n+1,0);
  for(int i=1;i<=n;i++){
    cin>>t[i]>>x[i]>>y[i];
  }
  for(int i=1;i<=n;i++){
    int sum=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    if(t[i]-t[i-1]<sum){
      cout<<"No"<<endl;
      return 0;
    }
    if(sum%2!=(t[i]-t[i-1])%2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 4580
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N;

void solve() {
	cin >> N;
	ll v = N / 11;
	ll m = N % 11;
	ll ans = 2 * v;
	if(0 < m && m <= 6) ans += 1;
	if(m >= 7) ans += 2;
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define EPS 1e-10
#define equals(a, b) (fabs(a - b) < EPS)

class Vector {
public:
  double x, y;
  Vector() {}
  Vector(double x, double y) : x(x), y(y) {}

  Vector operator+(Vector v) { return Vector(x + v.x, y + v.y); }
  Vector operator-(Vector v) { return Vector(x - v.x, y - v.y); }
  double norm() { return x * x + y * y; }
};

// inner product
double dot(Vector v1, Vector v2) { return v1.x * v2.x + v1.y * v2.y; }

// inner product
double cross(Vector v1, Vector v2) { return v1.x * v2.y - v1.y * v2.x; }

class Line {
public:
  Vector v1, v2;
  Line() {}
  Line(Vector v1, Vector v2) : v1(v1), v2(v2) {}
};

bool is_parrallel(Vector a, Vector b) { return equals(cross(a, b), 0); }
bool is_parrallel(Line a, Line b) {
  return is_parrallel(a.v1 - a.v2, b.v1 - b.v2);
}

bool is_orthogonal(Vector a, Vector b) { return equals(dot(a, b), 0); }
bool is_orthogonal(Line a, Line b) {
  return is_orthogonal(a.v1 - a.v2, b.v1 - b.v2);
}

int main() {
  Line line[2];
  int nq;
  cin >> nq;
  for (int i = 0; i < nq; i++) {
    for (int j = 0; j < 2; j++) {
      int x0, y0, x1, y1;
      cin >> x0 >> y0 >> x1 >> y1;
      line[j] = Line(Vector(x0, y0), Vector(x1, y1));
    }
    if (is_parrallel(line[0], line[1]))
      cout << 2 << endl;
    else if (is_orthogonal(line[0], line[1]))
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
}

Measured memory_bytes: 3100
use proconio::input;

fn main() {
        input! {
                n: i64
        }

        println!(
                "{}",
                match n % 10 {
                        2 | 4 | 5 | 7 | 9 => "hon",
                        0 | 1 | 6 | 8 => "pon",
                        3 => "bon",
                        _ => panic!(""),
                }
        );
}

Measured memory_bytes: 2104
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
X = I()
kouho = []
ans = 1
kouho.append(1)
for i in range(2,1000):
    j = 1
    while i**j<=1000:
        j += 1
        if i**j<=1000:
            kouho.append(i**j)
kouho.sort()
for x in kouho:
    if x<=X:
        ans = x
    else:
        break
print(ans)


Measured memory_bytes: 12204
n, q = map(int, input().split())
S = 'X' + input()
T = [0]*(n+1)
for i in range(n):
    s = S[i:i+2]
    if s == 'AC':
        T[i+1] = T[i] + 1
    else:
        T[i+1] = T[i]
for _ in range(q):
    l,r = map(int, input().split())
    print(T[r]-T[l])

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

int a, b, c;
int j = 0;

int divide(int a, int b, int c){
    for(int i = a;i < b + 1; i++){
        if(c % i == 0)j++;
    }
    return j;
}

int main(int argc, const char * argv[]) {
    cin >> a >> b >> c;
    divide(a, b, c);
    cout << j << endl;
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a)      cout<<a<<" "
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc2(n,m);
	fu(i,1,n)A[i]=i-1+m,sum+=A[i];
	c=oo;
	fu(i,1,n){
		if(abs((sum-A[i])-sum)<c){
			c=abs((sum-A[i])-sum);
			ans=sum-A[i];
		}
	}
	pr(ans);
	

	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

class Node:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left  
        self.right = right

D = {}  

def get_all_depth(T: dict, u: int, p: int):
    D[u] = p
    if T[u].right is not None:
        get_all_depth(T, T[u].right, p)
    if T[u].left is not None:
        get_all_depth(T, T[u].left, p+1)

def ret_children(T, u):
    chilren = []
    c = T[u].left
    while c is not None:
        chilren.append(c)
        c = T[c].right
    return chilren

def print_for_a_node(T, node, D):
    if T[node].left is not None: 
        node_type = 'internal node'
    else:
        node_type = 'leaf'
        
    if T[node].parent is None:
        parent = -1
        node_type = 'root'
    else:
        parent = T[node].parent
        
    children = ret_children(T, node)
    print(f'node {node}: parent = {parent}, depth = {D[node]}, {node_type}, {children}')


n = int(input())

T = {k: Node(None, None, None) for k in range(n)}  

for _ in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] != 0:  
        T[tmp[0]].left = tmp[2]  
        T[tmp[2]].parent = tmp[0]  
        prev_sibling = tmp[2]  
        
        for sib in tmp[3:]:
            T[prev_sibling].right = sib
            T[sib].parent = tmp[0] 
            prev_sibling = sib

for node in range(n):
    if T[node].parent is None:
        get_all_depth(T, node, 0)  
        break

for node in range(n):
    print_for_a_node(T, node, D)


Measured memory_bytes: 142144
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int N=int.Parse(Console.ReadLine());
    int[] a=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int sum=0;
    int Alicesum=0;
    Array.Sort(a);
    Array.Reverse(a);
    for(int i=0;i<N;i++)
    {
      sum+=a[i];
      if(i%2==0)Alicesum+=a[i];
      
    }
    Console.WriteLine(Alicesum*2-sum);
  }
}


Measured memory_bytes: 13396
#include <stdio.h>
int main(){
//N回の操作　2倍するかK足すか　min
//2倍したものとK足したものの代償比べて小さいほうを選択、上書きさせる
int n,k;
n <= 10, k >= 1;
scanf("%d", &n);
scanf("%d", &k);
int i,j;
j = 1;
for(i = 0; i < n; i++){
	if(j*2 > j + k){
		j = j + k;
	}
	else{
	j = j*2;
	}
}
printf("%d",j);
return 0;	
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include<set>
#include<iostream>
int main(){
    int n,k;
    cin>>n>>k;
    int d[110];
    int A[110];
    set<int> a;
    int count=1;
    for(int i=0;i<k;i++){
        cin>>d[i];
        for(int j=0;j<d[i];j++){
          cin>>A[j];
         for(int k=1;k<=n;k++){
            if(A[j]==k)a.insert(k);
         }
        }
    }
    int ans=n-a.size();
    cout<<ans<<endl;
    return 0;
    

}

Measured memory_bytes: 3632
n = int(input())
slimes = list(map(int, input().split()))

slimes_cp = slimes[:]
num_list = [i+1 for i in range(len(slimes))]
count = 0

for i in range(1, len(slimes_cp)):
    num_list = [i+1 for i in range(len(slimes))]
    
    if slimes_cp[i-1] == slimes_cp[i]:
        num_list.remove(slimes_cp[i-1])
        
        try:
            num_list.remove(slimes_cp[i+1])
            
            slimes_cp[i] = num_list[0]
        except:
            slimes_cp[i] = num_list[0]
            
        count+=1
        
print(count)

Measured memory_bytes: 3064