akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main() {
	int n, u, k, x;
	int matrix[101][101] = {};

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> x;
			matrix[u][x] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << matrix[i][j] ;
			if (j != n)	cout << " ";
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<int> e(m);
    vector<pair<int,int>> num;
    for (int i=0;i<n;++i)
        num.emplace_back(i+1,i+1);
    for (int i=0;i<m;++i){
        int e; cin >> e;
        num[--e].first=-i;
    }
    sort(num.begin(),num.end());
    for (int i=0;i<n;++i) cout << num[i].second << '\n';
}


Measured memory_bytes: 5352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vector<ll> a(n, 1), b(n, -1);
	rep(i, n){
 		int p; cin >> p; p--;
		if(i){
			a[0] -= i;
			a[p] += i;
			
			b[0] += i;
			if(p + 1 < n) b[p + 1] -= i;
		}
	}
	rep(i, n - 1){
		a[i + 1] += a[i];
		b[i + 1] += b[i];
	}
	ll am = *min_element(all(a)), bm = *min_element(all(b));
	
	rep(i, n) cout << a[i] - am + 1 << (i==n-1?"\n":" ");
	rep(i, n) cout << b[i] - bm + 1 << (i==n-1?"\n":" ");
	
	return 0;
}

Measured memory_bytes: 896
// its_mind_changer_
//                         _don't_under_estimate_
#include<bits/stdc++.h>
using namespace std;
#define int long long 


signed main()
{
    int a,b;cin>>a>>b;

    for(int i=1;i<=10000;i++)
    {
        if((i*8)/100==a and (i)/10==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back

using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll r){
    cout << pow(r, 2) << "\n";
}

int main() {
    ll r;
    ignore_ret(scanf("%lld",&r));
    solve(r);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        BinaryTree btr = new BinaryTree();
        for (int i = 0; i < n; i++)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            switch (inputs[0])
            {
                case "insert": btr.Insert(int.Parse(inputs[1])); break;
                case "find":
                    if(btr.Find(int.Parse(inputs[1])) != null) Console.WriteLine("yes");
                    else Console.WriteLine("no");
                    break;
                case "print": btr.Print(); break;
            }
        }
    }
}

class BinaryTree
{
    public class Node
    {
        public int Value {get; set;}
        internal Node parent, left, right;
        internal Node(int val, Node parent)
        {
            this.Value = val;
            this.parent = parent;
        }
    }

    Node root;

    public void Insert(int val)
    {
        Node tmpParent = null;
        Node tmpPosition = this.root;
        while(tmpPosition != null)
        {
            tmpParent = tmpPosition;
            if(val < tmpParent.Value) tmpPosition = tmpParent.left;
            else tmpPosition = tmpParent.right; 
        }
        if(tmpParent == null) this.root = new Node(val, null);
        else if(val < tmpParent.Value) tmpParent.left = new Node(val, tmpParent);
        else tmpParent.right = new Node(val, tmpParent);
    }

    public Node Find(int val)
    {
        if(this.root.Value == val) return this.root;
        Node node = this.root;
        while(node != null && node.Value != val)
        {
            if(val < node.Value) node = node.left;
            else node = node.right;
        }
        return node;
    }

    public void Print()
    {
        InorderedDisplay(this.root);
        Console.WriteLine();
        PreorderedDisplay(this.root);
        Console.WriteLine();
    }
    private void InorderedDisplay(Node node)
    {
        if(node == null) return;
        InorderedDisplay(node.left);
        Console.Write(" " + node.Value);
        InorderedDisplay(node.right);
    }
    private void PreorderedDisplay(Node node)
    {
        if(node == null) return;
        Console.Write(" " + node.Value);
        PreorderedDisplay(node.left);
        PreorderedDisplay(node.right);
    }
}

