akhauriyash/Code-Regression huggingface dataset:
kx = list(map(int, input().split()))
 
k = kx[0]
x = kx[1]
ans = [i for i in range(x-k+1, x+k, 1) if (1000000 >= i) and (i >= -1000000) ]
 
for a in ans:
    print(a, end =" ")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
const int INF = 1e9;
using namespace std;

int main(void) {
    int N;cin>>N;
    int W[N];
    int total_weight = 0;
    for (int i=0;i<N;i++) {
        cin>>W[i];
        total_weight+=W[i];
    }
    int result = INF;
    for (int T = 0; T < N - 1; T++) {
        int weight = 0;
        for (int i = 0; i <= T; i++) {
            weight += W[i];
        }
        int later_weight = total_weight - weight;
        if (result > abs(later_weight - weight)) result = abs(later_weight - weight);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	int count = 0;
	rep(i, 0, n) cin >> p[i];
	rep(i, 1, n - 1) {
		int a = p[i - 1];
		int b = p[i];
		int c = p[i + 1];
		if (a < b && b < c || c < b && b < a) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, h, cnt=0, top=0;

    cin >> n;

    for(int i=0; i<n; i++)
    {
        cin >> h;

        if(top <= h)
        {
            top = h;

            cnt++;
        }
    }

    cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	k = II()
	x = LI()
	ans = 0
	for xx in x:
		ans += min(xx, abs(k-xx))*2
	print(ans)


if __name__ == '__main__':
	main()

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

int main() {
	int n; cin >> n;
	vector<int> a(n);
	map<int, ll> mp;
	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	ll ans = 0;
	for (auto& c : mp) {
		ans += c.second * (c.second - 1) / 2;
	}
	rep(i, n) {
		ll tmp = ans;
		if (mp[a[i]] == 2) {
			tmp--;
		}
		if (mp[a[i]] > 2) {
			tmp -= (mp[a[i]] - 1);
		}
		cout << tmp << endl;
	}
	return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int>P(N);
    for (int i = 0; i < N; ++i) {
      cin >> P[i];
    }
    vector<int>stock(3, 0);
    for (int i = 0; i < N; ++i) {
        if(P[i] <= A) {
            stock[0]++;
        } else if(P[i] > B){
            stock[2]++;
        } else{
            stock[1]++;
        }
    }
    sort(stock.begin(), stock.end());
    cout << stock[0];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
char s[maxn];
int vis[maxn];
int n,a,b,c,d;
int main()
{

    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    scanf("%s",s+1);
   // int len=strlen(s+1);
    //cout<<len<<endl;
    if(s[c]=='#'||s[d]=='#')
         puts("No");
    else
    {
        if(a>b)
        swap(a,b),swap(c,d);
        int f1=0;
        for(int i=a; i<=max(c,d); i++)
        {
            if(s[i]=='#'&&s[i-1]=='#')
            {
                  f1=1;
                 break;
            }
        }
        if(f1)
            puts("No");
        else
        {    
            if(c<d)
                puts("Yes");
            else
            {
                    int  f=0;
                for(int i=b; i<=d; i++)
                {
                    if(s[i]=='.'&&s[i-1]=='.'&&s[i+1]=='.')
                          f=1;
                }
                if(f)
                    puts("Yes");
                else
                    puts("No");
            }
        }

    }
    return 0;
}


Measured memory_bytes: 384
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int A, B;

int main() {
    cin >> A >> B;
    int ans = 0;

    int tap = 1;
    while(tap<B) {
        tap += (A-1);
        ans++;
    }    
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int k,s;
	 cin>>k>>s;
	 int res=0;
	 for(int i=0;i<=k;i++)
	 {
	 	  for(int j=0;j<=k;j++)
	 	  {
	 	  	    int c=s-i-j;
	 	  	    if(c>=0&&c<=k)
	 	  	    	++res;
	 	  }
	 }
	 cout<<res<<endl;
	 return 0;
	}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()
S = S.replace("hi", "")

if S == "":
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    cin >> n;
    deque<int> p(n);
    // deque<bool> flg(n, false);
    int cnt = 0;
    rep(i, n)
    {
        cin >> p[i];
        if (i + 1 != p[i])
        {
            // flg[i] = true;
            cnt++;
        }
    }
    if (cnt == 2 || cnt == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
import numpy as np
hights=np.array(list(map(int,input().split())))
steps=np.array([10**10]*N)
steps[0]=0
for i in range(N-1):
    gaps=hights[i+1:i+K+1]-hights[i]
    gaps=np.abs(gaps)
    gaps+=steps[i]
    steps[i+1:i+K+1]=np.minimum(steps[i+1:i+K+1],gaps)
print(steps[-1])

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, K;
int a[1111];
vec<int> cand;

int func(int mask) {
   int cnt = 0;

   for (int i = 0; i < cand.size(); i++) {
      if ((cand[i] & mask) == mask) {
         cnt++;
      }
   }

   return cnt;
}

signed main() {
   cin >> N >> K;
   rep (i, N) {
      cin >> a[i];
   }

   for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = i; j < N; j++) {
         sum += a[j];
         cand.push_back(sum);
      }
   }

   int mask = 0;
   for (int i = 40; i >= 0; i--) {
      if (func(mask | (1LL << i)) >= K) {
         mask |= (1LL << i);
      }
   }
   cout << mask << endl;

   return 0;
}

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

using namespace std;

#define pb push_back

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i = sy; i < ty; i++){
        cout << 'U';
    }
    for(int i = sx; i < tx; i++){
        cout << 'R';
    }
    for(int i = sy; i < ty; i++){
        cout << 'D';
    }
    for(int i = sx; i < tx; i++){
        cout << 'L';
    }
    cout << 'L';
    for(int i = sy; i <= ty; i++){
        cout << 'U';
    }
    for(int i = sx; i <= tx; i++){
        cout << 'R';
    }
    cout << 'D';
    cout << 'R';
    for(int i = sy; i <= ty; i++){
        cout << 'D';
    }
    for(int i = sx; i <= tx; i++){
        cout << 'L';
    }
    cout << 'U';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;


const int MAX_V= 5005;
 
struct edge{
  int to,cap,cost,rev;
  edge(int to,int cap,int cost,int rev) :
    to(to),cap(cap),cost(cost),rev(rev) {}
};
  
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
  
void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(edge(to,cap,cost,G[to].size()));
  G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  while(f>0){
    fill(dist,dist+MAX_V,MAX); dist[s] = 0;
    bool update=true;
    while(update){
      update=false;
      for(int v=0; v<MAX_V; v++){
        if(dist[v]==MAX) continue;
        for(int i=0; i<(int)G[v].size(); i++){
          edge &e=G[v][i];
          if(e.cap>0 && dist[e.to]>dist[v]+e.cost){
            dist[e.to]=dist[v]+e.cost;
            prevv[e.to]=v; preve[e.to]=i; update=true;
          }
        }
      }
    }
    if(dist[t]==MAX) return -1;
    int d = f;
    for(int v=t; v!=s; v=prevv[v]){
      d=min(d,G[prevv[v]][preve[v]].cap);
    }
    f-=d;res+=d*dist[t];
    for(int v=t; v!=s; v=prevv[v]){
      edge &e=G[prevv[v]][preve[v]];
      e.cap-=d;G[v][e.rev].cap+=d;
    }
  }
  return res;
}

ll d[55][55];

void Main() {
  ll n,m;
  cin >> n >> m;
  vector<string> s(n);
  rep(i,n) R s[i];
  ll cnt=0;
  rep(i,n) {
    rep(j,m) {
      if(s[i][j]!='#') add_edge(i*m+j+n*m,5002,1,0);
      if(s[i][j]=='o') {
        cnt++;
        add_edge(5001,i*m+j,1,0);
        REP(x,i,n)REP(y,j,m) d[x][y]=-MAX;
        d[i][j]=0;
        REP(x,i,n) {
          REP(y,j,m) {
            if(d[x][y]!=-MAX) add_edge(i*m+j,x*m+y+n*m,1,-d[x][y]);
            REP(k,1,3) {
              int xx=x+dx[k],yy=y+dy[k];
              if(check(n,m,xx,yy)&&s[xx][yy]!='#') {
                d[xx][yy]=max(d[xx][yy],d[x][y]+1);
              }
            }
          }
        }
      }
    }
  }
  pr(-min_cost_flow(5001,5002,cnt));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 6684
// Vicfred
// https://atcoder.jp/contests/abc163/tasks/abc163_b
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;

void main() {
    long n, m;
    readf("%s %s\n", &n, &m);

    long[] a = readln.split.map!(to!long).array;

    if(n >= sum(a))
        writefln("%s", n-sum(a));
    else
        "-1".writefln;
}



Measured memory_bytes: 3280
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> r(N);
	for (int i = 0; i < N; i++)
		cin >> r[i];
	sort(r.begin(), r.end());
	double ma = 0;
	for (int n = 3; n <= N; n++) {
		vector<int> a(r.end() - n, r.end());
		do {
			vector<double> x(n), y(n);
			for (int i = 0; i < n; i++) {
				x[i] = a[i] * cos(M_PI*2 / n * i);
				y[i] = a[i] * sin(M_PI*2 / n * i);
			}
			for (int t = 0; t < 3; t++) {
				int i = rand() % n;
				int j = (i + n - 1) % n, k = (i + 1) % n;
				double dx = x[k] - x[j], dy = y[k] - y[j];
				double _dx = dy, _dy = -dx;
				double r = sqrt(_dx * _dx + _dy * _dy);
				x[i] = _dx / r * a[i];
				y[i] = _dy / r * a[i];
			}
			double sum = 0;
			for (int i = 0; i < n; i++) {
				int j = (i + 1) % n;
				sum += x[i] * y[j] - y[i] * x[j];
			}
			ma = max(ma, sum);
		} while (next_permutation(a.begin() + 1, a.end()));
	}
	printf("%.15f\n", ma / 2);
}

Measured memory_bytes: 3656
#define rep(i,n) for(int i=0;i<(n);++i)

#include<iostream>
#include<fstream>
#include<iomanip>

#include<vector>
#include<array>
#include<string>
#include<bitset>
#include<queue>

#include<utility>

#include<algorithm>
#include<cmath>
using ll = long long;
using namespace std;

inline bool isOK(const ll index,const vector<ll>& A,const vector<ll>& F,const ll k,const ll n){
    ll sum=0;
    rep(i,n){
        sum += max(0ll,A[i]-index/F[i]);
        if(sum>k){return(false);}
    }
    return(true);
}


int src(){
    ll n,k;
    cin>>n>>k;
    vector<ll> A(n,0),F(n,0);
    vector<pair<ll,ll>> t(n,{0,0});
    rep(i,n){cin>>A[i];}
    rep(i,n){cin>>F[i];}
    sort(A.begin(),A.end());
    sort(F.rbegin(),F.rend());
    ll ng = -1; 
    ll ok = 1e12;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        (isOK(mid,A,F,k,n)? ok:ng) = mid;
    }
    cout<<ok;
    return 0;
}


