akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;

    int a, b;
    in >> a, b;
    for (int i = 0; i < 100000; ++i) {
        if (static_cast<int>(i * 0.08) == a && static_cast<int>(i * 0.1) == b) {
            out(i);
            return;
        }
    }
    out(-1);
}

int main()
{
    prog();
    return 0;
}


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

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

    int p[M];
    string S[M];
    for (int i=0; i<M; i++){
        p[i] = 0;
        S[i] = "";
    }

    for (int i=0; i<M; i++){
        int tmp;
        cin >> tmp >> S[i];
        p[i] = tmp-1;
    }

    int problem[N], count_WA[N];
    for (int i=0; i<N; i++){
        problem[i] = 0;
        count_WA[i] = 0;
    }

    for (int s=0; s<M; s++){
        if (S[s]=="AC" and problem[p[s]]==0){
            problem[p[s]]=1;
        } else if (S[s] == "WA" and problem[p[s]]==0){
            count_WA[p[s]]+= 1;
        }
    }

    int count_AC = 0;
    for (int i=0; i<N; i++){
        count_AC += problem[i];
    }

    int count_penalty = 0;
    for (int i=0; i<N; i++){
        if (problem[i]==1){
            count_penalty += count_WA[i];
        }
    }
    cout << count_AC << ' ' << count_penalty << endl;
}


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

int main(){
  int N; cin>>N;
  set<int> a;
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin>>b.at(i);
    a.insert(b.at(i));
  }
   cout<<a.size()<<endl;
}

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


int main(){

int t,n;
	
	
	
	for(int i=0;i<4;i++){
		cin>>t>>n;
		if(t==1){
		cout<<n*6000<<endl;
		}
		if(t==2){
		cout<<n*4000<<endl;
		}
		if(t==3){
		cout<<n*3000<<endl;
		}
		if(t==4){
		cout<<n*2000<<endl;
		}
	}


}


Measured memory_bytes: 3096
#include <iostream>
#include <cctype>
#include <iterator>
#include <algorithm>

int main(int argc, char const* argv[])
{
	std::string s;
	std::getline(std::cin, s);
	std::transform(s.begin(), s.end(), s.begin(), toupper);
	std::cout << s << std::endl;

	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	ll N;
	string S;
	cin >> N >> S;
	ll cnt = 0; // times of fusion
	rep(i, N-1) {
		if(S[i]==S[i+1]) cnt++;
	}
	
	cout << N-cnt << endl;
	
	return 0;
}

Measured memory_bytes: 512
N = int(input())
S = []
for i in range(N):
    S.append(''.join(sorted(list(input()))))
S.sort()
#print('S', S)

count=0
n=1
for i in range(1,N):
    if S[i-1] == S[i]:
        n+=1
    else:
        count+= n*(n-1)*0.5
        n=1
count+=n*(n-1)*0.5
print(int(count))


Measured memory_bytes: 57176
#include<iostream>
#include<string>
#include<vector>

using namespace std;

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

    for (int i=1; i<50001; ++i)
    {
        if(N == (int)(i*1.08))
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}

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

using namespace std;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}
 
template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

