akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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;
}

int main() {
    ll a,b,k;
    cin>>a>>b>>k;
    if(a<k){
        cout<<0<<" "<<max((ll)0, b-(k-a))<<endl;
    }
    else{
        cout<<a-k<<" "<<b<<endl;
    }





    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int c[3][3];
	int a[3];
	int b[3];
	bool info = true;

	rep(i, 3) rep(j, 3) cin >> c[i][j];

	a[0] = 0;
	a[1] = c[1][0] - c[0][0];
	a[2] = c[2][0] - c[0][0];
	b[0] = c[0][0];
	b[1] = c[0][1];
	b[2] = c[0][2];

	rep(i, 3) {
		rep(j, 3) {
			if (c[i][j] != a[i] + b[j]) info = false;
		}
	}

	cout << (info ? "Yes" : "No") << endl;

	return 0;
}

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

#ifdef HELTHAZAR
#define derr if (true) cerr
#else
#define derr if (false) cerr
#endif

#define rep(i, from, to) for (int i = from; i < int(to); i++)
#define repn(i, from, to) for (int i = from; i <= int(to); i++)
#define repr(i, from, to) for (int i = int(from); i >= to; i--)
#define trav(a, x) for (auto& a: x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<ll> vll;

const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int MAXN = 1e5 + 1;

bool check(vector<string> &b, int n) {
	rep(i, 0, n) rep(j, 0, n) if (b[i][j] != b[j][i]) return false;
	return true;
}

void solve() {
	int n;
	cin >> n;
	vector<string> v(n);
	rep(i, 0, n) {
		cin >> v[i];
		v[i] += v[i];
	}
	rep(i, n, 2 * n) v.push_back(v[i - n]);
	int res = 0;
	rep(a, 0, n) {
		vector<string> s(n);
		rep(i, 0, n) rep(j, 0, n) s[i].pb(v[a + i][j]);
		if (check(s, n)) res += n - a;
	}
	rep(b, 1, n) {
		vector<string> s(n);
		rep(i, 0, n) rep(j, 0, n) s[i].pb(v[i][b + j]);
		if (check(s, n)) res += n - b;
	}
	cout << res;
}

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

	solve();
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int const MAX = 500003;
int heap[MAX];
int h;

int parent(int i) {
  return i / 2;
}
int left(int i) {
  return 2 * i;
}
int right(int i) {
  return 2*i + 1;
}