int main(int argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void) {
	int n,i;
	char s[100], t[100];
	scanf("%d",&n);
	scanf("%s %s", s, t);
	for (i = 0; i < n;i++){
		printf("%c%c", s[i], t[i]);
	}
	printf("\n");

	return 0;    
}


Measured memory_bytes: 128
# coding: utf-8

def main():
  while True:
    (n, m, a) = map(int, raw_input().split(' '))
    if (n, m, a) == (0, 0, 0): break

    bars = []
    for i in range(m):
      (h, p, q) = map(int, raw_input().split(' '))
      bars.append((h, p, q))

    x = a
    while True:
      # Down step by step, and above bars are removed in each step
      # To handle straight down case (no possible bars), next_bar can be (0,x,x)
      next_bar = max([b for b in bars if b[1] == x or b[2] == x] + [(0, x, x)])
      x = next_bar[2] if next_bar[1] == x else next_bar[1]
      y = next_bar[0]
      map(lambda b: bars.remove(b), [b for b in bars if b[0] >= y])
      if bars == []: break
    print x

if __name__ == '__main__':
  main()

Measured memory_bytes: 4320
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int C, D, W, X;
	static int[][] E, F;

	public static void main(String[] args) throws Exception {
		while (true) {
			C = sc.nextInt();
			D = sc.nextInt();
			W = sc.nextInt();
			X = sc.nextInt();
			if (C == 0) break;
			E = new int[C][D];
			F = new int[C][D];
			for (int i = 0; i < C; ++i) {
				for (int j = 0; j < D; ++j) {
					E[i][j] = sc.nextInt();
				}
			}
			for (int i = 0; i < C; ++i) {
				for (int j = 0; j < D; ++j) {
					F[i][j] = sc.nextInt();
				}
			}
			System.out.println(solve());
		}
	}

	static int solve() {
		int[][][] dp = new int[D + 1][W + 1][X + 1];
		for (int[][] a : dp) {
			for (int[] aa : a) {
				Arrays.fill(aa, -1);
			}
		}
		dp[0][0][0] = 0;
		for (int i = 0; i < D; ++i) {
			for (int j = 0; j <= W; ++j) {
				for (int k = 0; k <= X; ++k) {
					dp[i + 1][j][k] = dp[i][j][k];
				}
			}
			for (int j = 0; j < C; ++j) {
				int gain = 0;
				int tire = 0;
				for (int k = j; k < C; ++k) {
					if (E[k][i] == 0) break;
					gain += E[k][i];
					tire += F[k][i];
					if (k == j) {
						for (int l = W - tire; l >= 0; --l) {
							for (int m = X; m >= 0; --m) {
								if (dp[i][l][m] >= 0) dp[i + 1][l + tire][m] = Math.max(dp[i + 1][l + tire][m], dp[i][l][m] + gain);
							}
						}
					} else {
						for (int l = W - tire; l >= 0; --l) {
							for (int m = X - 1; m >= 0; --m) {
								if (dp[i][l][m] >= 0)
									dp[i + 1][l + tire][m + 1] = Math.max(dp[i + 1][l + tire][m + 1], dp[i][l][m] + gain);
							}
						}
					}
				}
			}
		}
		int max = 0;
		for (int i = 0; i <= D; ++i) {
			for (int j = 0; j <= W; ++j) {
				for (int k = 0; k <= X; ++k) {
					max = Math.max(max, dp[i][j][k]);
				}
			}
		}
		return max;
	}

}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll vector <pll>
#pragma 03
using namespace std;
double dp[3005][3005];
double p[3005];
int main(){
	cout << fixed << setprecision(10);
	ll n;
	cin >> n;
	for (int i = 0; i<n; i++) cin >> p[i];
	for (int i = 1; i<3005; i++) dp[0][i] = 0;
	dp[0][0] = 1;
	for (int i = 1; i<3005; i++){
		dp[i][0] = dp[i-1][0] * (1 - p[i-1]);
		for (int j = 1; j<3005; j++){
			dp[i][j] = (dp[i-1][j] * (1 - p[i-1])) + (dp[i-1][j-1] * p[i-1]);
		}
	}
	double ans = 0;
	for (int i = n; i>=(n+1)/2; i--) ans += dp[n][i];
	cout << ans << endl;  
	return 0;
}
 