int main()
{
    const size_t n = read<size_t>();
    auto a = reads<size_t>(n);
    auto b = reads<size_t>(n);
    auto c = reads<size_t>(n);

    sort(begin(a), end(a));
    sort(begin(c), end(c));

    size_t count = 0;

    for(size_t mid : b)
    {
        auto top = lower_bound(begin(a), end(a), mid);
        auto bottom = upper_bound(begin(c), end(c), mid);
        count += distance(begin(a), top) * distance(bottom, end(c));
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#define lli long long int
#define mod 998244353
using namespace std;
int main(){
	
string s;
getline(cin,s);


int l1=s.size();

string t;

getline(cin,t);
int l2=t.size();
if(l2==l1+1){
t.resize(l1);
	if(t==s)
	cout<<"Yes";
	else 
	cout<<"No";
	
}

}


Measured memory_bytes: 3604
#include<stdio.h>

void plus(int start,int end,int sum,int np,int sp);
int count;

int main(){

	int i,n,s;

	while(scanf("%d %d",&n,&s)!=EOF){
		if(!n && !s) break;
		count=0;
		for(i=0;i<11-n;i++){
			if(n==1){
				if(i==s){
					count++;
					break;
				}
			}
			else plus(i+1,2,i,n,s);
		}

		printf("%d\n",count);
	}





	return 0;

}

void plus(int start,int end,int sum,int np,int sp){
	int i;

	for(i=start;i<10-np+end;i++){
		if(np==end){
			 if(sum+i==sp){
				count++;
				return;
			 }
		}
		else plus(i+1,end+1,sum+i,np,sp);

	}

}

Measured memory_bytes: 596
# ABC157e


#print(bin(toBitSet([1, 2, 3, 2])))

# for i in range(97, 123):
#    print(chr(i))


def main():
    import sys
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    #####segfunc######
    def segfunc(x, y):
        return x | y  # 例としてmin関数を設定

    def init(init_val):  # セグ木にしたい配列を渡す
        # set_val
        for i in range(len(init_val)):
            seg[i+num-1] = init_val[i]
        # built
        for i in range(num-2, -1, -1):
            seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

    def update(k, x):
        k += num-1
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1], seg[k*2+2])

    def query(p, q):
        if q <= p:
            return ide_ele
        p += num-1
        q += num-2
        res = ide_ele
        while q-p > 1:
            if p & 1 == 0:
                res = segfunc(res, seg[p])
            if q & 1 == 1:
                res = segfunc(res, seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = segfunc(res, seg[p])
        else:
            res = segfunc(segfunc(res, seg[p]), seg[q])
        return res

    #####単位元######
    ide_ele = 0

    n = int(input())
    s = list(input())
    q = int(input())
    # num:n以上の最小の2のべき乗
    num = 2**(n-1).bit_length()  # nは元々の配列の長さ
    seg = [ide_ele] * (2 * num+1)

    def toBitSet(numberSet):
        theSet = 0
        for i in numberSet:
            theSet = theSet | 1 << i
        return theSet

    def alphabetToZeroIndexed(alphabet):
        return ord(alphabet)-97

    for i in range(n):
        update(i+1, toBitSet([alphabetToZeroIndexed(s[i])]))

    for _ in range(q):
        a, b, c = input().split()
        b = int(b)
        if int(a) == 1:
            update(b, toBitSet([alphabetToZeroIndexed(c)]))
        else:
            c = int(c)
            print(bin(query(b, c+1)).count('1'))


if __name__ == '__main__':
    main()


Measured memory_bytes: 104232
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int c;
int cost[31][31] = {};
int gr[510][510];
int c_st[3][31] = {};
ll cost3[3][31] = {};

int main() {
	cin >> n >> c;
	ll ans = INF;
	form(i, c) {
		form(j, c) {
			cin >> cost[i][j];
		}
	}
#if 0
	form(i, c) {
		form(j, c) {
			form(k, c) {
				cost[j][ k] = min(cost[j][k], cost[j][i] + cost[i][k]);
			}
		}
	}
#endif
	forn(i) {
		forn(j) {
			cin >> gr[i][j];
			c_st[(i + j) % 3][gr[i][j]-1]++;
		}
	}
	for (int l = 0; l < 3; l++) {
		form(i, c) {
			form(j, c) {
				cost3[l][j] += cost[i][j] * c_st[l][i];
			}
		}
	}
	form(i, c) {
		form(j, c) {
			form(k, c) {
				if (i == j || j == k || k == i)continue;
				ans=min(ans, cost3[0][i] + cost3[1][j] + cost3[2][k]) ;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxm = 1002;

int n, m, k, ans, v[maxm];
vector<int> cur;

int get_ones(int x) {
    int res = 0;
    while (x > 0) {
        res += (x&1);
        x >>= 1;
    }
    return res;
}

void calc() {

    // for (int i = 0; i < cur.size(); ++i) {
    //     cout << cur[i] << " ";
    // }
    // cout << endl;

    int cnt = 0, pre = 0, sz = cur.size();
    vector<int> w(sz), sum(sz);

    for (int i = 0; i < sz; ++i) {
        w[i] = ((1 << cur[i]) - 1) << pre;
        pre += cur[i];

        // cout << "w:" << w << endl;
    }

    for (int j = 0; j < m; ++j) {
        bool ok = true;
        for (int i = 0; i < sz; ++i) {
            int tmp = get_ones(v[j] & w[i]);
            if (tmp > k)
                return;

            if (sum[i] + tmp > k) {
                ok = false;
                break;
            }
        }
        
        if (ok) {
            for (int i = 0; i < sz; ++i)
                sum[i] += get_ones(v[j] & w[i]);
        } else {
            ++cnt;
            for (int i = 0; i < sz; ++i)
                sum[i] = get_ones(v[j] & w[i]);
        }
    }
// cout << endl;
    ans = min(ans, cnt + sz - 1);
}

void dfs(int rem, int ops) {
    if (ops == 0) {
        cur.push_back(rem);
        calc();
        cur.pop_back();
        return;
    }

    for (int i = 1; i < rem+1-ops; ++i) {
        cur.push_back(i);
        dfs(rem - i, ops-1);
        cur.pop_back();
    }
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n >> m >> k;
    
    int tot = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < m; ++j) {
            if (s[j] == '1') {
                v[j] |= (1 << i);
                ++tot;
            }
        }
    }

    if (tot <= k) {
        cout << 0 << endl;
        return 0;
    }

    ans = tot;
    for (int i = 0; i <= min(n-1, ans-1); ++i) {
        cur.clear();
        dfs(n, i);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << 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)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 累乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
 
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};









int main(){
  ll H, W;
  cin >> H >> W;
  if(H == 1 || W == 1){
      print(1);
      return 0;
  }

  ll a = (W + 1) / 2;
  ll b =  W / 2;
  ll c = (H + 1) / 2;
  ll d = H / 2;

  ll ans = a * c + b * d;
  print(ans);
  return 0; 

}


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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 212345;

LL n;

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

    cin >> n;
    if (n & 1) {
        cout << 0 << '\n';
    } else {
        n /= 2;
        LL ans = 0;
        for (LL cur = 5; cur <= n; cur *= 5) {
            ans += n / cur;
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	m := nextInt()
	p := make([]pair, n)

	for i := 0; i < n; i++ {
		p[i].a = nextInt()
		p[i].b = nextInt()
	}

	sortPairs(p)

	cost := 0
	nowM := 0
	for i := 0; i < n; i++ {
		if nowM >= m {
			break
		}

		buy := min(p[i].b, m-nowM)
		cost += p[i].a * buy
		nowM += buy
	}
	fmt.Println(cost)

}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// Pair ソート
// s := make([]pair, n)
// sortPairs(s)
type pair struct { // f=first, s=second
	a int
	b int
}

// []pair をf->sの順でソートする
func sortPairs(s []pair) {
	sort.Slice(s, func(i, j int) bool {
		if s[i].a == s[j].a { // fが同じ場合はsを比較する
			return s[i].b < s[j].b
		}
		return s[i].a < s[j].a
	})
	return
}

// ---- 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: 5300
n,m=map(int,input().split())
graph=[[False]*n for i in range(n)] #点の隣接連結を示す
node=[None for i in range(m)]#辺のデータをリストとして保管
visited=[False]*n #dfsを書くときに訪問した点を記録する
for i in range(m):
    a,b=map(int,input().split())
    graph[a-1][b-1],graph[b-1][a-1]=True,True
    node[i]=[a-1,b-1]
def dfs(v):
    visited[v]=True
    for i in range(n):
        if graph[v][i]==False:continue
        if visited[i]==True:continue
        dfs(i)#訪問済みでなく辺によってつながれている頂点に対して同じ操作を繰り返す
ans=0
for i in range(m):
    graph[node[i][0]][node[i][1]],graph[node[i][1]][node[i][0]]=False,False #m本の辺について、一本ずつ辺を無視していく。その際にグラフが非連結となったらその辺は橋となる（橋の定義通り調べていく）
    for j in range(n):visited[j]=False#初期化
    dfs(0)
    for h in range(n):
        if visited[h]==False:
            ans+=1
            break
    graph[node[i][0]][node[i][1]],graph[node[i][1]][node[i][0]]=True,True#調査が終わったら戻しておく
print(ans)


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

using namespace std;

const int maxn=100005;
typedef long long ll;

ll n,d;
ll x,y;
ll ans=0;

int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		if(x*x+y*y<=d*d) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    int h[100000];
    for(int i = 0;i < N;i++) cin >> h[i];
   int ans = 0;
   for(int i =0;i < N;i++){
       if(h[i] >= K) ans++;
   }
   cout << ans <<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int n,A[20];

int solve(int i,int m){
  int res1,res2;
  
  if(m==0) return 1;
  if(i>=n) return -1;
  res1=solve(i+1,m);
  res2=solve(i+1,m-A[i]);

  if(res1==1||res2==1)return 1;
}
int main(){
  int i,q,m;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&m);
    if(solve(0,m)==1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }    
  }
  
  return 0;
}
  



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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 組合せを素数で割った値を求める
const int MAX = 1000005;
long long inv[MAX];

// テーブルを作る前処理
void COMinit() {
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  map<ll, ll> mp;
  for (int i = 0; i < n; i++) {
    ll now = a.at(i);
    for (int j = 2; j * j <= a.at(i); j++) {
      ll count = 0;
      while (now % j == 0) {
        now /= j;
        count++;
      }
      if (count > 0) mp[j] = max(mp[j], count);
    }
    if (now > 1) mp[now] = max<ll>(mp[now], 1);
  }
  
  ll lcm = 1;
  for (auto i : mp) {
    lcm *= pow(i.first, i.second);
    lcm %= MOD;
  }
  
  COMinit();
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += lcm * inv[a.at(i)];
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,M; cin>>N>>M;
  vi A(M),B(M);
  vii C(N);
  rep(i,0,M){
    cin>>A[i]>>B[i];
    C[A[i]-1].push_back(B[i]-1);
    C[B[i]-1].push_back(A[i]-1);
  }
  int ans=0;
  rep(i,0,M){
    bitset<50> BB;
    vector<bool> F(N,1);
    queue<int> Q;
    Q.push(0);
    F[0]=0;
    while(Q.size()>0){
      int K=Q.front();
      Q.pop();
      BB.set(K);
      rep(j,0,C[K].size()){
        if(F[C[K][j]]){
          if(A[i]-1!=K||B[i]-1!=C[K][j]){
            if(B[i]-1!=K||A[i]-1!=C[K][j]){
              F[C[K][j]]=0;
              Q.push(C[K][j]);
            }
          }
        }
      }
    }
    if(BB.count()<N)
      ans++;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
fn main() {
    let st = read_vec::<String>();
    println!("{}{}", st[1], st[0]);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;
int main()
{
  string s;
  int a=0;
  for(;cin>>s;)
    {
      for(int i=0;;i++)
	{
	  if(s[i]!=s[s.size()-1-i])
	    break;
	  else if(i>=s.size()-1-i)
	    {
	      a++;
	      break;
	    }
	}
    }
     cout<<a<<endl;    
}

Measured memory_bytes: 1184
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[100010][20];
	long long march[5];
	int n,i;
	memset(march,0,sizeof(march));
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",&a[i]);
	}
	for(int i=0;i<n;i++){
        if(a[i][0]=='M')    march[0]++;
        if(a[i][0]=='A')    march[1]++;
        if(a[i][0]=='R')    march[2]++;
        if(a[i][0]=='C')    march[3]++;
        if(a[i][0]=='H')    march[4]++;
       }
       long long int ans =0;
       ans=march[0]*march[1]*march[2]+march[0]*march[1]*march[3]+march[0]*march[1]*march[4]+
	   march[0]*march[2]*march[3]+march[0]*march[2]*march[4]+march[0]*march[3]*march[4]+
	   march[1]*march[2]*march[3]+march[1]*march[2]*march[4]+march[1]*march[3]*march[4]+march[2]*march[3]*march[4];

        printf("%lld",ans);
        return 0;
}

Measured memory_bytes: 2176
// Aizu 1180: Recurring Decimals
// 2017.9.13 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char a[105][7];
char max[7], min[7];

int asc(char *a, char *b) { return *a - *b; }
int des(char *a, char *b) { return *b - *a; }

int main()
{
	int a0, w, i, j, k, c;

	while (scanf("%d%d", &a0, &w) && w) {
		for (k = 0; k < w; k++) a[0][k] = a0 % 10, a0 /= 10;
		for (i = 1; ; i++) {
			memcpy(max, a[i-1], w), memcpy(min, a[i-1], w);
			qsort(max, w, sizeof(char), asc), qsort(min, w, sizeof(char), des);
			for (c = 0, k = 0; k < w; k++) {
				if (max[k] >= min[k]+c) a[i][k] =    max[k]-(min[k]+c), c = 0;
				else                    a[i][k] = 10+max[k]-(min[k]+c), c = 1;
			}
			for (j = 0; j < i; j++) if (!memcmp(a[j], a[i], w)) {
				printf("%d ", j);
				for (k = w-1; k > 0; k--) if (a[i][k] > 0) break;
				for ( ; k >= 0; k--) putchar(a[i][k]+'0');
				printf(" %d\n", i-j);
				break;
			}
			if (j < i) break;
		}
	}
	return 0;
}

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

bool dp[110000];
int a[110];
int n, k;

int main()
{
    //fill(dp, dp + 110000, -1);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = k; i >= 1; i--)
    {
        if (!dp[i])
        {
            for (int j = 1; j <= n; ++j)
            {
                if (i >= a[j])
                    dp[i - a[j]] = 1;
                else
                    break;
                if (dp[0])
                    break;
            }
        }
    }
    if (dp[0])
        cout << "First";
    else
        cout << "Second";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i=0;i<=n;i+=4){
        if((n-i)%7==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout <<"No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e2 + 5;
const int INF = 1e9 + 7;

string s, t;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s >> t;
	if (t.substr(0, s.size()) == s)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}
//11-09-2020 09:54:04

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int n;

void CountingSort(int A[], int B[], int k) {
	int C[k + 1] = { 0 };

	for (int i = 0; i < n; i++) {
		C[A[i]]++;
	}

	for (int i = 1; i <= k; i++) {
		C[i] += C[i - 1];
	}

	for (int i = 0; i < n; i++) {
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
}

int main() {
	cin >> n;

	int A[n], B[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	CountingSort(A, B, 10000);

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

	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(max(a,b)>8) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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


const ll MOD=1e9+7;
const ll INF=1e18;

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

int  card[60];
int tmp[60];
int p,c;

int main(){
	while(1){
		int n,r;
		scanf("%d %d",&n,&r);
		if(n + r == 0) break;
		for(int i = 0;i < n;i++){
			card[n-i] = i+1;
		}
		for(int i = 0;i < r;i++){
			scanf("%d %d",&p,&c);
			for(int j = 1;j <= c;j++){
				tmp[j] = card[j + p - 1];
			}
			for(int j = p-1;j > 0;j--){
				card[j+c] = card[j];
			}
			for(int j = 1;j <= c;j++){
				card[j] = tmp[j];
			}
		}
		printf("%d\n",card[1]);

	}
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}

int main(){
    fio
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;

  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 2001

int N,X,Y;

int num[maxn];
bool vis[maxn];

int main(){
	fast;
	
	cin>>N>>X>>Y;
	
	FOR(rt,1,N){
		
		mem(vis,0);
		queue <pi> q;
		q.push(pi(rt,0));
		
		while (!q.empty()){
			pi cur = q.front(); q.pop();
			
			if (vis[cur.f]) continue;
			vis[cur.f] = 1;
			
			num[cur.s]++;
			
			if (cur.f + 1 <= N) q.push(pi(cur.f + 1,cur.s + 1));
			if (cur.f - 1 >= 1) q.push(pi(cur.f - 1,cur.s + 1));
			if (cur.f == X) q.push(pi(Y,cur.s + 1));
			if (cur.f == Y) q.push(pi(X,cur.s + 1));
		}
	}
	
	
	FOR(i,1,N-1) cout<<num[i]/2<<'\n';
	
	
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void E(){puts("-1");exit(0);}
const int N=1e5+5;
int T,n,m,i,j,a[N],x[N],y[N];
char c[N];
namespace T1{
bitset<50005>b[N],all;
int lst[N];
bool bb[N];
inline void main(){
	for(i=1;i<=n;++i)all.set(i);
	for(i=1;i<=m;++i){
		if(!lst[x[i]])b[i].set(x[i]);else b[i]|=b[lst[x[i]]];
		if(!lst[y[i]])b[i].set(y[i]);else b[i]|=b[lst[y[i]]];
		lst[x[i]]=lst[y[i]]=i;
		if(b[i]==all)break;
	}
	if(i>m)E();
	for(j=m;j>i;--j)c[j]='^';
	bb[x[i]]=bb[y[i]]=1;
	for(j=i;j;--j)if(bb[x[j]])c[j]='^',bb[y[j]]=1;
		else c[j]='v',bb[x[j]]|=bb[y[j]];
}
}
namespace T2{
int u[N],v[N],z;
bool fl[N];
void link(int x,int y){a[x]=y;a[y]=x;}
void setv(int i,int z){c[i]=(x[i]<y[i])^(z==y[i])?'^':'v';}
inline void main(){
	if(n==2 && m>=1)E();
	memset(a+1,0,n<<2);
	for(i=1;i<=m;++i){
		if(!a[x[i]] && !a[y[i]]){
			u[i]=-1;link(x[i],y[i]);
		}else if(a[x[i]] && a[y[i]]){
			if(a[x[i]]!=y[i]){
				u[i]=a[x[i]];v[i]=a[y[i]];
				link(u[i],v[i]);link(x[i],y[i]);
			}else u[i]=0;
		}else{
			if(a[y[i]])swap(x[i],y[i]);
			u[i]=-2;v[i]=x[i];a[a[x[i]]]=0;link(x[i],y[i]);
		}
	}
	memset(fl+1,1,n);memset(c+1,0,m+2);
	for(i=1;i<=n;++i)if(a[i]>i)fl[i]=0;
	for(i=m;i;--i){
		if(u[i]>0){
			if(fl[u[i]] && fl[x[i]])fl[x[i]]=0,fl[y[i]]=1,setv(i,x[i]);
				else if(fl[u[i]] && fl[y[i]])setv(i,y[i]);
					else if(fl[v[i]] && fl[x[i]])setv(i,x[i]);
						else fl[x[i]]=1,fl[y[i]]=0,setv(i,y[i]);
		}
		if(u[i]==0 || u[i]==-1)setv(i,fl[x[i]]?x[i]:y[i]);
		if(u[i]==-2){
			setv(i,fl[x[i]]?x[i]:y[i]);
			fl[v[i]]=0;fl[x[i]^y[i]^v[i]]=1;
		}
	}
}
}
int main(){
	scanf("%d%d%d",&n,&m,&T);for(i=1;i<=m;++i)scanf("%d%d",x+i,y+i);
	if(T==2)T2::main();else T1::main();
	puts(c+1);
}

Measured memory_bytes: 612480
a,b,c=map(int,input().split())
count=0

if a==b==c and(a%2==0 and b%2==0 and c%2==0):
    print(-1)
else:      
    while True:
        a1=a//2
        b1=b//2
        c1=c//2
        if (a%2==0 and b%2==0 and c%2==0):
            count+=1
            a=b1+c1
            b=a1+c1
            c=a1+b1
        else:
            print(count)
            break

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
        sc.close();

        if(t*s>=d) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 35852
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = distance(begin(S), unique(begin(S), end(S)));
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, k;

signed main() {
	cin >> n >> k;
	n = (n+1)/2;
	cout << (n>=k ? "YES" : "NO") << endl;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void){

  int n,d;
  scanf("%d %d", &n, &d);
	int x[n][d];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			scanf("%d", &x[i][j]);
		}
	}

	long square;
	long answer = 0;
	int flag;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			square = 0;
			for (int axis = 0; axis < d; axis++) {
				square += (x[i][axis]-x[j][axis])*(x[i][axis]-x[j][axis]);
			}
			flag = 0;
			for (long i = 1; i <= square; i++) {
				if (i*i == square) {
					flag = 1;
					break;
				}
				if (i*i > square) {
					break;
				}
			}
			if (flag == 1) {
				answer++;
			}
		}
	}

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

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,d;
int a[36][36],ans;
inline bool C(int x,int y)
{
	int ret=0;
	for(int i=1;i<=d;i++)
		ret+=(a[x][i]-a[y][i])*(a[x][i]-a[y][i]);
	if(int(sqrt(ret))*int(sqrt(ret))==ret)
		return 1;
	return 0;
}
int main()
{
    scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)
			if(C(i,j))
				ans++;
	printf("%d",ans);
}


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

using namespace std;

const int MAXN = 1100;
const int INF = (1 << 31) - 1;

vector <vector<pair<int, int>>> d;
vector <vector<int>> dist;
vector <int> w;
set <pair<int, int>> ss;

void dijkstra(int s, int n){
    for (int i = 0; i < n; i++){
        dist[s][i] = INF;
        if (i == s)
            dist[s][i] = 0;
        ss.insert({dist[s][i], i});
    }
    while (!ss.empty()){
        int from = ss.begin()->second;
        ss.erase(ss.begin());
        for (int i = 0; i < d[from].size(); i++){
            int to = d[from][i].first, cost = d[from][i].second;
            int distto = dist[s][from] + cost;
            if (dist[s][to] > distto){
                ss.erase({dist[s][to], to});
                ss.insert({distto, to});
                dist[s][to] = distto;
            }
        }
    }
}

int main()
{
    #ifdef HOME
        freopen("input.txt", "rt", stdin);
    #endif // HOME
    int n, m, r;
    scanf("%d %d %d", &n, &m, &r);
    d.resize(n + 10);
    dist.resize(n + 10, vector<int>(n + 10));
    w.resize(r);
    int x = 1;
    for (int i = 0; i < r; i++){
        scanf("%d", &w[i]);
        w[i]--;
        x *= (i + 1);
    }
    for (int i = 0; i < m; i++){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        a--;b--;
        d[a].push_back({b, c});
        d[b].push_back({a, c});
    }
    for (int i = 0; i < n; i++){
        dijkstra(i, n);
    }
    int ans = INF;
    do{
        x--;
        int k = 0;
        for (int i = 0; i < w.size() - 1; i++){
            k += dist[w[i]][w[i + 1]];
        }
        ans = min(ans, k);
        next_permutation(w.begin(), w.end());
    }while(x > 0);
    printf("%d", ans);
    return 0;
}


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

int main() {
  int64_t N,K,Q=1000000007,P=Q-2;
  cin>>N>>K;
  for(int64_t i=1;i<=K;i++){
    int64_t Z=0;
    if(N-K+1>=i){
    int64_t A=N-K+1,B=min(i,N-K+1-i),C=1;
      for(int j=1;j<=B;j++){
        C=(C*(A+1-j))%Q;
        int64_t N=P;
       int64_t a=1,b=0,c=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=j;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      }
        C=(C*c)%Q;
      }
      Z=(Z+C)%Q;
    }
    
    int64_t A=K-1,B=min(K-i,i-1),C=1;
      for(int j=1;j<=B;j++){
        C=(C*(A+1-j))%Q;
        int64_t N=P;
       int64_t a=1,b=0,c=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=j;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      }
        C=(C*c)%Q;
      }
      Z=(Z*C)%Q;
    cout<<Z<<endl;
  }
    
        
}




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

using namespace std;

string dp[71][71];

bool f(char c) {
    return c >= '0' && c <= '9';
}

string eraseZero(string s) {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != '0') {
            s = s.substr(i, s.size() - i);
            break;
        }
        if (i == s.size() - 1) {
            return "0";
        }
    }
    return s;
}

bool bigger(string a, string b) {
    if (a == "") return 0;
    if (b == "") return 1;
    a = eraseZero(a);
    b = eraseZero(b);
    if (a.size() > b.size()) return 1;
    if (a.size() < b.size()) return 0;
    return a >= b;
}


int main(void) {
    int w, h;

    while (1) {
        cin >> w >> h;
        if (w == 0) break;
        string c[71];
        for (int i = 0; i < h; i++) {
            cin >> c[i];
        }

        dp[0][0] = f(c[0][0]) ? c[0][0] : '?';

        string u, l;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i == 0 && j == 0) continue;
                if (i == 0) {
                    if (!f(c[i][j])) {
                        dp[i][j] = "?";
                    } else if (dp[i][j - 1] != "?") {
                        dp[i][j] = dp[i][j - 1] + c[i][j];
                    } else {
                        dp[i][j] = c[i][j];
                    }
                } else if (j == 0) {
                    if (!f(c[i][j])) {
                        dp[i][j] = "?";
                    } else if (dp[i - 1][j] != "?") {
                        dp[i][j] = dp[i - 1][j] + c[i][j];
                    } else {
                        dp[i][j] = c[i][j];
                    }
                } else {
                    if (!f(c[i][j])) {
                        dp[i][j] = '?';
                    } else {
                        u = "", l = "";
                        if (f(c[i - 1][j])) {
                            u = dp[i - 1][j] + c[i][j];
                        }
                        if (f(c[i][j - 1])) {
                            l = dp[i][j - 1] + c[i][j];
                        }
                        if (u == "" && l == "") {
                            dp[i][j] = c[i][j];
                        } else if (bigger(u, l)) {
                            dp[i][j] = u;
                        } else {
                            dp[i][j] = l;
                        }
                    }
                }
            }
        }

        string ans = "";
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (dp[i][j] == "?") continue;
                if (!bigger(ans, dp[i][j])) {
                    ans = dp[i][j];
                }
            }
        }
        ans = eraseZero(ans);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3264
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    S = input()
    stack = []
    ans = 0

    for i in range(len(S)):
        if len(stack) == 0:
            stack.append(S[i])
        else:
            if stack[-1] != S[i]:
                stack.pop()
                ans += 2
            else:
                stack.append(S[i])

    print(ans)


