akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b;
    cin >> a>>b;
    if(a==1){
      a=14;
    }
    if(b==1){
      b=14;
    }
    if(a>b){
    cout<<"Alice"<<endl;
    }
    else if(a==b){
      cout<<"Draw"<<endl;
    }else{
      cout<<"Bob"<<endl;
    }
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, b: [usize; n-1]};

    let mut v: Vec<usize> = vec![0; n];

    for i in 0..n - 1 {
        if v[i] < b[i] && i != 0 {
            v[i + 1] = b[i]
        } else {
            v[i] = b[i];
            v[i + 1] = b[i]
        }
    }

    println!("{}", v.iter().sum::<usize>())
}


Measured memory_bytes: 2204
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main()
{
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  int max_num = max(A, C);

  for(int i = max_num; i > 0; i--){
    
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }

    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

int main(void){
    int a,b,k,i;
    scanf("%d%d%d",&a,&b,&k);
    if(a+k>b-k){
        for(i=a;i<=b;i++){
            printf("%d\n",i);
        }
    }else{
        for(i=a;i<a+k;i++){
            printf("%d\n",i);
        }
        for(i=b-k+1;i<=b;i++){
            printf("%d\n",i);
        }
    }
    return 0;
}

Measured memory_bytes: 128
local DBG = false
function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

function dbgpr_t(tbl)
    if DBG then
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in ipairs(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end

function dbgpr_t2d(tbl2d)
    if DBG then
        dbgpr(tbl2d)
        for i,t in ipairs(tbl2d) do
            io.write("[dbg]")
            for j,v in ipairs(t) do
                io.write("(" .. tostring(i) .. "," .. tostring(j) .. "): ")
                io.write(tostring(v))
                io.write("; ")
            end
            print("")
        end
    end
end

function create_tbl(a, initial)
    local tbl = {}
    for i=1,a do
        tbl[i] = initial
    end
    return tbl
end

function create_2d_tbl(a, b, initial)
    local tbl = {}
    for i=1,a do
        local t = {}
        for j=1,b do
            t[j] = initial
        end
        tbl[i] = t
    end
    return tbl
end

function parse_problem()
    local N, M = io.read("n", "n")
    local bridges = {}
    for i=1, M do
        local a, b = io.read("n", "n")
        bridges[i] = {a, b}
    end
    return N, M, bridges
end

perf = 0

function main()
    local N, M, bridges = parse_problem()
    parents = {}
    for i=1,N do
        parents[i] = -1
    end
    local function find_union(a, b)
        local x, y = a, b
        while parents[x] > 0 do
            x = parents[x]
        end
        while parents[y] > 0 do
            y = parents[y]
        end
        local size_a, size_b = -parents[x], -parents[y]
        if x ~= y then
            if size_b > size_a then
                x, y = y, x
            end
            -- size(x) > size(y)
            -- x is new root of y
            parents[x] = parents[x] + parents[y]
            parents[y] = x
        end
        return x == y, size_a, size_b
    end
    dbgpr(N, M)
    dbgpr("====bridges")
    dbgpr_t2d(bridges)
    local ans_tbl = {}
    ans_tbl[M] = N * (N - 1) // 2
    dbgpr("M, ansM: ", M, ans_tbl[M])
    for i=M,1,-1 do
        local a, b = bridges[i][1], bridges[i][2]
        local same_group, size_a, size_b = find_union(a, b)
        --dbgpr(i, a, b, same_group, size_a, size_b, size_a * size_b)
        if same_group then
            ans_tbl[i-1] = ans_tbl[i]
        else
            ans_tbl[i-1] = ans_tbl[i] - size_a * size_b
        end
    end
    for i=1,M do
        print(ans_tbl[i])
    end
end

main()


Measured memory_bytes: 24168
#include <iostream>
using namespace std;
int main(){
  bool ans = false;
  string a, b;
  cin >> a >> b;
  for(int i=0;i<a.size();++i){
    int j;
    for(j=0;j<b.size();++j)
      if(a[(i+j)%a.size()] != b[j]) break;
    if(j == b.size())
      ans = true;
  }

  cout << (ans? "Yes": "No") << endl;

  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v) {
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v) {
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    {os << (i > 0 ? "," : "") << v.at(i);}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int>a(n), b(n), c(n - 1);
  std::cin >> a >> b >> c;
  auto ret = 0;
  ret += std::accumulate(all(b), 0);
  int prv = -2;
  for (auto x : a) {
    x--;
    if (x - prv == 1) ret += c.at(prv);
    prv = x;
  }
  std::cout << ret << std::endl;
  return 0;
}

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

int ko(int a,int b,int c){
  int ans;
  ans=min(a,b);
  ans=min(ans,c);
  for(int i=1;i<200;i++){
    if(ans%i!=0) continue;
    int ya=ans/i;
    if(a%ya==0&&b%ya==0){
      if(c%ya==0) return(ya);
    }
  }
}

int main(){
  int K;
  cin>>K;
  int a,b,c;
  long long ans=0;
  int sum;
  for(a=1;a<=K;a++){
    for(b=1;b<=K;b++){
      for(c=1;c<=K;c++){
        sum=ko(a,b,c);
        ans+=sum;
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

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

  int ans = 1;
  for(int i = 0;i<n;i++){
    ans = min(ans*2,ans+k);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int N, M;
    cin >> N >> M;

    vector<int> H(N);
    vector<bool> is_good(N, true);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        if (H[A] <= H[B]) {
            is_good[A] = false;
        }
        if (H[A] >= H[B]) {
            is_good[B] = false;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (is_good[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, m;
    cin >> n >> m;
    vector<ll> A(n);
    vector<ll> CulA(n+1);
    map<ll, ll> mp;
    CulA[0] = 0;
    mp[0] = 1;
    ll ans = 0;
    for(int i=0; i<n; i++){
        cin >> A[i];
        CulA[i+1] = CulA[i] + A[i];
        ans += mp[CulA[i+1] % m];
        mp[CulA[i+1] % m]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll h, w, a, b;
    int n;
    map<pair<ll, ll>, int> ab;
    ll cnt[100010];

    int delx[] = {0, -1, -2, 0, 0, -1, -1, -2, -2};
    int dely[] = {0, 0, 0, -1, -2, -1, -2, -1, -2};

    int cntit = 0;

    cin >> h >> w >> n;
    rep(i, n){
        cin >> a >> b;
        rep(i, 9){
            if(a + dely[i] <= 0 || h-2 < a + dely[i] || b + delx[i] <= 0 || w-2 < b + delx[i]) continue;
            ab[make_pair(a + dely[i], b + delx[i])]++;
            //cout << a << " " << b << " " << a + dely[i] << " " << b + delx[i] << endl;
        }
    }
    //cout << endl;
    //for(auto abb : ab) cout << abb.first << " " << abb.second << endl;

    ll res[10];
    rep(i, 10){
        res[i] = 0;
    }

    for(auto m : ab){
        res[m.second]++;
    }

    ll sum = 0;
    rep(i, 10){
        sum += res[i];
    }

    rep(i, 10){
        if(i == 0 && (h-2)*(w-2) - sum > 0){
            cout << (h-2)*(w-2) - sum << endl;
        }else{
            cout << res[i] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 56576
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5;
typedef long long ll;

int main(){
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int s = 0;	
	if(m1 <= m2){
		s = (h2 - h1) * 60 + (m2 - m1);
	}
	else {
		s = (h2 - h1 - 1) * 60 + (60 - m1 + m2);
	}
	cout << s - k;
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////
// 区間更新、区間最小の遅延セグメントツリー
struct RMQRUQ {
    ll n;
    vector<ll> dat, lazy;
    
    RMQRUQ(){}
    RMQRUQ(ll n_) {
        n = 1; while(n < n_) n *= 2;
        dat.assign(n*2, inf);
        lazy.assign(n*2, inf);
    }
    
    void eval(ll len,ll k) {
        if(lazy[k] == inf) return;
        if(k*2+1 < n*2-1) {
            lazy[2*k+1] = lazy[k];
            lazy[2*k+2] = lazy[k];
        }
        dat[k] = lazy[k];
        lazy[k] = inf;
    }
    
    // [a, b)
    ll update(ll a, ll b, ll x, ll k, ll l, ll r) {
        eval(r-l, k);
        if(b <= l || r <= a) return dat[k];
        if(a <= l && r <= b) {
            lazy[k] = x;
            return lazy[k];
        }
        return dat[k] = min(update(a, b, x, 2*k+1, l, (l+r)/2), update(a, b, x, 2*k+2, (l+r)/2, r));
    }
    ll update(ll a, ll b, ll x) { return update(a, b, x, 0, 0, n); }
    
    // [a, b)
    ll query(ll a, ll b, ll k, ll l, ll r) {
        eval(r-l, k);
        if(b <= l || r <= a) return inf;
        if(a <= l && r <= b) return dat[k];
        ll vl = query(a, b, 2*k+1, l, (l+r)/2);
        ll vr = query(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
    ll query(ll a, ll b) { return query(a, b, 0, 0, n); }
};
/////////////////////////////////////////////////////////////

int main(){
    ll n,q;cin>>n>>q;
    RMQRUQ u(n);
    u.update(0,n,(1LL<<31)-1);
    
    while(q--){
        ll c,x,y;
        cin>>c>>x>>y;
        if(c==0){
            u.update(x,x+1,y);
        }else{
            cout<<u.query(x,y+1)<<endl;
        }
    }
    
    return 0;
}




Measured memory_bytes: 6996
m = input().split()
N = int(m[0])
A = int(m[1])
B = int(m[2])
sum = 0

for n in range(N + 1):
  y = 0
  s = n
  while s > 0:
    y += s % 10
    s = s // 10

  if (y >= A) and (y <= B):
    sum += n

print(sum)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int x1,x2,x3,x4,y1,y2,y3,y4;
int dx,dy;
int main()
{
    cin>>x1>>y1>>x2>>y2;
    dx = x2-x1;
    dy = y2-y1;
    x3 = x2-dy;
    y3 = y2+dx;
    x4 = x3-dx;
    y4 = y3-dy; 
    cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;
    return 0;
}


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

#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int dp[1000000];
int a[1000000];

int solve(int i, int n)
{
    if(i==(n-1)) return 0;
    if(dp[i]!=-1) return dp[i];

    int ans = abs(a[i]-a[i+1]) + solve(i+1,n);
    if(i+2<n)
        ans = min(ans, abs(a[i]-a[i+2]) + solve(i+2,n));
    return dp[i] = ans;
}

int main()
{
    FIO;
    int n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; i++)
        cin >> a[i];

    cout << solve(0, n) << endl;
    return 0;
}


Measured memory_bytes: 14160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<string> S(N);
	REP(i, N)
	{
		cin >> S[i];
	}
	string T;
	cin >> T;
	int c1 = 0, c2 = 0;
	REP(i, N)
	{
		bool f = false, s = false;
		bool dif = false;
		REP(j, min(SZ(T), SZ(S[i])))
		{
			if (S[i][j] == '?')
			{
				if (T[j] == 'a')
				{
					f = true;
				}
				else if (T[j] == 'z')
				{
					s = true;
				}
				else
				{
					s = true;
					f = true;
					break;
				}
				continue;
			}
			if (S[i][j] < T[j])
			{
				s = true;
				dif = true;
				break;
			}
			else if (S[i][j] > T[j])
			{
				f = true;
				dif = true;
				break;
			}
		}
		if (!dif)
		{
			if (SZ(T) > SZ(S[i]))
				s = true;
			else if (SZ(T) < SZ(S[i]))
				f = true;
			else
			{
				s = true;
				f = true;
			}
		}
		if (f && (!s))
			c1++;
		if (s && (!f))
			c2++;
	}
	vi Ans;
	REP(i, N + 1)
	{
		if (i < c2)
			continue;
		if (i >= (N - c1 + 1))
			continue;
		Ans.push_back(i + 1);
	}
	REP(i, SZ(Ans))
	{
		if (i != 0)
			cout << " ";
		cout << Ans[i];
	}
	cout << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

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

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

  string ans = "";
  ll now = N;
  while(1){
    if(now%26 == 0) ans += 'z';
    else ans += char(now % 26 + 'a' - 1);
    if(1 <= now && now <= 26) break;    
    now = (now-1)/26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n;
    cin >> n;
    V<Pii> v;
    REP2(i, 1, n+1) {
        int a;
        cin >> a;
        v.push_back(make_pair(i, a));
    }

    sort(ALL(v), [](const Pii &a, const Pii &b) {
        return a.second < b.second;
    });

    FOR(i, v) {
        std::cout << i->first << ' ';
    }
    std::cout << '\n';

    return 0;
}


Measured memory_bytes: 1780
#!/usr/bin/env python3



numbers = input().split(" ")

x = [int(numbers[0]), int(numbers[1])]
y = [int(numbers[2]), int(numbers[3])]

if(int(numbers[0]) < 0 and int(numbers[1]) > 0):
    x.append(0)
if(int(numbers[2]) < 0 and int(numbers[3]) > 0):
    y.append(0)

xy = x[0] * y[0]

for xx in x:
    for yy in y:
        if xx * yy > xy:
            xy = xx * yy

print(xy)




Measured memory_bytes: 9200
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    char w[n][101];
    for(int i = 0; i < n; i++){
        scanf("\n%s",w[i]);
    }

    bool check = true;
    for(int i = 0; i + 1 < n; i++){
        if(w[i][strlen(w[i]) - 1] != w[i + 1][0]){
            check = false;
            break;
        }
    }
    if(check == false){
        printf("No\n");

        return 0;
    }

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(strcmp(w[i],w[j]) == 0){
                check = false;
            }
        }
    }

    if(check == true){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  ABC169C

#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[]) {
    long long  A,iB,ans;
    double B;
    cin>>A>>B;
    iB=B*100+0.5; // 実数→整数の誤差を吸収する
    ans=A*iB/100;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3260
N=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
S = 0

for i in range(N):
    S += B[A[i]-1]


for i in range(N-1):
    if A[i]-A[i+1] == -1:
        S += C[A[i]-1]
print(S)


Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
int32_t main()
{           
    IOS;   
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i!=0)
            continue;
        ll a=n/i-1;
        ll b=i-1;
        if(a!=0&&n/a==n%a)
            ans+=a;
        if(b!=0&&n/b==n%b)
            ans+=b;
    }
    cout<<ans;
}

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

typedef long long int ll;

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

    if(s[s.size() - 1] == '2' || s[s.size() - 1] == '4' || s[s.size() - 1] == '5' || s[s.size() - 1] == '7' || s[s.size() - 1] == '9'){
        cout << "hon";
    }
    else if(s[s.size() - 1] == '3'){
        cout << "bon";
    }
    else{
        cout << "pon";
    }
    
    return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll n,temp=0,i,j,num,n1=0;
  cin>>n;
  ll arr[n]={0};
  cin>>arr[0];
  for(i=1;i<n;i++){
    cin>>num; arr[i]=num^arr[0];
    n1 = n1^num;
  }
  cout<<n1<<" ";
  for(i=1;i<n;i++){
    cout<<(arr[i]^n1)<<" ";
  }
}

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

int main() {
	long long n,m,i,j,k,ans,cur,mod=1000000007;
	cin >> n;
	vector<long long> a(n),s(n);
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	s[0]=a[0];
	for(i=1; i<n; i++){
		s[i]=s[i-1]+a[i];
		s[i]%=mod;
	}
	
	ans=0;
	for(i=1; i<n; i++){
		ans+=a[i]*s[i-1];
		ans%=mod;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6424
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
const int MAX_V=1010;
struct edge
{
    int to,cap,rev;
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
};
vector<edge> G[MAX_V];
bool used[MAX_V];
bool sr[MAX_V],tr[MAX_V];
int a[10010],b[10010];
vector<int> v;
void add_edge(int from,int to,int cap)
{
	v.pb(G[from].size());
    edge new_edge1(to,cap,G[to].size());
    G[from].pb(new_edge1);
    edge new_edge2(from,0,G[from].size()-1);
    G[to].pb(new_edge2);
}
int dfs(int v,int t,int f)
{
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++)
    {
        edge &e=G[v][i];
        if(!used[e.to]&&e.cap>0)
        {
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0)
            {
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
void dfs1(int v)
{
    sr[v]=true;
    for(int i=0;i<G[v].size();i++)
    {
        edge &e=G[v][i];
        if(!sr[e.to]&&e.cap>0)dfs1(e.to);
    }
    return;
}
void dfs2(int v)
{
    tr[v]=true;
    for(int i=0;i<G[v].size();i++)
    {
        edge &e=G[v][i];
        if(!tr[e.to]&&e.cap==0)dfs2(e.to);
    }
    return;
}
int flow=0;
int N,M,S,T;
int max_flow(int s,int t)
{
    for(;;)
    {
        memset(used,0,sizeof(used));
        int f=dfs(s,t,INF);
        if(f==0)return flow;
        flow+=f;
    }
}

int main()
{
	while(1)
	{
		flow = 0;
		v.clear();
		for(int i=0;i<1010;i++)G[i].clear();
		memset(sr,false,sizeof(sr));
		memset(tr,false,sizeof(tr));
		scanf("%d %d %d %d",&N,&M,&S,&T);
		if(N==0&&M==0&&S==0&&T==0)break;
		S--;T--;
		for(int i=0;i<M;i++)
		{
		    scanf("%d %d",&a[i],&b[i]);
		    a[i]--;b[i]--;
		    add_edge(a[i],b[i],1);
		}
		max_flow(S,T);
		dfs1(S);
		dfs2(T);
		//for(int i=0;i<N;i++)printf("%d %d\n",sr[i],tr[i]);
		int ans = 0;
		for(int i=0;i<M;i++)
		{
		    if(G[a[i]][v[i]].cap==0)continue;
		    if(sr[b[i]]&&tr[a[i]])ans++;
		}
		if(ans>0)flow++;
		printf("%d %d\n",flow,ans);
	}
}

Measured memory_bytes: 1900
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, f, i;
  cin >> N;
  i = N;
  while (i > 0) {
      f += i%10;
      i /= 10;
  }
  if (N%f == 0) {
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;string s;cin>>N>>s;
	int L[2*N],R[2*N];
	long res = 1; int cnt = 0; bool flag = true;
	rep(i,0,2*N){
		R[i] = (s[i] == 'W') ^ i % 2;
		L[i] = R[i] ^ 1;
		cnt += L[i] - R[i];
		if(cnt < 0) flag = false;
		if(R[i] == 1) (res *= cnt + 1) %= mod;
	}
	if(!flag || cnt > 0){
		cout<<0<<endl;
		return 0;
	}
	rep(i,1,N+1) (res *= i) %= mod;
	cout<<res<<endl;
}

Measured memory_bytes: 2180
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int w, h, n, i, sum;
	int a, b, c;
	int x1, x2, y1, y2;
	while(cin >> w >> h >> n)
	{
		x1 = 0, x2 = w, y1 = 0, y2 = h;
		for(i = 0; i < n; i++)
		{
			cin >> a >> b >> c;
			if(c == 1) x1 = max(a, x1);
			if(c == 2) x2 = min(a, x2);
			if(c == 3) y1 = max(b, y1);
			if(c == 4) y2 = min(b, y2);
		}
		cout << max((x2 - x1), 0) * max((y2 - y1), 0) << 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;
//using ll = long long;
//using P = pair<int,int>;

int main() {

  string s; cin >> s;
  int q; cin >> q;

  string t;
  rep(i,q) {

    int x;
    cin >> x;

    if(x==1){
        swap(s,t);
    }
    else {
      int f;
      char c;
      cin >> f >> c;
      if(f==1) t += c;
      else s += c;
    }
  }
  reverse(t.begin(),t.end());
   t += s;
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 1128
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
ll h , ans=1 ;
int main()
{
    cin >> h ;
    while (h)
    {
        h/=2;
        ans *= 2 ;
    }
    cout << ans - 1 <<"\n";

}


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

int main(void){ 
    int n, cnt = 0, max = 0;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] > max) max = a[i];
    }
    sort(a.begin(), a.end());
    vector<bool> p(max+1);
    for(int i=0; i<n; i++){
        if(!p[a[i]]){
            cnt++;
            if(i != n-1 && a[i] == a[i+1]) cnt--;
            for(int t=a[i]; t<=max; t+=a[i]) p[t] = true;
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 4028
n = gets.to_i
as = gets.split.map(&:to_i)
as = as.unshift(0).push(0)

sum = 0
diff = []
as.each_with_index do |_, i|
  if i < as.size-1
    sum += (as[i] - as[i+1]).abs
  end

  if i < as.size-2
    d = (as[i] - as[i+1]).abs + (as[i+1] - as[i+2]).abs - (as[i] - as[i+2]).abs
    diff.push(d)
  end
end

diff.each { |d| puts sum-d }


Measured memory_bytes: 12812
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n;
  string s,ss,sss;
  cin>>a>>b;
  if(a!=1&&b!=1)cout<<1<<endl;
  else if(a!=2&&b!=2)cout<<2<<endl;
else
  cout<<3<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
	int h, w;
	bool row[100]{}, column[100]{}, matrix[100][100]{};
	char tmp;
	std::cin >> h >> w;
	for (int r = 0; r < h; ++r)
		for (int c = 0; c < w; ++c)
		{
			std::cin >> tmp;
			if (tmp == '#')
			{
				matrix[r][c] = column[c] = row[r] = true;
			}
		}

	for (int r = 0; r < h; ++r)
	{
		if (!row[r]) continue;
		for (int c = 0; c < w; ++c)
		{
			if (!column[c]) continue;
			if (matrix[r][c])
				std::cout << '#';
			else
				std::cout << '.';
		}
		std::cout << std::endl;
 	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	cin>>s;
	sort(all(s));
	cout<<(s.at(0)==s.at(1)&&s.at(2)==s.at(3)&&s.at(1)!=s.at(2)?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
//use brackets before operations if taking MOD
//use map only when necessary
//give long long to arrays and variables properly
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	//a = (a%mod+mod)%mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}

int main() {



	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
char ans[250010][256]={""};
int main(){
	int h,w,in;cin>>h>>w;
	bool mp[550][550];int ansc=-1;
	for (int j=0;j<h;++j)for (int i=0;i<w;++i)cin>>in,mp[j][i]=in%2;
	for (int j=0;j<h;++j){
		for (int i=0; i<w-1; ++i)
			if (mp[j][i]){mp[j][i]=0;mp[j][i+1]=!mp[j][i+1];sprintf(ans[++ansc],"%d %d %d %d\n",j+1,i+1,j+1,i+2);}
		if(j!=h-1&&mp[j][w-1]){mp[j][w-1]=0;mp[j+1][w-1]=!mp[j+1][w-1];sprintf(ans[++ansc],"%d %d %d %d\n",j+1,w,j+2,w);}
	}cout<<ansc+1<<endl;for (int i=0;i<=ansc;++i)cout<<ans[i];
	getchar();
	getchar();
}

Measured memory_bytes: 35072
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static int n;
	static long k;
	static int[] a;
	static int[] b;
	static long[] count; //count[i] : iが配列に何個含まれるか

	static void Main(){
		/* 入力の受取 */
		string[] input = Console.ReadLine().Split();
		n = int.Parse(input[0]);
		k = long.Parse(input[1]);
		a = new int[n];
		b = new int[n];
		for (int i = 0;i < n;i++){
			input = Console.ReadLine().Split();
			a[i] = int.Parse(input[0]);
			b[i] = int.Parse(input[1]);
		}

		/* countを計算 */
		count = new long[a.Max() + 1];
		for (int i = 0;i < n;i++) //各挿入操作を処理
			count[a[i]] += b[i];

		/* 答えの計算 */
		long index = 0;
		for (int i = 0;i < count.Length;i++){
			index += count[i];
			if (index >= k){
				Console.WriteLine(i);
				return;
			}
		}
	}
}

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

using namespace std;

using int64 = long long;

const int INF = 1 << 30;

int main() {
  int N, K, Q, A[2000];
  cin >> N >> K >> Q;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ret = INF;
  for(int i = 0; i < N; i++) {
    int low = A[i];
    vector< vector< int > > ok;
    ok.emplace_back(vector< int >());
    for(int j = 0; j < N; j++) {
      if(A[j] < low) {
        ok.emplace_back(vector< int >());
      } else {
        ok.back().emplace_back(A[j]);
      }
    }
    vector< int > ans;
    for(auto &vs : ok) {
      sort(begin(vs), end(vs));
      reverse(begin(vs), end(vs));
      while(vs.size() >= K) {
        ans.emplace_back(vs.back());
        vs.pop_back();
      }
    }
    sort(begin(ans), end(ans));
    if(ans.size() >= Q) ret = min(ret, ans[Q - 1] - low);
  }
  cout << ret << endl;
}

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N];
  int y[M];
  int XMAX = X;
  int YMIN = Y;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    XMAX = max(XMAX, x[i]);
  }
  for (int i = 0; i < M; i++) {
    cin >> y[i];
    YMIN = min(YMIN, y[i]);
  }
  if (XMAX < YMIN)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}

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

int main() {
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> h(n);
    for (auto& e : h) cin >> e;
    sort(begin(h), end(h));
    int64_t ans = 0;
    if (k < n) {
        ans = accumulate(begin(h), begin(h) + n - k, 0l);
    } 

    cout << ans << endl;
}

Measured memory_bytes: 1792
N=int(input())
num = list(map(int,input().split()))

num_sort = sorted(num)
ans = 0

for i in range(N):
  if num[i] == num_sort[i]:
    continue
  else:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
K = int(input())
List = [[1,2,3,4,5,6,7,8,9]]
for i in range(10):
  for j in List[i]:
    List.append([])
    if int(j)%10==0:
      List[i+1].append(str(j)+"0")
      List[i+1].append(str(j)+"1")
    elif int(j)%10==9:
      List[i+1].append(str(j)+"8")
      List[i+1].append(str(j)+"9")
    else:
      k=int(j)%10
      List[i+1].append(str(j)+str(k-1))
      List[i+1].append(str(j)+str(k))
      List[i+1].append(str(j)+str(k+1))

Sum = 0      
for i in range(10):
  Sum += len(List[i])
  if K<=Sum:
    print(List[i][K-(Sum-len(List[i]))-1])
    break

Measured memory_bytes: 58864
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,ans=0,p[100005],red=0,a[100005];
    str s;
    fill(p,p+100005,1);
    fill(a,a+100005,0);
    cin >> n >> m;
    a[1]=1;
    a[0]=1;
    int x , y;
    rep(i,0,m){
        cin >> x >> y;
        p[y]++;

        if(a[x]){
            if(p[x]<=1)a[x]=0;
            a[y]=1;
        }
        if(p[x]>=1)p[x]--;
    }
    rep(i,1,n+1){
        if(a[i]){ans++;}
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 1792
main(){__builtin_puts("1x1=1\n1x2=2\n1x3=3\n1x4=4\n1x5=5\n1x6=6\n1x7=7\n1x8=8\n1x9=9\n2x1=2\n2x2=4\n2x3=6\n2x4=8\n2x5=10\n2x6=12\n2x7=14\n2x8=16\n2x9=18\n3x1=3\n3x2=6\n3x3=9\n3x4=12\n3x5=15\n3x6=18\n3x7=21\n3x8=24\n3x9=27\n4x1=4\n4x2=8\n4x3=12\n4x4=16\n4x5=20\n4x6=24\n4x7=28\n4x8=32\n4x9=36\n5x1=5\n5x2=10\n5x3=15\n5x4=20\n5x5=25\n5x6=30\n5x7=35\n5x8=40\n5x9=45\n6x1=6\n6x2=12\n6x3=18\n6x4=24\n6x5=30\n6x6=36\n6x7=42\n6x8=48\n6x9=54\n7x1=7\n7x2=14\n7x3=21\n7x4=28\n7x5=35\n7x6=42\n7x7=49\n7x8=56\n7x9=63\n8x1=8\n8x2=16\n8x3=24\n8x4=32\n8x5=40\n8x6=48\n8x7=56\n8x8=64\n8x9=72\n9x1=9\n9x2=18\n9x3=27\n9x4=36\n9x5=45\n9x6=54\n9x7=63\n9x8=72\n9x9=81");}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	bool yes=false;
	vector<int>v;
	for(int i=1,d;;++i){
		d=a*i%b;
		if(d==c)yes=true;
		for(auto&j:v){
			if(j==d)goto end;
		}
		v.emplace_back(d);
	}
	end:
	cout<<(yes?"YES"s:"NO"s)<<"\n"s;
}

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

void solve()
{
    int n, W; cin >> n >> W;
    vector<ll> dp(W + 1);
    for (int i = 0; i < n; ++i) {
        int w, v; cin >> w >> v;
        for (int j = W - w; j >= 0; --j) {
            dp[j + w] = max(dp[j] + v, dp[j + w]);
        }
    }
    cout << dp[W] << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3936
#include<bits/stdc++.h>
using namespace std;
int h,w,k;
int bitmask(int r,int c,char mtr[6][6])
{
	char mtr1[6][6];
	for(int i=0; i<h; i++)
	{
		for(int j=0; j<w; j++)
		 mtr1[i][j]=mtr[i][j];
	}
	for(int i=0; i<h; i++)
	{
		if(r&(1<<i))
		{
			for(int x=0; x<w; x++)
			 mtr1[i][x]='r';
		}
	}
	for(int i=0; i<w; i++)
	{
		if(c&(1<<i))
		{
			for(int x=0; x<h; x++)
			 mtr1[x][i]='r';
		}
	}
	int cnt=0;
	for(int i=0; i<h; i++)
	{
		for(int j=0; j<w; j++)
		{
			if(mtr1[i][j]=='#')
			 cnt++;
		}
	}
	if(cnt==k){

	 return 1;
   }
	return 0;
}
int main()
{
	cin>>h>>w>>k;
	char mtr[6][6];
	for(int i=0; i<h; i++)
	 cin>>mtr[i];
/*	for(int i=0; i<h; i++)
	{
		for(int j=0; j<w; j++)
		 cout<<mtr[i][j];
		cout<<"\n";
	}*/
	int ans=0;
    for(int i=0; i<pow(2,h); i++)
    {
    	for(int j=0; j<pow(2,w); j++)
    	 ans+=bitmask(i,j,mtr);
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  bool yes = false;
  int a = N / 7;
  for(int j=0;j<=a;j++) {
    int b = N - 7 * j;
    if(b % 4 == 0) {
      yes = true;
      break;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, k;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	int all = (n-1)*(n-2)/2;
 	if(all<k) cout << -1;
 	else
 	{
 		vector <pii> edges;
		for(int i=2; i<=n; i++) edges.pb(mp(1, i));
		int x = 2, y = 3;
		while(all>k)
		{
			if(y==n+1)
			{
				x++;
				y = x + 1;
			}
			edges.pb(mp(x, y));
			all--;
			y++;
		}
		cout << sz(edges) << '\n';
		for(auto it : edges)
			cout << it.first << ' ' << it.second << '\n';
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  string s;
  cin >> N >> s;
  string ans;
  auto pb = [&](bool b) {
    if(b) {
      ans.push_back('S');
    } else {
      ans.push_back('W');
    }
  };
  auto check = [&](bool fst, bool snd) {
    pb(fst);
    bool prev = fst;
    bool cur = snd;
    bool next;
    REPS(i, 1, N) {
      if(s[i] == 'o') {
        next = !(prev ^ cur);
      } else {
        next = prev ^ cur;
      }
      pb(cur);
      prev = cur;
      cur = next;
    }
    if(fst == next) {
      if(s[0] == 'o') {
        next = !(prev ^ cur);
      } else {
        next = prev ^ cur;
      }
      if(snd == next) {
        cout << ans << endl;
        exit(0);
      }
    }
    ans = "";
  };

  check(true, true);
  check(true, false);
  check(false, false);
  check(false, true);
  cout << -1 << endl;
}


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

def sinsuu(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
 
ans = sinsuu(n,k)
print( len(ans) )

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

int main(){
	int k,a,b;
	cin>>k;
	cin>>a>>b;
	if(a%k==0 || b%k==0)
		cout<<"OK\n";
	else {
    	int y = b%k;
      	if(abs(a-b)>=y)
          cout<<"OK\n";
      	else
          cout<<"NG\n";
    }
//	else 
//		cout<<"NG\n";
}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N, P; cin >> N >> P;
    string S; cin >> S;

    ll ans = 0;
    if(P == 2 || P == 5){
        REP(i,N){
            if((S[i]-'0')%P == 0) ans += i+1;
        }
    }
    else{
        vector<ll> decmod(N+1);
        decmod[0] = 1;
        REP(i,N) decmod[i+1] = (decmod[i]*10)%P;
        vector<ll> U(N+1); U[N] = 0;
        REP(i,N){
            U[N-1-i] = (U[N-i] + decmod[i]*(S[N-1-i]-'0'))%P;
        }
        vector<ll> mod(P,0);
        RREP(i,N){
            if(U[i] == 0) ans++;
            ans += mod[U[i]];
            mod[U[i]]++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
int n;
struct node
{
    ll num,id;
    ll tot;
}s[100503];
inline bool cmp(node a,node b)
{
    return a.num<b.num;
}
ll ji,ou;
int main()
{
    n=read();
    for(register int i=1;i<=n;++i)
    {
    	 s[i].num=read(),s[i].id=i;
	}
       
    stable_sort(s+1,s+1+n,cmp);
    for(register int i=1;i<=n;++i)
        if(s[i].id%2==0)
            if(i%2==0)
                continue;
            else
                ou++;
        else 
            if(i%2!=0)
                continue;
            else
                 ji++;
    ll h=min(ou,ji);
    cout<<h+abs(ou-ji);
}

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


const ll INF = 1e18;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n+1);
  h[0]=0;
  rep(i,n){
    cin>>h[i+1];
  }
  ll dp[305][305];
  rep(i,305)rep(j,305)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,n)rep(j,n-k){
    rep(k,i+1){
      dp[i+1][j+1]=min(dp[i+1][j+1],dp[k][j]+max(ll(0),h[i+1]-h[k]));
  //    dp[i+1][j]=min(dp[i+1][j],dp[k][j-1]+abs(h[i+1]-h[k]));
    //  cout<<i+1<<"i"<<j+1<<'j'<<k<<'k'<<"dp"<<dp[i+1][j+1]<<"abs"<<abs(h[i+1]-h[k])<<endl;
    }
  }
  ll ans=INF;
  rep(i,n+1){
    ans=min(ans,dp[i][n-k]);
  }
  cout<<ans;

}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int res;
    for(int i = 1; i <= 5; i++) {
        int x; cin >> x;
        if(x == 0) res = i;
    }
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int hi = 0;
		int[] x = new int[n], y = new int[n], h = new int[n];
		for ( int i = 0; i < n; i++ ) {
			x[i] = in.nextInt();
			y[i] = in.nextInt();
			h[i] = in.nextInt();

			if ( h[i] != 0 ) hi = i;
		}
		in.close();

		for ( int cy = 0; cy <= 100; cy++ ) {
			for ( int cx = 0; cx <= 100; cx++ ) {
				boolean match = true;
				int Height = h[hi] + Math.abs(x[hi] - cx) + Math.abs(y[hi] - cy);

				for ( int i = 0; i < n; i++ ) {
					int tempH = h[i] + Math.abs(x[i] - cx) + Math.abs(y[i] - cy);
					
					if ( h[i] != 0 && Height != tempH ) {
						match = false;
						break;
					}
					if ( h[i] == 0 && Height > tempH ) {
						match = false;
						break;
					}
				}
				if ( match ) {
					System.out.println(cx + " " + cy + " " + Height);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 23636
mod=10**9+7
k=int(input())
s=input()
l=len(s)
fact=[1]
for i in range(1,k+l+1):
  fact.append((fact[-1]*i)%mod)
revfact=[]
for i in range(k+l+1):
  revfact.append(pow(fact[i],mod-2,mod))
pows=[1]
for i in range(1,k+l+1):
  pows.append((pows[-1]*25)%mod)
ans=0
for i in range(l,l+k+1):
  ans+=fact[l+k]*revfact[i]*revfact[l+k-i]*pows[l+k-i]
  ans%=mod
print(ans)

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

int main() {
	int m, n, c=0;
	vector<int> list;
	cin >> n >> m;
	list.resize(m+1);
	for (int i = 0; i < list.size(); i++) {
		list[i] = 0;
	}

	int k,t;
	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> t;
			list[t]++;
		}
	}

	for (int i = 0; i < list.size(); i++) {
		if (list[i] == n) {
			c++;
		}
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256