Measured memory_bytes: 70784
a, b, c = map(int, input().split())


def is_even(a, b, c):
    if a % 2 != 0:
        return False
    if b % 2 != 0:
        return False
    if c % 2 != 0:
        return False
    return True

count = 0
rem = []

flag = True

while is_even(a, b, c) and flag:
    a, b, c = (b + c) / 2, (a + c) / 2, (a + b) / 2
    count += 1
    if (a, b, c) in rem:
        print("-1")
        flag = False
        break
    rem.append((a, b, c))


if flag is True:
    print(count)


Measured memory_bytes: 3064
N=int(input())
AB=[list(map(int,input().split())) for i in range(N-1)]
l=[[] for i in range(N)]
e=[0]*(N-1)
for i,(a,b) in enumerate(AB):
    l[a-1].append((b-1,i))
    l[b-1].append((a-1,i))
from collections import deque
q=deque([(AB[0][0]-1,1),(AB[0][1]-1,1)])
e[0]=1
M=1
while q:
    vp,c=q.popleft()
    x=1
    for vn,en in l[vp]:
        if e[en]==0:
            if x==c:
                x=c+1
            q.append((vn,x))
            e[en]=x
            M=max(M,x)
            x+=1
print(M)
print(*e,sep='\n')

Measured memory_bytes: 87640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
int n,x,t;
cin >> n >> x >> t;
if (n%x == 0) cout << n/x*t << endl;
else cout << (n/x+1)*t << endl;

