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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	ll N; cin>>N;
	string s; cin>>s;
	sort(s.bg,s.ed);
	map<char,ll> m;
	rep(i,s.sz){
		m[s[i]]++;
	}
	ll ans=1;
	for(auto itr=m.bg;itr!=m.ed;itr++){
		ans*=(itr->second+1);
		if(itr==(--m.ed)) ans--;
		ans%=MOD;
	}
	cout<<ans;
}

Measured memory_bytes: 512
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
ls = [[0,0,0] for _ in range(3)]

for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                ls[i][j] = 1

for i in range(3):
    if sum(ls[i]) == 3:
        print('Yes')
        exit()
    if ls[0][i]*ls[1][i]*ls[2][i] == 1:
        print('Yes')
        exit()

if ls[0][0]*ls[1][1]*ls[2][2] == 1:
    print('Yes')
    exit()

if ls[0][2]*ls[1][1]*ls[2][0] == 1:
    print('Yes')
    exit()

print('No')

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int d, g; cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    for (int i = 0; i < d; ++i) {
        cin >> p[i] >> c[i];
    }

    int ans = INF;

    for (int bit = 0; bit < (1 << d); ++bit) {
        int sum = 0;
        int cnt = 0;
        for (int i = 0; i < d; ++i) {
            if (bit & (1 << i)) {
                sum += 100 * (i + 1) * p[i] + c[i];
                cnt += p[i];
            }
        }

        if (sum >= g) {
            ans = min(ans, cnt);
        } else {
            for (int i = d - 1; i >= 0; --i) {
                if (!(bit & (1 << i))) {
                    bool brk = false;
                    for (int j = 1; j <= p[i]; ++j) {
                        sum += 100 * (i + 1);
                        cnt++;
                        if (sum >= g) {
                            brk = true;
                            break;
                        }
                    }
                    if (brk) break;
                }
            }

            ans = min(ans, cnt);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int k,s;
    int result = 0;
    std::cin >> k>>s;
    rep(i,k+1){
        rep(j,k+1){
            if(0 <= s-i-j && s-i-j <=k ){
                result++;
            }
        }
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
from operator import mul
from functools import reduce

def cmb(n,r):
    if r==0 or n==r:return 1
    r = min(n-r,r)
    ue = reduce(mul, range(n, n-r, -1))
    shita = reduce(mul, range(1,r+1))
    return ue//shita

n=int(input())
l=[input() for i in range(n)]
for i in range(n):
	l[i]="".join(sorted(l[i]))
l.sort()
cnt=ans=0
ref=[]
for i,j in zip(l,l[1:]):
	if i==j:
		cnt+=1
	else:
		ref.append(cnt)
		cnt=0
ref.append(cnt)
for i in ref:
	if i!=0:
		ans+=cmb(i+1,2)
print(ans)

Measured memory_bytes: 70616
# ABC141E - Who Says a Pun?
class RollingHash:
    def __init__(self, source: str, base=1000000007, mod=9007199254740997):
        self.source = source
        self.length = len(source)
        self.base = base
        self.mod = mod
        self.hash = self._get_hash_from_zero()
        self.power = self._get_base_pow()

    def _get_hash_from_zero(self):  # compute hash of interval [0, right)
        cur, hash_from_zero = 0, [0]
        for e in self.source:
            cur = (cur * self.base + ord(e)) % self.mod
            hash_from_zero.append(cur)
        return hash_from_zero

    def _get_base_pow(self):  # computer mod of power of base
        cur, power = 1, [1]
        for i in range(self.length):
            cur *= self.base % self.mod
            power.append(cur)
        return power

    def get_hash(self, l: int, r: int):  # compute hash of interval [left, right)
        return (self.hash[r] - self.hash[l] * self.power[r - l]) % self.mod


def main():
    N = int(input())
    S = input().rstrip()
    rh, ok, ng = RollingHash(S, 1007, 10 ** 9 + 7), 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        flg, memo = 0, set()
        for i in range(N - 2 * mid + 1):
            memo.add(rh.get_hash(i, i + mid))
            if rh.get_hash(i + mid, i + 2 * mid) in memo:
                flg = 1
                break
        if flg:
            ok = mid  # next mid will be longer
        else:
            ng = mid  # next mid will be shorter
    print(ok)  # max length of substrings appeared twice or more


if __name__ == "__main__":
    main()

Measured memory_bytes: 20172
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1005;
struct lpl{double x, y, r;}node[maxn];
struct ld{
	int num; double d;
	bool operator < (const ld &A)const{return d > A.d;}
};
int n, s, t;
double dis[maxn][maxn];
double ddd[maxn];
priority_queue<ld> q;
bool vis[maxn];

inline double Dis(double x1, double y1, double x2, double y2){return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));}

inline void dijkstra(){
	q.push((ld){s, 0});
	while(!q.empty()){
		ld now = q.top(); q.pop(); if(vis[now.num]) continue;
		vis[now.num] = true; 
		if(now.num == t){printf("%.10lf", now.d); return;}
		for(int i = 1; i <= t; ++i){
			if(i == now.num) continue;
			if(ddd[i] > now.d + dis[now.num][i]){
				ddd[i] = now.d + dis[now.num][i];
				q.push((ld){i, ddd[i]});
			}
		}
	}
}

inline void check(){
	for(int i = 0; i <= t; ++i){
		for(int j = i + 1; j <= t; ++j){
			printf("dis[%d][%d] = %lf\n", i, j, dis[i][j]);
		}
	}
}

int main()
{
	//freopen("lpl.in", "r", stdin);
	lpl qaq;
	scanf("%lf%lf%lf%lf", &node[s].x, &node[s].y, &qaq.x, &qaq.y); scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%lf%lf%lf", &node[i].x, &node[i].y, &node[i].r);
	t = n + 1; node[t] = qaq;
	for(int i = 1; i <= t; ++i) ddd[i] = 1e17;
	for(int i = 0; i <= t; ++i)
		for(int j = 0; j <= t; ++j)
			dis[i][j] = 1e17;
	for(int i = 1; i <= n; ++i){
		dis[s][i] = max(0.0, Dis(node[s].x, node[s].y, node[i].x, node[i].y) - node[i].r);
		dis[i][t] = max(0.0, Dis(node[t].x, node[t].y, node[i].x, node[i].y) - node[i].r);	
	}
	dis[s][t] = max(0.0, Dis(node[s].x, node[s].y, node[t].x, node[t].y));
	//check();
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j)
			dis[i][j] = dis[j][i] = max(0.0, Dis(node[i].x, node[i].y, node[j].x, node[j].y) - node[i].r - node[j].r);
	
	dijkstra();
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  ll n, m;
  cin >> n >> m;
  vll k(m), p(m);
  vvll s(m);
  rep(i, 0, m){
    cin >> k.at(i);
    rep(j, 0, k.at(i)) {
      ll ss;
      cin >> ss;
      ss--;
      s.at(i).push_back(ss);
    }
  }
  vin(p);
  ll ans = 0;
  rep(bit, 0, 1<<n){
    bool check = true;
    rep(i, 0, m){
      ll on = 0;
      vrep(j, s.at(i))if(bit & 1<<j) on++;
      if(on % 2 != p.at(i))check = false;
    }
    if(check) ans++;
  }
  cout << ans << endl;
}

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

