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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);
  vll h(N);
  REP(i,N) IN(h[i]);
  vll dp(N,INFLL);
  dp[0] = 0;
  REP(i,N-1){
    FOR(j,1,K+1){
      if(i+j>=N) break;
      chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }

  OUT(dp[N-1]);

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    int odd = 0;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(a % 2 == 1) odd++;
    }
    if(n == 2)
    {
        if(odd == 1) cout << "NO" << endl;
        else cout << "YES" << endl;
    }
    else
    {
        if(odd % 2 != 0) cout << "NO" << endl;
        else cout << "YES" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int i,j;
    int count;

    int *a=NULL;

    scanf("%d",&count);

    /* 配列の領域を動的確保 */
    a =(int *)malloc(count*sizeof(int));
    if(a == NULL){
        return 0;
    }

    for(i=0;i<count;i++){
        if(i==0){
            scanf("%d",&a[i]);
        }
        else{
            scanf(" %d",&a[i]);
        }
    }

    for(j=0;j<count;j++){
        if(j==0){
            printf("%d",a[count-1]);
        }
        else{
            printf(" %d",a[count-j-1]);
        }
    }

    printf("\n");

    free(a);
    return 0;
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;



int main(){
    ll h,w,k;
    cin >> h >> w >> k;
    char s[h][w];
    vector<ll> count(h,0);
    ll memo=1e9;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin >> s[i][j];
            if(s[i][j]=='#'){
                count[i]++;
                memo=min(memo,i);
            }
        }
    }
    ll ans[h][w];
    ll res=0;
    for(ll i=memo;i<h;i++){
        ll cal=0;
        if(count[i]>0) res++;
        for(ll j=0;j<w;j++){
            if(count[i]>0){
                if(s[i][j]=='#') cal++;
                if(s[i][j]=='#'&&cal!=1) res++;
                ans[i][j]=res;
            }
            else if(count[i]==0){
                ans[i][j]=ans[i-1][j];
            }
        }
    }
    for(ll i=memo-1;i>=0;i--){
        for(ll j=0;j<w;j++){
            ans[i][j]=ans[i+1][j];
        }
    }
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cout << ans[i][j];
            if(j!=w-1) cout << " ";
            if(j==w-1) cout << endl;
        }
    }
    return 0;
}  


Measured memory_bytes: 4360
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
////@formatter:on
//endregion


int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    make(int, n, m);
    cout << (n == m ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,m=0,v=0;
  char s[11];
  scanf("%s\n",s);
  for(i=0;i<=11;i++){
    if((s[i]=='A')||(s[i]=='T')||(s[i]=='C')||(s[i]=='G')){
      m++;
    }else{
      m=0;
    }
    if(v<=m)v=m;
  }
  printf("%d\n",v);
  return 0;
}


Measured memory_bytes: 128
if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().split()))

    B = [0] * n
    C = [0] * 10001

    for i in A:
        C[i] += 1

    for i in range(1, len(C)):
        C[i] += C[i - 1]

    for i in A:
        B[C[i] - 1] = i
        C[i] -= 1
    
    print(' '.join(map(str, B)))



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

int main()
{
	ll i,j,k,l,m,n;

	string s,t;

	cin >> s >> t;

	l = s.size();

	k = 0;
	for(i=0;i<l;i++)
	{
		if(s[i] != t[i])
			k++;
	}

	cout << k << '\n';
}

Measured memory_bytes: 3916
// 解き直し.
// https://img.atcoder.jp/sumitrust2019/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1e9 + 7;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int A[111111], c[111111], x[111111], y[111111], z[111111];