if __name__ == '__main__':
    main()


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

namespace AtCoder
{
    class Program
    {
        static List<char> disliked;

        static void Main(string[] args)
        {
            //[summary]C - こだわり者いろはちゃん / Iroha's Obsession
            var line = ReadLine();
            int n = line[0];
            int k = line[1];

            disliked = GetDislikedNumbers().ToList();
            int i = n;

            while (true)
            {
                if (CanPay(i))
                {
                    Console.WriteLine(i);
                    break;
                }
                else
                {
                    i++;
                }                
            }
        }

        static bool CanPay(int money)
        {
            string s = money.ToString();

            foreach(var c in s)
            {
                if (disliked.Contains(c))
                {
                    return false;
                }
            }

            return true;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }

        static IEnumerable<char> GetDislikedNumbers()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            foreach(var a in array)
            {
                yield return a[0];
            }
        }
    }
}

Measured memory_bytes: 13280
# x以降のグラフの753数
def dfs(x):
    if x > N: return 0
    res = 1 if all(c in str(x) for c in '753') else 0  # x自身が753数かどうか
    for v in 3, 5, 7:
        res += dfs(10 * x + v)
    return res


N = int(input())
print(dfs(0))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll ncr(ll n,ll r)
{
	if(n==1 || r==0)
	return 1;
	if(r>n/2)
	r=n-r;
	ll ans=1;
	for(ll i=1;i<=r;i++)
	{
		ans=((ans * n )/i);
		n--;
	}
	return ans;
}
int main()
{
	ll a[4][4];
	for(ll i=0;i<3;i++)
	for(ll j=0;j<3;j++)
	cin>>a[i][j];
	
	ll n;
	cin>>n;
	ll b[n+1];
	for(ll i=0;i<n;i++)
	cin>>b[i];
	
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<3;j++)
		{
			for(ll k=0;k<3;k++)
			{
				if(a[j][k]==b[i])
				a[j][k]=-1;
			}
		}
	}
