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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n;
int h[maxN];
ll a[maxN], f[maxN], dp[maxN];

void update(int x, ll d)
{
    for (; x <= n; x += x & -x)
    {
        uax(f[x], d);
    }
}

ll prefix(int x)
{
    ll r = 0;
    for (; x > 0; x &= x - 1)
    {
        uax(r, f[x]);
    }
    return r;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(i, n)
    {
        cin >> h[i];
    }
    for1(i, n)
    {
        cin >> a[i];
    }
    for1(i, n)
    {
        dp[i] = prefix(h[i]) + a[i];
        update(h[i], dp[i]);
    }
    cout << *max_element(dp + 1, dp + n + 1);
    return 0;
}


Measured memory_bytes: 5760
function Main(input) {
  input = input.split("\n");
  var H = parseInt(input[0].split(" ")[0]);
  var W = parseInt(input[0].split(" ")[1]);
  input.shift();
  input.splice(H,input.length);
  var S = input.map(i => i.split(""));
  var edge = new Array();
  var id=0;
  for(var i=0;i<H;i++){
    for(var j=0;j<W;j++){
      if(S[i][j]=="."){
        if(i!=H-1){
          if(S[i+1][j]=="."){
            edge.push([id,id+W]);
          }
        }
        if(j!=W-1){
        if(S[i][j+1]=="."){
            edge.push([id,id+1]);
          }
        }
      }
      id++;
    }
  }
  var ans = 0;
  for(var j=0;j<H*W;j++){
    var queue=new Array();
    var save = new Array(H*W).fill(0);
    var d =0;
    save[j]=1;
    queue.push([j,0]);
    while(queue.length!=0){
      var now =queue[0][0];
      var d =queue[0][1];
      ans = Math.max(ans,d);
      queue.shift();
      var flag=0;
      for(var i=0;i<edge.length;i++){
        if(edge[i][0]==now&&save[edge[i][1]]==0){
          queue.push([edge[i][1],d+1]);
          save[edge[i][1]]=1;
        }
        if(edge[i][1]==now&&save[edge[i][0]]==0){
          queue.push([edge[i][0],d+1]);
          save[edge[i][0]]=1;
        }
      }
    }
  }


  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {
    int n;
    cin >> n;

    map<ll, ll> cnt;
    cnt[0]++;
    int p = 0;
    int ans = 0;
    fori (_, n) {
        int a;
        cin >> a;
        p += a;
        ans += cnt[p];
        cnt[p]++;
    }
    cout << ans;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950



int main() {
	int N; std::cin >> N;
	std::string S; std::cin >> S;
	int max = 0;
	int count = 0;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == 'I') ++count;
		else if (S[i] == 'D') --count;
		if (max < count) max = count;
	}
	std::cout << max << std::endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,M;
  cin >> N >> M;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  sort(rng(A));
  vp B(M);
  vi card(N,0);
  rep(i,M) {
    int b,c;
    cin >> b >> c;
    B[i] = P(b,c);
  }
  sort(rng(B),[](P &l,P &r) {
    return l.second > r.second;
  });
  int f = 0;
  vi D(N);
  rep(i,M) {
    rep(j,B[i].first) {
      if(f+j > N) break;
      D[f+j] = B[i].second;
    }
    if(f + B[i].first-1 > N) break;
    f += B[i].first;
  }
  
  ll ans = 0;
  rep(i,N) {
    ans += max(D[i],A[i]);
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <algorithm>
using namespace std;



int main() {
	int H, W;
	while (true) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == (H - 1) || i == 0) {
					printf("#");
				}
				else if (j == (W - 1) || j == 0) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}




Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(all(A));
    ll ans = 0;
    ll left = 0;
    ll right = N - 1;
    if (N % 2 == 0){
        ans += (A[right] - A[left]);
        for (ll i = 1; i < N / 2; i++){
            ans += (A[right] - A[left + 1]);
            ans += (A[right - 1] - A[left]);
            left++;
            right--;
        }
    }
    else{
        ans += (A[right] - A[left]);
        for (ll i = 1; i < N / 2; i++){
            ans += (A[right] - A[left + 1]);
            ans += (A[right - 1] - A[left]);
            left++;
            right--;
        }
        ans += (max(A[N / 2] - A[N / 2 - 1], A[N / 2 + 1] - A[N / 2]));
    }
    cout << ans << endl;
}

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

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

