akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

void zk() {
    cout << "-1" << endl;
    exit(0);
}

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

    int n;
    cin >> n;
    V<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    queue<int> que;
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (b[i] < a[i]) zk();
        que.push(i);
    }

    ll ans = 0;
    while (que.size()) {
        int i = que.front(); que.pop();
        ll near = b[(i + n - 1) % n] + b[(i + 1) % n];
        ll u = (b[i] - a[i]) / near;
        if (u <= 0) continue;
        ans += u;
        b[i] -= near * u;
        que.push((i + n - 1) % n);
        que.push((i + 1) % n);
    }

    if (a != b) zk();

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


Measured memory_bytes: 4224
import java.io.*
import java.util.*

const val YES = "Yes"
const val NO = "No"
var pw = PrintWriter(System.out)
fun solve(N: Int, K: Int, Q: Int, A: IntArray){
    val answerTimes = IntArray(N)
    for(i in 0 until Q){
        answerTimes[A[i]-1] += 1
    }
    answerTimes.forEach{ if (it > Q-K) println(YES) else println(NO) }
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val K = sc.next().toInt()
    val Q = sc.next().toInt()
    val A = IntArray(Q)
    for (i in 0 until Q) {
        A[i] = sc.next().toInt()
    }
    solve(N, K, Q, A)
}



Measured memory_bytes: 40936
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long i; long long j;
};


ll const MAX = 200005;
ll parent[MAX];
ll rk[MAX];

void init(ll n) {
	for (ll i = 1; i <= n; i++) {
		parent[i] = i;
		rk[i] = 1;
	}
}

ll find(ll x) {
	if (parent[x] == x) {
		return x;
	}
	parent[x] = find(parent[x]);
	return parent[x];
}

bool same(ll x, ll y) {
	return find(x) == find(y);
}

void unite(ll x, ll y) {
	if (!same(x, y)) {
		x = parent[x];
		y = parent[y];
		if (rk[x] < rk[y]) {
			parent[x] = y;
		}
		else {
			parent[y] = x;
			if (rk[x] == rk[y]) {
				rk[x]++;
			}
		}
	}
}

vll p[MAX];

int main() {
	ll n, m;
	cin >> n >> m;
	init(n);
	REP(i, 1, n) {
		ll k;
		cin >> k;
		REP(j, 1, k) {
			ll t;
			cin >> t;
			p[t].push_back(i);
		}
	}
	REP(i, 1, m) {
		if (SIZE(p[i]) == 0) {
			continue;
		}
		ll person = p[i][0];
		for (auto cur : p[i]) {
			unite(person, cur);
		}
	}
	REP(i, 2, n) {
		if (!same(1, i)) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

}


Measured memory_bytes: 8832
#include <iostream>
#include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
    int m,n,o,i;
    float f,g,h;
    //string a;
    //cin>>m;
    cin>>m>>n;
    //cin>>f>>g;
    if(n%m==0) cout<<n+m;
    else cout<<n-m;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())

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

memo = [0]*(n+1)

for i in range(n):
    memo[i+1] = t[i]

move = 1

count = 0

check = [0]*(n+1)

while check[move] == 0 and count < k-1:
    check[move] += 1
    move=memo[move]
    count += 1

if k == count:
    print(memo[move])
else:
    count2 = 0
    check = [0]*(n+1)
    move_log = []
    while check[move] == 0:
        move_log.append(move)
        check[move] += 1
        move=memo[move]
        count2 += 1
    print(move_log[(k-count)%count2])


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

