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

int main()
{
    int N;
    int p = 0, w = 0, g = 0, y = 0;
    string S;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> S;
        if (S == "P")
        {
            p++;
        }
        else if (S == "W")
        {
            w++;
        }
        else if (S == "G")
        {
            g++;
        }
        else if (S == "Y")
        {
            y++;
        }
    }

    cout << ((p && w && g && y) ? "Four" : "Three") << endl;
}

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

int main(){
  int n;
  cin >> n;
  double p[n];
  rep(i, n) cin >> p[i];
  vector<vector<double>> dp(n+1, vector<double>(n+1, 0.0));;
  dp[0][0] = 1.0;
  rep(i, n){
    rep(j, n+1) {
      if(j > 0) dp[i+1][j] = dp[i][j-1]*p[i] + dp[i][j]*(1.0-p[i]);
      else dp[i+1][j] = dp[i][j]*(1.0-p[i]);
    }
  }
  double ans = 0;
  for(int i = (n+1)/2; i <= n; i++) ans += dp[n][i];
  printf("%.10lf\n", ans);
  return 0;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

char affin(char c, int a, int b) {
  int i = (a * (c - 'a') + b) % 26;
  return char('a' + i);
}

string affin(string s, int a, int b) {
  string r = "";
  rep (i, s.size()) {
    char c = s[i];
    if ('a' <= c && c <= 'z') {
      r += affin(c, a, b);
    }
    else {
      r += c;
    }
  }
  return r;
}

bool okay(string s) {
  if (s.find("this") != string::npos) return true;
  if (s.find("that") != string::npos) return true;
  return false;
}

int main() {

  int n; cin >> n;
  getchar();

  rep (_, n) {
    string s;
    getline(cin, s);

    rep (a, 26) {
      if (a % 2 == 0) continue;
      if (a % 13 == 0) continue;
      rep (b, 26) {
        string t = affin(s, a, b);
        if (okay(t)) {
          cout << t << endl;
          goto more;
        }
      }
    }
more:;
  }

  return 0;
}

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

int main() {
	int n,k;cin>>n>>k;
	string s;cin>>s;
	if(s[k-1]=='A'){
		s[k-1]='a';
	}else if(s[k-1]=='B'){
		s[k-1]='b';
	}else{
		s[k-1]='c';
	}
	cout<<s<<endl;
	return 0;
}


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

int main()
{
    int n,m,b[110][110]={},c[110]={},ans[110]={};
    cin>>n>>m;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>b[i][j];
        }
    }

    for(int j=1;j<=m;j++){
        cin>>c[j];
    }

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

        for(int j=1;j<=m;j++){
            ans[i]+=b[i][j]*c[j];
        }
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int h, n;
    cin >> h >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vec.at(i);
    }
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += vec.at(i);
    }
    if (sum >= h)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 640
N = int(input())
S = [list(map(int, input().split())), list(map(int, input().split()))]

ue, shita = S[0][0], S[0][0]+S[1][0]
for i in range(1,N):
  ue = ue + S[0][i]
  shita = max(shita, ue) + S[1][i]