Measured memory_bytes: 39124
#include<stdio.h>
int main(void)
{
    int r, g, b, k = 0;
    scanf("%d", &r);
    scanf("%d", &g);
    scanf("%d", &b);

    k = 100 * r + 10 * g + b;

    if (k % 4 == 0) {
        printf("YES");
    }
    else {
        printf("NO");
    }
    return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (b / a >= c)
		cout << c;
	else
		cout << b / a;
	return 0;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
lengths = [0 for i in range(n)]
for start in range(1, n+1):
    for end in range(start+1, n+1):
        lengths[min(end - start, abs(x-start) + abs(y-end) + 1)] += 1
print("\n".join(map(str, lengths[1:])))

Measured memory_bytes: 43484
#include <stdio.h>

void isort(int n, int a[]){
	int i,j,k,v;
	for(i = 0; i <= n-1; i++){
		v = a[i];
		j = i-1;
		while(j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		for(k = 0; k < n; k++){
			printf("%d",a[k]);
			if(k != n-1)
				printf(" ");
		}
		//printf("a");
		//printf("\n");
		if(i != n-1)
			printf("\n");
	}
	printf("\n");
}

int main(){
	int n,i;
	int a[100];
	scanf("%d",&n);
	for(i = 0; i < n; i++)
		scanf("%d",&a[i]);
	isort(n,a);
	return 0;
}

Measured memory_bytes: 604
class Node
  attr_accessor :node, :left_child, :right_sibling, :parent
  def initialize(node)
    @node = node
    @parent = -1
    @children = []
  end

  def get_depth
    depth = 0
    u = node
    until $tree[u].parent == -1 do
      depth += 1
      u = $tree[u].parent
    end
    depth
  end

  def get_children
    if left_child.nil?
      []
    else
      u = left_child
      children = [u]
      until $tree[u].right_sibling == nil do
        u = $tree[u].right_sibling
        children << u
      end
      children
    end
  end

  def get_type
    # p self.get_children
    case
    when parent == -1
      'root'
    when get_children == []
      'leaf'
    else
      'internal node'
    end
  end
end

n = gets.to_i

$tree = {}

n.times do
  input = gets.split.map(&:to_i)
  id = input[0]
  children_count = input[1]
  children = input[2..-1] if children_count != 0

  $tree[id] ||= Node.new(id)
  node = $tree[id]
  if children_count == 0
    node.left_child = nil
  else
    node.left_child = children[0]

    children.push(nil).each_cons(2) do |a, b|
      $tree[a] ||= Node.new(a)
      $tree[a].parent = id
      $tree[a].right_sibling = b if b
    end
  end
end

for i in 0..n - 1 do
  node = $tree[i]
  puts "node #{node.node}: parent = #{node.parent}, depth = #{node.get_depth}, #{node.get_type}, #{node.get_children}"
end




Measured memory_bytes: 33184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);

namespace std {
    bool operator < (const P& a, const P& b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
}

template<class iter>
tuple<ld, P, P> closest_pair(iter left, iter right) {
    int n = distance(left, right);
    if(n <= 1) return make_tuple(numeric_limits<ld>::max(), *left, *left);
    iter middle = next(left, n/2);
    ld x = middle->real();
    auto d = min(closest_pair(left, middle), closest_pair(middle, right));
    inplace_merge(left, middle, right, [](const P &a, const P &b){
            return a.imag() < b.imag();
        });
    vector<iter> around;
    for(iter i = left; i != right; ++i){
        ld dx = fabs(i->real() - x);
        ld &opt = get<0>(d);
        if(dx*dx >= opt) continue;
        for(auto j = around.rbegin(); j != around.rend(); ++j){
            ld dx = i->real() - (**j).real();
            ld dy = i->imag() - (**j).imag();
            if(dy*dy >= opt) break;
            ld norm = dx*dx + dy*dy;
            if(get<0>(d) > norm){
                d = make_tuple(norm, *i, **j);
            }
        }
        around.push_back(i);
    }
    return d;
};

// http://www.spoj.com/problems/CLOPPAIR/
// 18124516

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(6) << endl;
    int n;
    cin >> n;
    vector<P> a;
    rep(i,n){
        ld x,y;
        cin >> x >> y;
        a.emplace_back(x,y);
    }
    ld z;
    P x, y;
    sort(all(a));
    tie(z, x, y) = closest_pair(all(a));
    cout << sqrt(z) << endl;
}

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

void solveA(){
  int H,W,h,w;
  cin >> H >> W >> h >> w;

  cout << H*W- (h*W+w*H) + h*w << endl;
}
void solveB(){
  int n,m,c;
  cin >> n >> m >> c;
  int ans=0;

  int b[m];

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

  for(int i =0 ;i<n ; i++){
    int sum=0;
    for(int j =0 ;j<m ; j++){
      int a;
      cin >> a;
      sum += a * b[j];		   
    }
    if (sum+c > 0) ans++;
  }

  cout << ans << endl;
}
void solveC(){
}

void solveD(){
}

int main(){
  solveB();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<'='<<x<<' '
typedef long long ll;
typedef pair<int,int> pi;

const int MAXN = 1e5+5;
ll N,A[MAXN],dp[MAXN];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> A[i];
    dp[1] = 0;
    dp[2] = abs(A[2]-A[1]);
    for (int i = 3; i <= N; i++) {
       dp[i] = min((dp[i-1]+abs(A[i-1]-A[i])),(dp[i-2]+abs(A[i-2]-A[i])));
    }
    cout << dp[N];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

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

    int k;
    cin >> k;
    string s;
    cin >> s;

    if (s.length() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size() - 1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min + (max - min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n, vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());

}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll a[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	ll n;
	cin >> n;
	n *= 4;
	vector<pair<double, ll>> b;
	rep(i, 4) {
		b.push_back(make_pair(a[i] / pow(2, i), i));
	}
	sort(all(b));
	ll ans = 0;
	rep(i, 4) {
		ans += ((ll)(n /(ll) pow(2, b[i].second)))*a[b[i].second];
		n = n % (ll)pow(2, b[i].second);

	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
if n==1:
  print(0)
else:
  ct=0
  for i in range(1,int(n**0.5)):
    if (n-i)%i==0:
      ct+=(n-i)//i
  if (n-int(n**0.5))%int(n**0.5)==0:
    x=(n-int(n**0.5))//int(n**0.5)
    if n//x==n%x:ct+=x
  print(ct)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int placeA,placeZ;
    int len=s.length();
    for(int i=0;i<len;++i)
    {
        if(s[i]=='A')
        {
             placeA=i;
             break;
        }
    }
    for(int i=len-1;i>=0;--i)
    {
        if(s[i]=='Z')
        {
           placeZ=i;
           break;
        }
    }
    cout<<placeZ-placeA+1;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	int x, y, t;
	bool flag = 0;
	while (n--) {
		cin >> t >> x >> y;
		int k = abs(x) + abs(y);
		if (t < k) flag = 1;
		if ((k - t) & 1) flag = 1;
	}
	cout << (flag ? "No" : "Yes") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
#include<stdlib.h> 
#include<string> 
#include<iostream> 
using namespace std;

struct Node {
    int key; 
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node*find(Node *u,int k){
    while(u!=NIL && k!=u->key){
        if(k < u->key) u=u->left;
        else u=u->right;
    }
    return u;
}
void insert(int k) {
    Node *y = NIL; 
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node)); 
    z->key = k; 
    z->left = NIL; 
    z->right = NIL;
    
    while ( x != NIL ) {
        y = x; 
        if ( z->key < x->key ) {
        x = x->left; 
        } else {
            x = x->right;
        }
    }
    z->parent = y; 
    if ( y == NIL ){
        root = z; 
    } else { 
        if ( z->key < y->key ) {
            y->left = z; 
        } else {
            y->right = z;
        }
    }
}

void inorder (Node *u) {
    if ( u == NIL ) return; 
    inorder(u->left); 
    printf(" %d", u->key); 
    inorder(u->right);
}
void preorder (Node *u) {
    if ( u == NIL ) return; 
    printf(" %d", u->key); 
    preorder(u->left); 
    preorder(u->right);
}

int main() {
    int n, i, x; 
    string com;
    scanf("%d", &n);
    for (i = 0; i<n; i++) {
        cin >> com; 
        if ( com[0] == 'f' ){
            scanf("%d", &x); 
            Node *t = find(root, x); 
            if ( t != NIL ) printf("yes\n");
            else printf("no\n"); 
            
        } else if ( com == "insert"){
            scanf("%d", &x);
            insert(x); 
            
        } else if ( com == "print" ) {
            inorder (root); 
            printf("\n"); 
            preorder(root); 
            printf("\n");
        }
    }
return 0;
}



Measured memory_bytes: 22060
#include <stdio.h>
 
int main(void)
{
    int i, j = 0, num[26];
    char moji;
     
    for(i = 0; i < 26; i++) num[i] = 0;
     
    while(scanf("%c", &moji) != EOF)
    {
        for(i = 0; i < 26; i++)
        if(i == (moji - 'a') || i == (moji - 'A')) num[i]++;
    }
     
    for(i = 0; i < 26; i++) printf("%c : %d\n", i + 'a', num[i]);
     
    return 0;
}
 

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
const int N = 1e5 + 5;
int dp[N][2];

int32_t main(){
	fast;
	int n,a,b;
	cin >> n >> a >> b;
	
	int arr[n+1];
	f(i,1,n+1)  cin >> arr[i];
	
	f(i,0,N)    dp[i][0] = dp[i][1] = inf64;
	
	dp[1][0] =dp[1][1] = 0;
	
	for(int i=2 ; i<=n ; i++)
	{
		dp[i][0] = min(dp[i-1][0] , dp[i-1][1]) + (arr[i]- arr[i-1])*a;
		dp[i][1] = min(dp[i-1][0] , dp[i-1][1]) + b;
	}
	
	cout << min(dp[n][0] , dp[n][1]);
	
	
}



Measured memory_bytes: 2560
#include <stdio.h>

int main(){
    unsigned long long w, h;
    unsigned long long moves = 0;

    scanf("%llu %llu", &w, &h);

    if(w == 1 || h == 1){
        printf("1");
    }else{
        moves += (w/2) * (h/2);

        moves += ((w/2) + (w%2)) * ((h/2) + (h%2));

        printf("%llu", moves);
    }

}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;


	double ans = 0;
	for (int i = 1; i <= n; i++) {
		int a = i;
		if (a < k) {
			double t = double(1)/double(n);
			while (a < k) {
				t *= 0.5;
				a *= 2;
			}
			ans += t;
		} else {
			ans += double(1)/double(n);
		}
	}

	cout << setprecision(12) <<  ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256
import Data.Array
import Control.Monad

main = do
    n <- read <$> getLine
    costs <- map read.words <$> getLine
    putStrLn.show.answer n $ listArray (1,n) costs

answer :: Int -> Array Int Int -> Int
answer n table = dp n table ! 1

dp n costs =
    let ans = array (1,n) $ (n,0) : (n-1, n#(n-1)) : [(k,min(ans!(k+1)+k#(k+1)) (ans!(k+2)+k#(k+2))) | k <- [1..n-2]]
    in ans where
        a#b = abs $ (costs ! a) - (costs ! b)

Measured memory_bytes: 49532
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;
typedef long long ll;

int main(){
   int a,b;
   cin >> a >> b;
   int sa =  b-a;
   int c = sa;
   for(int i=0;i<c;i++) sa += i;
   cout << sa - b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n, year, month, day, i, j, ans[100]={0};
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf(" %d %d %d",&year, &month, &day);
    for(j=month; j<=10; j++) { //初めの年
      if(j==month) {    //初めの月
	if(year%3==0||j%2==1){
	  ans[i]+=21-day;
	}
	else{
	  ans[i]+=20-day;
	}
      }
      else{
	if(year%3==0||j%2==1){
	  ans[i]+=20;
	}
	else{
	  ans[i]+=19;
	}
      }
    }

    for(j=year+1; j<1000; j++){
      if(j%3==0){
	ans[i]+=20*10;
      }
      else{
	ans[i]+=19*5+20*5;
      }
    }
  }
  for(i=0; i<n; i++){
    printf("%d\n", ans[i]);
  }



  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string q,w,e; cin >> q >> w >> e;
  cout << q[0] << w[0] << e[0];
}

Measured memory_bytes: 3624
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];
ll dp[100010] = {};

void dfs(ll cur, ll par){
    ll cnt = 0;
    ll sum = 0;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs(e, cur);
        if(dp[e] > 0) cnt++;
        sum += dp[e];
    }

    ll sz = tree[cur].size();
    if(par != -1) sz--;
    if(cnt >= sz-1){
        dp[cur] = sum; 
    }else{
        dp[cur] = sum + (sz-1 - cnt);
    }


}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[100010], b[100010];
    rep(i,0,N-1){
        cin >> a[i] >> b[i];
        tree[a[i]].push_back(b[i]);
        tree[b[i]].push_back(a[i]);
    }

    ll par = -1;
    rep(i,0,N){
        if(tree[i].size() >= 3){
            par = i;
            break;
        }
    }
    if(par == -1){
        print(1);
        return 0;
    }

    dfs(par, -1);
    print(dp[par]);
    

}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
int n;
int x[107], y[107], h[107];
int H;