return 0;
}



Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c>=b||a>=d)
    {
        cout<<"0";
    }
    else
    {
        cout<<min(b,d)-max(a,c);
    }
    return 0;
}


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

const ll mod = 1000000000+7;

//二項係数
/*繰り返し自乗法*/
ll fac[1001001];
ll invfac[1001001];
ll mod_pow(ll a, ll n, ll p){
    if(n == 0){
        return 1;
    }
    if(n%2){
        return (a * mod_pow(a, n-1, p)) % p;
    }
    ll t = mod_pow(a, n/2, p);
    return (t*t)%p;
}

ll combination(ll n, ll r, ll mod){
    if(r < 0 || r > n)  return 0;
    ll ret = fac[n];
    (ret *= invfac[n-r]) %= mod;
    (ret *= invfac[r]) %= mod;
    return ret;
}

int main(){
    int n, k;   cin >> n >> k;  
    fac[0] = 1;
    for(ll i = 1; i <= n+5; i++){
        fac[i] = fac[i-1] * i;
        fac[i] %= mod;
    } 
    for(ll i = 0; i <= n+5; i++){
        invfac[i] = mod_pow(fac[i], mod-2, mod);
    }
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0, tmp = 0;
    rep(j, 2){
        rep(i, n){
            switch(j){
                case 0:
                    tmp = a[i] * combination(i, k-1, mod);
                    tmp %= mod;
                    ans += tmp;
                break;
                case 1:
                    tmp = a[i] * combination(i, k-1, mod);
                    tmp %= mod;
                    ans -= tmp;
                break;
            }
            ans %= mod;
        }
        reverse(a.begin(), a.end());
    }
    cout << ans << endl;
}


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