ans = max(ue+S[-1][-1], shita)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <functional>
using namespace std;
#define MAX 10000
vector< pair<int,int> > V;
int main(){
	int H, W;
	cin >> H >> W;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		V.push_back(make_pair(x, i));
	}
	sort(V.begin(), V.end());
	
	//for (int i = 0; i < N; i++) cout << V[i].second << " ";

	int ans[100][100];
	int cnt = 0;
	for (int i = 0; i < H; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < W; j++) {
				if (V[cnt].first == 0) cnt++;
				ans[i][j] = V[cnt].second + 1;
				V[cnt].first--;
			}
		}
		else {
			for (int j = W - 1; j >= 0; j--) {
				if (V[cnt].first == 0) cnt++;
				ans[i][j] = V[cnt].second + 1;
				V[cnt].first--;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
  int H, W;
  char a[101][101];
  bool wh_row[101];
  bool wh_col[101];
  cin >> H >> W;

  rep(i,H) {
    rep(j,W) {
      cin >> a[j][i];
    }
  }

  rep(i,H) wh_row[i]=true;
  rep(i,W) wh_col[i]=true;

  rep(i,H) {
    rep(j,W) {
      if(a[j][i]=='#') {
        wh_row[i]=false;
        break;
      }
    }
  }

  rep(j,W) {
    rep(i,H) {
      if(a[j][i]=='#') {
        wh_col[j]=false;
        break;
      }
    }
  }
  
  rep(i,H) {
    if(!wh_row[i]) {
      rep(j,W) {
	if(!wh_col[j]) cout << a[j][i];
      }
      cout << endl;
    }
  }

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int X, Y, depa[50][50];
int dx[] = { 0, 1, 0, -1 };
int dy[] = { 1, 0, -1, 0 };
void move(int x, int y, int dir, int* nx, int* ny)
{
	int tx = x + dx[dir];
	int ty = y + dy[dir];
	if (tx >= 0 && ty >= 0 && tx < X && ty < Y
		&& depa[ty][tx] == 0
		)
	{
		*nx = tx;
		*ny = ty;
	}
	else
	{
		*nx = x;
		*ny = y;
	}
}
ll enc(int tx, int ty, int kx, int ky)
{
	return tx | ty << 7 | kx << 7*2 | ky << 7*3;
}
void dec(ll e, int* tx, int* ty, int* kx, int* ky)
{
	const int mask = (1 << 7) - 1;
	*tx = e & mask;
	*ty = e >> 7 & mask;
	*kx = e >> 7*2 & mask;
	*ky = e >> 7*3 & mask;
}

int main()
{
	while (scanf("%d%d", &X, &Y), X|Y)
	{
		int tx, ty, kx, ky;
		scanf("%d%d%d%d", &tx, &ty, &kx, &ky);
		--tx; --ty; --kx; --ky;
		for (int i = 0; i < Y; ++i)
			for (int j = 0; j < X; ++j)
				scanf("%d", &depa[i][j]);

		queue<ll> q;
		map<ll, int> memo;
		q.push(enc(tx, ty, kx, ky));
		memo[enc(tx, ty, kx, ky)] = 0;
		int res = -1;
		while (!q.empty())
		{
			ll e = q.front(); q.pop();
			int time = memo[e];

			dec(e, &tx, &ty, &kx, &ky);
			if (tx == kx && ty == ky)
			{
				res = time;
				break;
			}

			if (time >= 99)
				continue;

			for (int i = 0; i < 4; ++i)
			{
				int ttx, tty, kkx, kky;
				move(tx, ty, i, &ttx, &tty);
				move(kx, ky, (i+2)%4, &kkx, &kky);

				int en = enc(ttx, tty, kkx, kky);
				if (!memo.count(en))
				{
					memo[en] = time + 1;
					q.push(en);
				}
			}
		}
		if (res != -1)
			printf("%d\n", res);
		else
			puts("NA");
	}

	return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	map<int,int> even,odd;
	for(int i = 0; i < n; i++){
		if(i%2==0) odd[v[i]]++;
		else even[v[i]]++;
	}

	int even_1=0,even_2=0,odd_1=0,odd_2=0;
	int e1=0,e2=0,o1=0,o2=0;
	int cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			even_1 = itr->first;
		}
	}
	e1 = cnt;
	cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt && itr->first != even_1){
			cnt = itr->second;
			even_2 = itr->first;
		}
	}
	e2 = cnt;

	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			odd_1 = itr->first;
		}
	}
	o1= cnt;
	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt && itr->first != odd_1){
			cnt = itr->second;
			odd_2 = itr->first;
		}
	}
	o2=cnt;

	if(even_1 == odd_1){
		cout << min(n-e1-o2, n-e2-o1) << endl;
	}else{
		cout << n-e1-o1 << endl;
	}

	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int x[200000],y[200000];
