akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
namespace Domain
{
	class Result
	{
		bool ok;
	public:
		Result(bool ok=false):ok(ok){}
		bool disp() {	return  ok ;}
	};
	class Circle
	{
		int x, y,r;
		bool over(int b, int r, int m){	return (b+r > m) ? true : false;}
		bool under(int b, int r){	return (b-r < 0) ? true : false;}
	public:
		Circle(int x=0, int y=0 ,int r=0) :x(x), y(y),r(r) {}
		bool error(int W, int H)
		{
			if (!under(x, r) && !under(y, r) && !over(x, r, W) && !over(y, r, H)) return false;
			return true;
		}
	};
	class Rect
	{
		int W, H;
	public :
		Rect(int w=0, int h=0) :W(w), H(h) {}
		template <typename T,typename U>
		void  over(T& shape,U& result) {
			result=shape.error(W, H);
		}
	};

}
using namespace Domain;
namespace InterfaceAdapter
{
	class ResultDisp
	{
		static string msg[2];
	public:
		string disp(Result result) {	return  msg[result.disp()] ;}
	};
	string ResultDisp::msg[2]= { "Yes","No" };

	class RectInput
	{
	public :
		void inp(Rect& rect,Circle& circle)
		{
			int w,h,x,y,r;
			cin >> w>>h>> x>>y>>r;
			Rect rec(w,h);
			Circle cir(x,y,r);
			rect=rec;
			circle =cir;
		}
	};


}
using namespace Domain;
using namespace InterfaceAdapter;

namespace UseCase
{
	class Input
	{
	public :
		template <typename X>
		 static void inp(X shapeIn,Rect& shape1,Circle& shape2)
		{
		   shapeIn.inp(shape1,shape2);
		}
	};
	class Display
	{
	public:
		template <typename U,typename V>
		static void disp(U& result,V& dispType) { 
			cout << dispType.disp(result) << endl;
		}
	};
	class CaseOver
	{
	public:
		static void check()
		{
			RectInput rectInput;
			Rect rect;
			Circle circle;
			Input::inp(rectInput,rect,circle);
			Result result;
			rect.over(circle,result);
			ResultDisp resultDisp;
			Display::disp(result,resultDisp);
		}
	};
}
using namespace UseCase;
int main()
{
	CaseOver::check();
	return 0;

}

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

int main(){
    int a, b;
    string op;
    while (1){
        cin >> a >> op >> b;
        if (op == "?") break;
        else if (op == "+") cout << a + b << endl;
        else if (op == "-") cout << a - b << endl;
        else if (op == "*") cout << a * b << endl;
        else if (op == "/") cout << a / b << endl;
    }
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,n,input;
    int A[3][3];
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
            cin>>A[i][j];
    }
    cin>>n;
    while(n--)
    {
        cin>>input;
        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
                if(A[i][j]==input)
                {
                    A[i][j]=0;
                    break;
                }
            }
        }
    }

    if(A[0][0]==0 && A[0][1]==0 && A[0][2]==0)
        cout<<"Yes"<<endl;
    else if(A[1][0]==0 && A[1][1]==0 && A[1][2]==0)
        cout<<"Yes"<<endl;
    else if(A[2][0]==0 && A[2][1]==0 && A[2][2]==0)
        cout<<"Yes"<<endl;
    else if(A[0][0]==0 && A[1][0]==0 && A[2][0]==0)
        cout<<"Yes"<<endl;
    else if(A[0][1]==0 && A[1][1]==0 && A[2][1]==0)
        cout<<"Yes"<<endl;
    else if(A[0][2]==0 && A[1][2]==0 && A[2][2]==0)
        cout<<"Yes"<<endl;
    else if(A[0][0]==0 && A[1][1]==0 && A[2][2]==0)
        cout<<"Yes"<<endl;
    else if(A[0][2]==0 && A[1][1]==0 && A[2][0]==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
str1=set()
ans=len(s)
for i in range(len(s)):
    str1.add(s[i])
for i in range(len(str1)):
    str2=str1.pop()
    sans=0
    if s[0]==str2:
        cnt=0
    else:
        cnt=1
    for j in range(1,len(s)):
        if s[j]!=str2:
            cnt+=1
        else:
            sans=max(sans,cnt)
            cnt=0
    sans=max(sans,cnt)
    ans=min(ans,sans)
print(ans)


Measured memory_bytes: 9076
#include <iostream>

int main()
{
  int target, min, max;
  std::cin >> target;
  std::cin >> min >> max;

  for (int i = min; i <= max; i++)
  {
    if (i % target == 0)
    {
      std::cout << "OK" << std::endl;
      return 0;
    }
  }
  std::cout << "NG" << std::endl;
  return 0;
}

Measured memory_bytes: 3128
#   できる操作は２つ
#       偶数を２つ減らして偶数を１つ増やす
#       奇数を２つ減らして偶数を１つ増やす

#   つまり、奇数は操作２によってしか減らせない
#   減らせる数は偶数個である

#   操作は１回以上行われる必要がある
#   つまり、最終的な数列は偶数１つ（奇数は０つ）

#   奇数が偶数個であることが必要十分条件

N = int(input())
A = map(lambda x:int(x)%2,input().split(" "))
print(['YES','NO'][sum(A)%2])

Measured memory_bytes: 11108
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>

int main() {
	usize n, a, b;
	::std::cin >> n >> a >> b;
	::std::cout << ::std::min(a, b) << " ";
	if (a + b <= n) {
		::std::cout << 0;
	}
	else {
		::std::cout << a + b - n;
	}
	::std::cout << ::std::endl;
	return 0;
}


Measured memory_bytes: 256
def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]

    dp = {(-1, 0): 0, (-1, 1): -1e10}
    for i in range(0, N):
        dp[(i, 0)] = max(dp[(i - 1, 0)] + As[i], dp[(i - 1, 1)] - As[i])
        dp[(i, 1)] = max(dp[(i - 1, 0)] - As[i], dp[(i - 1, 1)] + As[i])
    print("{}".format(dp[(N - 1, 0)]))