/*	for(ll i=0;i<3;i++)
	{
		for(ll j=0;j<3;j++)
		cout<<a[i][j]<<" ";
		cout<<"\n";
	}*/
	ll ans=-1;
	for(ll i=0;i<3;i++)
	{
		ll x=0;
		for(ll j=0;j<3;j++)
		{
			if(a[i][j]==-1)
			x++;
		}
		ans=max(ans,x);
	}
	for(ll i=0;i<3;i++)
	{
		ll x=0;
		for(ll j=0;j<3;j++)
		{
			if(a[j][i]==-1)
			x++;
		}
		ans=max(ans,x);
	}
	if((a[0][0]==a[1][1] && a[1][1]==a[2][2] && a[2][2]==-1 )||(a[2][0]==a[1][1] && a[1][1]==a[0][2] && a[0][2]==-1))
	ans=3;
	if(ans==3)
	cout<<"Yes";
	else
	cout<<"No";
}

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

int main(){
  string S,T;
  cin>>S>>T;
  if(S=="SSS"){
    cout<<"0"<<endl;
  }
  else if(S=="RRR"){
    cout<<"3"<<endl;
  }
  else if(S=="SRS"||S=="SSR"||S=="RSS"||S=="RSR"){
    cout<<"1"<<endl;
  }
  else{
    cout<<"2"<<endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int ab,bc,ca;
    cin >> ab >> bc >> ca;

    int ans;

    if(max({ab,bc,ca}) == ab){
        ans = bc * ca / 2;
    }else if(max({ab,bc,ca}) == bc){
        ans = ab + ca / 2;
    }else{
        ans = ab * bc / 2;
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='p')
		{
			cnt++;
		}
	}
	cout<<s.size()/2-cnt<<endl;
	return 0;
}

Measured memory_bytes: 512