signed main(){
	int n,sum=0,sum2=0;
	cin>>n;
	f(i,n){
		cin>>x[i]>>y[i];
		sum+=y[i];
		sum2+=x[i]*y[i];
	}
	cout<<(sum2-1)/9+sum-1<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll h,w;
  cin >> h >> w;
  vector<string> c(h);
  for(int i = 0;i < h;i++)cin >> c[i];
  for(int i = 0;i < h*2;i++){
    for(int j = 0;j < w;j++){
      cout << c[i / 2][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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 (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

struct UnionFind {
    vector <int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector <ll> siz;

    UnionFind(int N) : par(N), siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        for(int i = 0; i < N; i++) siz[i] = 1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
  ll n, m;
  cin >> n >> m;
  UnionFind u(n);

  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    u.unite(a, b);
  }

  ll ans = 0;
  rep(i, n) chmax(ans, u.size(i));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5628
#include <stdio.h>

#define SIZE 2000000

int main() {
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  char com[21], buf[20];
  buf[19]='\0';
  char *p;
  do {
    fgets(com, 20, stdin);
    if (com[0] == 'i') {
      n = 0;
      p = com+7;
      while (*p!='\n') {
        n = n*10+*p-'0';
        p++;
      }
      A[++H] = n;
      for (i=H; i>1 && A[i/2]<A[i];i>>=1) {
        tmp = A[i/2];
        A[i/2] = A[i];
        A[i] = tmp;
      }

    } else if (com[1]=='x') { // extract
      n = A[1];

      for (i=18; n>0; n/=10){
	if(n>0)break;
      }
      
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      puts(buf+i+1);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        largest = i;
        if (l < H && A[l] > A[i])        largest = l;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (com[2]!='d');
  return 0;
}



Measured memory_bytes: 5480
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

for i in range(N - 2):
    if D[i][0] == D[i][1] and D[i + 1][0] == D[i + 1][1] and D[i + 2][0] == D[i + 2][1]:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 62232
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);

int main() {
	ll n,d,a;
	cin >> n >> d >> a;
	vector<ll> v;
	vector<pair<ll,ll>> vv;
	rep(i,n){
		ll x,h;
		cin >> x >> h;
		v.push_back(x);
		vv.emplace_back(x,h);
	}
	v.push_back(MOD); v.push_back(MOD);
	sort(all(v));
	sort(all(vv));

	ll damage[n+10] = {},sum = 0;
	for(int i = 1; i <= n; i++){
		damage[i] += damage[i-1];
		ll now_h = vv[i-1].second-damage[i]*a;
		if(now_h <= 0) continue;
		ll cnt = (now_h-1)/a+1,range = v[i-1]+2*d;
		sum += cnt;
		damage[i] += cnt;
		damage[lower_bound(all(v),range+1)-v.begin()+1] -= cnt;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 7396
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) ((long long 1) << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
using namespace std;
typedef long long ll;
ll const MAX = 1e5 + +5;
vll G[MAX];

struct edge{
    ll a; ll b;
};

void prnt(edge e,edge f){
    if(e.a == f.b){
        swap(f.a, f.b);
    }
    else if(e.b == f.a){
        swap(e.a, e.b);
    }else if(e.b == f.b){
        swap(e.a, e.b);
        swap(f.a, f.b);
    }
    cout << e.a << " " << e.b << endl;
    cout << f.a << " " << f.b << endl;
}

ll from[MAX] = {};
ll color[MAX] = {};
ll num[MAX] = {};
stack<edge> st;
void bfs(ll cur){
    color[cur] = 1;
    for(auto nex: G[cur]){
        if(color[nex] == 0){
            from[nex] = cur;
            bfs(nex);
            edge e = st.top();
            if(e.a == cur || e.a == nex || e.b == cur || e.b == nex){
                st.pop();
                prnt(e, {cur,nex});
            }else{
                st.push({cur,nex});
            }

        }
        if(color[nex] == 1 && from[cur] != nex){
            edge e = st.top();
            if(e.a == cur || e.a == nex || e.b == cur || e.b == nex){
                st.pop();
                prnt(e, {cur,nex});
            }else{
                st.push({cur,nex});
            }
        }
    }
    color[cur] = 2;
}

int main(){
    ll n, m;
    cin >> n >> m;
    REP(i,1,m){
        ll a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if(m % 2 == 1){
        cout << -1 << endl;
        return 0;
    }
    st.push({-1,-1});
    bfs(1);
    
}


Measured memory_bytes: 16256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}

void solve()
{
    int n;
    scanf("%d", &n);
    if (n == 3) {
        printf("2 5 63\n"); return;
    }
    vector<int> z;
    int i;
    int cnt = 0;
    for (i = 1; i < 15000; i++) {
        if (gcd(i, 15000) > 1) {
            z.push_back(i);
            z.push_back(30000 - i);
            cnt++;
            if (cnt == n / 2) break;
        }
    }
    if (n % 2) z.push_back(15000);

    for (i = 0; i < (int)z.size(); i++) {
        printf("%d", z[i]);
        if (i < (int)z.size() - 1) printf(" ");
    }
    printf("\n");

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    long l, r;
    cin >> l >> r;

    if (r - l >= 2019)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        long minNum = 2018;
        for (long i = l; i < r; i++)
        {
            for (long j = l+1; j <= r; j++)
            {
                minNum = min((i*j)%2019, minNum);
            }
        }
        
        cout << minNum << endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    int B = 0, A = 0, BA = 0;
    int ans = 0;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        for(int j = 1; j < s.size(); j++){
            if(s.substr(j - 1, 2) == "AB"){
                ans++;
            }
        }
        if(s[0] == 'B' && s.back() == 'A'){
            BA++;
        }else if(s[0] == 'B'){
            B++;
        }else if(s.back() == 'A'){
            A++;
        }
    }
    if(B || A){
        cout << ans + min(B, A) + BA << endl;
    }else{
        cout << ans + max(0, BA - 1) << endl;
    }
}


Measured memory_bytes: 384
n, m = gets.split.map(&:to_i)
d = n.times.map{ gets.to_i }
h = m.times.map{ gets.to_i }
dp = Array.new(2){ Array.new(n+1, 1<<31) }
dp[0][0] = dp[1][0] = 0
m.times do |i|
  (0..[i,n-1].min).each do |j|
    dp[i%2^1][j+1] = [dp[i%2][j+1], dp[i%2][j] + d[j] * h[i]].min
  end
end
p dp[m%2][-1]

Measured memory_bytes: 8808
n,k=map(int,input().split())
d=[0]*(k+1)
mod=10**9+7
ans=0
for i in range(1,k+1)[::-1]:
    tmp=0
    c=0
    for j in range(i,k+1,i):
        c+=1
        tmp+=d[j]
    d[i]=pow(c,n,mod)-tmp
    ans=(ans+d[i]*i)%mod
print(ans)

Measured memory_bytes: 11280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll in()
{
    ll res=0,p=1;
    char c=getchar();
    while(c<'0'||c>'9') {if(c=='-') p=-1; c=getchar();}
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return p*res;
}
void out(ll x)
{
    if (x>9) out(x/10);
    putchar(x%10+48);
}

const int maxn = 1e5 + 5 + 32;
const int mod = 1e9 + 7;

ll quickpow(ll x, int k)
{
    ll res = 1;
    while(k){
        if(k & 1) res = (res * x) % mod;
        k >>= 1, x = (x * x) % mod;
    }
    return res;
}

ll fac[maxn] = {1, 1, 2};
ll C(int n, int m){return (fac[n] * quickpow((fac[m] * fac[n - m]) % mod, mod - 2)) % mod;}

map<int, int> mi;

void dis(int x)
{
    for (int i = 2; i * i <= x; ++i){
        while (x % i == 0) ++mi[i], x /= i;
    }
    if (x != 1) ++mi[x];
}
int main()
{
    for (int i = 3; i < maxn; ++i) fac[i] = (i * fac[i - 1]) % mod;
    int n, m;
    n = in(); m = in();
    dis(m);
    ll ans = 1;
    for (auto e : mi) ans = (ans * C(n + e.second - 1, e.second)) % mod;
    out(ans);
    return 0;
}

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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define insert ins
#define ers erase
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

int main() {
	
	fastio;

    rd2(ll, n, m);
    if(n == m)
        cout << "Yes\n";
    else
        cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter

input = sys.stdin.readline

#################
# 定数
#################
TIME = 0
VAL = 1

##################
# 入力処理
##################
N, T = [int(a) for a in input().split()]
time_value = [(-1, -1)] + [None] * (N)
for i in range(1, N + 1):
    time_value[i] = tuple(int(a) for a in input().split())

# Sort the array in the increasing order of value
time_value.sort(key = itemgetter(VAL))

###########################
# 動的計画法（Knapsack problem）のテーブル埋め
# 時間の最大値は T - 1
##########################
dp = [[-1] * T for _ in range(N + 1)] # (N+1)行 x T列 2次元リスト

for t in range(0, T):
    dp[0][t] = 0

for n in range(1, N + 1):
    dp[n][0] = 0
    for t in range(1, T):
        if time_value[n][TIME] > t:
            dp[n][t] = dp[n - 1][t]
        else:
            dp[n][t] = max(dp[n - 1][t],
                             time_value[n][VAL] + dp[n - 1][t - time_value[n][TIME]])

##########################
# DPテーブルを用いて問題を解く
##########################

# t = T - 1に食べ始める料理が N, N-1, N-2, ..., 2, 1それぞれの場合で
# 美味しさの最大値を出し、更にその最大値を取る

# 最後に食べる料理がNの場合
val_acum = time_value[N][VAL]
t = T - 1  # N以外の料理を食べるのに使える時間
max_val = val_acum + dp[N - 1][t]

for n in range(N - 1, 0, -1):  # 最後に食べる料理が n = N-1, N-2, ..., 2, 1の場合
    val_acum += time_value[n][VAL] # 料理 N, N-1, ..., nの美味しさ合計
    t -= time_value[n + 1][TIME] # その他の料理 1, 2, ..., n-1を食べるのに使える時間
    if t < 0:
        break
    else:
        max_val = max(max_val, val_acum + dp[n - 1][t])

print(max_val)


Measured memory_bytes: 114012
#include<cstdio>
using namespace std;
int a[10];
int abs(int a){
	return a>0?a:-a;
}
int main(){
	int n=3,ans=10000;
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	if (abs(a[1]-a[2])+abs(a[2]-a[3])<ans) 
	   ans=abs(a[1]-a[2])+abs(a[2]-a[3]);
	if (abs(a[1]-a[3])+abs(a[1]-a[2])<ans)
	   ans=abs(a[1]-a[3])+abs(a[1]-a[2]);
	if (abs(a[3]-a[1])+abs(a[2]-a[3])<ans)
	   ans=abs(a[3]-a[1])+abs(a[2]-a[3]);
	printf("%d",ans);
	return 0;
} 

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


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  int N = s.size();
  for (int i = 0; i < N - 1; i++){
    if (s[i] != 'a' && K >= 'z' + 1 - s[i]){
      K -= 'z' + 1 - s[i];
      s[i] = 'a';
    }
  }
  K %= 26;
  for (int i = 0; i < K; i++){
    if (s[N - 1] == 'z'){
      s[N - 1] = 'a';
    } else {
      s[N - 1]++;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
map<ll,ll> ma;
set<ll> s;
vi a;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n>>t;
    t/=2;
    in(a,n);
    s.insert(a[n-1]);
    for(int i=n-2;i>=0;i--){
        x = *s.rbegin();
        if(x>a[i]){
            ma[x-a[i]]++;
        }
        s.insert(a[i]);
    }
    cout<<(*ma.rbegin()).S;
    
    return 0;
}

Measured memory_bytes: 12020
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp

#define MAX 100005

struct PS
{
    string name;
    int time;
};

int head, tail;
PS ps[MAX];

static void enq(PS x) {
    ps[tail] = x;
    tail = (tail + 1) % MAX;
}

static PS deq() {
    PS p = ps[head];
    head = (head + 1) % MAX;
    return p;
}


int main() {
    int n , q; cin >> n >> q;
    REP(i, n) {
        string name;
        int time;
        cin >> name >> time;
        enq({name, time});
    }

    int elapse = 0;
    while(tail != head) {
        PS p = deq();
        int c = min(q, p.time);
        p.time -= c;
        elapse += c;
        if (p.time > 0) {
            enq({p.name, p.time});
        } else {
            printf("%s %d\n", p.name.c_str(), elapse);
        }
    }

    return 0;
}



Measured memory_bytes: 7256
#include <stdio.h>

int a[500000],h;
void maxheapify(int);

int main(){
  int i;
  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%d",&a[i+1]);
  }
  for(i=h/2;i>=1;i--){
    maxheapify(i);
  }
  for(i=1;i<=h;i++){
    printf(" %d",a[i]);
  }
  /*printf("%d",a[1]);
  for(i=1;i<h;i++){
    printf(" ");
    printf("%d",a[i+1]);
  }*/
 
  printf("\n");
  
  return 0;
}

void maxheapify(int i){
  int l,r,largest,b;
  l = 2*i;
  r = 2*i+1;

  if(l<=h && a[l]>a[i]) largest=l;
  else largest=i;
  if(r<=h && a[r]>a[largest])largest=r;

  if(largest!=i){
    b=a[i];
    a[i]=a[largest];
    a[largest]=b;
    maxheapify(largest);
  }
  
}



Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll m = (1e9+7); 
int main()
{
	ll n;ll sum = 0;
	cin>>n;ll pref[n];vector<ll>a;
	for(int i = 0; i<n; i++)
	{
		ll v;
		cin>>v;
		a.push_back(v);
		sum+=a[i];
		pref[i]=sum;
	}
	ll ans = 0;
	for(int i = 0; i<n; i++)
	{
		ll p = a[i];
		ll q = pref[n-1]-pref[i];
		ll z = ((p%m)*(q%m))%m;
		ans = ((ans%m)+(z%m))%m;
		
	}
  cout<<ans;
}

Measured memory_bytes: 6648
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  char c; cin >> c;
  if ('A' <= c && c <= 'Z') cout << 'A' << endl;
  else cout << 'a' << endl;

  return 0;
}

// EOF

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

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

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> ps(a), qs(b), rs(c);
  rep(i, a) cin >> ps[i];
  rep(i, b) cin >> qs[i];
  rep(i, c) cin >> rs[i];

  sort(ps.rbegin(), ps.rend());
  sort(qs.rbegin(), qs.rend());

  vector<int> v;
  rep(i, x) v.push_back(ps[i]);
  rep(i, y) v.push_back(qs[i]);
  rep(i, rs.size()) v.push_back(rs[i]);
  sort(v.rbegin(), v.rend());

  ll res = 0;
  rep(i, x + y) res += v[i];
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3572
def read():
    N, K = map(int, input().strip().split())
    H = map(int, input().strip().split())
    return N, K, H

def solve(N, K, H):
    return sum([1 if h >= K else 0 for h in H])

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

int main() {
	int n;
	cin >> n;
	int s = 0;
	int mn = INT_MAX;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		s += x;
		if (x % 10 != 0)
			mn = min(mn, x);
	}
	
	if (s % 10 == 0)
		if (mn != INT_MAX)
			s -= mn;
		else
			s = 0;
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
/*
 * Main.cpp
 *
 *  Created on: 26/03/2020
 *      Author: freyman
 */

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	double l;
	cin >> l;
	l /= 3.0;
	printf("%.7f\n",pow(l,3));




}














Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, T = 0;cin >> N;
vector<pair<ll, ll>> V(N);
   
rep(i, 0, N)cin >> V[i].second >> V[i].first;

sort(ALL(V));

for(auto x : V){

T += x.second;

if(T > x.first){cout << "No";exit(0);}

}

cout << "Yes";

}

Measured memory_bytes: 6760
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> K;
		ans += 2 * min(K, abs(M - K));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
function main(input){
    let radius = parseFloat(input);
    let area = radius*radius*Math.PI;
    let around = 2*radius*Math.PI;
    console.log(digit(area)+" "+digit(around));
    
}

function digit(num){
    if(num.toString().indexOf("e-")!==-1){
        let digit = num.toString().split("e-")[1];
        num = num.toFixed(parseInt(digit));
    }
    return num;

}


main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 15396
#include <map>
#include <cstdio>
using namespace std;
void solve(int T){
	map<pair<int,int>,int>m;
	char cmd[2];
	int n;
	for(;T--;){
		scanf("%s%d",cmd,&n);
		if(*cmd=='D'){
			for(auto it=m.begin();it!=m.end();){
				if(it->second==n){
					auto it2=it;
					++it;
					m.erase(it2);
				}else{
					++it;
				}
			}
		}else if(*cmd=='R'){
			pair<int,int> f={n,2000000000};
			auto it=m.lower_bound(f);
			if(it==m.begin()){
				puts("-1");
			}else{
				--it;
				printf("%d\n",it->first.first<=n&&n<=it->first.second ? it->second : -1);
			}
		}else if(*cmd=='W'){
			int z;
			scanf("%d",&z);
			int cur=0;
			for(auto it=m.begin();it!=m.end();++it){
				int d=it->first.first-cur;
				if(d>z)d=z;
				if(d)m[make_pair(cur,cur+d-1)]=n;
				z-=d;
				if(z==0)break;
				cur=it->first.second+1;
			}
			if(z)m[make_pair(cur,cur+z-1)]=n;
		}
	}
}
int main(){for(int T;~scanf("%d",&T)&&T;puts(""))solve(T);}

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

#define rep(i,n) = for(int i = 0; i < (n); i++);
using ll = long long;
int main(void){
    ll x, k ,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans;
    if(x / d >= k){
        ans = x - d * k;    
    }
    else{
        ll e = x/d;
        k -= e;
        x -= e*d;
        if(k % 2 == 1) x = abs(x - d);
        ans = x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>

void cmax(int &x, int y) {if(x < y) x = y;}

int main()
{
    //freopen("a.in", "r", stdin);
    int k, n; scanf("%d%d", &k, &n);
    int ans = 0;
    int pre, fir;
    scanf("%d", &fir);
    pre = fir;
    for(int i = 1; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        cmax(ans, x - pre);
        pre = x;
    }
    cmax(ans, fir + k - pre);
    printf("%d\n", k - ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int main(){

  ll n = in();
  ll ans = n / 11;
  n -= ans * 11;
  ans *= 2;
  if( n > 6 ){
    ans += 2;
  } else if( n > 0 ){
    ans += 1;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N,i,k;
  string moji,mojimoji;
  cin>>moji>>N;
  int j=0;
  for(i=0;i<N;i++){
    cin>>mojimoji;
    mojimoji+=mojimoji;
    k=mojimoji.find(moji);
    if(k!=string::npos){
 j++;
  }
  }
  cout<<j<<endl;
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int x;cin>>x;
  x-=400;
  cout<<(8-x/200)<<endl;

  return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a>b){
        for(int i=0;i<a;i++){
            cout<<b;
        }
    }else{
        for(int i=0;i<b;i++){
            cout<<a;
        }
    }
    
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Scanner;

public class Main {
	static final DateFormat df = SimpleDateFormat.getDateInstance();
	static final Calendar cal = Calendar.getInstance(new Locale("ja", "JP", "JP"));
	static {
		((SimpleDateFormat) df).applyPattern("yyyy MM dd");
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		try {
			final Date PRE_MAIJI = df.parse("1868 9 8");
			while (in.hasNextLine()) {
				Date date = df.parse(in.nextLine());
				cal.setTime(date);
				if (cal.getTime().before(PRE_MAIJI)) {
					System.out.println("pre-meiji");
				} else {
					int era = cal.get(Calendar.ERA);
					switch (era) {
					case 1:
						System.out.print("meiji ");
						break;
					case 2:
						System.out.print("taisho ");
						break;
					case 3:
						System.out.print("showa ");
						break;
					case 4:
						System.out.print("heisei ");
					default:
						break;
					}
					System.out.print(cal.get(Calendar.YEAR));
					System.out.print(' ');
					System.out.print(cal.get(Calendar.MONTH) + 1);
					System.out.print(' ');
					System.out.println(cal.get(Calendar.DATE));
				}
			}
		} catch (ParseException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 12000
package main

import	(
	"fmt"
)

type song struct {
	title string
	second int
}


func main() {
	var n int
	fmt.Scan(&n)
	
	songs := make([]song,n)

	for i := 0; i < n; i++ {
		fmt.Scan(&songs[i].title)
		fmt.Scan(&songs[i].second)
	}
	
	var sleepTitle string
	fmt.Scan(&sleepTitle)
	
	sleep := false
	sum := 0;
	for i := 0; i < n; i++ {
		if sleep {
			sum += songs[i].second
		}
		if songs[i].title == sleepTitle {
			sleep = true
		}
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{

	char a,e,i,o,u ;
	char x ;
	cin>>x ;
	if (x=='a' || x=='e' || x=='i' || x=='o' || x=='u')
		cout<<"vowel" ;
	else
		cout<<"consonant" ;

     
	return 0;

}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define LL long long
#define ULL unsigned long long


const string A = "Alice", B = "Brown";
bool sameParity(const LL& C, const LL& D){
	return (C % 2 == 0 && D % 2 == 0) || (C % 2 == 1 && D % 2 == 1);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	LL X, Y;
	cin >> X >> Y;

	if(abs(X - Y) <= 1)
		cout << B << endl;
	else
		cout << A << endl;

	return 0;
}

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

int main()
{

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    	cin>>a[i];
    int c=0;
    for(int i=1;i<n-1;i++)
    {
    	if(a[i]>a[i-1] && a[i+1]>a[i])
    		c++;
    	if(a[i]<a[i-1] && a[i]>a[i+1])
    		c++;
    	
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


bool is_bipartite(WG<int> es){
  vector<int> b(es.size(),0);
  queue<int> q;
  q.push(0);
  b[0]=1;

  while(q.size()){
    int x=q.front(); q.pop();
    for(auto e:es[x]){
      if(b[e.to]==b[x]) return false;
      else if(b[e.to]==0){
        b[e.to]=-1*b[x];
        q.push(e.to);
      }
    }
  }

  return true;
}




template< typename T >
vector<T> dijkstra(WG<T> &g,int s){
  const auto lim = numeric_limits<T>::max();
  vector<T> dist(g.size(),lim);
  using Pi = pair<T,int>;
  priority_queue<Pi,vector<Pi>,greater<Pi>> q;
  dist[s] = 0;
  q.emplace(dist[s],s);
  while(!q.empty()){
    T cost;
    int idx;
    tie(cost,idx) = q.top();
    q.pop();
    if(dist[idx] < cost) continue;
    for( auto &e : g[idx]){
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      q.emplace(dist[e.to],e.to);
    }
  }
  return dist;
}


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

  int n;
  cin>>n;
  WG<int> es(n);
  rep(i,n){
    string s;
    cin>>s;
    rep(j,n){
      if(s[j]=='1') es[i].PB(edge<int>(j,1));
    }
  }

  if(!is_bipartite(es)){
    cout<<-1<<endl;
  }else{   
    int ans=0;
    rep(i,n){
      vi res=dijkstra(es,i);
      rep(j,n){
        ans=max(ans,res[j]+1);
      }
    }
    cout<<ans<<endl;
  }


}

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

int main(void){
    string s;
    int sum = 0;
    for(int i = 0; i < 4; i++){
        cin >> s[i];
        if(s[i] == '+')
            sum++;
        else if(s[i] == '-')
            sum--;
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
	
def f(t,A,B):
  power = 1<<t
  mask = (power<<1)-1
  AA = A & mask
  BB = B & mask
  AA.sort()
  BB.sort()

  x1,x2,x3 = (np.searchsorted(BB, v-AA).sum() for v in [power, 2*power, 3*power])
  zero_cnt = x1 + (x3-x2)
  return (N-zero_cnt)%2
  
answer = sum(f(t,A,B) << t for t in range(30))
print(answer)


Measured memory_bytes: 35924
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
using namespace std;

int main() {
int N;cin >> N;
vector<int> V(N - 1);
vector<int> W(N);



for(int i = 0; i  < N - 1; i++){
cin >> V[i];
}

for(int i = 0; i < N - 1; i++){
W[V[i] - 1]++;
}

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

}

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int max = Math.max(a, b);

		if (max > 8){
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}


Measured memory_bytes: 21844