# all_apples = sorted(p + q + r, key=lambda x: -x)

p_rest = sorted(p + [0])
q_rest = sorted(q + [0])
r_rest = sorted(r + [0])

ans = 0
p_count = 0
q_count = 0
r_count = 0
while (p_count + q_count + r_count) < (X + Y):
    if p_count < X and q_count < Y:
        candidates = [p_rest[-1], q_rest[-1], r_rest[-1]]
    elif p_count < X and q_count == Y:
        candidates = [p_rest[-1], 0, r_rest[-1]]
    elif p_count == X and q_count < Y:
        candidates = [0, q_rest[-1], r_rest[-1]]

    wanna_eat = max(candidates)
    eat_idx = candidates.index(wanna_eat)

    if eat_idx == 0:
        p_count += 1
        ans += p_rest.pop()
    elif eat_idx == 1:
        q_count += 1
        ans += q_rest.pop()
    else:
        r_count += 1
        ans += r_rest.pop()
    # print(candidates, eat_idx, wanna_eat, p_count, q_count, r_count)

print(ans)

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

#define f(i,n) for (int i = 0; i < n; i++)
using pii = pair<int,int>;

int di[] = {0,0,1,-1};
int dj[] = {1,-1,0,0};

int main() {
	int n,m;
	cin >> n >> m;
	int dp[n][m];
	queue<pii> pq;
	f(i,n) {
		string s; cin >> s;
		f(j,m) {
			dp[i][j] = s[j] == '#'?0:n+m+1;
			if (!dp[i][j]) pq.push(pii(i,j));
		}
	}
	auto IN = [&](int i, int j) {
		return i>=0&&i<n&&j>=0&&j<m;
	};
	int ans = 0;
	while (pq.size()) {
		pii pp = pq.front(); pq.pop();
		int i = pp.first, j = pp.second;	
		f(k,4) {
			int ni = i+di[k], nj = j+dj[k];
			if (IN(ni,nj) && dp[ni][nj] == n+m+1) {
				dp[ni][nj] = dp[i][j]+1;
				pq.push(pii(ni,nj));
				ans = max(ans,dp[ni][nj]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

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

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define pow(x) (x)*(x)
#define mid(min, max) ((min + max) / 2)

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

	ll x = a * b;

	if (a < b)
		swap(a, b);

	ll r = a % b;

	while (r) {
		a = b;
		b = r;
		r = a % b;
	}

	out (x / b);


	return 0;
}


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

int main() {
  string s; cin >> s;
  int q; cin >> q;
  int t,f;
  char c;
  string _head, _tail=s;

  REP(i,q) {
    cin >> t;
    if (t==1) { swap(_head,_tail); continue; }
    cin >> f >> c;
    if (f==1) _head.push_back(c);
    else _tail.push_back(c);
  }
  reverse(_head.begin(),_head.end());
  string ans = _head + _tail;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1500
#include<stdio.h>
int main(void){
int a,b,i;
char op;
for(i=1;i>0;i++){
scanf("%d %c %d",&a,&op,&b);
if(op == '+'){
  printf("%d\n",a+b);
}
else if(op == '-'){
  printf("%d\n",a-b);
}
else if(op == '*'){
  printf("%d\n",a*b);
}
else if(op == '/'){
  printf("%d\n",a/b);
}
else if(op == '?') break;
}
  return 0;
}



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

int main(){
  int t[99];
  int r[99];
  int sum=0;
  int i=0;
  double n=0;

  while(scanf("%d,%d",&t[i],&r[i])!=EOF){
    sum=sum+t[i]*r[i];
    n=n+r[i++];
  }
  printf("%d\n%.0f\n",sum,round(n/i));
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
signed main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int ans=1145141919;
	int mon=0;
	rep(0,i,214514){
		if(i%2==1){}
		if(i/2>x){
			if(i/2>y)mon=c*i;
			else mon=b*(y-i/2)+c*i;
		}
		else{
			if(i/2>y)mon=a*(x-i/2)+c*i;
			else mon=a*(x-i/2)+b*(y-i/2)+c*i;
		}
		if(mon<ans)ans=mon;	
	}
	c(ans)
}	

Measured memory_bytes: 256
N = list(map(int, input()))
N.reverse()
l = []

tmp = sum(N)
l.append(tmp)
#print(N)

for i in range(0,len(N)-1):
    if N[i+1] != 0:
        N[i] = 9
        N[i+1] -= 1
    else:
        index_1 = 1000
        for j in range(i+1,len(N)):
            if N[j] != 0:
                index_1 = j
                break
        if index_1 == 1000:
            break
        else:
            N[index_1] -= 1
            for j in range(i,index_1):
                N[j] = 9
        
    #print(N)
    tmp = sum(N)
    l.append(tmp)

    

print(max(l))
    


Measured memory_bytes: 3064
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, M = rl()
A = rl()

import heapq

heap = []
for i, a in enumerate(A):
	heapq.heappush(heap, (-a, i))
nums = [0] * N
for i in range(M):
	a, i = heapq.heappop(heap)
	if abs(a) < 1:
		break
	a = a / 2
	nums[i] += 1
	heapq.heappush(heap, (a, i))
ans = 0
for i in range(N):
	ans += A[i] // pow(2, nums[i])
print(ans)


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> a(n), b(n), c(n-1);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n-1) cin >> c[i];

  int ans = 0;
  rep(i, n) {
    ans += b[a[i]-1];
    if(i < n-1 && a[i+1]-a[i] == 1) ans += c[a[i]-1];
  }
  cout << ans << endl;
}

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

const int MaxN = (int)1e5+7;

int n,a[MaxN],ans; char str[10];


int main()
{
	//freopen("K.in","r",stdin);
	//freopen("K.out","w",stdout);

	int i,j,le,ri,mi,cnt;

	scanf("%d",&n);
	scanf("%s",str+1);
	for(i=1;i<=n;i++)
		scanf("%d",a+i);

	if((str[1]=='A' && (n&1)) || (str[1]=='B' && (!(n&1))))
	{
		ans = 1<<30; j =(n+1)/2;
		for(i=1;i+j<=n;i++)
			ans = min(ans , a[i+j]-a[i]);
	}
	else
	{
		le = 0, ri = a[n];
		while(le<=ri)
		{
			mi = (le+ri)>>1;
			cnt = 1;
			for(i=j=1;i<=n;i++)
				if(a[i]-a[j]>mi) cnt++,j=i;
			//printf("%d %d\n",mi,cnt);
			if(cnt>(n+1)/2) le = mi+1;
			else ri = mi-1;
		}
		ans = le;
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <string.h>

using namespace std;

using ll = long long;

int N;
map<ll, int> m;
int main() {
  scanf("%d", &N);
  ll sum = 0, res = 0;
  m[0] = 1;
  for (int i = 0; i < N; i++) {
    int n;
    scanf("%d", &n);
    sum += n;
    res += m[sum];
    m[sum]++;
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	map<char,int>M1,M2;
	vector<int>t1,t2;
	int l1=s.length();
	int l2=t.length();
	for(int i=0;i<l1;i++)
	{
		M1[s[i]]++;
	}
	for(int i=0;i<l2;i++)
	{
		M2[t[i]]++;
	}
	map<char,int>::iterator it;
	for(it=M1.begin();it!=M1.end();it++)
	{
		t1.push_back(it->second);
	}
	for(it=M2.begin();it!=M2.end();it++)
	{
		t2.push_back(it->second);
	}
	sort(t1.begin(),t1.end());
	sort(t2.begin(),t2.end());
	int sz1 = t1.size();
	int sz2 = t2.size();
	if(sz1!=sz2)
	{
		cout<<"No"<<"\n";
	}
	else
	{
		bool check = true;
		for(int i=0;i<sz1;i++)
		{
			if(t1[i]!=t2[i])
			{
				check = false;
				break;
			}
		}
		if(check)
		{
			cout<<"Yes"<<"\n";
		}
		else
		{
			cout<<"No"<<"\n";
		}
	}
}


Measured memory_bytes: 904
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

R = iIn()
G = iIn()

ans = 2 * G - R
print(ans)

Measured memory_bytes: 62340
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}



int main() {
	string s;
	cin >> s;
	int n = s.size();
	int cnt = 0;
	rep(i, n) {
		int x = s[i] - '0';
		cnt += x;
		cnt %= 9;
	}
	if (cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3720
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	auto ans = 'A';
	foreach (line; stdin.byLine) {
		auto sw = line.split(",").map!(to!char);
		if (sw[0] == ans) ans = sw[1];
		else if (sw[1] == ans) ans = sw[0];
	}
	ans.writeln;
}

Measured memory_bytes: 1076
Devisor = 998244353
N, K = gets.chomp.split(' ').map(&:to_i)
sections = Array.new(K){ gets.chomp.split(' ').map(&:to_i) }

#### 素朴なもらうDP。やはりTLEする。
# dp = Array.new(N + 1) { 0 }
# dp[1] = 1
# 2.upto(N) do |i|
#     sections.each do |section|
#         s, e = section
#         s.upto(e) do |j|
#             dp[i] += dp[i - j] if i - j >= 1
#         end
#     end
# end
# puts dp[N] % Devisor

#### もらうDPに累積和も盛り込んだつもりだったけどこれもTLE。
dp = Array.new(N + 1) { 0 }
dp[1] = 1
cum = Array.new(N + 1) { 0 }
cum[1] = 1
2.upto(N) do |i|
    sections.each do |section|
        s, e = section
        cs = [i - e - 1, 0].max
        ce = [i - s, 0].max
        dp[i] += (cum[ce] - cum[cs]) % Devisor
        # puts "i = #{i}, section = #{section.to_s}"
        # puts "dp : #{dp.to_s}"
    end
    cum[i] = (cum[i - 1] + dp[i]) % Devisor
    # puts "cum : #{cum.to_s}"
end
puts dp[N] % Devisor

Measured memory_bytes: 17564
N = int(input())
A = list(map(int, input().split()))

# count occurences of digits (the number in A represent the boss of this member)
counts = {}
for num in A:
    if num in counts:
        counts[num] += 1
    else:
        counts[num] = 1

# print counts (number of times a member was a boss)
for n in range(1, N + 1):
    if n in counts:
        print(counts[n])
    else:
        print(0)

Measured memory_bytes: 33508
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 1000000000
#define MAX_N 150005
using namespace std;

int dp[10005][10005];

int main(){
    int n,a[101];
    cin>>n;
    rep(i,0,n)cin>>a[i];
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(a[j]<a[j-1]){
                swap(a[j],a[j-1]);
                cnt++;
            }
        }
        
    }
    rep(i,0,n){
        cout<<a[i];
        if(i==n-1)cout<<endl;
        else cout<<" ";
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <sstream>
#include "string.h"
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;
	s[K-1] = s[K-1] - 'A' + 'a';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC139
{
    class A
    {
        static void Main(string[] args)
        {
            int count = 0;
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            if (S[0] == T[0]) count++;
            if (S[1] == T[1]) count++;
            if (S[2] == T[2]) count++;
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long i;
    vector <long > mon;
    vector <long> hero;
    long te;
    scanf("%d",&n);
    for(i=0;i<=n;i++){
        cin>>te;
        mon.push_back(te);
    }
    for(i=0;i<n;i++){
        cin>>te;
        hero.push_back(te);
    }
    long long sum=0;
    long long xxx;
    for(i=0;i<n;i++){
        if(hero[i]>=mon[i]){
            sum=sum+mon[i];
            xxx=hero[i]-mon[i];
            hero.at(i)=xxx;
        }
        else{
            sum=sum+hero[i];
            hero.at(i)=0;
        }
       int x=0;

        if(hero[i]>=mon[i+1]){
            sum=sum+mon[i+1];
            mon.at(i+1)=0;


        }
        else{
            sum=sum+hero[i];
            mon.at(i+1)=mon[i+1]-hero[i];
        }
    }
    cout<<sum<<"\n";


    return 0;
}


Measured memory_bytes: 2548
import java.io.*;
 
class Main{
	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int i=0;
		StringBuilder str = new StringBuilder();
		
		while(true){
			i++;
			String str2 = br.readLine();
			int x = Integer.parseInt(str2);
			if(x == 0){
				break;
			}
			str.append("Case " + i + ": " + x + "\n");
		}
		System.out.print(str);

	}
}

Measured memory_bytes: 27164
#include <iostream>
#include <vector>
#include <chrono>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <random>
#include <map>
#include <string>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

char grid[10][10], cp[10][10];

int main()
{
    fastInp;

    ll h, w, k;
    cin >> h >> w >> k;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) cin >> grid[i][j];
    }
    ll s = h + w;
    ll pw = (1ll << s);

    ll ans = 0;
    for (int i = 0; i < pw; i++) {
        ll cnt = 0;
        
        for (int k = 0; k < h; k++) {
            for (int j = 0; j < w; j++) {
                if (((i >> k) & 1) || ((i >> (h + j)) & 1)) {
                    cp[k][j] = '.';
                }
                else {
                    cp[k][j] = grid[k][j];
                }
                if (cp[k][j] == '#') cnt++;
            }
        }

        if (cnt == k) ans++;
        
    }

    cout << ans;

    return 0;
}

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

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            var Num = int.Parse(Console.ReadLine());
            var End = (int)Math.Sqrt(Num) + 2;
            var Continue = true;

            if (Num == 2) Console.WriteLine(2);
            else if (Num % 2 == 0) Num++;
            if (Num != 2)
            {
                while (Continue)
                {

                    for (int i = 3; i < End; i += 2)
                    {

                        if (Num % i == 0)
                        {
                            Continue = false;
                            break;
                        }

                    }

                    Continue = !Continue;

                    if (Continue)
                    {

                        Num += 2;
                        if (End * End < Num)
                            End++;

                    }

                }

                Console.WriteLine(Num);
            }
        }

    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#define MAX 3

int main() {
    int a[MAX],i,SUM=0;
    for(i=0;i<MAX;i++){
      scanf("%d",&a[i]);
      if(a[i]<=0||a[i]>100){
        printf("No");
        return 0;
      }
      SUM+=a[i];
    }
    if(SUM%2==1){
      printf("No");
      return 0;
    }
    SUM=SUM/2;
    if(SUM==a[0]||SUM==a[1]||SUM==a[2]){
      printf("Yes");
    }else{
      printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=5e5;
int f[N],fst[N],nxt[N],to[N],vis[N],col[N],stack[N],top,root=1,rcnt,ring[N],n,m,mm,tmp[N];
int abs(int x){return x>0?x:-x;}
void dfs(int u,int fa)
{
    f[u]=col[u]?1:-1;
    for(int i=fst[u];i;i=nxt[i])
    {
        int v=to[i];if(v==fa)continue;
        if((u==ring[1]&&v==ring[rcnt])||(u==ring[rcnt]&&v==ring[1]))continue;
        dfs(v,u);f[u]+=f[v];
    }
}
void prework(int u,int c,int fa)
{
    vis[u]=1,col[u]=c;stack[++top]=u;
    for(int i=fst[u];i;i=nxt[i])
    {
        int v=to[i];if(v==fa)continue;
        if(u==ring[rcnt]&&v==ring[1])continue;
        if(vis[v])
        {
            while(stack[top+1]!=v)
                ring[++rcnt]=stack[top--];
            top+=rcnt;
            root=u;
            continue;
        }
        prework(v,c^1,u);
    }
    --top;
}
void ade(int u,int v){to[++mm]=v,nxt[mm]=fst[u],fst[u]=mm;}
int main()
{
    scanf("%d%d",&n,&m);if(n&1){puts("-1");return 0;}
    for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),ade(u,v),ade(v,u);
    prework(1,0,0);
    dfs(root,0);
    if(m==n)
    {
        if(rcnt&1)
        {
            
            if(f[root]&1){puts("-1");return 0;}
            int t=f[root]>>1;
            for(int i=1;i<=rcnt;i++)f[ring[i]]-=t;
        }
        else
        {
            if(f[root]){puts("-1");return 0;}
            for(int i=2;i<=rcnt;i++)tmp[i]=f[ring[i]];
            tmp[1]=0;
            sort(tmp+1,tmp+rcnt+1);
            int t=tmp[rcnt>>1];
            for(int i=1;i<=rcnt;i++)f[ring[i]]-=t;
        }
    }
    else
        if(f[root]){puts("-1");return 0;}
    long long ans=0;
    for(int i=1;i<=n;i++)ans+=abs(f[i]);
    cout<<ans<<endl;
}

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

int main() {
	 
	int h1, h2, k1, k2;
	int a, b, c, d;
	int H_point, K_point;

	cin >> h1 >> h2;
	cin >> k1 >> k2;
	cin >> a >> b >> c >> d;

	/* 浩の点数 */
	if (h1 >= 10) {
		if (h2 >= 20) H_point = (h1 * a) + (h2 * b) + (h1/10) * c + (h1 / 20) *  d;
		else  H_point = (h1 * a) + (h2 * b) + (h1 / 10) * c;
	}
	else if(h2 >= 20) H_point = (h1 * a) + (h2 * b) + (h1 / 20) * d;
	else H_point = (h1 * a) + (h2 * b);

	/* 健次郎の点数 */
	if (k1 >= 10) {
		if (k2 >= 20) K_point = (k1 * a) + (k2 * b) + (k1 / 10) * c + (k1 / 20) * d;
		else  K_point = (k1 * a) + (k2 * b) + (k1 / 10) * c;
	}
	else if (k2 >= 20) K_point = (k1 * a) + (k2 * b) + (k1 / 20) * d;
	else K_point = (k1 * a) + (k2 * b);

	/* 結果の発表 */
	if (H_point < K_point) cout << "kenjiro" << endl;
	else if (H_point > K_point) cout << "hiroshi" << endl;
	else cout << "even" << endl;

	return 0;
}


Measured memory_bytes: 3124
import math
num = int(raw_input())
num_max = 1
root_num = int(math.sqrt(num)+1)
for i in range (2,root_num):
    count = i**2
    if count <= num:
        while True:
            if count > num:
                break
            else:
                count *= i
        count = count//i
    if count > num_max:
        num_max = count
print num_max

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

int main() {
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i++) {
    if(S.at(0) != S.at(i)) {
      cout << "Yes" <<endl;
      break;
    }
    else if(i == S.size() - 1) {
      cout << "No" <<endl;
    }
  }
}


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

std::string try_restore(const std::string& S, const std::string& T, size_t k) {
  std::string res = S;
  for (size_t i = 0; i < T.length(); ++i) {
    if (S[i+k] == '?') {
      res[i+k] = T[i];
    } else if (S[i+k] != T[i]) {
      return "~";
    }
  }
  for (auto& c: res)
    if (c == '?') c = 'a';
  return res;
}

int main() {
  std::string S, T;
  std::cin >> S >> T;

  if (T.length() > S.length())
    return (std::cout << "UNRESTORABLE" << std::endl), 0;

  std::string Z = "~";
  for (size_t i = 0; i+T.length() <= S.length(); ++i)
    Z = std::min(Z, try_restore(S, T, i));

  if (Z == "~") Z = "UNRESTORABLE";
  std::cout << Z << std::endl;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int,x)

parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    S = readline()
    S = S[1:length(S)-1]
    s = 0
    for i in 1:2^(length(S)-1)
        bit=[Int(floor(i/2^j))%2 for j in 0:length(S)-2]
        prev = 0
        
        for j in 1:length(S)-1
            if bit[j]==1
                s+=parseInt(S[prev+1:j])
                prev=j
            end
            
        end
    s+=parseInt(S[prev+1:length(S)])

    end
    println(s)
end

main()


Measured memory_bytes: 110340
program prob43
    implicit none
    character :: s
    read(*,*) s
    if(s == 'S') then
        write(*,*) 'Cloudy'
    else if (s == 'C') then
        write(*,*) "Rainy"  
    else
        write(*,*) "Sunny"
    end if

    stop
contains
end program prob43

Measured memory_bytes: 2620
#include <iostream>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  string s;
  cin >> s;
  int a = INT_MAX;
  int z = 0;
  rep(i, s.size()){
    if(s[i] == 'A'){
      a = min(i, a);
    }
    if(s[i] == 'Z'){
      z = max(i, z);
    }
  }
  cout << z - a + 1 << endl;

  return 0;
}



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

typedef long long ll;

std::vector<ll> ret;

void divisor(ll n){
   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);
      }
   }
   //std::sort(ret.begin(),ret.end());
   return;
}