void maxHeapify(int i) {
  int l = left(i);
  int r = right(i);
  int largest;
  if (l <= h && heap[l] > heap[i]) largest = l;
  else largest = i;
  if (r <= h && heap[r] > heap[largest]) largest = r;

  if (largest != i) {
    int tmp = heap[i];
    heap[i] = heap[largest];
    heap[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap() {
  for (int i=h/2; i>=1; i--) {
    maxHeapify(i);
  }
}

int main() {
  cin >> h;
  rep(i,h) cin >> heap[i+1];

  buildMaxHeap();

  rep(i,h) cout << ' ' << heap[i+1];
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 5040
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_9-D

String - Transformation
Time Limit : 1 sec, Memory Limit : 65536 KB
???????????????

????????? str

?????????????????????????????????????????????????????????????????°???????????????????????????????????????????????\?????????????????????????????§??????

    print a b: str

??? a ??????????????? b ??????????????§??????????????????
reverse a b: str
??? a ??????????????? b ??????????????§?????????????????????
replace a b p: str

    ??? a ??????????????? b ??????????????§??? p ?????????????????????

????????§??????????????? str

????????????????????? 0 ???????????¨????????????
Input

1 ?????????????????? str
????????????????????????str ?????±?°????????????????????????????2 ????????????????????° q ?????????????????????????¶???? q

??????????????????????¨??????¢?????§?????????????????????
Output

??? print ???????????¨???????????????????????????????????????????????????
Constraints

    1???str????????????1000

1???q???100
0???a???b<str?????????
replace ????????§??? b???a+1=p?????????

Sample Input 1

abcde
3
replace 1 3 xyz
reverse 0 2
print 1 4

Sample Output 1

xaze

Sample Input 2

xyz
3
print 0 2
replace 0 2 abc
print 0 2

Sample Output 2

xyz
abc

=end

class Str_manipulate
  def initialize(s)
    @str = s
    #puts "str=" + @str
  end

  def print(a,b)
    puts @str.slice(a..b)
    #puts "str=" + @str
    @str
  end

  def reverse(a,b)
    len = @str.length
    if a-1>=0 then
      zen = @str.slice(0..(a-1))
    else
      zen = ""
    end
    naka= @str.slice(a..b).reverse
    if b+1 <= len-1 then
      kou = @str.slice((b+1)..(len-1))
    else
      kou=""
    end
    @str =  zen + naka + kou
    #puts "str=" + @str
    @str
  end

  def replace(a,b,p)
    @str[a..b] = p
    #puts "str=" + @str
    @str
  end
end

class Main
  def initialize()
    #fh = open("IPT1_9_D.txt")
    fh = STDIN
    s = fh.gets.chomp
    sm = Str_manipulate.new(s)
    n = fh.gets.chomp.to_i
    (1..n).each {|x|
      fl = fh.gets.chomp.split
      if fl[0] == "print" then
        sm.print(fl[1].to_i,fl[2].to_i)
      elsif fl[0] == "reverse" then
        sm.reverse(fl[1].to_i,fl[2].to_i)
      elsif fl[0] == "replace" then
        sm.replace(fl[1].to_i,fl[2].to_i,fl[3])
      end
    }
  end
end

if $0 == __FILE__ then
  Main.new
end

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec h = ivec(n);
    int ma = 0;
    int cnt = 0;
    rep (i, n - 1) {
        if (h[i] >= h[i + 1]) {
            cnt++;
        } else {
            chmax(ma, cnt);
            cnt = 0;
        }
    }
    chmax(ma, cnt);
    print(ma);

    return 0;
}


Measured memory_bytes: 1024
class UnionFindNode:
    def __init__(self, group_id, parent=None, value=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.value = value
        self.rank_ = 1
        self.member_num_ = 1
        self.enum = 0

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        root = self.root()
        return root.group_id_

    def rank(self):
        root = self.root()
        return root.rank_

    def unite(self, unite_node):
        root = self.root()
        unite_root = unite_node.root()
        if not self.check(unite_node):
            return False
        if root.group_id_ != unite_root.group_id_:
            if root.rank() > unite_root.rank():
                unite_root.parent_ = root
                root.rank_ = max(root.rank_, unite_root.rank_ + 1)
                root.member_num_ = root.member_num_ + unite_root.member_num_
                root.enum = root.enum + unite_root.enum + 1
            else:
                root.parent_ = unite_root
                unite_root.rank_ = max(root.rank_ + 1, unite_root.rank_)
                unite_root.member_num_ = root.member_num_ + unite_root.member_num_
                unite_root.enum = root.enum + unite_root.enum + 1
        else:
            root.enum += 1
        return True


    def check(self, unite_node):
        root = self.root()
        unite_root = unite_node.root()
        if root.group_id_ == unite_root.group_id_:
            if root.enum < root.member_num_:
                return True
        else:
            if root.member_num_ + unite_root.member_num_ > root.enum + unite_root.enum:
                return True
        return False


if __name__ == "__main__":
    N,H,W=[int(i) for i in input().strip().split(" ")]
    node_list = [UnionFindNode(i) for i in range(H+W)]
    import sys
    es = []
    for line in sys.stdin:
        es.append(tuple(int(i) for i in line.strip().split(" ")))
    es = sorted(es, key=lambda x:x[2])
    r = 0
    for e in es[::-1]:
        if node_list[e[0]-1].unite(node_list[e[1]+H-1]):
            r += e[2]
    print(r)



Measured memory_bytes: 103872
# ABC115D - Christmas
def burger(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    if x <= 1 + B[n - 1]:
        return burger(n - 1, x - 1)
    return burger(n - 1, x - 2 - B[n - 1]) + P[n - 1] + 1


def main():
    global B, P
    N, X = tuple(map(int, input().split()))
    B, P = [1], [1]  # burger, patty
    for i in range(N):
        B += [B[i] * 2 + 3]
        P += [P[i] * 2 + 1]
    ans = burger(N, X)
    print(ans)


if __name__ == "__main__":
    main()

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

int main(){
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>

using namespace std;

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

    char old, cur;
    cin >> old;
    int cnt = 1;

    for(int i=1; i<N; i++) {
       cin >> cur;
       if (cur != old) {
           cnt++;
       }
       old = cur;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import collections

N = int(input())
a = list(map(int,input().split()))
Q = int(input())
ans = sum(a)
a = collections.Counter(a)

for i in range(Q):
    b,c = map(int,input().split())
    ans += (c-b)*a[b]
    a[c] += a[b]
    a[b] = 0
    print(ans)

Measured memory_bytes: 23440
def plus(x):
    yen = 0
    if x < 4:
        yen = yen + 100000
    if x < 3:
        yen = yen + 100000
    if x < 2:
        yen = yen + 100000
    return yen

x, y = map(int, input().split())

res = plus(x) + plus(y)

if x == 1 and y == 1:
    res = res + 400000

print(res)

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	int ans[200005];
	for(int i=0;i<=n;i++){
		ans[i] = 0;
	}
	for(int i=2;i<=n;i++){
		int a; cin >> a;
		ans[a]++;
	}
	for(int i=1;i<=n;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4400
x = int(input())
ans = 1
power = 1
for b in range(2,x+1):
    p = 2
    if x == 1:
        break
    while True:
        power = b ** p
        if x < power:
            break
        else:
            ans = max(ans,power)
            p += 1
print(ans)

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

#define MX_N 100000
#define LL long long

#define PII pair<int,int>
#define st first
#define nd second

int n, M;
vector<int> graph[MX_N+5];

int parent[MX_N+5];
vector<int> tab[MX_N+5];
vector<LL> pref[MX_N+5], suf[MX_N+5];// veretex's v childs
int locat[MX_N+5];

LL dp1[MX_N+5], dp2[MX_N+5];

void dfs( int v, int p )
{
  dp1[v]=1;
  parent[v]=p;

  for( auto &u : graph[v] )
  {
    if( u==p ) continue;
    dfs(u,v);

    dp1[v]=( dp1[v]*(dp1[u]+1) )%M;
    tab[v].push_back(u);
    locat[u]=tab[v].size();
  }
}

void Count( )
{
  for( int i=1; i<=n; i++ )
  {
    int sz=tab[i].size();

    pref[i].push_back(1);
    for( int j=0; j<sz; j++ )
      pref[i].push_back( (pref[i][j]*( dp1[ tab[i][j] ]+1) )%M );

    suf[i].push_back(1);
    for( int j=sz-1; j>=0; j-- )
      suf[i].push_back( (suf[i][sz-1-j]*( dp1[ tab[i][j] ]+1 ) )%M );
  }
}

queue<PII> kol;
void bfs( int v, int p )
{
  kol.push( {v, p} );
  dp2[v]=1;

  while( !kol.empty() )
  {
    PII u=kol.front();
    kol.pop();

    int sz2=tab[u.st].size();
    for( auto &s : graph[u.st] )
    {
      if( s==u.nd ) continue;
      kol.push( {s,u.st} );

      dp2[s]=( ( ((dp2[u.st]*pref[u.st][ locat[s] -1 ])%M)*suf[u.st][ sz2-locat[s] ] )%M +1 )%M;
      //cout<<"dp2 "<<s<<" = "<<dp2[u.st]<<" * "<<pref[u.st][ locat[s] -1 ]<<" * "<<suf[u.st][sz2-locat[s] ]<<" \n";

    }
  }

}

int main( )
{
  cin>>n>>M;
  for( int i=1; i<n; i++ )
  {
    int a, b; cin>>a>>b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  dfs(1,0);

  // cout<<"dp1 :\n";
  // for( int i=1; i<=n; i++ )
  //   cout<<dp1[i]<<" ";
  //
  // cout<<"\n";

  Count( );

  // for( int i=1; i<=n; i++ )
  // {
  //   cout<<"locat : \n";
  //   for( int j=0; j<tab[i].size(); j++ )
  //     cout<<locat[ tab[i][j] ]<<" ";
  //
  //   cout<<"\n";
  //
  //   cout<<"pref dla "<<i<<" \n";
  //   for( int j=0; j<pref[i].size(); j++ )
  //     cout<<pref[i][j]<<" ";
  //
  //   cout<<"\n";
  //   cout<<"suf dla "<<i<<"\n";
  //   for( int j=0; j<suf[i].size(); j++ )
  //     cout<<suf[i][j]<<" ";
  //   cout<<"\n \n";
  // }

  bfs(1,0);

  // cout<<"dp2 :\n";
  // for( int i=1; i<=n; i++ )
  //   cout<<dp2[i]<<" ";
  //
  // cout<<"\n";

  for( int i=1; i<=n; i++ )
    cout<<( dp1[i]*dp2[i] )%M<<"\n";
}


Measured memory_bytes: 29696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int easy,normal,hard;
  easy=0;
  normal=0;
  hard=0;
  int tmp;
  for(int i=0;i<N;++i){
    cin>>tmp;
    if(tmp<=A){
      easy+=1;
    }
    else if(tmp>A && tmp<=B){
      normal+=1;
    }
    else if(tmp>B){
      hard+=1;
    }
  }
  cout<<min(min(easy,normal),hard);
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define VI vector<int>
#define VII vector<pair<int, int>>
#define PII pair<int, int>
#define MP make_pair
// #define log(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define log(fmt, ...)
// #define check(...) assert(##__VA_ARGS__)
#define check(...)

int gcd(int a, int b) {
    if (a < b) {
        swap(a, b);
    }
    while (b != 0) {
        int tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

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

    int k;
    cin >> k;
    ll ans = 0;
    rep(a, 1, k + 1) {
        rep(b, 1, k + 1) {
            int ab = gcd(a, b);
            rep(c, 1, k + 1) {
                int abc = gcd(ab, c);
                ans += abc;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3188
h, w = map(int, input().split())
s = [str(input()) for _ in range(h)]
data = [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            for x in range(-1, 2):
                for y in range(-1, 2):
                    if 0 <= i + x < h and 0 <= j + y < w:
                        if s[i+x][j+y] == '#':
                            data[i][j] += 1
        else:
            data[i][j] = '#'

for i in range(h):
    for j in range(w):
        if data[i][j] != '#':
            data[i][j] = str(data[i][j])

for i in range(h):
    print((''.join(data[i])))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 20000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 1000005

ll get(ll x)
{
    if(x<600)return 8;
    if(x<800)return 7;
    if(x<1000)return 6;
    if(x<1200)return 5;
    if(x<1400)return 4;
    if(x<1600)return 3;
    if(x<1800)return 2;
    if(x<2000)return 1;

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n,k,i,j,x,y,z;
    while(cin>>x>>y>>z)
    {
        cin>>k;
        for(i=1;i<=k;i++)
        {
            if(y<=x)y*=2;
            else if(z<=y)z*=2;
           // cout<<i<<" "<<x<<" "<<y<<" "<<z<<endl;
        }
        //cout<<x<<" "<<y<<" "<<z<<endl;
        if(y>x&&z>y)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int p[110],c[110];
int main()
{
    ios::sync_with_stdio(false);
    int D,G;
    while(cin>>D>>G)
    {
        for(int i=0;i<D;i++)
            cin>>p[i]>>c[i];
        int res=INT_MAX;
        for(int i=0;i<(1<<D);i++)
        {
            int s=0,cnt=0,pos=-1;
            for(int j=0;j<D;j++)
                if(i&(1<<j))
                {
                    s+=p[j]*100*(j+1)+c[j];
                    cnt+=p[j];
                }
                else
                    pos=j;
            if(s<G)
            {
                int x=(G-s+100*pos+99)/(100*pos+100);
                if(x>=p[pos])
                    continue;
                cnt+=x;
            }
            res=min(res,cnt);
        }
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 764
s = input()
t = input()

def match(s1, t):
    return all(a in (b, '?') for a, b in zip(s1, t))

substrings = [s[i:i+len(t)] for i in range(len(s)-len(t)+1)]
res = 'UNRESTORABLE'
for ss in reversed(substrings):
    if match(ss, t):
        left, _, right = s.rpartition(ss)
        res = left + t + right
        res = res.replace('?', 'a')
        break
print(res)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <bitset>
#include <vector>
using namespace std;
 
const int N = 1e5;
char s[N];

int main() {
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif
    int k;
    scanf("%d", &k);
    for (int i = 0; i < k; ++i) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vll H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  vector<bool> flag(N, true);
  for(int i = 0; i < M; i++){
    ll A, B;
    cin >> A >> B;
    A--; B--;
    if(H.at(A) > H.at(B)) flag.at(B) = false;
    else if(H.at(A) < H.at(B)) flag.at(A) = false;
    else{
      flag.at(A) = false;
      flag.at(B) = false;
    }
  }
  ll counter = 0;
  for(int i = 0; i < N; i++){
    if(flag.at(i)) counter++;
  }
  cout << counter << endl;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fs first
#define sc second
#define mk make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9+1;
const ll LINF = 1e17;
const int MAKS = 1010;
int n, x, day, num[MAKS][MAKS], cnt, in[MAKS*MAKS];
pii pos[MAKS*MAKS];
vector < int > lst, lst2, adj[MAKS*MAKS];
bool boo[MAKS*MAKS];
int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = i+1; j <= n; j++){
			num[i][j] = cnt;
			pos[cnt] = mk(i, j);
			cnt++;
		}
	}
	int last = -1;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < n-1; j++){
			cin >> x;
			int a = min(i, x);
			int b = max(i, x);
			int p = num[a][b];
			if (j!=0){
				adj[last].pb(p);
				in[p]++;
			}
			last = p;
		}
	}
	for (int i = 0; i < cnt; i++){
		if (in[i]==0) lst.pb(i);
	}
	while(!lst.empty()){
		day++;
		for (int now : lst){
//			printf("%d %d %d\n", pos[now].fs, pos[now].sc, now);
			boo[now] = true;
			
			for (int next : adj[now]){
				in[next]--;
				if (in[next]==0) lst2.pb(next);
			}
		}
		lst.clear();
		for (int now : lst2) lst.pb(now);
		lst2.clear();
	}
	for (int i = 0; i < cnt; i++){
		if (!boo[i]){
//			printf("%d\n", i);
			printf("-1");return 0;
		}
	}
	cout << day;
	
}

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

int N;
ll D,A[202020];
vector<pair<ll,pair<int,int>>> G;

const int MAX_V=202020;

int par[MAX_V]; //　親
int rnk[MAX_V]; // rank, 木の深さ

void init(){
  for(int i=0;i<MAX_V;i++){
    par[i]=i;
    rnk[i]=0;
  }
}

int find(int x){
  if (par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}


void solve(int l, int r){
  if(r-l<=1) return;
  int mid=(l+r)/2;
  int miL=l;
  for(int i=l+1;i<mid;i++) if(A[i]-D*i<A[miL]-miL*D) miL=i;
  int miR=mid;
  for(int i=mid+1;i<r;i++) if(A[i]+D*i<A[miR]+miR*D) miR=i;
  for(int i=mid;i<r;i++) G.push_back({A[i]+A[miL]+D*(i-miL),{i,miL}});
  for(int i=l;i<mid;i++) G.push_back({A[i]+A[miR]+D*(miR-i),{i,miR}});
  solve(l,mid);
  solve(mid,r);
}

int main(){
  cin>>N>>D;
  rep(i,N) cin>>A[i];
  solve(0,N);
  
  sort(G.begin(),G.end());
  init();
  ll ans=0;
  for(auto& p:G){
    if(!same(p.second.first,p.second.second)){
      ans+=p.first;
      unite(p.second.first,p.second.second);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 69472
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef vector<long long int> VL;
typedef vector<VL> VVL;

int main() {
    string s;
    getline(cin, s);
    for(int i=0; i<s.length(); i++) {
        char c = s[i];
        if('a' <= c && c <= 'z') {
            s[i] = c - 32;
        } else if('A' <= c && c <= 'Z') {
            s[i] = c + 32;
        }
    }
    
    cout << s << endl;
    
    return 0;
}



Measured memory_bytes: 3084
def solve_loop(loop, K):
    S = sum(loop)
    L = len(loop)
    if S < 0:
        acc = 0
        K = min(K, L)
        minL = 1
    elif K//L >= 2:
        acc = S * (K//L - 1)
        K = K - L * (K//L - 1)
        minL = 0
    else:
        acc = 0
        minL = 1

    ans = -10 ** 9 - 1
    for i in range(L):
        #print(loop[i:] + loop[:i], "acc=", acc, "min=", minL, "max=", K)
        tmp = 0
        if minL:
            tmp = loop[i]

        for l in range(minL, K):
            ans = max(tmp, ans)
            tmp += loop[(i+l) % L]
            #print(tmp)
            #print(i, l, tmp)
        ans = max(tmp, ans)

    #print(loop, ans, acc)
    return acc + ans
    if K >= L:
        return max(acc, acc + ans)
    else:
        return ans

def solve():
    N, K = map(int, input().split())
    P = list(map(lambda n: int(n)-1, input().split())) # 0-based index
    C = list(map(int, input().split()))

    flag = [False] * N
    ans = -10**9-1  # worst case is -10**9
    for i in range(N):
        if flag[i]:
            continue
        loop = []
        j = P[i]
        for _ in range(N):
            if flag[j]: # loop end
                break
            flag[j] = True
            loop += [C[j]]
            j = P[j]
        ans = max(ans, solve_loop(loop, K))
    print(ans)

solve()

Measured memory_bytes: 73976
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = sorted([int(input()) for _ in range(n)], reverse=True)
    ans = 0
    center = n // 2

    # See:
    # http://drken1215.hatenablog.com/entry/2018/10/28/222800
    # KeyInsight
    # a > b < c > d < e ...
    # a < b > c < d > e ...の形で決め打ちしてよい
    # それぞれの係数に着目する
    if n % 2 == 0:
        ans += sum(a[:center - 1]) * 2
        ans += a[center - 1]
        ans -= a[center]
        ans -= sum(a[center + 1:]) * 2
    else:
        ans1 = 0
        ans1 += sum(a[:center - 1]) * 2
        ans1 += a[center - 1]
        ans1 += a[center]
        ans1 -= sum(a[center + 1:]) * 2

        ans2 = 0
        ans2 += sum(a[:center]) * 2
        ans2 -= a[center]
        ans2 -= a[center + 1]
        ans2 -= sum(a[center + 2:]) * 2
        ans = max(ans1, ans2)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8288
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
{
	char W[11];
	char T[1001];
	int count=0,length,i;
	
	scanf("%s",W);
	length=strlen(W);
	
	for(i=0;i<length;i++)W[i]=toupper(W[i]);
	while(scanf(" %s",T)!=EOF)
	{
		if(strcmp(T,"END_OF_TEXT")==0)break;
		else
		{
			length=strlen(T);
			for(i=0;i<length;i++)T[i]=toupper(T[i]);
			if(strcmp(T,W)==0)count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

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

using namespace std;

using ll = long long;

constexpr ll inf = 1<<30;
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll f(ll a, ll b){
    if(a > b) swap(a,b);
    if(b%a == 0) return 2ll*(b/a)*a -a; 
    return 2ll * (b/a) * a + f(a,b%a);
}
int main(){
    ll n,x;
    cin>>n>>x;
    ll ret = n + f(x,n-x);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            double n = sc.nextDouble();
            double[] a=new double[11];
            a[1]=n;
            double sum=n;
            for(int i=2;i<=10;i++) {
                if(i%2==0) {
                    a[i]=a[i-1]*2;
                }else {
                    a[i]=a[i-1]/3;
                }
                sum+=a[i];
            }
            System.out.println(sum);
        }
    }
}



Measured memory_bytes: 27824
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int x = Integer.parseInt(sc.next());
      int y = Integer.parseInt(sc.next());

      int ans = 0;

      if(x<4){
        ans += (4-x)*100000;
      }
      if(y<4){
        ans += (4-y)*100000;
      }

      if(x==1&&y==1){
        ans += 400000;
      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 23036
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        a,b=map(int,input().split())
        if a==0 or b==0:
            return 'Zero'
        if a<0 and b>0:
            return 'Zero'
        else:
            if a<0 and b<0:
                if (b-a)%2==0:
                    return 'Negative'
                else:
                    return 'Positive'
            else:
                if a%2==0:
                    return 'Negative'
                else:
                    return 'Positive'
    print(main())
resolve()


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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)

vector<int> h;
vector<int> memo;

int dp(int i){
    if(memo[i]!=-1) return memo[i];
    
    if(i==1) return memo[i]=0;
    
    int ret;
    if(i==2)
        ret = dp(i-1) + abs(h[i]-h[i-1]);
    else
        ret = min(dp(i-1) + abs(h[i]-h[i-1]),
                  dp(i-2) + abs(h[i]-h[i-2]));
    
    return memo[i]=ret;
}

void solve(){
    int N;
    cin >> N;
    h.resize(N);
    rep(i,N) cin >> h[i+1];
    
    memo.assign(N+1, -1);
    
    cout << dp(N) << endl;
}


signed main(){
    cout << fixed << setprecision(18);
//    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int n;
vector<int> ans;

void exec(int k, int l){
  if(k+1 == l) return;

  rep(i,k) ans.pb(1);
  rep(i,l-k-1){
    ans.pb(1);
    ans.pb(n-1);
  }
  rep(i, n-l+1) ans.pb(1);
}

int main(){
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];

  int done = 0;
  while(done<n){
    int key = 0;
    rep(i,n-done) if(v[i] > v[key]) key = i;
    exec(key, n-done);
    rep(i, key, n-done-1) swap(v[i], v[i+1]);
    done++;
    // dbg(v);
    // dbg(ans);
  }

  cout << ans.size() << "\n";
  for(auto i : ans) cout << i << "\n";

  return 0;
}


Measured memory_bytes: 764
tmp = list(map(int, input().split()))

flag = False
if tmp[0] == tmp[1] and tmp[0] != tmp[2]:
    flag = True
elif tmp[1] == tmp[2] and tmp[1] != tmp[0]:
    flag = True
elif tmp[2] == tmp[0] and tmp[2] != tmp[1]:
    flag = True

if flag:
    print("Yes")
else:
    print("No")

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var a = ab[0];
        var b = ab[1];

        var f = a % 2 == 0
            ? (b - a + 1) / 2 % 2 ^ ((b - a + 1) % 2 == 0 ? 0 : b)
            : (b - a) / 2 % 2 ^ a ^ ((b - a) % 2 == 0 ? 0 : b);
        Console.WriteLine(f);
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
    int n,num,ans=1,vec=-1,p=0;
    cin>>n;
    cin>>p;
    for(int i=1;i<n;i++){
        cin>>num;
        if(vec==-1){
            if(num-p!=0) vec=!!(num-p>0);//増加なら1、減少なら0
            p=num;
        }else{
            if((num!=p)&&((num-p>0)!=vec)){
                vec=-1;
                ans++;
            }
            p=num;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,tk[10];
	for(a=0;a<10;a++)
		scanf("%d",&tk[a]);
	for(a=0;a<10;a++){
		for(b=a;b<10;b++){
			if(tk[a]<tk[b]){
				c=tk[b];
				tk[b]=tk[a];
				tk[a]=c;
			}
		}
	}
	for(a=0;a<3;a++)
		printf("%d\n",tk[a]);
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);
  int sum;
  
  if (1<= b && b <= 9){
    sum = a*10 + b;
  } else if (10 <= b && b <= 99){
    sum = a*100 + b;
  } else {
    sum = a*1000 + 100;
  }
  
  
  int mark = 0;
  
  for (int i = 4; i <= 317; i++) {
    if (sum == i*i) {
     mark = 1;
     break;
    }
  }

  
  if(mark == 1){
  printf("Yes");
  } else {
  printf("No");
  }
    
  return 0;
  
}



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

#define mod 1000000007

using namespace std;
using ll = long long; 

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

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

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

	ll ans = 1LL;
	
	for(int i=0; i<N; i++){
		ll T;
		cin >> T;
		ans = lcm(ans, T);
	}
	cout << ans;
	
	return 0;
}

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


int main() {
int N,M;
cin>>N>>M;
vector<vector<long>> s(M);
vector<long> p(M);

for(int i=0;i<M;i++) {
  int k;
  cin>>k;
  for(int j=0;j<k;j++){
    int t;
    cin>>t;
    s[i].push_back(t);
  }
}
for(int i=0;i<M;i++) cin>>p[i];
long ans=0;
//cout<<(1<<10)<<endl;
for(int b=0;b<(1<<N);b++){
  vector<long> o(N);
  for(int i=0;i<N;i++){
    if(b&(1<<i)){
      o[i]=1;
    }
  }
  //cout<<b<<endl;
  int cur=0;
  for(int i=0;i<M;i++){
    int tmp=0;
    for(int j=0;j<s[i].size();j++){
      tmp += o[s[i][j]-1];
      }
      if(tmp%2==p[i]){
        cur++;
      }
    }
if(cur==M) ans++;
}

cout<<ans<<endl;

}


Measured memory_bytes: 256
n = int(input())

def calc(i,j):
    x = i^j
    for k in range(20):
        if((x>>k)&1):
            return k+1

ans = [[0]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        ans[i][j] = calc(i,j)

for i in range(n-1):
    print(' '.join(map(str,ans[i][i+1:])))

Measured memory_bytes: 75880
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] count = new int[N];
        for(int i = 0; i < N; i++) {
            int num = sc.nextInt();
            if(N % 2 == 0 && num % 2 == 0) {
                System.out.println(0);
                return;
            }
            if(N % 2 != 0 && num % 2 != 0) {
                System.out.println(0);
                return;
            }
            count[num]++;
        }
        long answer = 1;
        int mod = 1000_000_007;
        for(int i = 1; i < N; i++) {
            if(count[i] != 2 && count[i] != 0) {
                System.out.println(0);
                return;
            }
            if(count[i] == 2) {
                answer *= 2;
                answer %= mod;
            }
        }
        System.out.println(answer);
    }
}



Measured memory_bytes: 50144
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin>>h>>w;
    ll res=1e18;
    rep(i,h){
        ll nokorih=h-i;
        nokorih/=2;
        chmin(res,max({i*w,nokorih*w,(h-i-nokorih)*w})-min({i*w,nokorih*w,(h-i-nokorih)*w}));
        ll spw=w/2;
        chmin(res,max({i*w,(h-i)*spw,(h-i)*(w-spw)})-min({i*w,(h-i)*spw,(h-i)*(w-spw)}));
    }
    swap(h,w);
    rep(i,h){
        ll nokorih=h-i;
        nokorih/=2;
        chmin(res,max({i*w,nokorih*w,(h-i-nokorih)*w})-min({i*w,nokorih*w,(h-i-nokorih)*w}));
        ll spw=w/2;
        chmin(res,max({i*w,(h-i)*spw,(h-i)*(w-spw)})-min({i*w,(h-i)*spw,(h-i)*(w-spw)}));
    }
    cout<<res<<endl;
}


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(6);
  cout << fixed;
  int x; cin >> x;
  double p = (x / 3.0000);
  cout << p*p*p << '\n';
  return 0;
}


Measured memory_bytes: 256
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kotae=0
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    #print(hako)
    hako=",".join(hako)
    hako=hako.replace(",","")
    #print(hako)
    kotae=eval(hako)
    ans+=kotae
print(ans)

Measured memory_bytes: 3064
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import accumulate
    import bisect
    n, k = map(int, readline().split())
    a = list(map(int, readline().split()))
    s = []
    for i in range(n):
        nx = list(accumulate(a[i:]))
        s.extend(nx)

    s.sort()

    first = len(format(s[-1], "b")) - 1
    cur = 0

    for i in range(first, -1, -1):
        x = cur + 2 ** i
        cnt = 0
        for y in s[::-1]:
            if x & y == x:
                cnt += 1
            if x > y:
                break
        if cnt >= k:
            cur = x

    print(cur)


if __name__ == '__main__':
    main()


Measured memory_bytes: 170100
#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 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()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#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 PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



template< typename Monoid >
struct segTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  segTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid get(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

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

  int n,q;
  cin>>n>>q;
  segTree<int> seg(n,[](int a,int b){return a+b;},0);

  while(q--){
    int t,x,y;
    cin>>t>>x>>y;
    if(t==0) seg.update(x,seg.get(x,x+1)+y);
    else cout<<seg.get(x,y+1)<<endl;
  }


}


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

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

using namespace std;
typedef long long ll;
const int MAXN = 100;

int bubblesort(int *A, int N) {
	int flag = 1;
	int count = 0;
	for (int j = 0; flag;j++) {
		flag = 0;
		for (int i = N - 1; i > j; i--) {
			if (A[i - 1] > A[i]) {
				swap(A[i - 1], A[i]);
				flag = 1;
				count++;
			}
		}
	}
	return count;
}

int main() {
	int  N, count;
	int A[MAXN];
	cin >> N;
	rep(i, N)cin >> A[i];
	count = bubblesort(A, N);
	rep(i, N) {
		if (i != N - 1)cout << A[i] << " ";
		else cout << A[i] << endl;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3088
import sys

n = input()
v = map(int, raw_input().split(' '))
startHere = [0 for i in range(n)]

if sum(v) % ((n * (n + 1)) / 2) != 0:
	print "NO"
	sys.exit()

operations = sum(v) / ((n * (n + 1)) / 2)
operationsFound = 0

for i in range(n):
	diff = v[(i + 1) % n] - v[i]

	if (operations - diff) % n != 0 or operations - diff < 0:
		print "NO"
		sys.exit()
	else:
		operationsFound += (operations - diff) / n

if operationsFound == operations:
	print "YES"
else:
	print "NO"


Measured memory_bytes: 11348
#include <iostream>
using namespace std;
string s;
int main() {
  int wcnt = 0;
  long long ans = 0;
  cin >> s;
    for(int j = 0; j < s.size(); j++) {
      if(s[j] == 'B')
	continue;
      else if(s[j] == 'W') {
	ans += j;
	ans -= wcnt;
	++wcnt;
      }
    }
  cout << ans << endl;
}



Measured memory_bytes: 640
def main():
    from collections import defaultdict
    from collections import deque
    import sys
    input = sys.stdin.readline
    dd = defaultdict(list)
    pq = defaultdict(int)

    N, Q = map(int, input().split())

    for _ in range(N-1):
        a,b = map(int, input().split())
        dd[a].append(b)

    for _ in range(Q):
        p,q = map(int, input().split())
        pq[p] += q
    
    answer = [0]*N
    queue = deque()
    queue.append(1)

    while queue != deque():
        tmp = queue.popleft()
        answer[tmp-1] += pq[tmp]
        for i in dd[tmp]:
            queue.append(i)
            answer[i-1] += answer[tmp-1]
            
    print(*answer)

if __name__ == '__main__':
    main()

Measured memory_bytes: 123000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int maxN = 100010; 
const int INF = 1000000000;
const int MOD = 1000000007;
int n,m;
int main()
{
	scanf("%d %d",&n,&m);
	int ans = (n*m - m - n + 1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256