int main(){

    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%d", A + i);
    
    // 2. x, y, z を 特定し, 場合の数を計算.
    rep(i, N){
        x[i + 1] = x[i];
        y[i + 1] = y[i];
        z[i + 1] = z[i];
        if(c[A[i]] == 0) x[i + 1]++;
        if(c[A[i]] == 1) y[i + 1]++;
        if(c[A[i]] == 2) z[i + 1]++;
        c[A[i]]++;
    }
    // rep(i, N) printf("%d %d %d\n", x[i], y[i], z[i]);
    
    // 3. 場合の数を計算.
    LL ans = 1, a = 0;
    rep(i, N){
        a = 0;
        if(A[i] == x[i]) a++;
        if(A[i] == y[i]) a++;
        if(A[i] == z[i]) a++;
        ans *= a;
        ans %= MOD;
    }
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define N 105
int a,b,s[N][N],n,m,last;
int main()
{
	scanf("%d%d",&a,&b);int tot=min(a,b),res=tot-max(a,b);
	n=m=100,printf("%d %d\n",n,m);a--,b--;
	for(int i=1;i<=n;i++) s[i][m]=1;
	for(int i=2;i<=n;i+=2)
	 	for(int j=2;j<=m;j++) s[i][j]=1;
	for(int i=1;i<=n;i+=2)
		for(int j=2;j<m;j+=2) if(a) a--,s[i][j]=1;
	for(int i=n;i;i-=2)
	 	for(int j=3;j<m;j+=2) if(b) b--,s[i][j]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			putchar(s[i][j]?'#':'.');
		puts("");
	}
	return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 2e5 + 7;

int main() {
    string s;
    cin >> s;
    int flag = 0;
    for (int i = 0; i < s.size(); i ++) {
        if (flag == 0) {
            if (s[i] == 'C') flag = 1;
        } else if (flag == 1) {
            if (s[i] == 'F') flag = 2;
        }
    }
    if (flag == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
  int n;
  string s;

  int n_abc = 0;

  cin >> n >> s;

  for (int i=0; i<n-2; i++) {
    if (s.substr(i, 3) == "ABC") {
      n_abc += 1;
    }
  }

  cout << n_abc << endl;
}


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

long n,mod=1000000007,x,y;
vector<long> a(100001),aa(100000,-1),ans(100001),fac(200000);

long modpow(long modpow_x,long modpow_y) {
  long modpow_return=1;
  for(long i=1;i<=modpow_y;i*=2) {
    if(modpow_y/i%2==1) modpow_return=modpow_return*modpow_x%mod;
    modpow_x=modpow_x*modpow_x%mod;
  }
  return modpow_return;
}

long ncr(long ncr_n,long ncr_r) {
  return fac[ncr_n]*modpow(fac[ncr_r],mod-2)%mod*modpow(fac[ncr_n-ncr_r],mod-2)%mod;
}

int main() {
  cin >> n;
  for(long i=0;i<n+1;i++) cin >> a[i];
  fac[0]=1;
  fac[1]=1;
  for(long i=2;i<200000;i++) fac[i]=(fac[i-1]*i)%mod;

  for(long i=0;i<n+1;i++) {
    if(aa[a[i]-1]==-1) {
      aa[a[i]-1]=i;
    } else {
      x=aa[a[i]-1],y=i;
      break;
    }
  }

  for(long i=0;i<n+1;i++) ans[i]=ncr(n+1,i+1);

  for(long i=0;i<=x+n-y;i++) ans[i]=(ans[i]+mod-ncr(x+n-y,i))%mod;

  for(long i=0;i<n+1;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 7004
#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 n;
  cin >> n;
  int ans = 0;
  rep(i,(int)n.size()) {
    if (n.at(i) == '1') ans++;
  }
    cout << ans << endl;
}

Measured memory_bytes: 3620
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip() + 'T'
    x,y = map(int, input().split())
    # 奇数はy方向, 偶数はx方向
    l = []
    susumu = 0
    for i in range(len(s)):
        if s[i] == 'T':
            l.append(susumu)
            susumu = 0
        else:
            susumu += 1
    b = len(l)
    dp = [[0]*16001 for _ in range(3)]
    dp[0][8000] = 1
    dp[1][8000] = 1
    for i in range(b):
        if i==0:
            dp[2][8000+l[i]] = 1
        elif i%2 == 0:
            for j in range(16000):
                if dp[0][j]:
                    dp[2][j-l[i]] = 1
                    dp[2][j+l[i]] = 1
        elif i%2 == 1:
            for j in range(16000):
                if dp[0][j]:
                    dp[2][j-l[i]] = 1
                    dp[2][j+l[i]] = 1
        dp = dp[1:] + [[0]*16000]
    if b%2 == 0:
        if dp[0][x+8000] == 1 and dp[1][y+8000] == 1:
            print('Yes')
        else:
            print('No')
    else:
        if dp[1][x+8000] == 1 and dp[0][y+8000] == 1:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

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

int main(){
  int q;cin>>q;
  vector<int> p(2e5,1);
  p[0]=0,p[1]=0;
  for(int i=2;i<2e5;i++){
    /*エラトステネスの篩
    (素数ならp[i]=1,素数でないならp[i]=0)*/
    if(p[i]){
      for(int j=i*2;j<2e5;j+=i)p[j]=0;
    }
  }
  vector<int> vec(2e5);
  rep(i,2e5){
    if(i%2==0)continue;
    if(p[i]&&p[(i+1)/2])vec[i]=1;//2017に似た数
  }
  vector<int> sum(2e5+1);
  //2017に似た数の累積和
  rep(i,2e5)sum[i+1]=sum[i]+vec[i];
  rep(i,q){
    int l,r;cin>>l>>r;
    cout<<sum[r+1]-sum[l]<<endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<int> a(n);
    int xall = 0;
    FOR(i, n) {
        cin >> a[i];
        xall ^= a[i];
    }
    FOR(i, n)
        cout << (xall^a[i]) << " ";

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3796
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
int a,b,c;
ll k;
int main(void){
	register int i;
	scanf("%d%d%d%lld",&a,&b,&c,&k);
	printf("%d",(a-b)*(k&1?-1:1));
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int inputN, flag = 0;
    char *inputString;
    
    scanf("%d", &inputN);
    inputString = (char *)malloc(inputN + 1);
    scanf("%s", inputString);

    if (inputN % 2 == 0)
    {
        int startStringNum = inputN / 2;
        for (int index = 0; index < startStringNum; index++)
        {
            if (inputString[index] != inputString[index + startStringNum])
            {
                flag = 1;
                break;
            }
        }
    }
    else
    {
        flag = 1;
    }

    if (flag == 0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

    free(inputString);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int TAM = 100004;

vector <ll> adj [TAM];
ll val [TAM], pt [TAM];
int n;

void form( int x ){
    int nxt;
    for( int i = 0 ; i < adj[x].size() ; i ++ ){
        nxt = adj[x][i];
        if( nxt == pt[x] ) continue;
        pt[nxt] = x;
        //cout << " parent " << nxt << " = " << pt[nxt] << endl ;
        form(nxt);
    }
}

ll dn, up;
void solve ( ll cap , ll sum ){
    dn = sum - cap;
    up = cap - dn;
}

bool pos = 1;

ll find_up( int x ){
    //cout << " IN " << x << endl ;
    if( adj[x].size() == 1 ) return val[x];
    ll sum = 0, cap = val[x];
    int nxt;
    ll v;
    for( int i = 0 ; i < adj[x].size() ; i ++ ){
        nxt = adj[x][i];
        if( nxt == pt[x] ) continue;
        v = find_up(nxt);
        sum += v;
        if( v > cap ) pos = 0;
        //cout << x << " -> " << nxt << " = " << v << endl ;
    }
    solve( cap , sum );
    if( dn + up != cap or dn < 0 or up < 0 ) pos = 0;
    return up;
}

int main(){

    int a, b;
    scanf("%d",&n);
    for( int i = 1 ; i <= n ; i ++ )
        scanf("%lld",&val[i]);
    for( int i = 0 ; i < n-1 ; i ++ ){
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    if( n == 2 ){
        if( val[1] == val[2] ) printf("YES\n");
        else printf("NO\n");
        return 0;
    }

    int rt;
    for( int i = 1 ; i <= n ; i ++ ){
        if( adj[i].size() > 1 ){
            pt [i] = i;
            form(i);
            rt = i;
            break;
        }
    }
    if( !find_up(rt) and pos ) printf("YES\n");
    else printf("NO\n");

    return 0;
}


Measured memory_bytes: 12672
import java.io.*;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        char[] arr = br.readLine().toCharArray();
        int max = 0, cur = 0;
        for(char c : arr)
        {
            if( c =='A' || c=='T' || c=='C' || c=='G' )
            {
                max = Math.max(max,++cur);
            }
            else
            {
                cur = 0;
            }
        }
        bw.write(max+"");
        bw.close();

    }
}


Measured memory_bytes: 21716
import math

n = int(input())
L = [list(map(int,input().split())) for i in range(n)]
Lsum = 0
Llen = 0
for i in range(n-1):
    for j in range(n-1-i):
        Lsum += math.sqrt((L[i][0]-L[i+j+1][0])**2 + (L[i][1]-L[i+j+1][1])**2)
        Llen += 1
print((Lsum/Llen)*(n-1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using ld = long double;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<int> a;

int main(){
    cin >> N;
    a.resize(N);
    rep(i,0,N - 1) cin >> a[i];
    rep(i,0,N - 1) a[i]--;

    int ans = 0;
    rep(i,0,N - 2){
        if(i == a[i]){
            swap(a[i],a[i + 1]);
            ans++;
        }
    }
    if(a[N - 1] == N - 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 640
from collections import deque
N, M = map(int, input().split())

lists = [False for i in range(N)]
lists[0] = True
a = N - 1
dicts = {i:[] for i in range(N)}
d = deque([0])

for i in range(M):
    tmpa, tmpb = map(lambda x: int(x) - 1, input().split()) 
    dicts[tmpa] += [tmpb]
    dicts[tmpb] += [tmpa]

print('Yes')
while a > 0:
    tmp = d.popleft()
    for i in dicts[tmp]:
        if not lists[i]:
            if tmp != 0:
                lists[i] = tmp
            else:
                lists[i] = -1
            d.append(i)
            a -= 1
    
for i in range(1, N):
    print(lists[i] + 1 if lists[i] != -1 else 1)


Measured memory_bytes: 99288
from collections import deque
h , w = map(int,input().split())
ma = [list(input()) for i in range(h)]
visit = [[False for i in range(w)] for j in range(h)]
ans = 0
muki = [(0,1),(0,-1),(1,0),(-1,0)]
for i in range(h):
    for j in range(w):
        if ma[i][j] == "#" and not visit[i][j]:
            visit[i][j] = True
            d = deque()
            d.append((i,j,1))
            kuro = 1
            siro = 0
            while d:
                nowx , nowy , p = d.popleft()
                for a,b in muki:
                    nex = nowx + a
                    ney = nowy + b
                    if 0 <= nex <= h-1 and 0 <= ney <= w-1:
                        if not visit[nex][ney]:
                            if p == 1 and ma[nex][ney] == ".":
                                d.append((nex,ney,0))
                                siro += 1
                                visit[nex][ney] = True
                            if p == 0 and ma[nex][ney] == "#":
                                d.append((nex,ney,1))
                                kuro += 1
                                visit[nex][ney] = True
            ans += kuro*siro
print(ans)

Measured memory_bytes: 11996
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int outlet = 1;
        int count = 0;
        if(B > 1){
            while(true){
                outlet += (A-1);
                count++;
                if(outlet >= B){
                    System.out.println(count);
                    break;
                }
            }
        }
        else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
int C[101];
int dp[100][100];
const int INFTY = (1 << 30);

int main() {
	cin >> N;
	rep(i, N) cin >> C[i] >> C[i+1];

	rep(y, N) rep(x , N) dp[y][x] = INFTY;

	rep(y, N) dp[y][y] = 0;

	for(int d = 1; d < N; d++)
		for(int y = 0; d + y < N; y++){
			for (int dd = 0; dd < d; dd++) {
				int m1_s = y;
				int m1_e = y+dd;
				int m2_s = y+dd+1;
				int m2_e = y+d;

				int cl = C[m1_s] * C[m2_s] * C[m2_e + 1];
				dp[m1_s][m2_e] = min(dp[m1_s][m2_e], dp[m1_s][m1_e] + dp[m2_s][m2_e] + cl);
			}
		}
	cout << dp[0][N-1] << endl;

}

Measured memory_bytes: 3148
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

N,Q = map(int,input().split())
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b,c,d = map(int,input().split())
    graph[a].append((b,c,d))
    graph[b].append((a,c,d))
query = [[int(x) for x in input().split()] for _ in range(Q)]

def set_ancestor(x=1, d=0, parent=0):
    depth[x] = d
    ax = ancestor[x]
    ax[0] = parent
    for i in range(d.bit_length() - 1):
        ax[i+1] = ancestor[ax[i]][i]
    for y, _, _ in graph[x]:
        if y == parent:
            continue
        set_ancestor(y, d+1, x)

depth = [0] * (N+1)
U = 17
ancestor = [[0] * (U+1) for _ in range(N+1)] # 2**i だけ遡った頂点の番号、行き過ぎは0
set_ancestor()

def LCA(x,y):
    dx = depth[x]
    dy = depth[y]
    if dx > dy:
        x,y = y,x
        dx,dy = dy,dx
    diff = dy - dx
    while diff:
        step = diff & (-diff)
        y = ancestor[y][step.bit_length() - 1]
        diff -= step
    while x != y:
        j = 0
        while ancestor[x][j] != ancestor[y][j]:
            j += 1
        if j == 0:
            return ancestor[x][0]
        x = ancestor[x][j-1]
        y = ancestor[y][j-1]
    return x

tasks = [[] for _ in range(N+1)]
for i,(x,y,u,v) in enumerate(query):
    tasks[u].append((i,x,y,1))
    tasks[v].append((i,x,y,1))
    tasks[LCA(u,v)].append((i,x,y,-2))

answer = [0] * Q

def dfs(x = 1, sums = [0] * (N+1), nums = [0] * (N+1), total = 0, parent = 0):
    for i,c,d,coef in tasks[x]:
        answer[i] += coef * (total - sums[c] + nums[c] * d)
    for y,c,d in graph[x]:
        if y == parent:
            continue
        sums[c] += d
        nums[c] += 1
        total += d
        dfs(y, sums, nums, total, x)
        sums[c] -= d
        nums[c] -= 1
        total -= d
    return

dfs()

print('\n'.join(map(str,answer)))



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

class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    int numRow = scanner.nextInt();
    int numColumn = scanner.nextInt();
    scanner.nextLine(); // expecting line break
    int[][] determinantA = new int[numRow][numColumn];
    int[] determinantB = new int[numColumn];
    for (int i = 0; i < numRow; i++) {
      String[] rowElementsInString = scanner.nextLine().split(" ");
      for (int j = 0; j < numColumn; j++) {
        determinantA[i][j] = Integer.parseInt(rowElementsInString[j]); 
      }
    }
    for (int i = 0; i < numColumn; i++) {
      determinantB[i] = Integer.parseInt(scanner.nextLine());
    }
    int ans = 0;
    for (int y = 0; y < numRow; y++) {
      for (int x = 0; x < numColumn; x++) {
        ans += determinantA[y][x] * determinantB[x];
      }
      System.out.println(ans);
      ans = 0;
    }
  }
}

Measured memory_bytes: 25340
#include<stdio.h> 
#include<stdlib.h>
#include<string.h>
#define min(a,b)((a)<(b)?(a):(b))

int n,k;
int fares[101][101];
void kouro(int f,int t,int m){
	int a,b,c,d;
	if(fares[f][t]==-1 | fares[f][t]>m){
		fares[f][t]=m;
		fares[t][f]=m;
		for(a=1;a<=n;a++){
			for(b=1;b<=n;b++){
				fares[a][b]=min(fares[a][b],fares[a][t]+fares[f][t]+fares[f][b]);
                                fares[b][a]=fares[a][b];
			}
		}
	}
	
}
void kyaku(int f,int t){
	if(fares[f][t]>=10000000)printf("-1\n");
	else printf("%d\n",fares[f][t]);
}
int main(void){  
	int a,b; 
	int s,f,t,m; 
		while(1){          
		memset(fares,0,sizeof(fares));
		scanf("%d %d",&n,&k);
		if(n==0 && k==0)break;
		for(a=1;a<=n;a++){
			for(b=1;b<=n;b++){
				if(a==b)fares[a][b]=0;else fares[a][b]=100000000;
			}
		}
		for(a=0;a<k;a++){
			scanf("%d %d %d",&s,&f,&t);
			if(s==1){
				scanf("%d",&m);
				kouro(f,t,m);
			}
			if(s==0){
				kyaku(f,t);
			}
		}
	}
	return 0;
}

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

int m,c,maxim,minim,k;
int bc[100];

int search(int w){
    int empty = 0;
    int d = 1;
    for(int i = 0; i < c; i++){
        if(empty + bc[i] >= w){
            if(d == m){
                return 0;
            }else{
                d++;
                empty = bc[i];
            }
        }else{
            empty += bc[i];
        }
    }
    //cout << "ばーか" << w <<endl;
    return 1;
}

int saiki(int n,int s){
    //cout << n << " " << s << endl;
    if(s <= 2){
        if(search(n + 1)==1){
            return n;
        }else{
            return n + 1;
        }
    }else{
        if(s % 2 == 1){
            if(search(n + (s + 1) / 2)==1){
                return saiki(n, (s + 1) / 2);
            }else{
                return saiki(n + (s + 1) / 2, (s + 1) / 2);
            }
        }else{
            if(search(n + s / 2)==1){
                return saiki(n, s / 2);
            }else{
                return saiki(n + s / 2, s / 2);
            }
        }
    }
}

int main(){
    for(;;){
        maxim = 0;
        minim = 0;
        if(cin >> m >> c){
            if(m == 0 && c == 0){
                break;
            }else{
                for(int i = 0; i < c; i++){
                    cin >> bc[i];
                    maxim += bc[i];
                    if(minim <= bc[i]){
                        minim = bc[i];
                    }
                    //cout << bc[i] << endl;
                }
                cout << saiki(minim, maxim-minim) << endl;
            }
        }else{
            break;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int D, T, S;
  cin >> D >> T >> S;

  double t = (double)D / (double)S;
  if (t <= T) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

    return 0;
}


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

int main(){
    int h,n;
    cin>>h>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];

    vector<int> dp(h+1,1e9);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<h;j++){
            dp[min(j+a[i],h)]=min(dp[min(j+a[i],h)],dp[j]+b[i]);
        }
    }
    cout<<dp[h]<<endl;
}

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


int main()
{
  int  n, now = 1, m;
  cin >> n;
  vector<int> a(n - 1), ans(n);
  for(int i = 0; i < n - 1; i++){
    cin >> a[i];
  }
  
  for(int i = 0; i < n - 1; i++){
    ans[a[i] - 1]++;
  } 
  for(int i = 0; i < n; i++){
    cout << ans[i] <<endl;
  }
}

Measured memory_bytes: 4788
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    p=int(input())
    r=[0]*(p+1)
    r[1]=-1; r[p]=1
    ans=[0]*p
    for i,a in enumerate(map(int,input().split())):
        if(not a): continue
        u=[0]*(p+1) # u(x)=r(x)/(x-i)
        for k in range(p-1,-1,-1):
            u[k]=(r[k+1]+i*u[k+1])%p
            ans[k]-=u[k]
            ans[k]%=p
    print(*ans)
resolve()

Measured memory_bytes: 43484
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let (n, k, q) = input_int_tuple();
    let mut points = vec![0;n as usize];
    for _ in 0..q {
        let answerer: usize = input();
        points[answerer - 1] += 1;
    }
    for p in points {
        if q - p < k {
            println!("Yes");
        } else {
            println!("No");
        }
    }

}


Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
signed main(){
    int n,k;cin>>n>>k;
    vector<int> a(n);
    int cnt=0;
    int sum=0;
    double ans=0;
    for(int i=1;i<=n;i++){
        cnt=i;
        sum=0;
        while(1){
            if((cnt>=1)&&(cnt<=(k-1))){
                cnt*=2;
                sum++;
            }else break;
        }
        ans+=double(1)/double(n)*double(1)/pow(2,float(sum));
    }
    printf("%.12lf",ans);
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int t[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		int b;scanf("%d",&b);b=min(b,3200);
		t[b/400]++;
	}
	int ret=0;
	for(int i=0;i<8;i++){
		if(t[i])ret++;
	}
	printf("%d %d\n",max(1,ret),ret+t[8]);
}


Measured memory_bytes: 128
package main

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

type sortRune []rune

func (r sortRune) Len() int           { return len(r) }
func (r sortRune) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r sortRune) Less(i, j int) bool { return r[i] < r[j] }

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	m := make(map[string]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		r := sortRune([]rune(sc.Text()))
		sort.Sort(r)
		m[string(r)]++
	}

	ans := 0
	for _, v := range m {
		ans += v * (v - 1) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8704
import io.{StdIn => in}

object Main extends App {
  val a = Iterator.continually(in.readLine)
    .take(3)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val t = Array.ofDim[Int](5)
  
  a.foreach(e => {
    t(e(0)) += 1
    t(e(1)) += 1
  })

  val ans = if(!t.exists(_ > 2)) "YES" else "NO"
  println(ans)
}


Measured memory_bytes: 27328
#include<bits/stdc++.h>
using namespace std;
void test_cases(){
    int n;
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i * j >= n) break;
            ans++;
        }
    }
    cout << ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tt = 1;
//    cin >> tt;
    while(tt--){
        test_cases();
    }
    return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
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()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N; cin >> N;
  vector<int> x(N), y(N);
  FOR(i,N){ cin >> x[i] >> y[i]; }
  vector<int> v(N);
  FOR(i,N){ v[i] = i; }
  
    
  //main
  double ans = 0; ll count = 0;
  do{
    for(int i=0; i<N-1; i++){ ans += sqrt((x[v[i+1]]-x[v[i]])*(x[v[i+1]]-x[v[i]])+(y[v[i+1]]-y[v[i]])*(y[v[i+1]]-y[v[i]])); }
    count ++;
  }while(next_permutation(v.begin(), v.end()));
  
  
  // output
  cout << fixed << setprecision(10) << ans/count << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VL vector<long>
#define VD vector<double>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;

int main(void)
{
    int N; cin>>N;
    vector<int> L(N*2);
    REP(i,L.size()) cin>>L[i];
    SORT(L); long ans=0;
    for(int i=0;i<L.size();i+=2){
        ans+=L[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
x,y = map(int,input().split())

if (x+y)%3 != 0:
  print(0)
  exit()
if 2*x < y:
  print(0)
  exit()
if 2*y < x:
  print(0)
  exit()
  
mod = 10**9+7
n = (2*x-y)//3
m = (2*y-x)//3

def make_array_for_comb(N, mod=10**9+7):
    fact = [1,1]
    fact_inv = [1,1]
    inv = [0,1]
    for i in range(2, N+1):
        fact.append((fact[-1]*i) % mod)
        # モジュラ逆数の性質
        inv.append((-inv[mod%i] * (mod//i)) % mod)
        fact_inv.append((fact_inv[-1]*inv[i]) % mod)
    return fact, fact_inv

def comb(n, r, mod=10**9+7):
  if (r < 0) or (n < r):
      return 0
  r = min(r, n - r)
  return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

fact, fact_inv = make_array_for_comb(n+m,mod)

print(comb(n+m,n,mod))

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


int main(){
	long long int n,h; cin>>n>>h;
	long long int a[n],b[n];
	
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	sort(b,b+n);
	long long int count =0;
	long long int maxa = *max_element(a,a+n);
	for(int i=n-1;i>=0;i--){

		if(h <= 0) break;
		if(b[i] >= maxa){
			h -= b[i];
			count++;
		}
	}
	if(h > 0){
		count += (h/maxa);
		if(h%maxa > 0) count += 1;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 1792
//Priyanshu Kumar : IIIT Allahabad
#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define MAX 100005
#define MOD 1000000007
#define sz size()
#define ln length()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pin(n) printf("%d\n",n);
#define pl(n) printf("%lld",n)
#define pln(n) printf("%lld\n",n);
inline ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
inline ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
inline ll powmod(ll a,ll b,ll mod) 
{
	ll res=1;
	a%=mod; 
	assert(b>=0); 
	for(;b;b>>=1)
	{
		if(b&1)res=res*a%mod;
		a=a*a%mod;
	}
	return res;
}
inline ll mulmod(ll a, ll b, ll c)
{
	if(!b)return 0;
	ll x = mulmod(a, b/2, c);
	if (b & 1)return (x+x+a)%c;
	return (x+x)%c;
}

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll m = max(a,max(b,c));
    ll tot = a + b + c - m;
    cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
  typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
#define all v.begin(),v.end()
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ulll;
 
using namespace std ;
int main () {

  char arr[2][3];
  
  for(int i=0;i<2;++i)
     for(int j=0;j<3;++j)
        cin>>arr[i][j];
        
  if(arr[0][0]==arr[1][2]&&arr[1][0]==arr[0][2]&&arr[0][1]==arr[1][1])
      cout<<"YES";
      
      else
         cout<<"NO";
   
  return 0;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


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

    cout << (1900 * m + 100 * (n - m)) * pow(2, m) << endl;

    return 0;
}


Measured memory_bytes: 256
n, t = gets.chomp.split.map(&:to_i)
arr = Array.new(t + 1, 0)
n.times{
    l, r = gets.chomp.split.map(&:to_i)
    arr[l] += 1
    arr[r] -= 1
}
cum, max = 0, 0
arr.each{|x|
    cum += x
    max = cum if max < cum
}
puts max


Measured memory_bytes: 8924
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll H,W,K;
    cin>>H>>W>>K;
    vector<vector<char>> c(H,vector<char>(W));
    ll ori=0;
    REP(i,H){
        REP(j,W){
            cin>>c[i][j];
            if(c[i][j]=='#') ori++;
        }
    }

    ll ans=0;

    REP(i,1<<H){
        REP(j,1<<W){
            vector<vector<char>> copy(H,vector<char>(W));
            REP(k,H){
                REP(l,W){
                    copy[k][l]=c[k][l];
                }
            }
            REP(k,H){
                REP(l,W){
                    ll mask1=1<<k;
                    ll mask2=1<<l;
                    if(i&mask1){
                        REP(n,W){
                            copy[k][n]='r';
                        }
                    }
                    if(j&mask2){
                        REP(n,H){
                            copy[n][l]='r';
                        }
                    }
                }
            }
            ll cnt=0;
            REP(k,H){
                REP(l,W){
                    if(copy[k][l]=='#') cnt++;
                }
            }
            if(cnt==K){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
# coding=utf-8


def string_rotate(string):
    return_string = string[:]
    return return_string[-1:] + return_string[:-1]


if __name__ == '__main__':
    S = input()
    T = input()

    if S == T:
        print('Yes')
    else:
        S_copy = S[:]
        S_copy = string_rotate(S_copy)

        for i in S:
            if S_copy == T:
                print('Yes')
                break
            S_copy = string_rotate(S_copy)
        else:
            print('No')


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
    class Program {
        static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
            Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
            Console.Out.Flush();
        }
		public void Solve(ConsoleInput cin) {
			while(!cin.isEOF) {
				var atlas = Enumerable.Repeat(-1, 12).Select(
					x => cin.ReadLine.ToCharArray().Select(c=>c=='1').ToArray()
				).ToArray();
				var islandC = 0;
				for(int i = 0; i < 12; i++) {
					for(int j = 0; j < 12; j++) {
						if(!atlas[i][j]) continue;
						islandC++;
						var S = new Stack<Cartes>();
						S.Push(new Cartes(i, j));
						while(S.Any()) {
							var c = S.Pop();
							atlas[c.y][c.x] = false;
							if(c.x > 0 && atlas[c.y][c.x - 1]) S.Push(new Cartes(c.y, c.x - 1));
							if(c.x < 11 && atlas[c.y][c.x + 1]) S.Push(new Cartes(c.y, c.x + 1));
							if(c.y > 0 && atlas[c.y - 1][c.x]) S.Push(new Cartes(c.y - 1, c.x));
							if(c.y < 11 && atlas[c.y + 1][c.x]) S.Push(new Cartes(c.y + 1, c.x));
						}
					}
				}
				Console.WriteLine(islandC);
				var empty = cin.ReadLine;
			}
		}
		public struct Cartes {
			public int x{ get; set; }
			public int y{ get; set; }
			public Cartes(int yy, int xx) { x = xx; y = yy; }
		}

	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}



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

int main(){
  int N;
  cin >> N ;
  vector<int> num(N);
  for(int i = 0; i < N; i++){
    cin >> num.at(i) ;
  }
  
  sort(num.begin(), num.end());
  reverse(num.begin(), num.end());
  
  int scoreA = 0;
  int scoreB = 0;
  
  for(int i=0;i<N;){
    scoreA = scoreA + num.at(i);
    i++;
    if(i<N){
    scoreB = scoreB + num.at(i);
    i++;
    }
  }
  int r = scoreA - scoreB;
  cout << r << endl;
}

    
    
    
  
  

Measured memory_bytes: 256