int main(){
   ll N;
   std::cin >> N;

   ll ans = 0;
   divisor(N);
   for(ll i=0; i<(ll)ret.size(); ++i){
      if(ret[i]<N/ret[i]-1) ans += N/ret[i] - 1;
   }
   std::cout << ans << std::endl;
   return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    string s,t;
    cin >> s >> t;
    int sum=0;
    REP(i,s.size()){
       if(s[i] != t[i]){
           sum++;
       }
    }
    cout << sum << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a.at(i) >> b.at(i);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if(n%2 == 1) {
        int r = b.at(n/2);
        int l = a.at(n/2);
        cout << r-l+1 << endl;
    }
    else {
        int r = b.at(n/2) + b.at(n/2 - 1);
        int l = a.at(n/2) + a.at(n/2 - 1);
        cout << r-l+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4776
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"3 5 4
" => r"YES",

r"2 2 6
" => r"NO",

r"5 3 2
" => r"NO"
}

use std::cmp;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i32,
        b: i32,
        x: i32
    }

    if a + b < x || a > x {
        "NO".to_string()
    } else {
        "YES".to_string()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005

int main(){
  ll a,b,c,ans=0;
  cin >> a >> b >> c;
  FOR(i,a,b+1){
    if(c%(i)==0){ans++;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3092
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
#include <string>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;

	int *a = new int[n];
	int *b = new int[n];
	int *c = new int[m];
	int *d = new int[m];

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

	int min;
	int minNum;
	for (int i=0;i<n; ++i){
		min = abs(a[i]-c[0]) + abs(b[i]-d[0]);
		minNum = 0;
		for (int j=1; j<m; ++j){
			if (min > abs(a[i]-c[j]) + abs(b[i]-d[j])){
				min = abs(a[i]-c[j]) + abs(b[i]-d[j]);
				minNum = j;
			}
		}
		cout << minNum+1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
h,w =map(int,input().split())

if h%3==0:
  print(0)
elif h%3==0:
  print(0)
elif h%2==0 and w%2==0:
  ans=min(w,h)
  for i in range(w+1):
    ans = min(abs((h//2)*(w-i)-h*i),ans)
  for i in range(h+1):
    ans = min(abs((w//2)*(h-i)-w*i),ans)
  print(ans)
elif h%2==0 and w%2==1:
  ans=min(w,h)
  for i in range(w+1):
    ans = min(abs((h//2)*(w-i)-h*i),ans)
  for i in range(h+1):
    ans = min(max(abs((w//2)*(h-i)-w*i),abs((w//2+1)*(h-i)-w*i),abs(h-i)),ans)
  print(ans)
elif h%2==1 and w%2==0:
  ans=min(w,h)
  h,w=w,h
  for i in range(w+1):
    ans = min(abs((h//2)*(w-i)-h*i),ans)
  for i in range(h+1):
    ans = min(max(abs((w//2)*(h-i)-w*i),abs((w//2+1)*(h-i)-w*i),abs(h-i)),ans)
  print(ans)
elif h%2==1 and w%2==1:
  ans=min(w,h)
  for i in range(w+1):
    ans = min(max(abs((h//2)*(w-i)-h*i),abs((h//2+1)*(w-i)-h*i),abs(w-i)),ans)
  for i in range(h+1):
    ans = min(max(abs((w//2)*(h-i)-w*i),abs((w//2+1)*(h-i)-w*i),abs(h-i)),ans)
  print(ans)



Measured memory_bytes: 3192
#include<stdio.h>
    
int main(){
    
	int a,b,n,k[256]={0},i=0;


 while(scanf("%d %d",&a,&b)!=EOF){
	 n=a+b;


	 for(;;){
		 n/=10;

	
		 k[i]++;
		 if(n==0)break;

	 }

	 i++;

 }
 for(n=0;n<i;n++)printf("%d\n",k[n]);

    return 0;
}

Measured memory_bytes: 600
// atcoder/abc174/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  lli k;
  while (cin >> k) {
    set<lli> vis;

    bool f = false;
    lli x = 0;
    for (int i = 1; i < 1000000; ++i) {
      if (vis.count(x)) break;
      vis.insert(x);
      x = x * 10 + 7;
      x %= k;
      if (x == 0) {
        f = true;
        cout << i << endl;
        break;
      }
    }
    if (!f) cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 50520
n, k = map(int, input().split())
a = list(map(int, input().split()))

l = 0
r = 10**9 + 1
ref = 0

while r - l > 1:
    now = (l + r)//2
    for i in a:
        ref += 0 - -i//now - 1
    if ref <= k:
        ref = 0
        r = now
    else:
        ref = 0
        l = now
print(r)

Measured memory_bytes: 30984
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;


signed main(void) {
  int i,j;
  int k;
  cin>>k;
  int n=50;
  vi a(n);
  int cnt=k/n;
  rep(i,n)a[i]=i+cnt;
  int t=k%n;
  rep(i,n){
    if(i<t)a[i]+=n-t+1;
    else a[i]-=t;
  }
 cout<<n<<endl;
 rep(i,n){
   cout<<a[i];
   if(i<n-1)cout<<" ";
   else cout<<endl;
 }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String Sun = "Sunny";
		String Clo= "Cloudy";
		String Rai= "Rainy";

		if(str.equals(Sun)) {
			System.out.println(Clo);
		}
		else if(str.equals(Clo)) {
			System.out.println(Rai);
		}
		else {
			System.out.println(Sun);
		}
	}

}


Measured memory_bytes: 19412
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N;
    cin >> N;
    vector<string> S(N);
    rep(i, 0, N) cin >> S[i];
    map<string, ll> mp;
    rep(i, 0, N) mp[S[i]]++;
    ll mx = -1;
    for(pair<string, ll> P : mp){
        mx = max(mx, P.second);
    }
    vector<string> ans;
    for(pair<string, ll> P : mp){
        if(P.second == mx) ans.pb(P.first);
    }
    sort(ALL(ans));
    for(string s: ans){
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 28404