#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define int long long

int n, k, dp[305][305][305], h[305], mn1[305][305], mn2[305][305], lev[305];
unordered_map<int, int> mp;

main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	cin >> k;
	set<int> s;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		s.insert(h[i]);
	}
	s.insert(0);
	int id = 0;
	for (auto u : s) {
		mp[u] = id;
		lev[id] = u;
		id++;
	}
	for (int i = 1; i <= n; i++) {
		h[i] = mp[h[i]];
	}
	memset(dp, -1, sizeof(dp));
	for (int j = 0; j <= k; j++) {
		for (int o = 0; o < id; o++) {
			mn1[j][o] = 0;
			mn2[j][o] = 1e18;
		}
	}
	mn2[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		//no change
		for (int j = min(k, i); j >= 0; j--) {
			dp[i][j][h[i]] = min(mn2[j][h[i]], mn1[j][h[i]] + lev[h[i]]);
			if (dp[i][j][h[i]] == 1e18) dp[i][j][h[i]] = -1;
		}
		//change
		for (int j = min(k, i); j >= 1; j--) {
			for (int o = 0; o < id; o++) {
				if (o == h[i]) continue;
				if (dp[i][j][o] == -1) dp[i][j][o] = 1e18;
				dp[i][j][o] = min(dp[i][j][o], mn1[j - 1][o] + lev[o]);
				dp[i][j][o] = min(dp[i][j][o], mn2[j - 1][o]);
				if (dp[i][j][o] >= 1e18) dp[i][j][o] = -1;
			}
		}
		for (int j = min(k, i); j >= 0; j--) {
			if (dp[i][j][0] == -1) mn1[j][0] = 1e18;
			else mn1[j][0] = dp[i][j][0] - lev[0];
			for (int o = 1; o < id; o++) {
				if (dp[i][j][o] != -1) mn1[j][o] = min(mn1[j][o - 1], dp[i][j][o] - lev[o]);
				else mn1[j][o] = mn1[j][o - 1];
			}
			mn2[j][id] = 1e18;
			for (int o = id - 1; o >= 0; o--) {
				if (dp[i][j][o] != -1) mn2[j][o] = min(mn2[j][o + 1], dp[i][j][o]);
				else mn2[j][o] = mn2[j][o + 1];
			} 
		}
		for (int j = 0; j <= min(k, i); j++) {
			for (int o = 0; o < id; o++) {
				//cout << i << ' ' << j << ' ' << o << ' ' << dp[i][j][o] << endl;
			}
		}
	}
	int res = 1e18;
	for (int j = 0; j <= k; j++) {
		for (int o = 0; o < id; o++) {
			if (dp[n][j][o] == -1) continue;
			res = min(res, dp[n][j][o]);
		}
	}
	cout << res;
	return 0;
}

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