sub()

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll l = 0, r = 0;
  int li = 0, ri = n - 1;
  rep(i, n) {
    if (l <= r) l += a[li++];
    else r += a[ri--];
  }
  cout << abs(l - r) << endl;
  return 0;
}


Measured memory_bytes: 4776
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using dl = double long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  dl a, b, h, m;
  cin >> a >> b >> h >> m;
  dl shorter = (h / 12 + m / 60 / 12) * M_PI * 2;
  dl longer = m / 60 * M_PI * 2;
  dl diff = abs(shorter - longer);
  cout << fixed << setprecision(10);
  cout << sqrt(a * a + b * b - 2 * a * b * cos(diff)) << endl;
}


Measured memory_bytes: 3576
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class FPlayingTagOnTree {
public:

    vector<int> graph[100001];
    vector<int> t, a;

    void dfs(int p, vector<int>& dp) {
      for(auto e: graph[p]) {
        if (dp[e] == -1) {
          dp[e] = dp[p]+1;
          dfs(e, dp);
        }
      }
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, u, v; cin >> n >> u >> v;
      u--; v--;
      t.resize(n, -1);
      a.resize(n, -1);
      rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
      }
      t[u] = 0;
      dfs(u, t);
      a[v] = 0;
      dfs(v, a);
      int ans = 0;
      rep(i, n) {
        debug(i, t[i], a[i]);
        if (t[i] < a[i]) {
          chmax(ans, a[i]-1);
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  FPlayingTagOnTree solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main()
{
    ll x, y;
    cin >> x >> y;

    int cnt = 0;
    while (x <= y)
    {
        ++cnt;
        x *= 2;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
(defn input []
  (->> (repeatedly (Integer/parseInt (read-line)) read-line)
    (mapv #(Integer/parseInt %))))

(defn Trained? [A]
  (loop [i (A 0) n 1]
    (cond
      (= 2 i) n
      (> n (count A)) -1
      :else (recur (A (dec i)) (inc n)))))

(-> (input)
  Trained?
  println)

Measured memory_bytes: 92856
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

int main()
{
	int n;
	int base[3], out, point;
	string ev;

	cin >> n;
	for(int i=0; i<n; i++){
		point = 0;
		out = 0;
		base[0] = base[1] = base[2] = 0;
		while(out < 3){
			cin >> ev;
			if(ev == "OUT") out++;
			else if(ev == "HOMERUN"){
				point += base[0] + base[1] + base[2] + 1;
				base[0] = base[1] = base[2] = 0;
			} else {
				if(base[2] == 1) point++;
				base[2] = base[1];
				base[1] = base[0];
				base[0] = 1;
			}
		}
		cout << point << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    int k;
    cin >> s >> k;
    int n = sz(s);
    rep(i, n) {
        if (i == n-1) {
            int x = s[i] + k - 'z' - 1;
            s[i] = ((x % 26) + 26) % 26 + 'a';
        } else {
            int x = ('z' + 1 - s[i]) % 26;
            if (x <= k) {
                k -= x;
                s[i] = 'a';
            } else {
                continue;
            }
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
	vector <int> heights;
	for ( int i = 0; i < 10; i++ )
	{
		int height;
		cin >> height;
		heights.push_back( height );
	}

	sort( heights.rbegin(), heights.rend() );

	for ( int i = 0; i < 3; i++ )
	{
		cout << heights.at(i) << endl;
	}

	return 0;
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

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



int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N, K; cin >> N >> K;

	vector<ll> A(N); REP(i, N) cin >> A[i], --A[i];

	ll logK = 1;
	while ((1ll << logK) < K) logK++;

	vector<vector<ll>> doubling(logK, vector<ll>(N));
	REP(i, N)
		doubling[0][i] = A[i];

	REP(k, logK-1)
	{
		REP(i, N)
		{
			doubling[k+1][i] = doubling[k][doubling[k][i]];
		}
	}

	ll now{0};
	for (ll k = 0; K > 0; ++k)
	{
		if (K & 1) now = doubling[k][now];
		K = K >> 1;
	}

	std::cout << now + 1 << std::endl;
	return 0;
}


Measured memory_bytes: 100084
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

long long A, B, C;
long long X, Y;

int main() {
	cin >> A >> B >> C >> X >> Y;
	if (A + B >= 2 * C) {
		long long cl = min(X,Y) * 2;
		long long costcl = C * cl + A * (X - cl / 2) + B * (Y - cl / 2);
		long long ce = max(X, Y) * 2;
		long long costce = C * ce;
		cout << min(costcl, costce) << endl;
	}
	else {
		cout << A * X + B * Y << endl;
	}
	return 0;
}

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



// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    long long N;
    int Q;
    string S;
    cin >> N;
    cin >> S;
    cin >> Q;
    vector<set<int>> alphabets(26);
    for(int i=0;i<N;i++){
        alphabets[S[i]-'a'].insert(i);
    }
    cerr << "read finish" << endl;
    for(int i=0;i<Q;i++){
        int j;
        cin >>j;
        if(j==1){
            int k;
            char c;
            cin >> k >> c;
            k--;
            alphabets[S[k]-'a'].erase(k);
            S[k] = c;
            alphabets[c-'a'].insert(k);
        }else{
            int s,t;
            cin >> s >> t;
            s--;
            t--;
            int ans =0;
            for(int l=0;l<26;l++){
                auto iter = alphabets[l].lower_bound(s);
                if(iter != alphabets[l].end() &&*iter <= t){
                    cerr << *iter << endl;
                    ans++;
                }
            }
            cout << ans << "\n";

        }
    }
    return 0;
}


Measured memory_bytes: 24196
#include <cstdio>
#include <algorithm>
#include <list>

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

using namespace std;

struct T{
	int a, s, e;
};

int n;
list<T> f;

int main(){
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}

		rep(i, n){
			char w;
			int a;
			scanf(" %c%d", &w, &a);

			if(w == 'W'){
				int c;
				scanf("%d", &c);

				for(auto it = f.begin(); it != f.end(); ++it){
					if(it->a == -1 && c > 0){
						c -= (it->e - it->s);
						if(c < 0){
							f.insert(it, T{a, it->s, it->e + c});
							it->s = it->e + c;
						}
						else{
							it->a = a;
						}
					}
				}
				if(c > 0){
					f.push_back(T{a, f.back().e, f.back().e + c});
				}
			}
			else if(w == 'D'){
				for(auto it = f.begin(); it != f.end(); ++it){
					if(it->a == a){
						it->a = -1;
					}
				}
			}
			else if(w == 'R'){
				bool b = false;
				for(auto it = f.begin(); it != f.end(); ++it){
					if(a < it->e){
						printf("%d\n", it->a);
						b = true;
						break;
					}
				}
				if(!b){
					printf("-1\n");
				}
			}
		}
		f.clear();
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2960
import math

def solve():
    N, K = map(int,input().split())
    A = list(map(int, input().split()))

    state = 1
    chklist = [0] * (N + 1)
    chklist_flag = [False] * (N + 1)
 
    chkmod = 0
    chkrem = K

    chklist_flag[0] = True

    for i in range(1, K + 1):
        state = A[state - 1]
        if chklist_flag[state - 1]:
            chkmod = (K - chklist[state - 1]) % (i - chklist[state - 1]) 
            chkrem = chklist[state - 1]
            break
        chklist[state - 1] = i 
        chklist_flag[state - 1] = True
    
    state = 1

    for i in range(chkrem + chkmod):
        state = A[state - 1]
    
    print(state)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 32252
/*Always success does not build on success,success build on failure*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t)
#define lscn(t)      scanf("%lld",&t)
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=1e5+5;
int main()
{
   ll n;
   lscn(n);
   
   ll w;
   lscn(w);
   
   ll arr[n+1][2];
   
   for(ll i=0;i<n;i++)
   {
       lscn(arr[i+1][0]);
       lscn(arr[i+1][1]);
   }
   
   ll ans[n+1][w+1];
   
   memset(ans,0,sizeof(ans));
   
   for(ll i=1;i<=n;i++)
   {
       for(ll j=1;j<=w;j++)
       {
           ans[i][j]=ans[i-1][j];
           if(arr[i][0]<=j)
           {
               ans[i][j]=max(ans[i][j],arr[i][1]+ans[i-1][j-arr[i][0]]);
           }
       }
   }
//   for(ll i=1;i<=n;i++)
//   {
//       for(ll j=1;j<w;j++)
//       {
//           cout<<ans[i][j]<<" ";
//       }
//       cout<<endl;
//   }
   cout<<ans[n][w];
}

Measured memory_bytes: 79232
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

template <typename M>
struct SegmentTree
{
	const int n;
	const M I;
	const std::function<M(M,M)> f;
	std::vector<M> data;
	SegmentTree(int n, M I, std::function<M(M,M)> f) : n(n), data(2*n,I), I(I), f(f) {}
	void set(int i, const M& v) {
		data[n+i]=v;
	}
	void build() {
		for(int i=n-1;i>0;i--) {
			data[i]=f(data[i<<1],data[i<<1|1]);
		}
	}
	void update(int i, const M& v) {
		set(i,v);
		i+=n;
		for(i>>=1;i>0;i>>=1) {
			data[i]=f(data[i<<1],data[i<<1|1]);
		}
	}
	M get(int i) {
		return data[n+i];
	}
	M query(int l, int r) {
		M L=I, R=I;
		l+=n; r+=n;
		while(r>l) {
			if(l&1) L=f(L,data[l++]);
			if(r&1) R=f(data[--r],R);
			l>>=1; r>>=1;
		}
		return f(L,R);
	}
};


struct M
{
	int x, i;
	M(int x, int i) : x(x),i(i) {}
};

struct I
{
	int l, r, m;
	I(int l, int r, int m) : l(l),r(r),m(m) {}
	bool operator<(const I a) const {
		return m>a.m;
	}
};

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> p(n);
	rep(i,n) std::cin >> p[i];
	const int INF=1e9;
	std::vector<SegmentTree<M> > even(2,SegmentTree<M>(n,M(INF,-1),[](M a, M b) { return (a.x<b.x)?a:b; }));
	// SegmentTree<M> odd(n,M(INF,-1),[](M a, M b) { return (a.x<b.x)?a:b; });
	rep(i,n) {
		even[i&1].set(i,M(p[i],i));
	}
	std::vector<int> ans;
	even[0].build(); even[1].build();
	std::priority_queue<I> que;
	que.emplace(0,n,even[0].query(0,n).x);
	while(!que.empty()) {
		I t=que.top(); que.pop();
		int w=t.l&1;
		M f=even[w].query(t.l,t.r);
		M s=even[w^1].query(f.i,t.r);
		ans.emplace_back(f.x);
		ans.emplace_back(s.x);
		if(t.l<f.i) que.emplace(t.l,f.i,even[w].query(t.l,f.i).x);
		if(s.i+1<t.r) que.emplace(s.i+1,t.r,even[w].query(s.i+1,t.r).x);
		if(f.i+1<s.i) que.emplace(f.i+1,s.i,even[w^1].query(f.i+1,s.i).x);
	}
	for(auto x:ans) std::cout << x << ' ';
	std::cout << EL;
	return 0;
}


Measured memory_bytes: 20608
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
#define SIZE 1000000

int main(){
	int n;
	vi hoge;
	int x;
	cin>>n;
	set<int> ss;
	for(int i=0;i<n;i++){
		cin>>x;
		hoge.pb(x);
		if(i%2==1)ss.insert(x);
	}
	sort(hoge.begin(),hoge.end());
	for(int i=0;i<n;i++){
		if(i%2==1)ss.insert(hoge[i]);
	}
	cout<<ss.size()-n/2<<endl;
}
	

Measured memory_bytes: 5368
from collections import defaultdict

N = int(input())
S1 = input()
S2 = input()

D = defaultdict(int)

mod = 10**9 + 7

for x in S1:
  D[x] += 1

def cnt(x, y):
  if x == 1 and y == 1:
    return 2
  elif x == 1 and y == 2:
    return 2
  elif x == 2 and y == 1:
    return 1
  else:
    return 3

L = list(D.values())
n = len(L)

ans = 1
if L[0] == 1:
  ans *= 3
else:
  ans *= 6

for i in range(1, n):
  ans *= cnt(L[i-1], L[i])
  ans %= mod

print(ans)

Measured memory_bytes: 9380
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<set>
#include<cmath>
using namespace std;



int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n,0);
  
  for(int i=0;i<n;i++) cin >> a[i];
  if(k>=n){
    cout << 0 << endl;
    return 0;
  } 
  

  sort(a.begin(),a.end());
  long long sum = 0;
  for(int i=0;i<n-k;i++) sum += a[i];

  cout << sum << endl;
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>

using namespace std;


int main(int argc, char** argv) {
    long long a, b;
    cin >> a >> b;

    long long rank = 2;
    long long ans = 0;
    int max_rank = 50;

    for (int r = 0; r < max_rank; ++r) {
        long long cnt = (b / rank - a / rank) * rank/2;
        long long a_remain = a % rank;
        long long b_remain = b % rank;
        if (a_remain >= rank/2) {
            cnt -= a_remain - rank/2;
        }
        if (b_remain >= rank/2) {
            cnt += b_remain - rank/2 + 1;
        }
        if (cnt % 2 == 1) {
            ans += ((long long)1 << r);
        }
        rank *= 2;
    }
    cout << ans << endl;

    return 0;
}


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


int X;


void input() {
    cin >> X;
}


int main() {
    input();
    int a = X / 500;
    X -= a * 500;
    int b = X / 5;
    int ans = a * 1000 + b * 5;
    cout << ans << endl;
}


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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h[2000000], n=0;
    int key;
    int i, m;
    
    string com;
    while(true) {
        cin>>com;
        if(com[0]=='i') {
            cin>>key;
            i = ++n;
            while(i>1) {
                if(h[i/2]>key) break;
                h[i]=h[i/2];
                i/=2;
            }
            h[i]=key;
        } else if(com[1]=='x') {
            cout<<h[1]<<'\n';
            key=h[n--];
            i=1;
            while(true) {
                m=2*i;
                if(m>n) break;
                if(m<n && h[m+1]>h[m]) ++m;
                if(h[m]<key) break;
                h[i]=h[m];
                i=m;
            }
            h[i]=key;
        } else {
            break;
        }
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    double a = 0.0;
    double v;
    rep(i, n)
    {
        cin >> v;
        a += (double)1.0 / v;
    }
    a = (double)1.0 / a;
    cout << fixed << setprecision(16);
    cout << a << endl;
}

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

int main(){
  string s;
  cin >> s;
  vector<string> A(s.size(),"");
  string c = "";
  int count  = 1;
  
  A.at(0) = s.at(0);
  for(int i=1; i<s.size(); i++){
    c += s.at(i);
    if(A.at(count-1) == c){
      A.at(count) += s.at(i);
    }else{
      c = "";
      A.at(count) +=s.at(i);
      count += 1;

    }

  }
  cout << count << endl;
}

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

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



int main() {
    // 入力
    int N,A,B;
    cin >> N >> A >> B;
    int total = 0;

    for (int i = 0; i <= N; i ++){
      int sum = findSumOfDigits(i);
      if(sum >= A && sum <=B){
        total += i;
      }
    }
    cout << total << endl;
}


Measured memory_bytes: 3636
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void rec(int[][] map ,int i, int j, int count){

		map[i][j] = count;

		int[] x = {1,-1,0,0};

		int[] y = {0,0,1,-1};

		for(int d=0;d<4;d++){

			int ni = i+x[d];

			int nj = j+y[d];

			if(map[ni][nj] == 1){

				rec(map,ni,nj,count);

			}			

		}

	}

	

	void run(){

		for(;sc.hasNextLine();){

			int[][] map = new int[14][14];

			boolean c = false;

			for(int i=0;i<12;i++){

				String l = sc.nextLine();

				if(l.length() == 0){

					c=true;

					break;

				}

				for(int j =0; j <12;j++){

					map[i+1][j+1] = l.charAt(j)-'0';

				}

			}

			if(c) continue;

			int count = 0;

			for(int i = 1; i<13; i++){

				for(int j= 1; j < 13;j++){

					if(map[i][j] == 1){

						rec(map,i,j, count++ + 2);

					}

				}

			}

			System.out.println(count);

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<stack>
#include<algorithm>
#include<queue>
#include<cmath>
#include<numeric>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<iomanip>
#include<functional>
#include<bitset>

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

using namespace std;

typedef long long ll;
const int INF = 1001001001;
vector<int> to[100010];

int main(){
    int n,m;
    cin>>n>>m;
    int a,b;
    rep(i,m) {
        cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    queue<int> q;
    vector<int> dist(n,INF),pre(n,-1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();q.pop();
        for(int u:to[v]){
            if(dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n){
        if(i==0) continue;
        int ans = pre[i];
        ++ans;
        cout<<ans<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 10628
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <cassert>
#include <tuple>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll INF = 1e15;


using Weight = ll;
class Edge {
public:
	int s, d;
	Weight w;
	Edge() : s(0), d(0), w(0) {}
	Edge(int s, int d, Weight w) : s(s), d(d), w(w) {}
	bool operator < (const Edge &e) const {
		return w != e.w ? w < e.w :
			   s != e.s ? s < e.s :
			   d < e.d;
	}
};
using Graph = vector<vector<Edge>>;

// 最小全域木とそのコストを返す O(ElogE)
pair<Weight, Graph> prim(Graph& g) {
	vector<int> visited(g.size());
	Weight cost = 0;
	Graph f(g.size());
	priority_queue<Edge> que;
	que.push(Edge(-1, 0, 0));
	while (!que.empty()) {
		Edge now = que.top();
		now.w *= -1;
		que.pop();
		if (visited[now.d])
			continue;
		visited[now.d] = true;
		cost += now.w;
		if(now.s >= 0)
			f[now.s].push_back(now);
		for (auto&& e : g[now.d]) {
			if (!visited[e.d])
				que.push(Edge(e.s, e.d, -e.w));
		}
	}
	return make_pair(cost, f);
}

using P = pair<ll, ll>;
int main() {
	ll N;
	cin >> N;
	Graph g(N);
	vector<P> xv(N);
	vector<P> yv(N);
	for (int i = 0;i < N;i++) {
		ll x, y;
		cin >> x >> y;
		xv[i] = P(x, i);
		yv[i] = P(y, i);
	}
	sort(xv.begin(), xv.end());
	sort(yv.begin(), yv.end());
	for (int i = 0;i < N;i++) {
		if (i > 0) {
			g[xv[i].second].push_back(Edge(xv[i].second, xv[i - 1].second, abs(xv[i].first - xv[i - 1].first)));
			g[yv[i].second].push_back(Edge(yv[i].second, yv[i - 1].second, abs(yv[i].first - yv[i - 1].first)));
		}
		if (i < N - 1) {
			g[xv[i].second].push_back(Edge(xv[i].second, xv[i + 1].second, abs(xv[i].first - xv[i + 1].first)));
			g[yv[i].second].push_back(Edge(yv[i].second, yv[i + 1].second, abs(yv[i].first - yv[i + 1].first)));
		}
	}
	Weight cost;
	Graph f;
	tie(cost, f) = prim(g);
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 26736
n = int(input())
w_list = list(map(int,input().split()))
ans = abs(w_list[0] - sum(w_list[1:n]))
#print(ans)
for i in range(1,n):
    dum = abs(sum(w_list[0:i]) - sum(w_list[i:n]))
    ans = min(ans,dum)
print(ans)

Measured memory_bytes: 38384
n,a,b = map(int,input().split())
s = input()
m = 0
o = 0
for i in range(n):
    if s[i] == 'a':
        if m < a + b:
            print('Yes')
            m += 1
        else:
            print('No')
    elif s[i] == 'b':
        o += 1
        if m < a + b and o <= b:
            print('Yes')
            m += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
function main(input) {
  const args = input.split('\n');
  const N = args[0];
  const ary = args[1].split(' ');
  let ans = 'Three';
  
  ary.forEach(elm => {
    if(elm === 'Y') { ans = 'Four' };
  });
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
set<ll>s;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll n,i,j,x,y;
	sc(n);
	while(n--){
		sc(x);
		if(s.find(x) != s.end())s.erase(s.find(x));
		else s.insert(x);
	}
	y=s.size();
	pr(y);
}

Measured memory_bytes: 4864
n = int(input())
int_list = list(map(int,(input().split())))
count = 0
while count < 100:
    for i in range(len(int_list)):
        
        if int_list[i] % 2 == 0 :
            int_list[i] = int_list[i]/2
        else:
            int_list = []
            break      
    if len(int_list) == n :
        count += 1
    else: 
        break
print(count)

Measured memory_bytes: 9248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int w,h;
int v[51][51];

struct Pos{
    int ay,ax,by,bx;
    
    bool operator < (Pos obj) const{
        int t = ay + ax*60 + by*60*60 + bx*60*60*60;
        int p = obj.ay + obj.ax*60 + obj.by*60*60 + obj.bx*60*60*60;
        return t<p;
    }
    
};

int main(){
    while(cin>>w>>h&&(w||h)){
        int ax,ay,bx,by;
        cin>>ax>>ay>>bx>>by;
        ax--,ay--,bx--,by--;
        
        rep(i,h)rep(j,w)cin>>v[i][j];
        
        int dy[]={1,0,-1,0};
        int dx[]={0,1,0,-1};
        
        map<Pos,int> mp;
        queue<Pos> que;
        
        mp[Pos{ay,ax,by,bx}] = 0;
        que.push( Pos{ay,ax,by,bx} );
        
        bool f = false;
        while(que.size()){
            Pos q = que.front();
            int iy = q.ay, ix = q.ax;
            int jy = q.by, jx = q.bx;
            if(iy==jy && ix==jx){
                cout<<mp[Pos{iy,ix,jy,jx}]<<endl;
                f = true;
                break;
            }
            
            rep(k,4){
                int ddix = ix+dx[k];
                int ddjx = jx-dx[k];
                int ddiy = iy+dy[k];
                int ddjy = jy-dy[k];
                
                if(ddiy<0 || ddiy>=h || ddix<0 || ddix>=w || v[ddiy][ddix])ddiy = iy, ddix = ix;
                if(ddjy<0 || ddjy>=h || ddjx<0 || ddjx>=w || v[ddjy][ddjx])ddjy = jy, ddjx = jx;
                
                if( mp.count( Pos{ddiy, ddix, ddjy, ddjx} )==0 || mp[Pos{ddiy, ddix, ddjy, ddjx}]>mp[Pos{iy, ix, jy, jx}]+1 ){
                    que.push( Pos{ddiy, ddix, ddjy, ddjx} );
                    mp[Pos{ddiy, ddix, ddjy, ddjx}] = mp[Pos{iy, ix, jy, jx}]+1;
                }
            }
            que.pop();
        }
        
        if(!f)cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 14280
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long M, std::vector<long long> L, std::vector<long long> R, std::vector<long long> C){
  multiset<pair<long long, long long>> q;
  vector<pair<pair<long long, long long>, long long>> v;

  for (int i = 0; i < M; i++) {
    v.push_back(make_pair(make_pair(L[i], R[i]), C[i]));
  }
  sort(v.begin(), v.end());

  long long p = 1;
  long long ans = 0;
  for (int i = 0; i < M; i++) {
    while (v[i].first.first > p) {
      p++;
      while (!q.empty() && (*q.begin()).second < p) {
        q.erase(q.begin());
      }
      if (q.empty()) {
        std::cout << -1 << std::endl;
        return;
      }
      ans = (*q.begin()).first;
    }
    q.insert(make_pair(ans+v[i].second, v[i].first.second));
  }

  p = N;
  while (!q.empty() && (*q.begin()).second < p) {
    q.erase(q.begin());
  }
  if (q.empty()) {
    std::cout << -1 << std::endl;
    return;
  }
  ans = (*q.begin()).first;
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> L(M);
  std::vector<long long> R(M);
  std::vector<long long> C(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&L[i]);
    scanf("%lld",&R[i]);
    scanf("%lld",&C[i]);
  }
  solve(N, M, std::move(L), std::move(R), std::move(C));
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int N,T;
    cin >> N >> T;
    ll ans = T;
    int t[N];
    cin >> t[0];
    for(int i = 1; i < N; i++){
        cin >> t[i];
        ans += min(t[i]-t[i-1],T);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    double D = 0.0,ans=0;
    cin>>N;
    vector<int>x(N),y(N);
    for (int i=0;i<N;i++){
        cin>>x.at(i)>>y.at(i);
    }
    
    for (int i=0;i<N;i++){
        for (int j=i;j<N;j++){
            D
            +=sqrt((x.at(j)-x.at(i))*(x.at(j)-x.at(i))+(y.at(j)-y.at(i))*(y.at(j)-y.at(i)));
        }
    }
    ans = (D*2)/N;
    cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define PRINT_ARRAY_H(i,a) REPALL(i,a) {cout<<a[i]<<(i != a.size()-1 ? " " : "");} newline;
#define e1 first
#define e2 second
#define newline putchar('\n')
#define cspace ' '
#define sspace " "
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    int h,w,k,ans=0;
    vector<string> c;
    cin>>h>>w>>k;
    REP(i,h) {
        c.push_back(input<string>());
    }
    REP(i,1<<h) {
        REP(j,1<<w) {
            int cnt = 0;
            REP(y,h) {
                REP(x,w) {
                    if ((i>>y & 1) == 0 && (j>>x & 1) == 0 && c[y][x] == '#') {
                        cnt++;
                    }
                }
            }
            ans += (cnt == k);
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

typedef long long int ll;

int main(){
    ll n; cin >> n;
    ll gcdb[n+5] , gcdf[n+5] , arr[n+5];
    cin >> arr[1]; gcdb[1] = arr[1];
    ll val = arr[1];
    for(int i = 2; i <= n; i++){
        cin >> arr[i];
        val = __gcd(val , arr[i]);
        gcdb[i] = val;
    }
    val = arr[n];
    gcdf[n] = val;
    for(int i = n-1; i >= 1; i--){
        val = __gcd(val , arr[i]);
        gcdf[i] = val;
    }
    ll ans = gcdf[2];
    for(int i = 2; i< n; i++){
        ans = max(ans , __gcd(gcdb[i-1] , gcdf[i+1]));
    }
    ans = max(ans , gcdb[n-1]);
    cout << ans << endl;
}

Measured memory_bytes: 2560
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    string st;
    cin >> st;

    int s = 0, t = 0, rm = 0;

    rep(i, 0, st.size()) {
        if(st[i] == 'S')
            s ++, t = 0;
        else
            t ++;

        if(st[i] == 'T') {
            int here = min(s, t);
            s -= here;
            t -= here;
            rm += here;
        }
    }

    prin(st.size() - rm * 2);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

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

int main()
{
    int N;
    scanf("%d", &N);
    ll res = -1, B = 1e9+10;
    for(int i = 0; i < N; ++i) {
        ll a, b;
        scanf("%lld %lld", &a, &b);
        if(res < a) res = a, B = b;
    }
    printf("%lld\n", res + B);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    int k;cin>>k;
    string s;cin>>s;
    int n = s.size();
    if(n<=k) cout<<s;
    else{
        for(int i=0;i<k;i++) cout<<s[i];
        cout<<"...";
    }
}

Measured memory_bytes: 3596
S = input()

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            print('No')
            exit()
    if i % 2 == 1:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)

signed main() {
	for (int d, w; cin >> d >> w && d;) {
		vector<vector<int>> e(d, vector<int>(w));
		rep(i, 0, d)rep(j, 0, w)cin >> e[i][j];
		int ans = 0;
		rep(i, 0, d)rep(j, 0, w)rep(ii, i + 2, d)rep(jj, j + 2, w) {
			int m = e[i][j];
			rep(ci, i, ii + 1) {
				m = min(m, e[ci][j]);
				m = min(m, e[ci][jj]);
			}
			rep(cj, j, jj + 1) {
				m = min(m, e[i][cj]);
				m = min(m, e[ii][cj]);
			}
			int k = e[i + 1][j + 1];
			int sum = 0;
			rep(ci, i + 1, ii)rep(cj, j + 1, jj) {
				k = max(k, e[ci][cj]);
				sum += m - e[ci][cj];
			}
			if (k >= m)continue;
			ans = max(sum, ans);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
N=int(input())
d=[[int(s) for s in input().split()] for i in range(3)]
ans=0
for i in range(N):
    ans+=d[1][d[0][i]-1]
    if i<=N-2 and d[0][i+1]-d[0][i]==1:
        ans+=d[2][d[0][i]-1]
print(ans)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  string res = "Good";
  for(int i=0; i<4; i++)
  {
    if(s[i]!=s[i+1])
      continue;
    else
    {
      res = "Bad";
      break;
    }

  }
  cout<<res;
  return 0;
}


Measured memory_bytes: 256
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, m, q = LI()

train = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = LI_()
    train[n - 1 - l][r] += 1

for i in range(n):
    for j in range(1, n):
        train[i][j] += train[i][j - 1]

for j in range(n):
    for i in range(1, n):
        train[i][j] += train[i - 1][j]

for _ in range(q):
    a, b = LI_()
    print(train[n - 1 - a][b])


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

N = int(input())
A = list(map(int, input().split()))
A.append(0)

S = [A[0], A[1], A[2], sum(A[3:])]
l = 0
r = 2
while r < N-1:
    if S[2] + A[r+1] <= S[3] - A[r+1]:
        S[2] += A[r+1]
        S[3] -= A[r+1]
        r += 1
    else:
        break

S2 = [S[0], S[1], S[2]+A[r+1], S[3]-A[r+1]]
ans = min(max(S)-min(S), max(S2)-min(S2))
for m in range(2, N-2):
    S[1] += A[m]
    S[2] -= A[m]
    while r < N-1:
        if S[2] + A[r+1] <= S[3] - A[r+1]:
            S[2] += A[r+1]
            S[3] -= A[r+1]
            r += 1
        else:
            break
    
    while l < m:
        if S[0] + A[l+1] <= S[1] - A[l+1]:
            S[0] += A[l+1]
            S[1] -= A[l+1]
            l += 1
        else:
            break
    
    S1 = [S[0]+A[l+1], S[1]-A[l+1], S[2], S[3]]
    S2 = [S[0], S[1], S[2]+A[r+1], S[3]-A[r+1]]
    S3 = [S[0]+A[l+1], S[1]-A[l+1], S[2]+A[r+1], S[3]-A[r+1]]
    ans = min([ans, max(S)-min(S), max(S1)-min(S1), max(S2)-min(S2), max(S3)-min(S3)])

print(ans)

Measured memory_bytes: 24140
from collections import defaultdict

N = int(input())
S = input()
S1 = S[:N]
S2 = S[::-1][:N]

def get_s(s, i):
  s1 = s2 = ''
  for j in range(N):
    if i>>j & 1:
      s1 += s[j]
    else:
      s2 += s[j]
  return (s1, s2)

d1 = defaultdict(int)
d2 = defaultdict(int)
for i in range(2**N):
  s1 = get_s(S1, i)
  d1[s1] += 1
  s2 = get_s(S2, i)
  d2[s2] += 1

ans = 0
for k in d1:
  ans += d1[k] * d2[k]

print(ans)

Measured memory_bytes: 192012