int main()
{
    ll n, m, ans = 0;
    cin >> n >> m;
    priority_queue<ll> pq;
    rep(i, n)
    {
        ll a;
        cin >> a;
        pq.push(a);
    }

    rep(i,m){
        ll top=pq.top()/2;
        pq.pop();
        pq.push(top);
    }

    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }

    // ll a[n];
    // rep(i, n) cin >> a[i];
    // sort(a, a + n, greater<>());
    // while (m > 0)
    // {
    //     a[0] /= 2;
    //     m--;
    // }
    // rep(i, n) ans += a[i];
    cout << ans << endl;
    // rep(i, n) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 4324
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    bool cnt[8] = {};
    int N,ov = 0,a;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> a;
        if(a >= 3200)ov++;
        else cnt[a/400]++;
    }
    int sum = accumulate(cnt,cnt+8,0);
    if(ov == N)cout << 1 << " " << N << endl;
    else cout << sum << " " << sum+ov << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	if (abs(b - a) >= abs(c - a)) {
		printf("B\n");
	}
	else {
		printf("A\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,M;
    cin>>N>>M;
    vi H(N);
    for(int i=0;i<N;i++){
        cin>>H[i];
    }

    vvi tonari(N,vi(0));
    for(int i=0;i<M;i++){
        int A,B;
        cin>>A>>B;
        A--;B--;
        tonari[A].push_back(B);
        tonari[B].push_back(A);
    }
    int ans=0;
    for(int i=0;i<N;i++){
        int L=tonari[i].size();
        bool ok=true;
        for(int j=0;j<L;j++){
            if(H[i]<=H[tonari[i][j]]){
                ok=false;break;
            }
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8804
#include<stdio.h>

int main()
{
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if(x-r>=0&&y-r>=0&&x+r<=w&&y+r<=h) printf("Yes\n");
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

typedef long long ll;

using namespace std;

int main(){

    ll ans=0;
    
    ll k,n;
    cin>>k>>n;
    vector<ll> a;

    for(int i=0;i<n;i++){
        ll b=0;
        cin>>b;
        a.push_back(b);
    }

    vector<ll> d;

    for(int i=0;i<n-1;i++){
        d.push_back(a[i+1]-a[i]);
    }
    d.push_back(a[0]+(k-a[n-1]));

    sort(d.begin(),d.end());

    ans=k-d[n-1];

    cout<<ans<<endl;

  
    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define pqll priority_queue<ll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX


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

	int n;
	cin>>n;
	n%=1000;
	n=(1000-n)%1000;
	cout<<n;
	return 0;
}


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

int main(){
  int a[5];
  bool can = true;
  int w = 0;
  int ans = 0;
  rep(i, 5){
    cin >> a[i];
    int b = abs(((a[i] + 9)/10)*10 - a[i]) % 10;
    if(b > w) w = b;
    ans += ((a[i] + 9)/10)*10;
  }
  cout << ans - w << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b;
    char op;
    cin >> a >> op >> b;
    cout << ((op == '+') ? a + b : a - b) << endl;
}


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

using namespace std;

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

  int n;
  cin >> n;
  cout << n * 800 - (n/15) * 200 << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <deque>
#include <algorithm>
#include <queue>
using namespace std;

const long long  MAXN = 1e6 + 5;
const long long  mod = 1e9 + 7;
long long  fact[MAXN];
long long  invfact[MAXN];

//https://awwapp.com/b/u1ilntznq/

bool sieve[MAXN];

long long powe(long long x,  long long y, long long mod)
{
    long long res = 1;

    while (y > 0) {
        if (y & 1)
            res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

void makesieve()
{
  for (long long i = 0; i < MAXN; ++i)
  {
    sieve[i] = 1;
  }
  sieve[0] = 0;
  sieve[1] = 0;
  for (long long i = 2; i*i <= MAXN; ++i)
  {
    for (long long j = 2*i; j < MAXN; j += i)
    {
      sieve[j] = 0;
    }
  }
}

void pre()
{
  fact[0] = 1;
  invfact[0] = 1;
  for (long long  i = 1; i < MAXN; ++i)
  {
    fact[i] = (fact[i-1] * i) % mod;
    invfact[i] = powe(fact[i], mod - 2, mod);
  }

  makesieve();
}


long long comb(long long n, long long r)
{
  if(r == 0 || n == r) return 1;
  if(r > n) return 0;
  long long A = (fact[n] * invfact[r]) % mod;
  return (A * invfact[n - r]) % mod;

}

long long gcde(long long a, long long b) {if(a == 0) return b; return gcde(b%a, a);  }

long long gcdExtended(long long a, long long b, long long *x, long long *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    long long x1, y1;
    long long gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

long long modInverse(long long a, long long m)
{
    long long x, y;
    long long g = gcdExtended(a, m, &x, &y);
    return (x%m + m) % m;

}

bool ifcontains(string str, string smlstr)   // brute force
{
  if(str.length() < smlstr.length()) return false;

  for (long long i = 0; i < str.length(); ++i)
  {
    bool fg = 0;

      for (long long j = 0; j < smlstr.length(); ++j)
      {
         if(i + j >= str.length())
          {
            fg = 1;
            break;
          }
         if(smlstr[j] != str[i + j])
         {
          fg = 1;
          break;
         }
      }

      if(!fg) return true;

  }
  return false;
}

/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------*/



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


  long long X, Y;
  cin >> X >> Y;

  long long ans = 0;

  if(X == 0 && Y == 0) {cout << "1\n";
  return 0;}

  for (size_t i = 1; i <= X; i++)
  {
     long long onereq = 2 * i - X;
     long long tworeq = i - onereq;
     if(onereq < 0 || tworeq < 0 ) continue;
     if(onereq > i || tworeq > i ) continue;

     long long C = 2 * onereq + tworeq;

     if(C != Y) continue;

     ans += comb(i, onereq);
     ans %= mod;




  }

  cout << ans << "\n";





  return 0;
}


// g++ -std=c++11


Measured memory_bytes: 16896
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,fa[100005],f[100005];
int find(int x)
{
	if (x==fa[x]) return x;
	int y=find(fa[x]);
	f[x]+=f[fa[x]];
	fa[x]=y;
	return fa[x];
}
void merge(int x,int y,int z)
{
	int fx=find(x),fy=find(y);
	if (fx==fy)
	{
		if (f[y]-f[x]!=z) 
		{
			cout<<"No";
			exit(0);
		}
		return; 
	}
	fa[fy]=fx;
	f[fy]+=f[x]+z-f[y];
}
int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		fa[i]=i;
		f[i]=0;
	}
	int x,y,z;
	for (int i=1;i<=m;i++)
	{
		scanf("%d %d %d",&x,&y,&z);
		if (z<0)
		{
			int t=x;
			x=y;
			y=t;
			z=-z;
		}
		merge(x,y,z);
//		for (int i=1;i<=n;i++) cout<<fa[i]<<' '<<f[i]<<'\n';
//		cout<<'\n';
	}
	cout<<"Yes";
//	int ans=0;
//	for (int i=1;i<=n;i++)
//	{
//		find(i);
//		ans=max(f[i],ans);
//	}
//	cout<<ans;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b * 2) << endl;
    return 0;
}

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

long long n, m, sum = 0, cnt = 0;
vector<long long> a;

int main() {
  cin >> n >> m;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(auto p : a) sum += p;
  for(int i = 0; i < n; ++i)
    if(a[i] * 4 * m >= sum) ++cnt;
  if(cnt >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
ans = ""
if k-1 == 0:
    ans += s[k-1].lower()
    ans += s[k:]
elif k-1 == n-1:
    ans += s[:k-1]
    ans += s[k-1].lower()
else:
    ans += s[:k-1]
    ans += s[k-1].lower()
    ans += s[k:]

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
vector<int> v;
vector<int> v2;

signed main(){
  int n;
  cin >>n;
  REP(i,pow(2,n)){
    int k;
    cin >> k;
    v.pb(-k);
  }
  v.pb(INF);
  sort(v.begin(),v.end());
  v2.pb(v[0]);
  v[0]=-INF;
  REP(i,n){
    sort(v.begin(),v.end());
    sort(v2.begin(),v2.end());
    REP(j,pow(2,i)){
      int k2 = v2[j];
      int t2 = lower_bound(v.begin(),v.end(),k2+1)-v.begin();
      if(v[t2]==INF){
        cout << "No" << endl;
        return 0;
      }
      v2.pb(v[t2]);
      v[t2]=-INF;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

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

    if (A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 1; i < N; i++) {
        if (A[i] - A[i - 1] > 1) {
            cout << -1 << endl;
            return 0;
        }
    }

    uint64_t ans = 0;
    vector<int64_t> X(N, 0);
    for (int64_t i = N - 1; i >= 1; i--) {
        if (X[i] != A[i]) {
            ans += A[i];
        }
        X[i - 1] = A[i] - 1;
    }

    cout << ans << endl;
}

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

using namespace std;
int main() {
	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

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

	int ans = a[n - 1] - a[0];
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[1000];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int c,b,e;
    cin>>c>>b>>e;
    int mi=1e9+1,ma=-1e9-1;
    for(int i=b;i<e;i++){
      ma=max(ma,a[i]);
      mi=min(mi,a[i]);
    }
    if(!c)cout<<mi<<endl;
    else cout<<ma<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

char a[10],b[10];

int main()
{
	int n;scanf("%d",&n);
	puts("0");fflush(stdout);
	scanf("%s",a);if (a[0]=='V') return 0;
	int l=1,r=n-1;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		printf("%d\n",mid);fflush(stdout);
		scanf("%s",b);if (b[0]=='V') return 0;
		if ((mid&1)^(a[0]!=b[0])) r=mid-1; else l=mid+1;
	} 
	return 0;
}


Measured memory_bytes: 760
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  long int a, b, c, d, ans;
  cin >> a>> b >> c >> d;
  // if (a >= 0 || c >= 0) {
  //   ans = b*d;
  // } else{
  //   ans = a*c;
  // }
  // cout << ans;

  ans = a*c;
  ans = max(ans, a*c);
  ans = max(ans, a*d); 
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  cout << ans;
  
}

Measured memory_bytes: 3632
N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

ab_cnt = 0
a_saigo = 0
b_atama = 0
ba_cnt = 0
for s in s_list:
    ab_cnt += s.count("AB")
    if s[0] =="B":
        b_atama += 1
    if s[-1] == "A":
        a_saigo += 1
    if s[0] =="B" and s[-1] == "A":
        ba_cnt += 1

result = ab_cnt + min(b_atama,a_saigo)
if b_atama == ba_cnt and a_saigo == ba_cnt and ba_cnt != 0:
    result += -1

print(result)

Measured memory_bytes: 45016
#include "stdio.h"
#include <iostream>
#include <string>
#include <vector>
#include <cctype>

using namespace std;

int main(){
    string s;
    int C = 0;
    cin >> s;
    if(s[0] == 'A'){
        if(s.size() > 4){
            int sumc = 0;
            for(int i=2;i<=s.size()-2;i++){
               if(s[i] == 'C'){
                    sumc++;   
                    C = i;
                }
            }
            if(sumc == 1){
                bool flag = true;
                for(int i=1;i<s.size();i++){
                    if(i == C)continue;
                    if(!islower(s[i]))flag = false;
                }
                if(flag == true){
                    cout << "AC" << endl;
                    return 0;
                }
            }
        }
        else if(s.size() == 4){
            if(s[2] == 'C' && islower(s[1]) && islower(s[3])){
                cout << "AC" << endl;
                return 0;
            }
        }
    }
    cout << "WA" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    ll ans = 0;
    for(int i = 0; i <= min(n,k); i++){
        for(int j = 0; j <= min(n,k)-i; j++){
            ll score = 0;
            priority_queue<ll> pq;
            rep(l,i){
                score += v[l];
                pq.push(-v[l]);
            }
            rep(l,j){
                score += v[n-1-l];
                pq.push(-v[n-1-l]);
            }
            int can_move = k - i - j;
            while(can_move > 0 && !pq.empty()){
                if(pq.top() <= 0) break;
                ll t = pq.top();
                pq.pop();
                score += t;
                can_move--;
            }
            chmax(ans, score);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <vector>
#include <utility>

using namespace std;

using i64=long long;
using vi=vector<int>;
using sIter=set<int>::iterator;

int main() {
    size_t N;
    scanf("%llu", &N);

    vi a(N), b(N+1);
    for (size_t i=0; i<N; ++i) {
        scanf("%d", &a[i]);
        b[a[i]] = i;
    }

    set<int> s; s.insert(-1); s.insert(N);

    i64 res=0;
    for (size_t i=1; i<=N; ++i) {
        sIter cur=s.insert(b[i]).first;
        sIter l=cur; --l;
        sIter r=cur; ++r;
        res += i*(b[i]-*l)*(*r-b[i]);
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 11136
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int a,b;
int main(){
    cin>>a>>b;
    if(a*b%2==0)puts("Even");
    else puts("Odd");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int calcComb(ll n, ll r){
	ll num=1;
	for(ll i=1; i<=r; i++){
		num=num*(n-i+1)/i;
	}
	return num;
}
int main() {
	ll n;
	cin >> n;
	ll ans=1;
	ll res[1001]={0};
	for(int num=2; num<=n; num++){
		int c = num;
		for(int i=2; i<=num; i++){
			while(c%i==0){
				res[i]++;
				c/=i;
			}
		}
	}
	for(int i=2; i<=n; i++){
		if(res[i]){
			//cout << i<< " " << res[i] << endl;
			ans*=res[i]+1;
			ans%=1000000007;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = list(map(int, input().split()))

import heapq
a = [-1*i for i in a]
heapq.heapify(a)
for i in range(M):
    b = heapq.heappop(a)
    b = (-1*b)//2
    heapq.heappush(a, -1*b)
print(-1*sum(a))

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

int main(){
	int A,B,C,X;
	cin >> A >> B >> C >> X;
	int ans = 0;
	for(int a = 0; a <= A; a++){
	for(int b = 0; b <= B; b++){
	for(int c = 0; c <= C; c++){
		int sum = 500*a + 100*b + 50*c;
		if(sum == X){
			ans++;
		}
	}
}
}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <unordered_map>
#define ele int
using namespace std;
#define maxn 200010
ele n,tag,f[maxn];
char s[maxn];
unordered_map<ele,ele> mp;
int main(){
	scanf("%s",s); n=strlen(s);
	f[0]=0; tag=0;
	mp[0]=0;
	for (int i=1; i<=n; ++i){
		f[i]=1e9;
		tag^=1<<(s[i-1]-'a');
		for (int j=0; j<26; ++j){
			ele x=tag^(1<<j);
			if (mp.find(x)!=mp.end()) f[i]=min(f[i],mp[x]+1);
		}
		if (mp.find(tag)!=mp.end()){
			f[i]=min(f[i],mp[tag]+1);
			mp[tag]=min(mp[tag],f[i]);
		}
		else mp[tag]=f[i];
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 9416
fun main(args : Array<String>) {
  val n = readLine()
  val a =  readLine()!!.split(" ").map{ it.toInt() }
  val b =  readLine()!!.split(" ").map{ it.toInt() }
  val c =  readLine()!!.split(" ").map{ it.toInt() }
  var score: Int = 0
  var last: Int = -10
  for(i in 0 until a.size){
    score += b[a[i] - 1]
    if(last + 1 == a[i]){
      score += c[a[i] - 1 - 1]
    }
    last = a[i]
  }
  println(score)
}

Measured memory_bytes: 37820
#include <iostream>                                             
#include <algorithm>                                            
#define N 10                                                    
#define Top 3                                                   
using namespace std;                                            
                                                                
int main() {                                                    
  int data[N];                                                  
  for (int i=0; i<N; i++) {                                     
    cin >> data[i];                                             
  }                                                             
  sort(data,data+N);                                            
  reverse(data,data+N);                                         
  for (int i=0; i<Top; i++) {                                   
    cout << data[i] << endl;                                    
  }                                                             
  return 0;                                                     
}                     

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

public class Main {
  private static String solve(char[] cs) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < cs.length; i++) {
      sb.append("x");
    }
    return sb.toString();
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] cs = reader.nextCharArray();
    out.println(solve(cs));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication27
{
    class Program
    {
        static void Main()
        {
            List<int> s = new List<int>();
            int x = 0;
            int y = 0;
            List<int> z = new List<int>();
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) break;//????????????
                int b = int.Parse(a);
                s.Add(b);
            }
            s.Sort();
            for (int c = 1; c < s[s.Count - 1] + 1; c++)
            {
                int b;
                for (b = 0; b < s.Count; b++)
                {
                    if (s[b] == c) x++;//?????§??°??????????????????
                }
                if (x > y)
                {
                    for (int f = 0; f < z.Count; f++)
                    {
                        z[f] = -1;//??????????????§???????????°??¨????????????????????????????°?????¶????????????????
                    }
                    z.Add(c); y = x;
                }
                else if (x == y) { z.Add(c); }//????????????????°?????¶????
                x = 0;
            }
            for (int t = 0; t < z.Count; t++)
            {if(z[t]!=-1) Console.WriteLine(z[t]); }
        }
    }
}

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

#define LL long long
LL x, y, z, u, d;
vector<LL> a, b, c;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    cin >> x >> y >> z >> d;

    for(int i = 0; i < x; i++) cin >> u, a.push_back(u);
    for(int i = 0; i < y; i++) cin >> u, b.push_back(u);
    for(int i = 0; i < z; i++) cin >> u, c.push_back(u);

    sort(a.rbegin(), a.rend()), sort(b.rbegin(), b.rend()), sort(c.rbegin(), c.rend());
    
    vector<LL> ans, f;
    for(int i = 0; i < x; i++) 
        for(int j = 0; j < y; j++)
            f.push_back(a[i] + b[j]);
    sort(f.rbegin(), f.rend());

    for(int i = 0; i < min(x*y, d); i++)
        for(int j = 0; j < z; j++)
            ans.push_back(f[i] + c[j]);
    sort(ans.rbegin(), ans.rend());

    for(int i = 0; i < d; i++) cout << ans[i] << '\n';
}

Measured memory_bytes: 44088
while true
    x = gets.to_i
    break if x == 0
    x = 1000 - x
    a, x = x.divmod 500
    b, x = x.divmod 100
    c, x = x.divmod 50
    d, x = x.divmod 10
    e, f = x.divmod 5
    puts a + b + c + d + e + f
end


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

using namespace std;

string s;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e9

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; }

typedef long long ll;

using namespace std;

int main(int argc, char const *argv[])
{
    int ans = 0;
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(30);
    REP(i, M) cin >> B[i];
    vector<vector<int>> A(30, vector<int>(30));
    REP(i, N)
    {
        REP(j, M) cin >> A[i][j];
    }
    
    REP(i, N)
    {
        int tmp = 0;
        REP(j, M) tmp += A[i][j] * B[j];

        if (tmp + C > 0)    
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin>>n;
	cin>>k;
	int i;
	int s;
	int a;
	s=0;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(k-a>a) s=s+a+a;
		else s=s+k-a+k-a;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())

zoro = 0
res = 0

for i in range(n):
    d1, d2 = map(int, input().split())

    if d1 != d2:
        zoro = 0
    else:
        zoro = zoro + 1
    if zoro == 3:
        res = 1

if res == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9176
import sys

X, N = map(int, input().split())
a = input().split()
a = [int(i) for i in a]

ans = 1000
count = 0

if len(a) == 0:
    print(X)
    sys.exit()
else:
    m = max(a)*200
    for i in range(-m, m+1):
        if i in a:
            pass
        else:
            kyori = abs(X-i)
            if ans > kyori:
                ans = kyori
                count = i
            elif ans == kyori:
                count = min(count, i)
            else:
                pass

print(count)


Measured memory_bytes: 9204
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	M = max(A)
	p = A.index(M)
	m = min(A)
	q = A.index(m)
	if m >= 0:
		print(N - 1)
		for i in range(N - 1):
			print(i + 1, i + 2)
	else:
		if abs(M) > abs(m):
			print(2 * N - 1)
			for i in range(N):
				print(p + 1, i + 1)
			for i in range(N - 1):
				print(i + 1, i + 2)
		else:
			print(2 * N - 1)
			for i in range(N):
				print(q + 1, i + 1)
			for i in range(N - 1):
				print(N - i, N - 1 - i)

if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();

	int A[100000];
	rep(i, N) *(A + i) = getint();
	sort(A, A + N);

	pair<int, int> BC[100000];
	rep(i, M) {
		(*(BC + i)).second = getint();
		(*(BC + i)).first = getint();
	}
	sort(BC, BC + M);

	int kazu = 0;
	int B[100000] = {};
	for (int i = M - 1; i >= 0; i--) {
		rep(j, BC[i].second) {
			if (kazu >= N) break;
			*(B + kazu) = BC[i].first;
			kazu++;
		}
	}

	ll kotae = 0;
	rep(i, N) kotae += max(A[i], B[i]);

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; (i) < (int) (n); (i) ++)
using namespace std;
 
int main() {
        int n;
        scanf("%d", &n);
        vector<long long> cur(3);
        rep(i, n) {
                int a, b, c;
                scanf("%d%d%d", &a, &b, &c);
                vector<long long> next(3);
                next[0] = max(cur[1] + a, cur[2] + a);
                next[1] = max(cur[0] + b, cur[2] + b);
                next[2] = max(cur[0] + c, cur[1] + c);
                rep(i, 3) swap(cur[i], next[i]);
        }
        printf("%lld\n", max({cur[0], cur[1], cur[2]}));
        return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve()
{
    int h , w , k;
    cin >> h >> w >> k;
    char grid[h][w];
    rep(i,h)
        rep(j,w)
            cin >> grid[i][j];
    int t1 = pow(2,h) , t2 = pow(2,w) , ans = 0;
    rep(i,t1)
        rep(j,t2)
        {
            int ft = 0;
            rep(x,h)
                rep(y,w)
                {
                    if(grid[x][y]=='.')
                        continue;
                    if(( ((int)pow(2,x)&i) != (int)pow(2,x)) && (((int)pow(2,y) & j) != (int)pow(2,y)))
                        ft++;
                }
            if(ft==k)
                ans++;
        }
    cout << ans << endl;
}

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <set>
using namespace std;
multiset<int> s;
vector<int> v;
signed main(){
    int n, x;
    cin >> n;
    int N = 1<<n;
    for(int i = 0; i < N; i++)
        cin >> x, s.insert(x);
    v.push_back(*prev(s.end()));s.erase(*prev(s.end()));
    for(int i = 1; i < N; i<<=1){
        for(int j = 0; j < i; j++){
            auto it = s.lower_bound(v[j]);
            if(it == s.begin())return cout << "No\n", 0;
            v.push_back(*(--it));
            s.erase(it);
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 13692
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


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

int main(void) {
    int m, nmin, nmax;
    while(cin >> m >> nmin >> nmax && m) {
        vector<int> p(m);
        REP(i, m) scanf("%d", &p[i]);
        sort(p.begin(), p.end(), greater<int>());
        int gap = 0;
        int ans = 0;
        for(int i=nmin-1; i<nmax; ++i) {
            if(p[i]-p[i+1] >= gap) {
                gap = p[i]-p[i+1];
                ans = i+1;
            }
        }
        printf("%d\n", ans);
    }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, D);
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) cin >> s[i][j];

  vector<int> t(D);
  rep(i, D) {
    cin >> t[i];
    --t[i];
  }

  int sat = 0;
  vector<set<int>> held(26, {0});
  rep(i, D) {
    sat += s[i][t[i]];
    held[t[i]].insert(i + 1);
  }
  rep(i, 26) {
    set<int>& h = held[i];
    h.insert(D + 1);
    auto it = h.begin();
    ++it;
    for (; it != h.end(); ++it) {
      auto jt = it;
      --jt;
      int n = (*it - *jt - 1);
      sat -= c[i] * n * (n + 1) / 2;
    }
  }

  in(int, m);
  while (m--) {
    in(int, d, q);
    --d, --q;
    assert(q != t[d]);

    {
      sat -= s[d][t[d]];
      auto it = held[t[d]].find(d + 1);
      assert(it != held[t[d]].end());
      auto jt = it;
      --jt;
      int n = (*it - *jt);
      jt = it;
      ++jt;
      sat -= c[t[d]] * (*jt - *it) * n;
    }

    held[t[d]].erase(d + 1);
    t[d] = q;
    assert(held[t[d]].count(d + 1) == 0);
    held[t[d]].insert(d + 1);

    {
      sat += s[d][t[d]];
      auto it = held[t[d]].find(d + 1);
      assert(it != held[t[d]].end());
      auto jt = it;
      --jt;
      int n = (*it - *jt);
      jt = it;
      ++jt;
      sat += c[t[d]] * (*jt - *it) * n;
    }

    out(sat);
  }
}


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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main(){
    ll n; cin >> n;
    ll ans = 0;
    vector<ll> A(n), S(n+1, 0);
    rep(i, n) cin >> A[i];
    rep(i, n) S[A[i]]++;
    rep(i, n+1) {
        if(S[i] > 1) ans += S[i] * (S[i]-1) / 2;
    }
    rep(i, n) {
        cout << ans - S[A[i]] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 6428