int main() {
	scanf("%d", &n);
	int dd;
	for(int i = 1; i <= n; i++) {
		scanf("%d %d %d", &x[i], &y[i], &h[i]);
		if(h[i]) dd = i;
	}
	for(int i = 0; i <= 100; i++) {
		for(int j = 0; j <= 100; j++) {
			H = h[dd] + abs(x[dd] - i) + abs(y[dd] - j);
			for(int k = 1; k <= n; k++) {
				int t1 = abs(x[k] - i), t2 = abs(y[k] - j);
				if(h[k] != max(H - t1 - t2, 0)) break;
				if(k == n) {
					printf("%d %d %d\n", i, j, H);
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 384
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

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

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

// const int N = 1e5 + 1;
// vector<int > graph[N];

// void bfs(int n, int s, int ans[]) {
//     ans[s] = 1;
//     queue<int> q;
//     q.push(s);
//     while(!q.empty()) {
//         int v = q.front();
//         q.pop();
//         // cout<<v<<" source\n";
//         for(int b: graph[v]) {
//             if(ans[b] == 0) {
//                 ans[b] = 1;
//                 q.push(b);
//             }
//         }
//     }
// }


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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n,m;
    cin>>n>>m;
    int start = 1,end = n;
    for(int i=0;i<m;++i) {
        int a,b;
        cin>>a>>b;
        start = max(a,start);
        end = min(end, b);
    }
    // cout<<start<<" "<<end<<"\n";
    if(start > end) cout<<"0";
    else cout<<end - start + 1;

    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (H, W) = nextIntList()
    val graph = Graph(10)
    for (i in 0..9) {
        val costs = nextIntList()
        costs.forEachIndexed { j, c -> graph.addEdge(j, i, c) }
    }
    val distances = graph.dijkstra(1)
    var ans = 0L
    repeat(H) {
        nextIntList().forEach { a -> if (a != -1) ans += distances[a] }
    }
    println(ans)
}

class Graph(v: Int) {
    private val vec = Array(v + 1) { mutableListOf<E>() }

    fun addEdge(a: Int, b: Int, c: Int = 0) {
        vec[a].add(E(b, c))
    }

    // 負のコストがない場合の起点から全頂点への移動最小コスト
    fun dijkstra(start: Int): IntArray {
        val que = PriorityQueue<E>(11, Comparator { o1, o2 -> o1.c - o2.c })
        que.add(E(start, 0))
        val d = IntArray(vec.size) { 1000000 }
        d[start] = 0
        while (que.isNotEmpty()) {
            val cur = que.poll()
            if (d[cur.v] < cur.c) continue
            for (next in vec[cur.v]) {
                if (d[next.v] > d[cur.v] + next.c) {
                    d[next.v] = d[cur.v] + next.c
                    que.add(next)
                }
            }
        }
        return d
    }

    data class E(val v: Int, val c: Int)
}

Measured memory_bytes: 42116
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
ll mod=1e18;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}
long modInverse(long a) {return powmod(a, mod-2);}
ll my_rand(){ll a=rand();ll b=rand();return (a*RAND_MAX+1)+b;}
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()


int main(){
    ios::sync_with_stdio(false);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0);
    cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0){
        c-=b;
        if(c<=0)break;
        a-=d;
    }
    if(a>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
    }


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fstream>
#include <chrono>
#include <iomanip>
#include <cstdarg>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <sstream>
#include <numeric>
#include <iterator>
#include <utility>
#include <stack>
#include <functional>
#include <deque>
#include <complex>
#include <bitset>
#include <list>
#include <array>
#include <regex>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
#include <typeinfo>
#include <bits/stdc++.h>
using namespace std;
void solve() {
	int x;
	cin >> x;
	if (x == 1) cout << 0;
	else cout << 1;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3532
// Problem : E - Dist Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli n,p,b,i;
	cin>>n;
	lli a[n],c[n];
	for(i=0;i<n;i++){
		cin>>p>>b;
		a[i]=p+b;
		c[i]=p-b;
	}
	sort(a,a+n);
	sort(c,c+n);
	cout<<max(a[n-1]-a[0],c[n-1]-c[0]);
	return 0;
}

Measured memory_bytes: 6732
using System;

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b; 
            string[] str = Console.ReadLine().Split(' '); 
            a = int.Parse(str[0]);
            b = int.Parse(str[1]); 
            Console.WriteLine( a * b + " " + (2*(a + b)));
         }
     }
    
}