int main() {
  int n;
  cin >> n;
  vector<ll>a(n+1);
  rep(i,0,n+1) cin >> a[i];
  vector<P>c(n+1);
  c[n].first = a[n];c[n].second = a[n];
  for(int i = n-1;i >= 0;i--){
    c[i].first = (c[i+1].first+1)/2+a[i];
    c[i].second = c[i+1].second+a[i];
  }
  if(c[0].first > 1){
    cout << -1 << endl;
    return 0;
  }
  ll ans = 1,v = 1;
  rep(i,1,n+1){
    ll t = min(2*v,c[i].second);
    ans += t;
    v = t-a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 5596
# Problem https://atcoder.jp/contests/abc064/tasks/abc064_a
# Python 2nd Try
yes = "YES"
no = "NO"
if __name__ == "__main__":
    r, g, b = map(int, input().split(' '))
    answer = ""
    checkNo = (g*10+b) % 4
    if checkNo == 0:
        answer = yes
    else:
        answer = no
    print(answer)
exit

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

const int n_max = 310;
int N;
double dp[n_max][n_max][n_max];

double ev (int a, int b, int c) {
  if (a + b + c == 0) {
    return 0.0;
  }
  if (dp[a][b][c] > -0.5) {
    return dp[a][b][c];
  }
  double ans = 0.0, ks = (double)N / (a + b + c);
  if (a) {
    ans += (ev(a - 1, b, c) + ks)* a / (a + b + c);
  }
  if (b) {
    ans += (ev (a + 1, b - 1, c) + ks) * b / (a + b + c);
  }
  if (c) {
    ans += (ev (a, b + 1, c - 1) + ks) * c / (a + b + c);
  }
  return dp[a][b][c] = ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  #ifdef LOCAL_DEFINE
  freopen ("input.txt", "r", stdin);
  freopen ("output.txt", "w", stdout);
  #endif 
  int n;  cin >> n; N = n;
  vector <int> a(4, 0);
  for (int i = 0; i < n; ++i) {
    int ai; cin >> ai;
    a[ai]++;
  }
  for (int i = 0; i < n_max; ++i) {
    for (int j = 0; j < n_max; ++j) {
      for (int k = 0; k < n_max; ++k) {
        dp[i][j][k] = -1.0;
      }
    }
  }
  cout <<setprecision(12) <<fixed << ev(a[1],a[2],a[3]);
}

Measured memory_bytes: 233088
import java.util.Scanner;

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

        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int z = scanner.nextInt();
        int sum = 0;
        int ans = 0;

        for (int i = 1; ; i++) {
            sum = (i * y) + ((i + 1) * z);

            if (sum <= x) {
                ans++;
            } else {
                break;
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String result = isTrue(s)%9 == 0? "Yes":"No";
        System.out.println(result);
    }
    public static int isTrue(String s){
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            count += s.charAt(i)-'0';
        }
        return count;
    }
}

Measured memory_bytes: 40088
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, i, sum=0;
  cin >> N;
  for (i=0; i<N; i++) {
    int l, r;
    cin >> l >> r;
    sum+=r-l+1;
  }
  cout << sum << "\n";
  return 0;
}

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

