akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int c2 = min(c, b + a + 1);
    cout << b + c2 << '\n';
}


Measured memory_bytes: 892
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

H, W = mi()
S = [li() for _ in range(H)]
f = 0
ans = []

for j in range(W):
    for i in range(H):
        if j%2:
            i = (H-1) - i
        if f:
            ans.append([pi, pj, i+1, j+1])
        if S[i][j] % 2:
            f = 1 - f
        pi, pj = i+1, j+1

N = len(ans)
print(N)
for i in range(N):
    print(ans[i][0], ans[i][1], ans[i][2], ans[i][3])

Measured memory_bytes: 73308
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;


int isPalindrome(string s) 
{ 
  int l=s.size();
  int ans=1;
  for(int i=0,j=l-1;i<l/2;++i,--j)
  {
    if(s[j]!=s[i])
    ans=0;
  }
  return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	string s;
	cin>>s;
	ll f=0;
	ll len=s.length();
	string s1="";
	string s2="";
	
	for(int i=0;i<(len-1)/2;i++)
    {
        s1+=s[i];
    }
	
	for(int i=((len+3)/2)-1;i<len;i++)
    {
        s2+=s[i];
    }
	
	if(isPalindrome(s))
    {
        if(isPalindrome(s1) && isPalindrome(s2))
            f=1;
    }
	
	if(f==1)
	    cout<<"Yes"<<endl;
	    else
	        cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v)    \
  {                          \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
#define ddump(v)                     \
  cerr << #v ":" << endl;            \
  for (auto macro_row : v)           \
  {                                  \
    cerr << "[";                     \
    for (auto macro__vi : macro_row) \
    {                                \
      cerr << macro__vi << " ";      \
    }                                \
    cerr << "]" << endl;             \
  }
#define damp(m)                                                   \
  for (auto macro_pair : m)                                       \
  {                                                               \
    cerr << macro_pair.first << ":" << macro_pair.second << endl; \
  }
#define dpair(p) cerr << #p ":" \
                      << "(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define itr(macro_v, i) macro_v.begin() + i
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << r * r << endl;
  return 0;
}

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* debug */
// auto debug = std::experimental::make_ostream_joiner(std::cout, " ");

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int n, q;

std::vector<std::vector<Int>> edge;
std::vector<bool> done;
std::vector<Int> ans;
std::vector<Int> add;

void dfs(Int i){
	done[i] = true;
	ans[i] += add[i];
	for(Int j : edge[i]){
		if(!done[j]){
			ans[j] += ans[i];
			dfs(j);
		}
	}
}

int main(){
	cin >> n >> q;
	edge.resize(n);
	done.resize(n);
	ans.resize(n);
	RC(i, n - 1){
		Int a, b;
		cin >> a >> b;
		--a;
		--b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	add.resize(n);
	RC(i, q){
		Int p, x;
		cin >> p >> x;
		--p;
		add[p] += x;
	}
	dfs(0);

	RC(i, n){
		cout << ans[i] << " \n"[i == n - 1];
	}
	// std::copy(ans.begin(), ans.end(), debug);
	// cout << endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            long[,] dp = new long[11, 1001];
            dp[0, 0] = 1;

            for (int k = 0; k <= 100; k++)
            {
                for (int i = 10; i > 0; i--)
                {
                    for (int j = k; j <= 1000; j++)
                    {
                        dp[i, j] += dp[i - 1, j - k];
                    }
                }
            }

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int n = int.Parse(input[0]);
                int s = int.Parse(input[1]);

                if (n == 0 && s == 0) break;

                sb.AppendLine(dp[n, s].ToString());
            }
            Console.Write(sb);
        }
    }
}

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

int main(){
  int p,q,r;
  cin >> p >> q >> r;
  
  int sum=p+q+r;
  cout << (sum - max(max(p,q),r));
  
  return 0;
}

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

vector<string> a;
bool d(int i, int j) {
	for (int k = 0; k < 10; k++) {
		if (a[i][k] != a[j][k])return false;
	}
	return true;
}

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		sort(s.begin(), s.end());
		a.push_back(s);
	}
	sort(a.begin(), a.end());
	long long sum = 0;
	long long c = 1;
	int i = 0, j = 1;
	while (j < N) {
		if (d(i, j)) {
			j++;
			c++;
		}
		else {
			i = j;
			j++;
			sum += c * (c - 1) / 2;
			c = 1;
		}
	}
	sum += c * (c - 1) / 2;
	cout << sum;
}

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