int main() {
    string s, sr;
    cin >> s;
    int n = s.length();
    sr = s;
    reverse(sr.begin(), sr.end());
    bool ok = true;
    if(s != sr)ok = false;
    if(s.substr(0, (n-1)/2) != sr.substr((n+1)/2))ok = false;
     if(sr.substr(0, (n-1)/2) != s.substr((n+1)/2))ok = false;

    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
   

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 3584
K = int(input())
 
res = [(0, 0)]
mm = 0
cands = []
for i in range(1, 1000):
  v = i
  for j in range(16):
    cands.append(v)
    v = 10 * v + 9

cands = list(sorted(set(cands)))

for x in cands:
  i = sum(ord(c) - ord('0') for c in str(x))
  while x / i < res[-1][0]:
    res = res[:-1]
  res.append((x / i, x))
 
for i in range(1, K + 1):
  print(res[i][1])

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int D, N;
    cin >> D >> N;
    int bs = 1;
    REP(i, 0, D) {
        bs *= 100;
    }
    if (N == 100) N++;
    cout << bs * N << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  auto a_cp = a;

  ll ans = 0;
  rep (i, n-1) {
    if (a[i] + a[i+1] > x) {
      ll eat = a[i] + a[i+1] - x;
      if (eat <= a[i+1]) {
        a[i+1] -= eat;
        ans += eat;
      } else {
        a[i] -= (eat - a[i+1]);
        a[i+1] = 0;
        ans += eat;
      }
    }
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1024
a, b, h, m = map(int, input().split())
aka = 360 * (h / 12) + 30 * (m / 60)
ao = 360 * (m / 60)
seta = aka - ao
import math
seta = math.radians(seta)
ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(seta)
print(math.sqrt(ans))


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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum^=a[i];
    }
    rep(i,n) cout<<(sum^a[i])<<' ';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 4620
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    char s[a + b + 1 + 1];
    scanf("\n%s",s);
    if(s[a] == '-'){
        for(int i = 0; s[i] != 0; i++){
            if(i != a){
                if('0' <= s[i] && s[i] <= '9'){
                    continue;
                }else{
                    printf("No\n");
                    
                    return 0;
                }
            }else{
                continue;
            }
        }
    }else{
        printf("No\n");

        return 0;
    }
    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char a=scan.next().charAt(0);
		char b=scan.next().charAt(0);
		scan.close();
		if(a=='H') {
			if(b=='H')System.out.println(a);
			else System.out.println(b);
		}else {
			if(b=='H')System.out.println(a);
			else System.out.println('H');
		}

	}
}

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

#define fi                      first
#define se                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

void solve();

int32_t main()
{
        fast;
        int t = 1;
        // cin >> t;
        for(int i = 1; i <= t; ++i)
                solve();
        cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}

void solve() {
	int n,m;
	cin >> n >> m;
	std::vector<int> v(n+1,0), cnt(n+1,0);
	ll a = 0, b = 0;
	FOR(i,0,m) {
		int p;
		cin >> p;
		string s;
		cin >> s;
		if(s[0] == 'A') {
			if(v[p])
				continue;
			else {
				v[p] = 1;
			}
		}
		else {
			if(v[p]) {
				continue;
			}
			else {
				cnt[p]++;
			}
		}
	}
	FOR(i,1,n+1) {
		if(v[i]) {
			a++;
			b += cnt[i];
		}
	}
	cout << a << " "  << b << endl;
}

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