int main() 
{
    int X,Y;
    cin>>X>>Y;

    if(500*X>=Y)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
        return 0;
    }
    

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c,d,ab,bc,ac;
	cin>>a>>b>>c>>d;
	ab=a-b;
	bc=b-c;
	ac=a-c;
	if(ab<0){
		ab=ab*-1;
	}
	if(ac<0){
		ac=ac*-1;
	}
	if(bc<0){
		bc=bc*-1;
	}
 
	if(ac<=d){
		cout<<"Yes"<<endl;
	}
	else if(ab<=d&&bc<=d){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


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


int main()
{
	ll N,K;
	cin>>N>>K;
	vector<ll> kind(1e5+1,0);
	rep(i,N)
	{
		ll a,b;
		cin>>a>>b;
		kind[a]+=b;
	}
	rep(i,1e5+1)
	{
		K-=kind[i];
		if(K<=0)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 4032
#include <algorithm>
#include <iostream>
#include <istream>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>


using namespace std;


long long n;
long long ans;

vector<char> cs = {'7', '5', '3'};


void dfs (string s) {
    if (s != "" and stoll(s) > n) return;
    if (
            find(s.begin(), s.end(), '7') != s.end() and
            find(s.begin(), s.end(), '5') != s.end() and
            find(s.begin(), s.end(), '3') != s.end()) {
        ans++;
    }

    for (char c: cs) {
        dfs(s+c);
    }
    return;
}


int main() {
    cin >> n;
    dfs("");
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

LL t[220000];

map<int,int> m1;
queue<int> q1;

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c,s=0;
	cin>>n>>m;
	a=0;
	m1[0]++;
	q1.push(0);
	for(i=0;i<n;i++){
		cin>>t[i];
		a+=t[i]-1;
		a%=m;
		if(i>=m-1){
			b=q1.front(),q1.pop();
			m1[b]--;
		}
		s+=m1[a];
		m1[a]++;
		q1.push(a);
	}
	cout<<s<<endl;

}

Measured memory_bytes: 12032
#include <stdio.h>
#include <algorithm>
int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	int gx, gy;
	switch (x)
	{
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		gx = 0;
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		gx = 1;
		break;
	case 2:
		gx = 2;
		break;
	default:
		gx = 3;
		break;
	}
	switch (y)
	{
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		gy = 0;
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		gy = 1;
		break;
	case 2:
		gy = 2;
		break;
	default:
		gy = 3;
		break;
	}
	printf("%s\n", (gx == gy ? "Yes" : "No"));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
int main()
{
	int N;
	cin>>N;
	vector<int> v(N);
	rep(i,N) cin>>v[i];
	double ans=0;
	rep(i,N) ans+=1.0/(v[i]*1.0);
	printf("%g\n",1/ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 1;
  
  for (int i = 0; i < N; i++) {
    if (sum <= K) {
      sum *= 2;
    }
    else {
      sum += K;
    }
  }
  cout << sum << endl;
  

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
typedef pair<int, int> P;
string s[334];
string naname[668];

void init() {
	for (int i = 0; i < 668; i++)naname[i].clear();
}
void move(int n) {
	s[n] = s[0];
	rep(i, n)s[i] = s[i + 1];
	s[n].clear();
}
signed main() {
	int n; cin >> n; rep(i, n)cin >> s[i];
	int ans = 0;

	//for (int i = 0; i <= 2 * n; i++)cout << naname[i] << endl;

	for (int x = 0; x < n; x++) {
		init();
		for (int i = -n + 1; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int ni = i + j, nj = j;
				if (ni >= 0 && ni<n && 0 <= nj&&nj<n)naname[i + n - 1].push_back(s[ni][j]);
			}
		}
		int flg = 0;
		for (int i = 0; i < n; i++) {
			int u = i, d = 2 * n - i-2;
			if (naname[u] != naname[d])flg++;
		}
		if (!flg)ans += n;

		for (int i = 0; i < n;i++) {
			char c = naname[i][i];
			naname[i].pop_back();
		
			naname[i + n].push_back(c);
			}

		for (int i = 0; i < 2 * n - 1; i++) {
			naname[i] = naname[i + 1];
		}
		naname[2 * n - 1].erase();
		move(n);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 640
X,N = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)
ans = []

(0..100).each do |i|
if p.include?(X-i)
  next if p.include?(X+i)
  ans = X+i
else
  ans = X-i
end
break if ans != []
end

puts ans
    
  

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;

ll x;

int main(){
  cin >> x;
  ll sum = 0;
  ll ans = 0;
  rep(i,1,INTMAX){
    sum += i;
    ans = i;
    if(sum >=x)break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>

using namespace std;

set<int> prime;

void calc_prime(int mm) {
    int cur = 2;
    while(cur <= mm) {
        for(auto itr = prime.begin();itr != prime.end();itr++) {
            if(cur % *itr == 0)
                goto not_prime;
        }
        prime.insert(cur);
    not_prime:
        cur++;
    }
}

int main(void) {
    int n,res = 0;
    cin >> n;
    if(n % 2 == 0)
        res = n;
    else
        res = 2 * n;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010]={0};
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int mx=1;
    int cur=1;
    for(int i=1;i<n;i++){
        if(a[i]<=a[i-1]){
            cur++;
            mx=max(cur,mx);
        } else{
            mx=max(cur,mx);
            cur=1;
        }
    }
    cout<<mx-1;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int a,b,c,t;
  scanf("%d %d %d",&a,&b,&c);
  if (a>b) {
    t=a;
	a=b;
	b=t;
  }

  if (c<a) {
    t=c;
    c=b;
    b=a;
    a=t;
  } else if (a<=c && c<b) {
	t=c;
	c=b;
	b=t;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int n,m,sum,a[100];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	for(int i=n;i>=n-m+1;i--){
		sum+=a[i];
	}
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 256
class Dice < Array
	def roll!(drct)
		drct.split("").each{|s|
		case s
		when "E" then
			self.replace([at(3),at(1),at(0),at(5),at(4),at(2)])
		when "N" then
			self.replace([at(1),at(5),at(2),at(3),at(0),at(4)])
		when "S" then
			self.replace([at(4),at(0),at(2),at(3),at(5),at(1)])
		when "W" then
			self.replace([at(2),at(1),at(5),at(0),at(4),at(3)])
		when "R" then
			self.replace([at(0),at(3),at(1),at(4),at(2),at(5)])
		end
		}
	end
	def is_top
		at(0)
	end
	def getr(face)
		while at(0) != face[0] do
			roll!(["E","N","S","W"].sample)
		end
		while at(1) != face[1] do
			roll!("R")
		end
		at(2)
	end
end

a = Dice.new(gets.split.map(&:to_i))
for i in 1..gets.chomp.to_i do
	puts a.getr(gets.split.map(&:to_i))
end

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

int main() {
    int n, m,ans;

    cin >> n >> m;
    vector<vector<int>> lmp(m);
    vector<int> p(m);
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int ss;
            cin >> ss;
            lmp[i].push_back(ss-1);
        }
    }
    rep(i, m)
        cin >> p[i];

    ans = 0;
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<int> S(n);
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) { // 列挙に i が含まれるか
                S[i] = 1;
            }
        }
        //電球チェック
        int flg = 0;
        rep(i, m) {
            int cnt = 0;
            rep(j, lmp[i].size()) {
                if (S[lmp[i][j]] == 1)
                    ++cnt;
            }
            if (cnt % 2 != p[i]) {
                ++flg;
                break;;
            }
        }
        if (flg == 0)
            ++ans;
    }

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
long long int p = pow(10, 9) + 7;

long long int modPow(long long int a, long long int n){//繰り返し自乗法
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return a % p;
    }
    if (n % 2 == 1){ 
        return (a * modPow(a, n - 1)) % p;
    }      
    long long t = modPow(a, n / 2);
    return (t * t) % p;
}

long long int per(long long int x){//階乗 x!
    long long int res = 1;
    while(x > 0){
        res *= x;
        res = res % p;
        x--;
    }
    return res;
}

long long int perY(long long int x, long long int y){//nPy
    long long int res = 1;
    for(int i = 0; i < y; i++){
        res *= x;
        res = res % p;
        x--;
    }
    return res;
}

int main(){
    long long int n, a, b;
    cin >> n >> a >> b;
    long long result = modPow(2, n);//すべての数
    //cout << result << endl;

    long long tmp;
    tmp = per(a);
    tmp = modPow(tmp, p - 2);
    //cout << (perY(n, a) * tmp) % p << endl;
    result += p;
    result -= (perY(n, a) * tmp) % p;
    tmp = per(b);
    tmp = modPow(tmp, p - 2);
    //cout << (perY(n, b) * tmp) % p << endl;
    result += p;
    result -= (perY(n, b) * tmp) % p;
    
    result--;

    cout << result % p << endl; 
}

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

int main()
{
    ll x,ans=0,r,c,cnt=0;
    double p=100.0;
    scanf("%lld",&x);
    while(p<x)
    {
        p=p+floor(p*0.01);
        //cout<<p<<endl;
        cnt++;
    }
    cout<<cnt<<endl;
    //cout<<ans<<endl;

}



Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define cerr if(0) cerr

void solve() {
    int a[5];
    loop(i, 5)
        cin >> a[i];
    loop(i, 5)
        if (a[i] == 0)
            cout << i + 1;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi 1
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

LL N;

int main()
{
  cin >> N;
  for (int h = 1; h <= 3500; h++) {
    for (int n = 1; n <= 3500; n++) {
      long double bunbo = 4*h*n - N*h - N*n;
      if(bunbo == 0) {
        continue;
      }
      long double ans = N * h * n / bunbo;
      if(ans == (LL)ans && ans > 0 && ans <= 3500) {
        cout << h << " " << n << " " << ans << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	ex := make([]float64, N)
	for i := 0; i < N; i++ {
		var p int
		fmt.Scan(&p)
		ex[i] = float64(1.0+p) / 2
	}
	cum := make([]float64, N+1)
	for i := 0; i < N; i++ {
		cum[i+1] = cum[i] + ex[i]
	}
	ans := 0.0
	for i := 0; i <= N-K; i++ {
		ans = math.Max(ans, cum[i+K]-cum[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6400
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int k;
  cin >> k;
  int len = (int) s.length();
  for (int i = 0; i < len; i++) {
    int x = 'z' - s[i] + 1;
    if (i == len - 1) {
      int c = s[i] + k % 26;
      if (c > 'z') c = 'a' + c - 'z' - 1;
      s[i] = c;
    } else {
      if (s[i] == 'a') continue;
      if (x <= k) {
        s[i] = 'a';
        k -= x;
      }
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 592
S = input()
T = input()

dp = [[0] * (len(T)+1) for i in range(len(S)+1)]
for i, s in enumerate(S, 1):
  for j, t in enumerate(T, 1):
    if s == t:
      dp[i][j] = dp[i-1][j-1] + 1
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = ''
while i > 0 and j > 0:
  if dp[i][j] == dp[i][j-1]:
    j -= 1
  elif dp[i][j] == dp[i-1][j]:
    i -= 1
  else:
    ans += S[i-1]
    i -= 1
    j -= 1

print(ans[::-1])

Measured memory_bytes: 112476
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <queue>

using namespace std;

struct edge{
  int to;
  int cost;
};

int d[2001][6011];
vector<edge> G[6011];
bool isGas[10001];
map<string,int> m;
int idx;
int st,gl;

int N,M,cap;
const int INF=1<<30;
typedef pair<int,int> pii;
typedef pair<int,pii> Sit;

int dijkstra(){
  for(int i=0;i<2001;i++)
    for(int j=0;j<6011;j++)
      d[i][j]=INF;
  priority_queue<Sit,vector<Sit>,greater<Sit> > pq;
  pq.push(make_pair(0,pii(cap*10,st)));
  d[cap*10][st]=0;
  while(pq.size()){
    Sit p=pq.top();pq.pop();
    int ccost=p.first;
    int ccap=p.second.first;
    int cnode=p.second.second;
    if(d[ccap][cnode]<ccost)continue;
    for(int i=0;i<(int)G[cnode].size();i++){
      edge &e=G[cnode][i];
      int ncap=ccap-e.cost;
      if(ncap<0)continue;
      int nnode=e.to;
      int ncost=ccost+e.cost;
      if(isGas[nnode])ncap=cap*10;
      if(d[ncap][nnode]>ncost){
	d[ncap][nnode]=ncost;
	pq.push(make_pair(ncost,pii(ncap,nnode)));
      }
    }
  }
  int res=INF;
  for(int i=0;i<2001;i++)
    res=min(res,d[i][gl]);
  return res;
}

int main(){
  while(cin>>N>>M>>cap&&(N|M|cap)){
    memset(isGas,0,sizeof(isGas));
    for(int i=0;i<6011;i++)G[i].clear();
    m.clear();
    idx=0;
    string s,t;
    cin>>s>>t;
    if(m.count(s)==0)m[s]=idx++;
    if(m.count(t)==0)m[t]=idx++;
    st=m[s];gl=m[t];
    for(int i=0;i<N;i++){
      string a,b;
      int c;
      cin>>a>>b>>c;
      if(m.count(a)==0)m[a]=idx++;
      if(m.count(b)==0)m[b]=idx++;
      int x,y;
      x=m[a];y=m[b];
      edge e;
      e.to=y;
      e.cost=c;
      G[x].push_back(e);
      e.to=x;
      G[y].push_back(e);
    }
    for(int i=0;i<M;i++){
      string s;
      cin>>s;
      if(m.count(s)==0)m[s]=idx++;
      isGas[m[s]]=true;
    }
    int res=dijkstra();
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 60000
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int temp;
  	int l1,l2;
  l1=0;
  l2=0;
  for(int i=0;i<3;i++)
  {
  	cin >> temp;
    if(temp==5)
      l1++;
    else if(temp==7)
      l2++;
  }
  if((l1==2)&&(l2==1))
	cout << "YES" << endl;
  else
    cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, ans;
char c[364][364];
signed main() {
	cin >> n;
	rep(i, n)rep(j, n)cin >> c[i][j];
	//X
	rep(i, n) {
		char d[364][364];
		rep(j, n)rep(k, n)d[(j + i) % n][k] = c[j][k];
		rep(j, n)rep(k, n) {
			if (d[j][k] != d[k][j])goto ng;
		}
		ans += n - i;
	ng:;
	}
	//Y
	REP(i, n) {
		char d[364][364];
		rep(j, n)rep(k, n)d[j][(k + i) % n] = c[j][k];
		rep(j, n)rep(k, n) {
			if (d[j][k] != d[k][j])goto ng2;
		}
		ans += n - i;
	ng2:;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	double pi=3.1415926536;
	int a,b,x,v;
	double ans,tg,ans1,k;
	cin>>a>>b>>x;
	v=a*a*b;
	if(x>v/2)
	{
		k=(double)(v-x)*2/(a*a);
		tg=(double)k/a;
		ans1=atan(tg);
		ans=(double)ans1*180/pi;
	}
	if(x<=v/2)
	{
		k=(double)x*2/(a*b);
		tg=(double)b/k;
		ans1=atan(tg);
		ans=(double)ans1*180/pi;
	}
	printf("%.10f\n",ans);
	return 0;
}

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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  string s;
  cin >> s;
  vector<int> v;
  ll ans = 0;
  for (int i = 0; i < sz(s); i++) {
    if (s[i] == 'A') v.pb(1);
    else if (s[i] == 'C') v.pb(0);
    else if (s[i] == 'B') {
      if (i+1 < sz(s) && s[i+1] == 'C') {
        v.pb(2);
        i++;
      } else {
        v.pb(0);
      }
    }
  }
  ll cnt1 = 0, cnt2 = 0;
  REP(i,sz(v)) {
    if (v[i] == 1) {
      cnt1++;
    } else if (v[i] == 2) {
      ans += cnt1;
    } else {
      cnt1 = 0;
      cnt2 = 0;
    }
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]){

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

Measured memory_bytes: 1532
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int day = in.nextInt();
        int number = in.nextInt();
        int sum = 0;
        for(int i = 0; i < number; i++){
            sum += in.nextInt();
        }
        if(sum<=day){
            System.out.print(day-sum);
        }
        else{
            System.out.print(-1);
        }
    }

}

Measured memory_bytes: 45940
#include <iostream>
#include <set>

using namespace std;

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

    set<int> a_set;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a_set.insert(a);
    }

    cout << (a_set.size() - (a_set.size() % 2 == 0 ? 1 : 0)) << endl;
}


Measured memory_bytes: 4992
from operator import itemgetter

n, m = map(int, input().split())
a = list(map(int, input().split()))
list_bc = [list(map(int, input().split())) for _ in range(m)]

list_bc.sort(key=itemgetter(1), reverse = True)
# list_bc.sort(reverse=True, key=lambda x: x[1])

cnt = 0
for i in range(m):
    cnt += list_bc[i][0]
    if cnt < n:
        a.extend([list_bc[i][1]] * list_bc[i][0])
    else:
        a.extend([list_bc[i][1]] * (n - list_bc[i][0] + cnt))
        break

print(sum(sorted(a, reverse = True)[:n]))

Measured memory_bytes: 38836
#include <stdio.h>

int main(){

	int i,x[10000],y[10000];
	int temp;

	for(i = 1; i <= 10000; i++){
		scanf("%d %d",&x[i],&y[i]);

		if((x[i] == 0) && (y[i] == 0)){
			break;
		}
	}

	for(i = 1; i <= 10000; i++){
		if((x[i] != 0) || (y[i] != 0)){
			if(x[i] > y[i]){
				temp = x[i];
				x[i] = y[i];
				y[i] = temp;
			}

			printf("%d %d\n",x[i],y[i]);
		}else{
			break;
		}
	}

	return 0;
}

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

int main(void){
    string s;
    cin >> s;

    rep(i, 3){
        if(s[i] == s[i + 1]){
            puts("Bad");
            return 0;
        }
    }

    puts("Good");
    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int c1 = 0;
		int c2 = 0;
		int c4 = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % 4 == 0) {
				c4++;
			} else if (a[i] % 2 == 0) {
				c2++;
			} else {
				c1++;
			}
		}
		if (c2 > 0) {
			if (c1 <= c4) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			if (c1 <= c4 + 1) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 50608
n = int(input())
an = list(map(int, input().split()))
num = 1
listnum = len(an)
count = 0
for a in an:
    if a == num:
        count += 1
        num += 1
notnum = len(an) - count
if listnum == notnum:
    print(-1)
else:
    print(notnum)

Measured memory_bytes: 24744
import sys
input = sys.stdin.readline

n = int(input())

ls_x = []
ls_x.append( int(n/1.08) )
ls_x.append( int(n/1.08) + 1 )

# print(ls_x)

for x in ls_x:

    y = int(x*1.08)
    # print(y)

    if y==n:
        print(x)
        exit()
    elif y<(n+1) and y>n:
        print(x)
        exit()

print(":(")
exit()

Measured memory_bytes: 3060
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N;
	cin >> N;
 
	// 解法
	ll ans;
	REP(i,16){
		ll a = N%10;
		ll b = N/10;
		if (a==9) ans += a;
		else if (b>0){
			ans += 9;
			b--;
		}
		else ans += a;
		N = b;
	}
	
	printf("%lld\n", ans);
}


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

int main()
{
  int a, b, c;
  while( cin >> a >> b >> c ) {
    if( a == 0 && b == 0 && c == 0 ) break;
    int p = 2*a, r = 2*a;
    int q = -(-b+(sqrt((double)(b*b-4*a*c))));
    int s = -(-b-(sqrt((double)(b*b-4*a*c))));
    //int tmp = (int)sqrt((double)(b*b-4*a*c));
    //cout << b*b-4*a*c << endl;
    //cout << sqrt((double)b*b-4*a*c) << endl;
    //cout << q << " " << s << endl;
    int tmp = (int)sqrt((double)(b*b-4*a*c));
    //cout << tmp << endl;
    if( abs(sqrt((double)(b*b-4*a*c)) - (double)tmp) != 0 || b*b-4*a*c < 0 ) {
      cout << "Impossible" << endl;
    } else { 
      //cout << sqrt((double)(b*b-4*a*c)) << endl;
      //cout << q << " " << s << endl;
      for(int i=100000; i>1; i--) {
	if( !(p % i) && !(q % i) ) {
	  p /= i; q /= i;
	}
	if( !(r % i) && !(s % i) ) {
	  r /= i; s /= i;
	}
	
	
      }

      if( p < r ) {
	swap(p, r);
	swap(q, s);
      }
      if( p == r ) {
	if( q < s ) {
	  swap(q, s);
	}
      }
      cout << p << " " << q << " " << r << " " << s << endl;
    }
  }
}
  

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




i64 x,y;
void solve(){
	cin >> x >> y;
	
	if(abs(x-y) >= 2) cout << "Alice" << endl;
	else cout << "Brown" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int n, m, ans, at[305], x[305][305], fre[305], ta;
bool rm[305], o;
 
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)	
			scanf("%d", x[i] + j);
	for (int i = n; i; i--) {
		memset(at, 0, sizeof(at));
		memset(rm, 0, sizeof(rm));
		o = 1;
		while (1) {
			memset(fre, 0, sizeof(fre));
			for (int j = 0; j < n && o; j++) {
				while (at[j] < m && rm[x[j][at[j]]])
					at[j]++;
				if (at[j] == m)
					o = 0;
				else
					fre[x[j][at[j]]]++;
				//printf("! %d %d %d\n",j,at[j],x[j][at[j]]);
			}
			if (!o)
				break;
			ta = -1;
			for (int j = 1; j <= m; j++)
				if (fre[j] > i) {
					rm[j] = 1;
					ta = j;
					break;
				}
		//	printf("%d %d\n",i,ta);
			
		//	for (int j = 0; j < n; j++)
		//	printf("%d%c",at[j],j == n-1 ? '\n':' ' );
		//	for (int j = 1; j <= m; j++)
		//	printf("%d%c",fre[j],j == m ? '\n':' ' );
		//	for (int j = 1; j <= m; j++)
		//	printf("%d%c",rm[j],j == m ? '\n':' ' );
			if (ta == -1)
				break;
		}
		if (o)
			ans = i;
		else
			break;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
from collections import Counter
c=Counter(a)
ans=0
for i in a:
  if c[i]==0:continue
  m=1<<i.bit_length()
  c[i]-=1
  if c[m-i]:
    ans+=1
    c[m-i]-=1
print(ans)

Measured memory_bytes: 110292
#include <iostream>
int read(){
	int x=0,f=1;char c;
	do{c=getchar();if(c=='-')f=-1;}while(!isdigit(c));
	do{x=x*10+c-'0';c=getchar();}while(isdigit(c));
	return x*f;
}
using Int = signed long long int;
const int N=100000+10;
const Int mod=Int(1e9)+7LL;

int vis[N],phi[N],prime[N],pcnt;
Int qpow(Int a,Int p){
	Int r=1; while(p){
		if(p&1) r=r*a%mod;
		a=a*a%mod; p>>=1;
	} return r;
}

void sieve(){
	phi[1]=1;
	for(int i=2;i<N;i++){
		if(!vis[i]){
			prime[pcnt++]=i;
			phi[i]=i-1;
		}
		for(int j=0;j<pcnt&&1LL*i*prime[j]<N;j++){
			int t=i*prime[j]; vis[t]=1;
			if(i%prime[j]==0){ phi[t]=phi[i]*prime[j]%mod; break; }
			phi[t]=phi[i]*(prime[j]-1)%mod;
		}
	}
}

int main(){
	int n=read(),k=read();
	sieve();


	Int ans=0;
	for(int i=1;i<=k;i++) ans=(ans+qpow(k/i,n)*phi[i]%mod)%mod;
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 3960
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

h, w, k = input_a

# 地図読み取り
tiles = Array.new(h)
h.times do |i|
  tiles[i] = gets.chomp.chars
end

h.times do |i|
  w.times do |j|
    if tiles[i][j] == "#"
      start_h = i
    end
  end
end

ans = 0
[0, 1].repeated_permutation(h) do |h_bits|
  [0, 1].repeated_permutation(w) do |w_bits|
    cnt = 0
    h.times do |i|
      next if h_bits[i] == 1
      w.times do |j|
        next if w_bits[j] == 1
        if tiles[i][j] == "#"
          cnt += 1
        end
      end
    end
    ans += 1 if cnt == k
  end
end
puts ans


Measured memory_bytes: 14396
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100000];

string ans = "No";

void solve(){
	sort(A,A+N,greater<LL>());
	set<LL> nums;//登場した番号を格納
	map<LL,LL> counter;//番号iが何回登場したかをcounter[i]とする
	for(int i=0;i<N;i++){
		nums.insert(A[i]);
		counter[A[i]]++;
	}
	if(nums.size()==1){
		LL num = *(nums.begin());
		if(num*2<=N || num==N-1){
			ans = "Yes";
			return;
		}
	}
	if(nums.size()>=3) return;

	LL miner = *(nums.begin());
	LL larger = *(++nums.begin());
	if(miner!=larger-1) return;
	if(counter[larger]>=2*(larger-counter[miner]) && larger-counter[miner]>0) ans = "Yes";
}

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

    solve();

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

Measured memory_bytes: 11904
package main

/*
最長共通部分列
*/

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func larger(l, r int) int {
	if l > r {
		return l
	}
	return r
}

var memo [1001][1001]int

func countLCS(x, y string) int {
	x = " " + x
	y = " " + y
	max := 0
	for xi := 1; xi < len(x); xi++ {
		for yi := 1; yi < len(y); yi++ {
			if x[xi] == y[yi] {
				memo[xi][yi] = memo[xi-1][yi-1] + 1
			} else {
				memo[xi][yi] = larger(memo[xi-1][yi], memo[xi][yi-1])
			}
			max = larger(max, memo[xi][yi])
		}
	}
	return max
}

func main() {
	scanner := makeScanner(1024)
	q := eGetInt(scanner)
	for i := 0; i < q; i++ {
		x := eGetLine(scanner)
		y := eGetLine(scanner)
		fmt.Println(countLCS(x, y))
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	buf.WriteString("[")
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = ", "
	}
	buf.WriteString("]")
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func min(a []int) int {
	m := a[0]
	for _, v := range a {
		if v < m {
			m = v
		}
	}
	return m
}

func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}
func find(n int, a ints) int {
	for i, v := range a {
		if n == v {
			return i
		}
	}
	return -1
}



Measured memory_bytes: 9004
import math
N, M = map(int, input().split())

MOD = 10 ** 9 + 7

factorial = [1, 1]
inverse = [1, 1]
invere_base = [0, 1]
for i in range(2, N + M + 1):
    factorial.append((factorial[-1] * i) % MOD)
    invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD)
    inverse.append((inverse[-1] * invere_base[-1]) % MOD)

def nCr(n, r):
    if not (0 <= r <= n):
        return 0
    return factorial[n] * inverse[r] * inverse[n - r] % MOD

def nPr(n, r):
    if not (0 <= r <= n):
        return 0
    return nCr(n, r) * factorial[r] % MOD

mod = MOD
ans = 0

n = N
m = M

if N == M:
    for i in range(N+1):
        #print(cmb(n,i,mod),i)
        ans += nCr(n,i)*factorial[n]*factorial[n-i]*(-1)**(i)
        #print(ans)
        ans %= mod
        #print(ans)
    print(ans)
else:
    for i in range(N+1):
        ans += nCr(n,i)*nPr(m,n)*nPr(m-i,n-i)*(-1)**(i)
        ans %= mod
        #print(ans)
    print(ans)


Measured memory_bytes: 167768
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> A_four, A_two, A_others;
    rep (i, 0, N) {
        int a; cin >> a;
        if (a % 4 == 0) A_four.push_back(a);
        else if (a % 2 == 0) A_two.push_back(a);
        else A_others.push_back(a);
    }

    if (!A_two.empty() and A_four.size() >= A_others.size())
        cout << "Yes" << endl;
    else if (A_two.empty() and A_four.size()+1 >= A_others.size())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 1012
n = gets.to_i

d = Hash.new(0)

n.times do
  x = gets.rstrip
  d[x] += 1
end

as = d.to_a.sort_by { |kv| [-kv[1], kv[0]] }

v = as[0][1]

as.each do |kv|
  puts kv[0] if kv[1] == v
end


Measured memory_bytes: 50424
#include <stdio.h>
int main(){
 
 int a, b, c, tmp;
 
 scanf("%d%d%d", &a, &b, &c);

 if ( b > c ) {

  tmp = b; b = c; c = tmp;

 } 

 if ( a > b ) {

  tmp = a; a = b; b = tmp;

}

 if ( b > c ) {

  tmp = b; b = c; c = tmp;

}

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



 
  
    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  int ans = 0;
  cin >> a >> b;
  vector<char> vec(a * b);
  for (int i = 0; i < a * b; i++) {
    cin >> vec.at(i);
    if (vec.at(i) == '#') ans++;
  }
  if (ans == a + b - 1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
    llin(n);
    sal(n*n*n);
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
long long n;
int main()
{
	cin>>n;
	while(n>0)
	{
		if(n%10==9)
		{
			cout<<"Yes";
			return 0;
		}
		n/=10;
	}
	cout<<"No";
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0]=='1') ++counter;
    if (s[1]=='1') ++counter;
    if (s[2]=='1') ++counter;
    cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int H,N,sUm=0;cin>>H>>N;
    int arr[N];
    for(int i=0;i<N;i++){
            cin>>arr[N];
            sUm+=arr[N];
    }
    if((H-sUm)>0){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
    return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string str = Console.ReadLine ();
            int N = int.Parse (str);

            var M = new string[N];

            for (int i = 0; i < N; i++)
            {
                str = Console.ReadLine ();
                M[i] = str;
            }

            Console.WriteLine (M.Distinct ().Count ());
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 48176