Measured memory_bytes: 9028
#include<iostream>

using namespace std;

int main() {
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans1 = (double)w * (double)h / 2.0;
	if (x+x == w  &&y+y == h ) {
		printf("%.10f %d\n", ans1, 1);
	}
	else {
		printf("%.10f %d\n", ans1, 0);
	}

	return 0;
}

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

//for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//abbreviati
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

//constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

//adjacency list
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,d; cin >> n >> d;
    vector<ll> x(n);
    vector<ll> y(n);
    ll cnt=0;
    rep(i,0,n){
        cin >> x[i] >> y[i];
        if(sqrt(x[i]*x[i]+y[i]*y[i])<=d){
            cnt++;
        }
    }

    
    cout << cnt ENDL;
    
    
    return 0;
}

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

int main(){
  
  int N;
  double A,sum = 0;
  
  cin >> N;
  for (int i = 0; i < N; i++){
    
    cin >> A;
    sum += 1/A;
    }
  cout << 1/sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K, S;
    cin >> N >> K;
    S = 1;
    for (int i = 0; i < N; i++){
        if (S*2 > S + K){
            S += K;
        }
        else {
            S *= 2;
        }
    }
    cout << S << endl;
    
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, t; cin >> n >> t;
  vi a(n);
  REP(i, n) {
    cin >> a[i];
  }

  int cnt = 1;
  int min = a[0];
  int diff = 0;
  bool upd = false;
  FOR(i, 1, n) {
    if(upd && a[i] - min == diff) {
      cnt++;
      upd = false;
    }
    if(a[i] < min) {
      min = a[i];
      upd = true;
    }
    if(a[i] - min > diff) {
      cnt = 1;
      diff = a[i] - min;
      upd = false;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main() {
  string s;
  cin >> s;
  int ans = 0;
  int d[500005] = {};
  rep(i, (int)s.size()) {
    if (s[i] == 'B') d[i] = 1;
  }
  rep(i, (int)s.size()) { d[i + 1] += d[i]; }
  rep(i, (int)s.size()) {
    if (s[i] == 'W') {
      ans += d[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4484
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	n <- readLn :: IO Int
	as <- readIntToList <$> BS.getLine
	let allXor = List.foldl' Bits.xor 0 as
	let ans = map (Bits.xor allXor) as
	mapM_ (putStr . (++ " ") . show) ans

Measured memory_bytes: 19908
#include <stdio.h>

int main()
{
	char S[100001];
	scanf("%s", S);
	
	int i, l;
	for (l = 0; S[l] != '\0'; l++);
	for (i = l; i > 0; ) {
		if (i >= 5 && S[i-5] == 'd' && S[i-4] == 'r' && S[i-3] == 'e' && S[i-2] == 'a' && S[i-1] == 'm') i -= 5;
		else if (i >= 7 && S[i-7] == 'd' && S[i-6] == 'r' && S[i-5] == 'e' && S[i-4] == 'a' && S[i-3] == 'm' && S[i-2] == 'e' && S[i-1] == 'r') i -= 7;
		else if (i >= 5 && S[i-5] == 'e' && S[i-4] == 'r' && S[i-3] == 'a' && S[i-2] == 's' && S[i-1] == 'e') i -= 5;
		else if (i >= 6 && S[i-6] == 'e' && S[i-5] == 'r' && S[i-4] == 'a' && S[i-3] == 's' && S[i-2] == 'e' && S[i-1] == 'r') i -= 6;
		else break;
	}
	
	if (i == 0) printf("YES\n");
	else printf("NO\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R,G,B,N;cin>>R>>G>>B>>N;
  ll ans=0;
  repeat(r,N/R+1){
    repeat(g,N/G+1){
      int b =  N-R*r-G*g;
      if(0<=b&&b%B==0)ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int N, K;
vector<int> V(55);
priority_queue<int, vector<int>, greater<int>> pq;  //val's queue
int res = 0;

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> V[i];

    for(int i = 0; i <= min(N, K); i++){    //操作A,Bを累計i回行うことにする
        for(int j = 0; j <= i; j++){  //操作Aをj回行う
            for(int a = 0; a < j; a++) pq.push(V[a]); //左からj個
            for(int b = 0; b < i-j; b++) pq.push(V[N - 1 - b]); //右からi-j個
            int pop_n = 0;
            for(int k = 0; k < K - i; k++){
                if(pq.empty()) break;
                if(pq.top() >= 0) break;
                pq.pop();
            }
            int sum = 0, val;
            while(!pq.empty()){ val = pq.top(); sum += val; pq.pop(); }
            res = max(res, sum);
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int     main(void)
{
    int h, w;
    int i, j;
    
    while (scanf("%d%d", &h, &w) == 2 && (h|w) != 0)
    {
        i = 0;
        while (i < h)
        {
            j = 0;
            while (j < w)
            {
                if ((i + j) % 2 == 0)
                    printf("#");
                else
                    printf(".");
                j++;
            }
            printf("\n");
            i++;
        }
        printf("\n");
    }
    return (0);
}


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

int main(){
	int T;
	cin >> T;
	while(T--){
		vector<int> v(3);
		cin >> v[0] >> v[1] >> v[2];
		sort(v.begin(),v.end());
		if( v[0]*v[0]+v[1]*v[1]==v[2]*v[2])
				cout << "YES" << endl;
		else cout << "NO" << endl;
		
	}
}

Measured memory_bytes: 1204
#include<iostream>

using namespace std;

int main(){

    int N;
    int A,B,C,D;
    int sc[101]={0};
    int rank[101];
    int n;
    int max,mi;
    int c;

    cin>>N;
    for(int i=0;i<N*(N-1)/2;i++){
        cin>>A>>B>>C>>D;
        if(C>D) sc[A]+=3;
        if(C==D) sc[A]++,sc[B]++;
        if(C<D) sc[B]+=3;
    }

    n=0;
    while(n<N){
        max=sc[1],mi=1;
        for(int i=2;i<=N;i++){
            if(sc[i]>max){
                max=sc[i];
                mi=i;
            }
        }
        c=0;
        for(int i=1;i<=N;i++){
            if(sc[i]==max){
                sc[i]=-1;
                c++;
                rank[i]=n+1;
            }
        }
        n+=c;
    }

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

}

Measured memory_bytes: 1160
s1 = input()
n = len(s1)
s2 = s1[:(n-1)//2]
s3 = s1[(n+2)//2:]

def St_Pal(str): return 1 if str == str[::-1] else 0

ans = 0
ans += St_Pal(s1)
ans += St_Pal(s2)
ans += St_Pal(s3)

if ans == 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll N; cin >> N;
	vector<ll> X(N), Y(N);
	rep(i, N) {
		cin >> X[i];
		Y[i] = X[i];
	}

	sort(ALL(Y));
	ll l = Y[N / 2 - 1];

	rep(i, N) {
		if (X[i] <= l)cout << Y[N / 2] << endl;
		else cout << Y[N / 2 - 1] << endl;
	}
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

struct Task {
    lli A;
    lli B;
    bool operator<(const Task &another) const {
        return B < another.B;
    };
};


int main() {

    int N;
    cin >> N;

    vector<Task> tasks(N);
    for (int i = 0; i < N; ++i) {
        lli a, b;
        cin >> a >> b;
        Task task;
        task.A = a;
        task.B = b;
        tasks[i] = task;
    }

    sort(tasks.begin(), tasks.end());

    lli time = 0;
    for (int i = 0; i < N; ++i) {
        Task task = tasks[i];
        time += task.A;
        if (time <= task.B) {
            continue;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3328
n = int(input())
d = {c: 0 for c in 'MARCH'}
for i in range(n):
    s = input()
    c = s[0]
    if c in d:
        d[c] += 1
v = [d[c] for c in d]

import itertools
ans = 0
for i, j, k in itertools.combinations(range(5), 3):
    ans += v[i] * v[j] * v[k]
print(ans)


Measured memory_bytes: 45380
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    string ans ="No";
    if(a==b){
        if(a!=c){
            ans ="Yes";
        }
    } else if(b==c && a!=b){
            ans ="Yes";
    } else if(c==a && c!=b){
            ans ="Yes";
    }
    cout<<ans;
}

Measured memory_bytes: 256