int main() {
    int N;
    cin >> N;
    int d[N];
    for (int i=0; i < N; ++i){
        cin >> d[i];
    }
    int res = 0;
    for (int i = 0; i < N-1; ++i){
        for (int j = i+1; j < N; ++ j){
            res += d[i] * d[j];
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
def actual(X):
    pow_nums = [1]

    for i in range(2, 40 + 1):
        for j in range(2, 40 + 1):
            if i ** j <= 1000:
                pow_nums.append(i ** j)

    pow_nums = sorted(set(pow_nums))

    return [pow_num for pow_num in pow_nums if pow_num <= X][-1]


X = int(input())
print(actual(X))


Measured memory_bytes: 9124
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    int N, X, tmp, cnt;  cin >> N >> X;
    tmp = 0;
    cnt = 1;
    for(int i=0; i<N; i++){
        int l;  cin >> l;
        tmp += l;
        if(tmp <= X)    cnt++;
    }
    print(cnt);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN  = 1e5+200;
int N;
int A[MAXN];
int abs(int a) {
    if (a<0)
        return -a;
    return a;
}
int main() {
    cin >> N;
    long long sum = 0;
    int minimum = 2*MAXN;
    int broi = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (A[i] < 0)
            broi++;
        minimum = min(minimum, abs(A[i]));
        sum+=(long long)abs(A[i]);
    }
    if (broi%2==0)
        cout << sum;
    else
        cout << sum-2*minimum;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define name(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int N=(int)1e6+7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    for(int & x : a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    vector<pii>ans;
    int now = 0;
    if(a[0] > 0){ /// all positive
        now = a[0];
        for(int i =1; i + 1 < n; i++) {
            ans.emplace_back(now, a[i]);
            now -= a[i];
        }
        ans.emplace_back(a[n - 1], now);
        now = a[n - 1] - now;
    }
    else if(a[n - 1] < 0){/// all negative
        now = a[n - 1];
        for(int i = n - 2; i >= 0; --i) {
            ans.emplace_back(now, a[i]);
            now -= a[i];
        }
    }
    else{
        now = a[0];
        for(int i = 1; i + 1 < n; i++) {
            if(a[i] >= 0){
                ans.emplace_back(now, a[i]);
                now -= a[i];
            }
        }
        ans.emplace_back(a[n - 1] , now);
        now = a[n - 1] - now;
        for(int i = 1; i + 1 < n; i++) {
            if(a[i] < 0){
                ans.emplace_back(now, a[i]);
                now -= a[i];
            }
        }

    } 
    cout << now << '\n';
    for(pii  c : ans){
        cout << c.first << ' ' << c.second << '\n';
    }
    return 0;
}



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

using namespace std;

int main(){
	char S[100005];
	for(int i=0;i<100000;i++){
		S[i]='A';
	}
	int big=0;
	scanf("%s",&S);
	for(int i=0;i<100000;i++){
		if(S[i]!='A')big++;
	}
	
	int cha=0;
	if(S[0]=='B')cha=1;
	if(S[0]=='W')cha=2;
	int ans=0;
	
	for(int i=1;i<big;i++){
		if(cha==1&&S[i]=='W'){
			ans++;cha=3;
		}
			
		if(cha==2&&S[i]=='B'){
			ans++;cha=1;
		}
		if(cha==3)cha=2;
	}
	printf("%d\n",ans);
	
	
}

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

typedef long long lint;
typedef long double louble;
typedef pair<int,int> pii;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline lint ty()
	{
		lint a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007;

int n;
struct cxk
{
	int a,b,c;
	cxk(int _a=0,int _b=0,int _c=0){a=_a,b=_b,c=_c;}
}p[_];

struct dlq
{
	multiset<int> val;
	lint sum;
	int lim;	

	dlq(){val.clear(),sum=0,lim=0;}

	inline void cls(int _lim=0){val.clear(),sum=0,lim=_lim;}

	inline void push(int dlt)
	{
		if((int)val.size()<lim){val.insert(dlt),sum+=dlt;return;}
		int co=*val.begin();
		if(co<dlt)val.erase(val.find(co)),val.insert(dlt),sum+=dlt-co;
	}
}q;

int tara,tarb,tarc;
pii cp[_];

lint ansl[_],ansr[_];

int main()
{
	/*n=ty(),*/tara=ty(),tarb=ty(),tarc=ty();
	n=tara+tarb+tarc;

	for(int i=1,a,b,c;i<=n;i++)a=ty(),b=ty(),c=ty(),p[i]=cxk(a,b,c);

	lint ans1=0,ans2=-9e18;
	for(int i=1;i<=n;i++)ans1+=p[i].c,cp[i]=make_pair(p[i].a-p[i].c,p[i].b-p[i].c);
	sort(cp+1,cp+n+1,[](pii a,pii b){return a.first-a.second<b.first-b.second;});

	q.cls(tarb);
	for(int i=1;i<=n;i++)q.push(cp[i].second),ansl[i]=q.sum;
	q.cls(tara);
	for(int i=n;i>=1;i--)q.push(cp[i].first),ansr[i]=q.sum;
	for(int i=tarb;i+1<=n-tara+1;i++)ans2=max(ans2,ansl[i]+ansr[i+1]);
	printf("%lld\n",ans1+ans2);

	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  cout<<((A*B*(A+B))%3==0?"Possible":"Impossible")<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
S = sum(A)%(10**9+7)
ans = 0
for i in range(N-1):
  S -= A[N-i-1]
  ans += S*A[N-i-1]%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 93960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    cout << 48 - n << endl;
}

Measured memory_bytes: 256
// ABC 173 C H and V

#include <bits/stdc++.h>
using namespace std;

int solve(int H, int W, int K, vector<vector<string>> t) {
  int ans = 0;
  for (int n=0; n < pow(2,H); n++) {
    for (int m=0; m < pow(2,W); m++) {
      int cnt = 0;
      for (int i=0; i < H; i++) {
        for (int j=0; j < W; j++) {
          if ((n >> i & 1) == 0 && (m >> j & 1) == 0) {
            if (t.at(i).at(j) == "#") {
              cnt++;
            }
          }
        }
      }
      if (cnt == K) ans++;
    }
  }
  return ans;
}

int main () {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<string>> t(H, vector<string>(W));
  for (int i=0; i<H; i++) {
    char line[W];
    cin >> line;
    for (int j=0; j<W; j++) {
      t.at(i).at(j) = line[j];
    }
  }
  cout << solve(H, W, K, t) << endl;
  return 0;
}

Measured memory_bytes: 4124
# -*- coding: utf-8 -*-
from sys import stdin

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
st = ""

for i in range(len(s)):
    st += s[i] + t[i]

st_sprit = [st[i: i+2] for i in range(0, len(st), 2)]

s_unique = list(set(s))
t_unique = list(set(t))
st_sprit_unique = list(set(st_sprit))

if min(len(s_unique),len(t_unique)) == len(st_sprit_unique):
    print("Yes")
else:
    print("No")



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

#if DEBUG && !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=(a)-((a)>(n)); i!=(n)-((a)>(n)); i+=1-2*((a)>(n)))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_back
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(12);
#define fill(a, b) memset(a, b, sizeof(a)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000009

int main(){
	flash; QuickSilver;
	int n,k; cin>>n>>k;
	vl a(n); get(a);
	vb ans(k+1,false); ans[a[0]]=true;
	rep(j,a[0]+1,k+1) rep(i,0,n)
		if(j>=a[i])ans[j]=ans[j] || !ans[j-a[i]];
	cout<<(ans[k]?"First":"Second")<<"\n";
	return 0;
}

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

cnt = 0
blue = 0
red = 0

for i in range(1, n):
	if s[i] == s[i-1]:
		cnt += 1
	elif s[i-1:i+1] == 'LR':
		blue += 1
	elif s[i-1:i+1] == 'RL':
		red += 1

if k <= min(blue, red):
	cnt += 2 * k
else:
	cnt += 2 * min(blue, red)
	if s[0] == 'R' and s[-1] == 'L':
		cnt += 1
	elif s[0] == 'L' and s[-1] == 'R':
		cnt += 1
	else:
		pass

print(cnt)


Measured memory_bytes: 39664
#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>;

char table[60][60];

int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            char x;
            cin >> x;
            if (x == '.')
                x = '0';
            table[i][j] = x;
        }
    }
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (table[i][j] == '#')
            {
                for (int k = i - 1; k <= i + 1; k++)
                {
                    for (int l = j - 1; l <= j + 1; l++)
                    {
                        if (table[k][l] == '#')
                            continue;
                        else
                        {
                            table[k][l] += 1;
                        }
                    }
                }
            }
        }
    }
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            cout << table[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main() {
string a,b,c;
cin>>a>>b>>c;
int x=a.length();
int y=b.length();
int z=c.length();
if(a[x-1]==b[0]&&b[y-1]==c[0]) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMain

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		try {
			FastScannerMain sc = new FastScannerMain(System.in);
			int N = sc.nextInt();

			ArrayList<String> arr = new ArrayList<String>();
			dfs("", String.valueOf(N).length(), N, arr);
			System.out.println(arr.size());

		} catch (

		Exception e) {
			e.printStackTrace();
		}

	}

	private void dfs(String s, int len, int N, ArrayList<String> arr) {

		if (s.length() == len) {
			if (Integer.valueOf(s) <= N && s.contains("3") && s.contains("5") && s.contains("7")) {
				//System.out.println(s);
				arr.add(s);
			}
		} else {
			if (s != "" && Integer.valueOf(s) <= N && s.contains("3") && s.contains("5") && s.contains("7")) {
				//System.out.println(s);
				arr.add(s);
			}
			for (int i = 3; i <= 7; i += 2) {
				dfs(s + String.valueOf(i), len, N, arr);
			}
		}
	}
}

//高速なScanner
class FastScannerMain {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 33364
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++)
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define pii pair<int,int>
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n,t;
	cin>>n>>t;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	a.push_back(a[n-1]+t);
	
	llong ans=0;
	REP(i,n){
		if(a[i+1]-a[i]<t) ans+=a[i+1]-a[i];
		else ans+=t;
	}
	
	cout<<ans<<endl;
}

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

def main():
    N = int(input())
    c = input()
    cnt_r = 0
    cnt_w = 0
    for i in c:
        if i == 'R':
            cnt_r += 1
        else:
            cnt_w += 1
    
    w_left = 0
    r_right = cnt_r
    ans = N
    for i in range(N):
        ans = min(ans, max(w_left, r_right))

        if c[i] == 'W':
            w_left += 1
        else:
            r_right -= 1
    print(min(ans, max(w_left, r_right)))

main()

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

int main(){
  int a,b,c;
  int dif;
  cin>>a>>b>>c;
  dif=a-b;
  if(dif>c){
    cout<<0<<endl;
  }
  else{
    cout<<c-dif<<endl;
  }
  return 0;
}

Measured memory_bytes: 256