int main(){
    string s1,s2;
    cin>>s1>>s2;
    bool flag=false;
    for(int i=0;i<s1.size();i++){
        if(s1==s2) {
            flag=true;
            break;
        }
        else{
            s1.insert(s1.begin(),s1.back());
            s1.pop_back();
        }
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int main()
{
    int a, b, c;
    double s, l, h, d, rad;
    const double PI = 4 * atan(1);
    scanf("%d%d%d", &a, &b, &c);
    rad = PI * c / 180;
    s = a * b * sin(rad) / 2; 
    d = sqrt(a*a + b*b - 2*a*b*cos(rad));
    l = a + b + d;
    h = b*sin(rad);

    printf("%.6lf\n", s);
    printf("%.6lf\n", l);
    printf("%.6lf\n", h);
    return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, x, t;
  cin >> n >> x >> t;
  ll ans = (n + x - 1) / x;
  ans *= t;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
n = gets.to_i
array = []
n.times { array.push(gets.to_i) }

m = array.max
cpd = array.clone
cpd.delete(m)
second_m = cpd.max
second_m = m if array.count(m) > 1

array.each do |a|
  if a < m
    puts m
  elsif 
    puts second_m
  end
end


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

#define MAX 100000
#define INFTY (1 << 30)
class Edge {
public:
  int t, w;
  Edge() {}
  Edge(int t, int w): t(t), w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s) {
  rep(i, 0, n) d[i] = INFTY;
  queue<int> Q;
  Q.push(s);
  d[s] = 0;
  int u;
  while (!Q.empty()) {
    u = Q.front();
    Q.pop();
    rep(i, 0, G[u].size()) {
      Edge e = G[u][i];
      if (d[e.t] == INFTY) {
        d[e.t] = d[u] + e.w;
        Q.push(e.t);
      }
    }
  }
};

void solve() {
  // 適当な始点sからもっとも遠い点tgtを求める
  bfs(0);
  int maxv = 0;
  int tgt = 0;
  rep(i, 0, n) {
    if (d[i] == INFTY) continue;
    if (maxv < d[i]) {
      maxv = d[i];
      tgt = i;
    }
  }

  // tgtからもっとも遠い点の距離maxvを求める
  bfs(tgt);
  maxv = 0;
  rep(i, 0, n) {
    if (d[i] == INFTY) continue;
    maxv = max(maxv, d[i]);
  }
  cout << maxv << endl;
};

int main() {
  int s, t, w;
  cin >> n;
  rep(i, 0, n - 1) {
    cin >> s >> t >> w;
    G[s].pb(Edge(t, w));
    G[t].pb(Edge(s, w));
  }
  solve();
};



Measured memory_bytes: 9860
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
	string S;
	cin >> S;
	
	reverse(S.begin(), S.end());
	for(int i = 0; i < 4; i++){
		reverse(divide[i].begin(), divide[i].end());
	}

	bool can = true;
	for(int i = 0; i< S.size();){
		bool can2 = false;
		for(int j = 0; j < 4; j++){
			string d = divide[j];
			if(S.substr(i,d.size()) == d){
				can2 = true;
				i += d.size();
			}
		}
		if(!can2){
			can = false;
			break;
		}
	
	}
	
	if(can) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int a,b,c;
    int temp;
    scanf("%d %d %d",&a,&b,&c);
     if(a>b){
        temp = a;
        a = b;
        b = temp;
    }
     if(b>c){
        temp = b;
        b = c;
        c = temp;
    }
    if(a>b){
        temp = a;
        a = b;
        b = temp;
    }
    
    printf("%d %d %d\n",a,b,c);
    return 0;
    
    
}


Measured memory_bytes: 2032
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){
  char r[1000000];
  int count = 101;
  char s;
  char c;
  int maru=0;
  int shikaku=0;
  while(true){
    //はじめの文字の判定
    scanf("%c",&s);
    if(s=='\n')scanf("%c",&s);
    if(s=='.')break;
    else if(s=='('){
      r[count++]=')';
      maru++;
    }
    else if(s=='['){
      r[count++]=']';
      shikaku++;
    }
    else if(s==')'){
  	maru=-111;

    }
    else if(s==']'){
      shikaku=-111;
    }
    //終了条件ではないとき
    while(true){
      cin>>c;
      //    cout<<c;
      if(c=='.'||maru<0||shikaku<0)break;
      else if(c=='('){
	r[count++]=')';
	maru++;
      }
      else if(c=='['){
	r[count++]=']';
	shikaku++;
      }
      else if(c==')'){
	if(r[count-1]==c){
	  count--;
	  maru--;
	}
	else maru=-111;
      }
      else if(c==']'){
	if(r[count-1]==c){
	  count--;
	  shikaku--;
	}
	else shikaku=-111;
      }
    }
   if(c!='.'){
      while(true){
	cin>>c;
	//    cout<<c;
	if(c=='.')break;
      }
   }
   if(maru==0&&shikaku==0)cout<<"yes"<<endl;
   else cout<<"no"<<endl;
   maru=0;
   shikaku=0;
  }
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int d, n; cin >> d >> n;
    ll ans;

    if(n == 100) { 
        ans = (n+1)*pow(100,d);
    } else {
        ans = n*pow(100,d);
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 384
n=int(input())
a=[int(input()) for i in range(n)]
b=[]

m=0
count=[0 for i in range(n)]
count[m]=1

ans_count=0
a.sort()

for i in range(n-1):
    if a[m]==a[i+1]:
        count[m]=count[m]+1
    else:
        m=i+1
        count[m]=1

for i in range(n):
     ans_count=ans_count+count[i]%2

print(ans_count)

Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for(int x=0; x<=k; ++x){
    for(int y=0; y<=k; ++y){
      int z = s-(x+y);
      if(z >= 0 && z <= k) ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

ll N;

const bool Contains357(const string &str)
{
    vector<char> chars{ '3', '5', '7' };
    for (const char ch : chars)
    {
        if (str.find(ch) == -1)
        {
            return false;
        }
    }
    return true;
}

const int DFS(const string &str)
{
    if (stoll(str) > N)
    {
        return 0;
    }
    int ret = Contains357(str) ? 1 : 0;
    for (const char ch : { '3', '5', '7' })
    {
        ret += DFS(str + ch);
    }
    return ret;
}

int main()
{
    cin >> N;
    cout << DFS("0") << endl;
}

Measured memory_bytes: 256
import math
a, b = list(map(int,input().split()))
i = 0
j = 0
res = 0
while i < a or j < b:
	i = math.floor(res * 0.08)
	j = math.floor(res * 0.1)
	#print(i)
	#print(j)
	#print(res)
	#print("\n\n")
	if i == a and j == b:
		break
	res += 1

if i > a or j > b:
	print(-1)
else:
	print(res)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S;
  string a="0";
  string b="1";
  cin >> S;
  size_t size = S.length();
  int i=0,count_0=0,count_1=0;
  for(i=0;i<size;i++){
    if('0'==S[i]){
      count_0++;
    }else if('1'==S[i]){
      count_1++;
    }
  }
  if(count_0 == 0||count_1 == 0){
    cout<< 0 << endl;
  }else{
    if(count_0 >= count_1){
      cout << count_1*2 << endl;
    } else{
      cout << count_0*2 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  if((a*b)%2==1){
    cout << "Odd" << endl;
  }else{
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 256
let x1,x2,x3,x4,x5 = Scanf.sscanf (read_line()) "%d %d %d %d %d" (fun q w e r t -> q,w,e,r,t)
let _ = (
  if x1 = 0 then "1" else
  if x2 = 0 then "2" else
  if x3 = 0 then "3" else
  if x4 = 0 then "4" else
"5") |> print_endline

Measured memory_bytes: 3716
n,m=map(int,input().split())
s=[list(map(int,input().split()))for _ in range(n)]
a=0
for i in range(1<<3):
    t=[[v for v in s[i]]for i in range(n)]
    for j in range(3):
        if i>>j&1:
            for k in range(n):
                t[k][j]*=-1
    for j in range(n):
        t[j]=sum(t[j])
    a=max(a,sum(sorted(t)[::-1][:m]))
print(a)

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

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

  long long n, m; cin >> n >> m;
  long long ans = 0;
  
  long long t = min(n, m/2);
  n-=t;
  m-=t*2;
  ans+=t;

  ans+=m/4;

  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<n;i++)
int main(){
    long long n,ans=0,a=0,b=0,c=0,A,B;
    string s[200000];
    cin>>n;
    rep(i,n) cin>>s[i];
    rep(i,n)rep(j,s[i].size()-1) if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
    rep(i,n){
        if(s[i][0]=='B') b++;
        if(s[i][s[i].size()-1]=='A') a++;
        if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A') c++;
    }
  if(c>0){
    A=a-c;B=b-c;c--;
    if(A>0) c++,A--;
    if(B>0) c++,B--;
    cout<<ans+min(A,B)+c;
  }
  else cout<<ans+min(a,b);
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
//#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
using namespace std;
#define fin << '\n'
#define finl << '\n';
#define finn cout << '\n'
#define unless(flg) if(!(flg))
#define alles(obj) obj.begin(), obj.end()
// bashise
#define elif else if
#define echo cout <<
#define read cin >>
// javaise
#define bash push_back
#define makePair make_pair
#define isEmpty empty
// germanise
#define drucken(obj) cout << obj << '\n'
#define lesen(obj) cin >> obj
#define fur for
#define wenn if
#define sonst else
#define Zahl int
// type-define
#define String string
#define Stack stack
#define Queue queue
#define pQueue priority_queue
#define Vector vector
#define Pair pair
#define Map map
typedef long long llong;
typedef bool boolean;
typedef Pair<int,int> Pii;
typedef Vector<int> Vi;
// utils
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
boolean isMovable(int x,int y,int w,int h){return (x>=0&&y>=0&&x<w&&y<h);};
const int INF = 1 << 29;

int ans;

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

    String s;
    read s;
    int cnt = 0;
    for ( int i = 1; i < s.size(); i++ ) {
        if ( s[i-1] != s[i] ) cnt++;
    }
    echo cnt fin;



    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;
ll n, k;
vector<int> one_counts(60);
vector<ll> a_list;

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

    rep(i, n) {
        ll a;
        cin >> a;
        a_list.push_back(a);
    }

    for (ll a : a_list) {
        for (int keta = 0; keta < 60; keta++) {
            int konoketaha_one_ka = (a >> keta) & 1;
            one_counts[keta] += konoketaha_one_ka;
        }
    }

    ll x = 0;
    for(int i = 60 ; i >= 0 ; i --){
        ll bairitsu = 1ll << i;
        ll one_count = one_counts[i];
        ll zero_count = n - one_count;

        if (one_count < zero_count && x + bairitsu <= k) {
            x += bairitsu;
        }
    }

    ll ans = 0;
    rep(i, n) {
        ans +=( x ^ a_list[i]);
    }

    cout << ans << endl;

}

// https://atcoder.jp/contests/abc117/submissions/8569276
// 参考

Measured memory_bytes: 1400
n , x = map(int, input().split())
# ABCの長さ
a = [1]
for i in range(n):
    a.append(a[i] * 2 + 3)

# パティの枚数
p = [1]
for i in range(n):
    p.append(p[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x == 1:
        return 0
    elif 1 <  x <=  1 + a[n - 1]:
        return f(n - 1, x - 1)
    elif x == 2 + a[n-1]:
        return p[n-1] + 1
    elif 2 + a[n - 1] < x <= 2 + 2 * a[n - 1]:
        return f(n - 1, x - 2 - a[n - 1]) + p[n-1] + 1
    elif x == 3 + 2 * a[n - 1]:
        return 2 * p[n-1] + 1

print(f(n, x))

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

int main() {
  int A,  B;
  cin >> A >> B;
  int ans = 0;
  if (A >= 13) {
    ans = B;
  } else if (A >= 6) {
    ans = B/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {

	static Map<Integer, Integer> monthDay = null;
	static String[] dayOfTheWeek = { "Wednesday", "Thursday", "Friday",
			"Saturday", "Sunday", "Monday", "Tuesday" };

	public static void main(String[] args) {
		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextInt()) {
				int month = sc.nextInt();
				int day = sc.nextInt();
				if (month == 0 || day == 0) {
					break;
				}
				if (monthDay == null) {
					createMonth();
				}
				System.out.println(getDayOfTheWeek(month, day, monthDay));

			}

		} finally {
			sc.close();
		}

	}

	public static String getDayOfTheWeek(int m, int d, Map<Integer, Integer> map) {

		int sum = 0;
		for (int i = 1; i < m; i++) {
			sum += map.get(i);
		}
		sum += d;

		return dayOfTheWeek[sum % 7];
	}

	public static Map<Integer, Integer> createMonth() {
		monthDay = new HashMap<Integer, Integer>();
		monthDay.put(1, 31);
		monthDay.put(2, 29);
		monthDay.put(3, 31);
		monthDay.put(4, 30);
		monthDay.put(5, 31);
		monthDay.put(6, 30);
		monthDay.put(7, 31);
		monthDay.put(8, 31);
		monthDay.put(9, 30);
		monthDay.put(10, 31);
		monthDay.put(11, 30);
		monthDay.put(12, 31);

		return monthDay;

	}

}

Measured memory_bytes: 26112
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#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;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	ll sub[n], len = 0;
	sub[0] = 0;
	rep(i, 1, n)
	{
		if (s[i] == 'C' and s[i - 1] == 'A')
			len++;
		sub[i] = len;
	}

	// rep(i, 0, n)
	// cout << sub[i] << " ";
	while (q--)
	{
		ll x, y;
		cin >> x >> y;
		cout << sub[y - 1] - sub[x - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 4528
from math import cos, pi, sqrt
a, b, h, m = map(int, input().split())

tot_m = h * 60 + m
a_rad = 2 * pi * tot_m / 720
b_rad = 2 * pi * m / 60
dif_rad = abs(a_rad -b_rad)
if dif_rad > pi:
    theta = 2*pi - dif_rad
else:
    theta = dif_rad

c = sqrt(a*a + b*b - 2*a*b*cos(theta))

print(c)

Measured memory_bytes: 9452
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF intONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	string s;
	cin >> s;
	int a = 0;
	rep(i, s.size()) {
		if (s[i] == 'o')a++;
	}
	if (a + (15 - s.size()) >= 8)puts("YES");
	else puts("NO");
	return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll n,m; cin >> n >> m;
    VL h(n);
    rep(i,n) cin >> h[i];

    set<ll> smaller;

    rep(i,m){
        ll a,b; cin >> a >> b;
        a--; b--;
        if(h[a] < h[b]){
            smaller.insert(a);
        }else if(h[a] > h[b]){
            smaller.insert(b);
        }else{
            smaller.insert(a);
            smaller.insert(b);
        }
    }

    cout << n - smaller.size() << endl;

    return 0;
}

Measured memory_bytes: 6624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
struct UnionFind {
  UnionFind(int sz) : data(sz, -1) {}

  int root(int ver) { return data[ver] < 0 ? ver : data[ver] = root(data[ver]); }

  void unite(int ver1, int ver2) {
    ver1 = root(ver1);
    ver2 = root(ver2);
    if (ver1 != ver2) {
      if (data[ver1] < data[ver2]) {
        data[ver1] += data[ver2];
        data[ver2] = ver1;
      } else {
        data[ver2] += data[ver1];
        data[ver1] = ver2;
      }
    }
  }

  bool same(int ver1, int ver2) { return root(ver1) == root(ver2); }

  int size(int ver) { return -data[root(ver)]; }

private:
  vector<int> data;
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<int> p(n); REP(i, n) cin >> p[i];
  UnionFind uf(n+1);
  REP(i, m) {
    int x, y; cin >> x >> y;
    uf.unite(x, y);
  }
  vector<int> ro(n+1, 0);
  FOR(i, 1, n+1) ro[i] = uf.root(i);
  vector<pair<int, pair<int, int>>> vec(n);
  REP(i, n) vec[i] = {ro[i+1], {p[i], i+1}};
  sort(ALL(vec));
  int now = vec[0].first, sum = 2, ans = 0;
  set<int> st{vec[0].second.first, vec[0].second.second};
  FOR(i, 1, n) {
    if (now == vec[i].first) {
      st.insert(vec[i].second.first);
      st.insert(vec[i].second.second);
      sum += 2;
    } else {
      ans += sum - st.size();
      now = vec[i].first;
      st.clear();
      st.insert(vec[i].second.first);
      st.insert(vec[i].second.second);
      sum = 2;
    }
    if (i == n-1) ans += sum - st.size();
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7296
n = int(input())
aa = list(map(int,input().split()))
oddNum = 0
mainasuNum = 0
min_abs = abs(min(aa))
for a in aa:
    min_abs = abs(a) if abs(a) < min_abs else abs(min_abs)
    if a < 0:
        mainasuNum += abs(a)
        oddNum += 1
if oddNum%2 == 0:
    print(sum(aa)+mainasuNum*2)
else:
    print(sum(aa)+mainasuNum*2 - min_abs*2)

Measured memory_bytes: 14332
#!/usr/bin/perl

my ($n,$k) = map {$_ - 0} split(/\s+/o,<STDIN>);

my $res = 0;
my $rat = 1;

# 最初は何もしなくても勝ち

if( $k==1 ){
  print "1\n";
  exit(0);
}

my $a = $n;

while(1){
  if( $k <= $a ){
    $res += ( $a - $k + 1 ) * $rat;
    $a = $k - 1;
  }
  $rat /= 2;
  last if $k == 1;
  $k = int(( $k + 1 ) / 2);
}
$res /= $n;
print "$res\n";

exit(0);



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>>A(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>A.at(i).at(j);
    }
  }
  int N;
  cin>>N;
  vector<int>B(N);
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(B.at(i)==A.at(j).at(k)){
          A.at(j).at(k)=0;
        }
      }
    }
  }
  bool flag=false;
  vector<int>zero={0,0,0};
  for(int i=0;i<3;i++){
    if(A.at(i)==zero){
      flag=true;
    }
  }
  for(int i=0;i<3;i++){
    if(A.at(0).at(i)==0 && A.at(1).at(i)==0 && A.at(2).at(i)==0){
      flag=true;
    }
  }
  if(A.at(0).at(0)==0 && A.at(1).at(1)==0 && A.at(2).at(2)==0){
    flag=true;
  }
  if(A.at(0).at(2)==0 && A.at(1).at(1)==0 && A.at(2).at(0)==0){
    flag=true;
  }
  if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
    
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
    tree_order_statistics_node_update> ost;

const int N=4010;
const ll P=1e9+7;
const ll PH=(P+1)/2;
int bn[2*N][2*N];
ll t[2*N];

int main() {
    int i, j, n, a, b, ans=0;
    for(i=0; i<2*N; i++) bn[i][0]=1;
    for(i=1; i<2*N; i++) for(j=1; j<=i; j++) {
        bn[i][j]=bn[i-1][j]+bn[i-1][j-1];
        if(bn[i][j]>=P) bn[i][j]-=P;
    }
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d%d", &a, &b);
        ans=(ans+P-bn[2*a+2*b][2*b])%P;
        for(j=0; j<=a+b; j++)
            t[N-a+j]+=bn[a+b][j];
    }
    for(i=-N+1; i<N; i++) t[N+i]%=P;
    for(i=-N+1; i<N; i++)
        ans=(ans+t[i+N]*t[-i+N])%P;
    printf("%lld\n",ans*PH%P);
    return 0;
}

Measured memory_bytes: 249856
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> d(n+1,0);
    rep(i,n) cin >> d[i+1];
    sort(d.begin(),d.end());

    cout << d[n/2+1] - d[n/2]  << endl;


    return 0;
}

Measured memory_bytes: 3764
#include <iostream>

#if defined(__GNUC__) && !defined(__clang__)
#  pragma GCC optimize("Ofast")
#  pragma GCC target("sse4.2", "tune=native")
#endif


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

  char c;
  std::cin >> c;
  switch (c) {
    case 'A':
      std::cout.put('T');
      break;
    case 'C':
      std::cout.put('G');
      break;
    case 'G':
      std::cout.put('C');
      break;
    case 'T':
      std::cout.put('A');
      break;
  }
  std::cout << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 50000;

int n, m, R;
int all;
int num[10];
int dis[205][205];
int pre[2 * MaxN + 5], last[MaxN + 5], other[2 * MaxN + 5];
int cost[2 * MaxN + 5];
bool inque[205];

void build(int x, int y, int w) {
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = w;
}

void SPFA(int s) {
	memset(inque, 0, sizeof(inque));
	dis[s][s] = 0;
	queue <int> q;
	q.push(s);
	int ed, dr;
	while(!q.empty()) {
		int x = q.front();
		inque[x] = 1;
		q.pop();
		ed = last[x];
		while(ed != -1) {
			dr = other[ed];
			if(dis[s][x] + cost[ed] < dis[s][dr]) {
				dis[s][dr] = dis[s][x] + cost[ed];
				if(inque[dr] == 0) {
					inque[dr] = 1;
					q.push(dr);
				}
			}
			ed = pre[ed];
		}
		inque[x] = 0;
	}
}

int main()
{
	while(scanf("%d %d %d", &n, &m, &R) != EOF)
	{
		all = -1; memset(last, -1, sizeof(last));
		for(int i = 1; i <= R; i++)
			scanf("%d", &num[i]);
		sort(num + 1, num + R + 1);
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				dis[i][j] = inf;
		for(int i = 1; i <= m; i++) {
			int u, v, w;
			scanf("%d %d %d", &u, &v, &w);
			build(u, v, w); build(v, u, w);
		}
		for(int i = 1; i <= n; i++) {
			SPFA(i);
		}
		int ans = inf;
		do {
			int d = 0;
			for(int i = 1; i <= R - 1; i++) {
				d += dis[num[i]][num[i + 1]];
			}
			ans = min(ans, d);
		}while(next_permutation(num + 1, num + R + 1));
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC122D
{
    static class MainClass
    {

        static int[] s;
        static long[,,,] dp = new long[101, 4, 4, 4];
        static bool[,,,] done = new bool[101, 4, 4, 4];
        static long mod = (long)Math.Pow(10,9)+7;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            long ptn = 0;
            for(int i = 0; i < 4; i++)
            {
                for(int j = 0; j < 4; j++)
                {
                    for(int k = 0; k < 4; k++)
                    {
                        done[3,i,j,k] = true;
                        if (Ok(3, i, j, k))
                        {
                            dp[3, i, j, k]++;
                        }
                    }
                }
            }
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        ptn += Dfs(s[0], i, j, k);
                    }
                }
            }
            Console.WriteLine(ptn%mod);

        }

        public static long Dfs(int n, int w1, int w2, int w3) {
            if (n == 0)
            {
                return 1;
            }
            else if (done[n,w1,w2,w3])
            {
                return dp[n, w1, w2, w3];
            }
            else
            {
                long ptn = 0;
                for (int i = 0; i < 4; i++)
                {
                    if (Ok(i,w1, w2, w3))
                    {
                        //Console.WriteLine("OK:  i  : " + i + " w1 " + w1 + " w2 " + w2 + " w3 " + w3);
                        ptn += Dfs(n-1,i,w1,w2);
                    }
                    else
                    {
                        //Console.WriteLine("NG:  i  : " + i + " w1 " + w1 + " w2 " + w2 + " w3 " + w3);

                    }
                }
                done[n, w1, w2, w3] = true;
                dp[n, w1, w2, w3] = ptn%mod;
                //Console.WriteLine("ptn: " + ptn + " n " + n + " w1 " + w1 + " w2 " + w2 + " w3 " + w3);
                return dp[n, w1, w2, w3];
            }
        }

        public static bool Ok(int w1,int w2,int w3,int a)
        {
            string s1 = w1.ToString();
            string s2 = w2.ToString();
            string s3 = w3.ToString();
            string sa = a.ToString();

            if ((s1 + s2 + s3 + sa).Contains("012")) return false;
            if ((s2 + s1 + s3 + sa).Contains("012")) return false;
            if ((s1 + s3 + s2 + sa).Contains("012")) return false;
            if ((s1 + s2 + sa + s3).Contains("012")) return false;
            return true;
        }
    }
}


Measured memory_bytes: 17488
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  string S; cin>>S;
  bool judge=true;
  ll Q; cin>>Q;
  string A,B; A=B="";
  rep(i,Q)
  {
    int hoge; cin>>hoge;
    if(hoge==1) {judge=!(judge); continue;}
    int F; cin>>F;
    char C; cin>>C;
    if(F==1)
    {
      if(judge) {A+=C; continue;}
      B+=C;
      continue;
    }
    //F==2
    if(judge) {B+=C; continue;}
    A+=C;
  }
  S+=B;
  reverse(S.begin(),S.end());
  S+=A;
  if(judge){reverse(S.begin(),S.end());}
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll n, x;
    cin >> n;
    ll a[n], hash[n + 1];
    memset(hash, 0, sizeof(hash));
    for (ll i = 0; i < n - 1; i++)
    {
        cin >> x;
        hash[x]++;
    }
    for (ll i = 1; i < n + 1; i++)
    {
        cout << hash[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5212
#include <cstdio>

int a,b;

int main(){
    scanf("%d%d", &a, &b);
    if(a == b){
        printf("a == b\n");
    }else if(a < b){
        printf("a < b\n" );
    }else{
      printf("a > b\n" );
    }
}


Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=40005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int t[maxn];
int v[maxn];

int T=0;

int s[maxn];
int main()
{
	REP(i,maxn) s[i]=INF;
	
	
	int n;
	cin>>n;
	REP(i,n) cin>>t[i+1];
	REP(i,n) cin>>v[i+1];
	v[n+1]=0,t[n+1]=0;
	v[0]=0,t[0]=0;
	int cur=0;
	
	
	for(int i=0;i<=n+1;i++){
		for(int j=0;j<maxn;j++){
			if(j<=cur*2){
				s[j]=min(s[j],2*v[i]+(2*cur-j));
			}
			else if(j>=2*(cur+t[i])){
				s[j]=min(s[j],2*v[i]+(j-2*cur-2*t[i]));
			}
			else s[j]=min(s[j],2*v[i]);
		}
		cur+=t[i];
	}
	
	REP(i,n) T+=t[i+1];
	//cout<<T<<'\n';
	int ans=0;
	for(int i=0;i<2*T;i++){
		//cout<<s[i]<<' ';
		ans+=s[i]+s[i+1];
	}
	cout<<fixed<<setprecision(6)<<0.125*ans;
	return 0;
}












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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int ans=0;

    ans+=min(a,k);
    k-=min(a,k);

    k-=min(b,k);

    ans-=min(c,k);

    cout<<ans<<endl;

}



Measured memory_bytes: 3656
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll foo(ll a)
{
	if(a%4==0)
		return a;
	if(a%4==1)
		return 1;
	if(a%4==2)
		return a+1;
	return 0;
}
int main()
{
	ll a,b,c,d,n,m;
	ll ans = 0,diff;
	cin>>a>>b;
	if(a!=0)
		a--;
	ll a1 = foo(a);
	ll a2 = foo(b);
	ans = a1^a2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n, m = [int(item) for item in input().split()]
INF = 10 ** 10
dp = [INF] * (2 ** n)
dp[0] = 0
for i in range(m):
    a, b = [int(item) for item in  input().split()]
    c = [int(item) - 1 for item in  input().split()]
    bit = 0
    for item in c:
        bit |= 1 << item
    for j in range(2 ** n):
        dp[j | bit] = min(dp[j | bit], dp[j] + a)
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 48088
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <string>
#include <cstring>
using namespace std;

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

	bool result = false;
    int tmp1 = N / 100;
	if (tmp1==7) {
		result = true;
	}
    int tmp2 = (N - tmp1 * 100) / 10;
	if (tmp2==7) {
		result = true;
	}
    int tmp3 = (N - tmp1 * 100 - tmp2 * 10);
	if (tmp3==7) {
		result = true;
	}
	cout << (result?"Yes":"No") << endl;
}

Measured memory_bytes: 3620
n=int(input())
a=list(map(int,input().split()))
#print(bin(11^9^24))
B=bin(a[0])
for i in range(1,n):
    B=bin(int(str(B)[2:],2)^a[i])
for j in range(n):
    x=bin(int(str(B)[2:],2)^a[j])
    print(int(str(x)[2:],2))

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

int main()
{
  char s[20];
  scanf("%s",s);
  int n=strlen(s);
  int ans=0,k=0;
  for(int i=0;i<n;i++){
    int a=s[i]-'0';
    if(a>0){
      ans=max(ans,k+a-1+(n-i-1)*9);
    }
    k+=a;
  }
  ans=max(ans,k);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

int main(){
	int N;
	long long V,R=0;
	scanf("%d%lld",&N,&V);
	vector<long long>a(N),b(N),c(N),d(N);
	for(int i=0;i<N;i++)scanf("%lld",&a[i]);
	for(int i=0;i<N;i++)scanf("%lld",&b[i]);
	for(int i=0;i<N;i++)scanf("%lld",&c[i]);
	for(int i=0;i<N;i++)scanf("%lld",&d[i]);
	map<long long,long long>m1,m2;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)m1[a[i]+b[j]]++;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)m2[c[i]+d[j]]++;
	for(auto &e:m1){
		auto it=m2.lower_bound(V-e.first);
		if(it!=m2.end()&&it->first==V-e.first)R+=e.second*it->second;
	}
	printf("%lld\n",R);
}

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


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


	int A, B;
	cin >> A >> B;

	for (int i = B - A + 1; i <= B + A - 1; i++) cosp(i);

	Would you please return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math


N,K = map(int,input().split())
l = [int(i) for i in input().split()]


l.sort(reverse=True)

print(sum(l[:K]))


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

using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    if(S.size() == 1) {
        cout << S << endl;
        return 0;
    }

    for(int i = 1; i < S.size(); i++) {
        if(S.at(i) != '9') {
            break;
        }
        if(i == S.size() - 1) {
            cout << 9*S.size() - 9 + S.at(0) - '0' << endl;
            return 0;
        }
    }

    cout << 9*S.size() - 9 + S.at(0) - '0' - 1 << endl;


    return 0;
}

Measured memory_bytes: 3608
n=int(input())
a=list(map(int,input().split()))
r=[0]*9
for i in range(n):
    if a[i]<=399:
        r[0]+=1
    elif a[i]<=799:
        r[1]+=1
    elif a[i]<=1199:
        r[2]+=1
    elif a[i]<=1599:
        r[3]+=1
    elif a[i]<=1999:
        r[4]+=1
    elif a[i]<=2399:
        r[5]+=1
    elif a[i]<=2799:
        r[6]+=1
    elif a[i]<=3199:
        r[7]+=1
    else:
        r[8]+=1
c=0
for i in range(8):
    if r[i]:
        c+=1
print(max(c,1),c+r[8])


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

int main() {
  int W, H;
  string topbtm_str="#";
  string str;
  
  cin >> H >> W; 
  
  vector<string> image; 
  
  rep(i, W+1)
    topbtm_str = topbtm_str + "#";
  
  cout << topbtm_str << endl;
  rep(i,H){
    cin >> str;
    str = "#" + str + "#";
    image.push_back(str);
    cout << str << endl;
  }
  cout << topbtm_str << endl;
  
}


Measured memory_bytes: 256
open System
open System.Collections.Generic

let ReadOne T = stdin.ReadLine()|> T
let ReadSplit T = stdin.ReadLine().Split()|>Array.map T
[<EntryPoint>]
let main argv =
    let a,b=stdin.ReadLine().Split()|>fun c -> int c.[0],int c.[1]
    if b>=a then a else a-1
    |>stdout.WriteLine
    0


Measured memory_bytes: 11220