akhauriyash/Code-Regression huggingface dataset:
all_set = ['S ' + str(i) for i in range(1, 14)] + ['H ' + str(i) for i in range(1, 14)] + ['C ' + str(i) for i in range(1, 14)] + ['D ' + str(i) for i in range(1, 14)]
r = int(input())

for _ in range(r):
    x = input()
    if x in all_set:
        del all_set[all_set.index(x)]
        
for i in all_set:
    print(i)


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int a, b, c;
	cin >> a>> b >> c;
	cout << c << ' ' << a << ' ' << b<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int mod=998244353;
const int N=1e6+5;
int n,m,ans,a[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();
	ans=n*(n-1)/2+m*(m-1)/2;
	cout<<ans;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n, a;
  cin >> n;
  vector<int> bin(100010);
  for(int i = 0; i < n; ++i)
  {
    cin >> a;
    bin[max(0, a - 1)]++;
    bin[a + 2]--;
  }
  for(int i = 0; i < 100005; ++i)
  {
    bin[i + 1] += bin[i];
  }
  cout << *max_element(ALL(bin));

}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3660
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(S: str):
    a =  ['Sunny', 'Cloudy', 'Rainy']
    t = a.index(S)
    ret = a[(t + 1) % 3]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n,a,b,c = map(int,input().split())
m = [a,b,c]
l = sorted([int(input()) for i in range(n)])

import itertools 
data = list(itertools.product(range(4), repeat = n))

ans = float('inf')
for d in data:
    x = [[] for i in range(4)]
    for i in range(n):
        x[d[i]].append(l[i])
    if len(x[0])<1 or len(x[1])<1 or len(x[2])<1:
        continue
    buf = 0
    for i in range(3):
        buf += 10*(len(x[i])-1)
        buf += abs(sum(x[i])-m[i])

    ans = min(ans,buf)
print(ans)



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

using namespace std;

#define  MOD 1000000007
template <class t1, class t2>
inline void add(t1 &a, t2 b, int mod = -1) {
  if(mod == -1) mod = MOD;
  a += b;
  while(a >= mod) a -= mod;
  while(a < 0) a += mod;
}

const int maxn = 330;
int n;
int orig[maxn * 2];
int status[maxn * 2];
int dp[2][maxn][maxn];

int main() {
  scanf("%d", &n);
  int free = 0;
  for (int i = 0; i < n * 2; i++) {
    scanf("%d", orig + i);
    orig[i]--;
    if (i % 2) {
      if (orig[i - 1] != -2 && orig[i] != -2) {
        status[orig[i - 1]] = status[orig[i]] = 2;
      } else if (orig[i - 1] != -2 || orig[i] != -2) {
        status[orig[i - 1] + orig[i] + 2] = 1;
      } else {
        free++;
      }
    }
  }

  memset(dp, 0, sizeof(dp));
  int now = 0, nxt = 1;
  dp[now][0][0] = 1;
  for (int i = n * 2 - 1; i >= 0; i--) if (status[i] != 2) {
    memset(dp[nxt], 0, sizeof(dp[nxt]));
    for (int j = 0; j <= min(i, n * 2 - i) + 1; j++)
      for (int k = 0; k + j <= min(i, n * 2 - i) + 1; k++) if (dp[now][j][k]){
        if (j) add(dp[nxt][j - 1][k], dp[now][j][k]);
        if (status[i] == 0) {
          add(dp[nxt][j + 1][k], dp[now][j][k]);
          if (k) add(dp[nxt][j][k - 1], 1ll * dp[now][j][k] * k % MOD);
        } else {
          add(dp[nxt][j][k + 1], dp[now][j][k]);
        }
      }
    swap(now, nxt);
  }
  long long ans = 1;
  for (int i = 1; i <= free; i++) ans = ans * i % MOD;
  cout << ans * dp[now][0][0] % MOD << endl;

  return 0;
}


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

using namespace std;

#define int long long

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    char p[h][w];
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) cin >> p[i][j];
    int ans = h + w;
    for (int i = 0; i < (1 << (h - 1)); ++i) {
        int cnt = 0, val = 0;
        for (int j = 0; j < h - 1; ++j) if (i & (1 << j)) ++cnt;
        val = cnt;
        vector <int> skr(cnt + 1);
        //cout << i << ' ' << cnt << '\n';
        for (int j = 0; j < w; ++j) {
            int id = 0;
            int pos = 0;
            while (id < h) {
                while ((i & (1 << id)) == 0 && id < h) {
                    skr[pos] += (p[id][j] - '0');
                    ++id;
                }
                if (id < h) skr[pos] += (p[id][j] - '0');
                ++id;
                ++pos;
            }
            bool ch = 0;
            for (auto el : skr) if (el > k) ch = 1;
            if (ch) {
                ++val;
                for (int skrid = 0; skrid <= cnt; ++skrid) skr[skrid] = 0;
                id = 0;
                pos = 0;
                while (id < h) {
                    while ((i & (1 << id)) == 0 && id < h) {
                        skr[pos] += (p[id][j] - '0');
                        ++id;
                    }
                    if (id < h) skr[pos] += (p[id][j] - '0');
                    ++id;
                    ++pos;
                }
            }
            ch = 0;
            for (auto el : skr) if (el > k) ch = 1;
            if (ch) {
                val = h + w;
                break;
            }
            /*for (auto el : skr) cout << el << ' ';
            cout << '\n';*/
        }
        //cout << i << ' ' << val << endl;
        ans = min(ans, val);
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

using namespace std;
int main() {
    std::string line;
    std::getline(std::cin, line);
    std::vector<string> strings;
    std::istringstream f(line);
    std::string _r;
	std::string _g;
	std::string _b;
    getline(f, _r, ' ');
	getline(f, _g, ' ');
	getline(f, _b, ' ');
	int r = stoi(_r);
	int g = stoi(_g);
	int b = stoi(_b);
	int result = 100 * r + 10 * g + b;
	if (result % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=998244353;
const long long inf=1ll<<61;
int a[200006];
signed main(){
	int n,k;cin>>n>>k;
	rep(i,n)cin>>a[i];
	int lb=0,ub=1e9;
	while(ub-lb>1){
		int mi=(ub+lb)/2;
		int res=0;
		rep(i,n){
			res+=(a[i]+mi-1)/mi-1;
		}
		if(res<=k)ub=mi;
		else lb=mi;
	}
	cout<<ub<<endl;
}

Measured memory_bytes: 5164
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_smaller(const pii& left, const pii& right) {
    return left.second < right.second;
}
#endif


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

    int N; cin >> N;
    vi x(N), y(N), h(N); REP(i, N) cin >> x[i] >> y[i] >> h[i];
    
    vector<pii> dh;
    const int CMAX = 100;
    FOR(cx, 0, CMAX+1) {
        FOR(cy, 0, CMAX+1) {
            REP(i,N){
                dh.push_back(pii(i, abs(x[i] - cx) + abs(y[i] - cy)));
            }

            int H = INF;
            REP(i, N){
                H = min(H, h[dh[i].first] + dh[i].second);
            }

            bool ok = true;
            REP(i, N-1){
               int curH = h[dh[i].first] + min(dh[i].second, H);
               int nextH = h[dh[i + 1].first] + min(dh[i + 1].second, H);
               if (curH != nextH) {
                   ok = false;
                   break;
               }
            }

            if (H >= 1 && ok) {
                cout << cx << ' ' << cy << ' ' << H << endl;
                return 0;
            }

            dh.clear();
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 111;
int dp[N][N], nxt[N][N], edge[N][N];
bool vis[N * 10];

void path(int x, int y) {
	while (x != y) {
		vis[edge[x][nxt[x][y]]] = true;
		x = nxt[x][y];
	}
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			dp[i][j] = 1e9;
	memset(nxt, -1, sizeof nxt);
	for (int i = 0, a, b, c; i < m; ++i) {
		scanf("%d%d%d", &a, &b, &c);
		--a, --b;
		dp[a][b] = dp[b][a] = c;
		nxt[a][b] = b;
		nxt[b][a] = a;
		edge[a][b] = edge[b][a] = i;
	}
	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				if (dp[i][j] > dp[i][k] + dp[k][j]) {
					dp[i][j] = dp[i][k] + dp[k][j];
					nxt[i][j] = nxt[i][k];
				}
	
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			path(i, j);
	
	int ans = 0;
	for (int i = 0; i < m; ++i)
		ans += vis[i] == 0;
	printf("%d\n", ans);
	return 0;
}


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

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


int main(){
    ll h;
    cin>>h;
    ll hc = h;
    ll co=0;
    while(hc>0){
        hc /= 2;
        co++;
    }

    if(co==0){
        co++;
    }

    ll sum=0;
    ll val=1;
    for(ll i=0;i<co;i++){
        sum += val;
        val *= 2;
    }

    cout<<sum<<endl;



}





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

using namespace std;

int main(){
	int N;
	int sum = 0;
 
	scanf("%d", &N);
	int tmp = N;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (N % sum == 0) {
		puts("Yes");
	} else {
		puts("No");
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

typedef struct{
  int key;
  int parent;
  int depth;
  int left;
  int right;
}Data;

int main(){
  int i,j,id,n,child,x,count=0,key,l;
  Data T[MAX];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent = T[i].left = T[i].right = -1;
    T[i].depth = 0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&T[id].key);
    key = T[id].key;
    for(j=0; j<key; j++){
      scanf("%d",&child);
      if(j==0)T[id].left = child;
      else T[l].right = child;
      l = child;
      T[child].parent = id;
    }
  }

  for(id=0;id<n;id++){
    x = id;
    count = 0;
    while(T[x].parent != -1){
      x = T[x].parent;
      count++;
    }
    T[id].depth = count;
  }

  for(id=0;id<n;id++){
    printf("node %d: parent = %d, depth = %d, ",id,T[id].parent,T[id].depth);
    if(T[id].depth == 0){
      printf("root, [");
      if(T[id].key == 0)printf("]\n");
      else{
	for( i=0,child = T[id].left ; i<T[id].key-1 ; i++,child = T[child].right){
	  printf("%d, ",child);
	}
	printf("%d]\n",child);
      }
    }
    else if(T[id].key == 0)printf("leaf, []\n");
    else {
      printf("internal node, [");
      for( i=0,child = T[id].left ; i<T[id].key-1 ; i++,child = T[child].right){
	printf("%d, ",child);
      }
      printf("%d]\n",child);
    }
  }
  
  return 0;
}

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

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);
  	int size;
    int rules;
    cin >> size;
    cin>>rules;
  
    vector<string> digits(size, "0");
    for(int i = 0; i<rules; i++)
    {
      int digit;
      string rule;
      cin>>digit;
      cin>>rule;
      if(digit == 1 && rule == "0" && size > 1){
          cout << -1;
          return 0;
      }
      if((digits[digit-1] != "0" && digits[digit-1] == rule) || digits[digit-1] ==  "0")
      {
        digits[digit-1] = rule;
      }else{
        cout << -1;
        return 0;
      }
    }
    string str = "" ;
    for(int i = 0; i< size; i++){
      if(i == 0)
      {
        if(digits[i] == "0" && size > 1)
          str += "1";
        else{
          str += digits[i];
        }
      }else
      str+=digits[i];
    }  
    cout<<str;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<P> v(n);
    rep(i, n)
    {
        int a;
        cin >> a;
        v[i] = P(a, i + 1);
    }
    sort(all(v));
    rep(i, n) cout << v[i].second << " ";
    cout << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  
  dsu D(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    D.merge(a,b);
  }
  
  auto x = D.groups();
  cout << x.size()-1 << endl;
  return 0;
}


Measured memory_bytes: 9028
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        cout << "Possible";
    else cout << "Impossible";
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    priority_queue<int> que_r;
    priority_queue<int, vector<int>, greater<int> > que_l;
    int N;
    cin >> N;
    vector<int> A(3 * N);
    rep(i, 3 * N) {
        cin >> A[i];
    }
    vll S_l(N + 1), S_r(N + 1);
    rep(i, N) {
        que_l.push(A[i]);
        S_l[0] += A[i];
    }
   
    rep(i, N) {
        S_l[i + 1] = S_l[i] + A[N + i];
        que_l.push(A[N + i]);
        S_l[i + 1] -= que_l.top();
        que_l.pop();
    }


    rep(i, N) {
        que_r.push(A[3 * N - 1 - i]);
        S_r[N] += A[3 * N - 1 - i];
    }
    rep(i, N) {
        S_r[N - 1 - i] = S_r[N - i] + A[3 * N - 1 - N - i];
        que_r.push(A[3 * N - 1 - N - i]);
        S_r[N - 1 - i] -= que_r.top();
        que_r.pop();
    }
    ll ans = -LINF;
    rep(i, N + 1) {
        ans = max(ans, S_l[i] - S_r[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4088
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
y.sort()

for z in range(X+1, Y):
    if x[n-1] < z  <= y[0]:
        print("No War")
        exit()
print("War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    string s;
    cin >> s;

    map<string,int> mp;

    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    cout << mp[s] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main (){
	int n;
	cin>>n;
	map<string,int>mp;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	ll ans=0;
	for(auto& p:mp){
		ll t=p.second;
		ans+=t*(t-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ll s;
  cin >> s;
  ll x2 = 1e9;
  ll y2 = 1;
  ll x1 = (x2 - s % x2) % x2;
  ll y1 = (s + x1) / x2;

  cout << x1 << " " << y1 << " " << x2 << " " << y2 << " 0 0" << endl;
  return 0;
}


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

int main(){
    int a,b,c,ans;
    cin >> a >> b >> c;
    if((a - b) >= c){
        ans = 0;
    }
    else{
        ans = c - (a - b);
    }

    cout << ans << 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 (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();

            if (h == 0 && w == 0) break;

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    System.out.print("#");
                }
                System.out.println("");
            }
            System.out.println("");
        }

        sc.close();
    }
}



Measured memory_bytes: 33092
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* greedy */

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int h,w,n,sr,sc; string S,T;
    while (cin >> h >> w >> n >> sr >> sc >> S >> T) {
        int L = sc, R = sc, U = sr, D = sr;
        bool ans = true;
        FOR(i,0,n) {
            L -= S[i] == 'L';
            R += S[i] == 'R';
            U -= S[i] == 'U';
            D += S[i] == 'D';
            if (L <= 0 || R > w || U <= 0 || D > h)
                ans = false;
            L += T[i] == 'R'; L = min(w,L);
            R -= T[i] == 'L'; R = max(1,R);
            U += T[i] == 'D'; U = min(h,U);
            D -= T[i] == 'U'; D = max(1,D);
        }
        const string res = ans ? "YES" : "NO";
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 920
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	bool h=true;
	int n;
	cin>>n;
	int a=0,b=0,c=0;
	rep(i,n){
		int x,y,z;
		cin>>x>>y>>z;
		a=x-a;
		b=abs(y-b);
		c=abs(z-c);
		if(a>=b+c&&(a-b-c)%2==0);
		else h=false;
		a=x;b=y;c=z;
	}
	if(h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}











Measured memory_bytes: 256
let iota ?(start=0) ?(step=1) cnt =
  let rec doit i acc =
    if i <= 0 then acc
    else doit (i - 1) (start + step*(i - 1) :: acc) in
  doit cnt []

let safe_p p qs =
  let rec doit i = function
    | [] -> true
    | q :: qs ->
      if p = q + i || p = q - i then false
      else doit (i + 1) qs in
  doit 1 qs

let answer_p rc qs =
  let rec doit i = function
    | ([], _) -> true
    | (_, []) -> assert false
    | ((r, c) :: xs as rc, q :: qs) ->
      if r <> i then doit (i + 1) (rc, qs)
      else if c = q then doit (i + 1) (xs, qs)
      else false in
  doit 0 (rc, qs)

let print qs =
  List.iter (fun q ->
    for i = 0 to 7 do
      print_string (if i = q then "Q" else ".")
    done;
    print_newline ()) qs

let () =
  let k = read_int () in
  let rec read i rc =
    if i = k then rc
    else read (i + 1) (Scanf.scanf "%d %d\n" (fun r c -> (r, c)) :: rc) in
  let rc = read 0 [] |> List.sort (fun (a, _) (b, _) -> a - b) in
  let rec doit qs = function
    | [] -> if answer_p rc qs then print qs
    | ps ->
      List.iter (fun p ->
        if safe_p p qs then List.filter (fun e -> e <> p) ps |> doit (p :: qs))
        ps in
  iota 8 |> doit []

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  int nokori=0;
  int owari=0;
  nokori = K;
 
  if ((nokori -A <= 0) && (owari==0)) {
    cout << min(A,nokori) << endl;
    owari=1;
  }
  nokori-=A;
  if ((nokori - B <= 0) && (owari==0)) {
    cout << A << endl;
    owari=1;
  }
  nokori-=B;
  if ((owari==0)) {
    cout << A - nokori << endl;
    owari=1;
  }
  
}
    

Measured memory_bytes: 3596
n,m=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort()
s=sum(A)
SA=[0]
for a in A:
  SA.append(SA[-1]+a)
for i in range(n+1):
  SA[i]=s-SA[i]
l,r=0,2*max(A)+1
import bisect
def chk(x):
  ct=0
  for a in A:
    ct+=n-bisect.bisect_left(A,max(x-a,0))
  if ct>=m:
    return True
  else:
    return False

def count(x):
  ct=0
  for a in A:
    ct+=n-bisect.bisect_left(A,max(x-a,0))
  return ct

while r-l>1:
  mid=(l+r)//2
  if chk(mid):
    l=mid
  else:
    r=mid
ans=0
for a in A:
  aa=bisect.bisect_left(A,max(l-a,0))
  ans+=SA[aa]+a*(n-aa)
print(ans-l*(count(l)-m))


Measured memory_bytes: 59052
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'

int dist[100001];
int par[100001];
int vis[100001];
int32_t  main()
{
    IOS; 
    int n,m;
    cin>>n>>m;
    vector<int> v[n+1];
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    queue<int> q;
    q.push(1);
    vis[1]=1;
    memset(dist,-1,sizeof(dist));
    dist[1]=0;
    while(!q.empty())
    {
        int node=q.front();
        q.pop();
        for(int i=0;i<v[node].size();i++)
        {
            if(vis[v[node][i]]==0)
            {
                dist[v[node][i]]=1+dist[node];
                par[v[node][i]]=node;
                vis[v[node][i]]=1;
                q.push(v[node][i]);
            }
        }
    }
    for(int i=2;i<=n;i++)
    {
        if(dist[i]==-1)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
        cout<<par[i]<<endl;
}

Measured memory_bytes: 11388
#include <iostream>
#include <map>

using namespace std;

int s[100001];
bool h[100001];

int main(){
	int n, m;
	cin >> n >> m;
	
	for(int i = 1;i <= n;i++){
		s[i] = 1;
		h[i] = false;
	}
	
	h[1] = true;
	int num = 1;
	
	for(int i = 0;i < m;i++){
		int x, y;
		cin >> x >> y;
		
		s[y]++;
		if(!h[y] && h[x]){
			h[y] = true;
			num++;
		}
		
		s[x]--;
		if(s[x] == 0 && h[x]){
			h[x] = false;
			num--;
		}
	}
	
	cout << num << endl;
	
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
LL fac2(LL n) {
  LL cnt = 0;
  while (n % 2 == 0) {
    ++cnt;
    n /= 2;
  }
  return cnt;
}

int main() {
  LL A, B, C;
  cin >> A >> B >> C;
  if (A == B && B == C && C == A) {
    LL sum = A + B + C;
    cout << (sum % 2 == 0 ? -1 : 0) << endl;
    return 0;
  }
  int cnt = 0;
  while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
    int na = B / 2 + C / 2;
    int nb = A / 2 + C / 2;
    int nc = A / 2 + B / 2;
    A = na;
    B = nb;
    C = nc;
    ++cnt;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  string s; cin >> s;

  std::deque<char> w{};
  for (auto& c : s) {
    if (w.empty()) {
      w.push_back(c);
    } else if (w.back() != c) {
      w.push_back(c);
    }
  }
  cout << w.size() << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

void pd(const vector<vector<int>>& dist, const vector<vector<bool>>& left) {
  REP(i, dist.size()) {
    REP(j, dist.size()) {
      if (left[i][j])
        cerr << ' ';
      else
        cerr << dist[i][j];
    }
    cerr << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<tuple<int, int>> steps = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

  int N;
  cin >> N;
  vector<int> P(N * N);
  for (auto& x : P) {
    cin >> x;
    x--;
  }

  vector<vector<int>> dist(N, vector<int>(N));
  vector<vector<bool>> left(N, vector<bool>(N));
  REP(i, N) {
    REP(j, N) {
      int d = N;
      d = min(d, i);
      d = min(d, j);
      d = min(d, N - 1 - i);
      d = min(d, N - 1 - j);
      dist[i][j] = d;
    }
  }

  auto upd = [&](int r0, int c0, i64 d0) -> void {
    deque<tuple<int, int, i64>> q;
    q.emplace_back(r0, c0, d0);
    // set<tuple<int, int>> vis;
    while (q.size()) {
      auto [r, c, d] = q.front();
      q.pop_front();
      //   auto rc = make_tuple(r, c);
      //   if (vis.count(rc)) {
      //     continue;
      //   }
      //   vis.insert(rc);
      for (auto [drow, dcol] : steps) {
        int row2 = r + drow;
        int col2 = c + dcol;
        if (row2 < 0 || row2 >= N || col2 < 0 || col2 >= N) continue;
        i64 s = d + int(!left[r][c]);
        if (dist[row2][col2] > s) {
          dist[row2][col2] = s;
          q.emplace_back(row2, col2, s);
        }
      }
    }
  };

  i64 total_cost = 0;
  //  int i = 0;
  for (const auto& p : P) {
    int col = p % N;
    int row = p / N;
    left[row][col] = true;
    total_cost += dist[row][col];
    upd(row, col, dist[row][col]);

    // cerr << "--- step " << (i++) << ": (" << row << "-" << col << ") "
    //      << "--------------------------------------------------------------"
    //      << endl;
    // pd(dist, left);
  }
  cout << total_cost << endl;
}

Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a, b;
    cin >> a >> b;
    if (a.size() < b.size()) cout << "LESS";
    else if (a.size() > b.size()) cout << "GREATER";
    else {
        bool equal = true;
        for (int i = 0; i < a.size(); i++)
        {
            if (a[i] > b[i])
            {
                equal = false;
                cout << "GREATER";
                break;
            }
            else if (a[i] < b[i])
            {
                equal = false;
                cout << "LESS";
                break;
            }
        }
        if (equal == true) cout << "EQUAL";
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    k--;
    if(w == 1){
        cout << 1 << endl;
        return 0;
    }
    vector<vector<ll>> dp(h+1, vector<ll>(w, 0));
    dp[0][k] = 1;
    int mod = 1000000007;
    for(int i = 1; i <= h; i++){
        rep(j, 1 << (w-1)){
            bool v = true;
            rep(k, w-2){
                if((1 & (j >> k)) && (1 & (j >> (k+1))))v = false;
            }
            if(!v)continue;

            rep(k, w){
                if(1 & (j >> (k-1))){
                    (dp[i][k-1] += dp[i-1][k]) %= mod;
                }else if(1 & (j >> k)){
                    (dp[i][k+1] += dp[i-1][k]) %= mod;
                }else{
                    (dp[i][k] += dp[i-1][k]) %= mod;
                }
            }
        }
    }
    cout << dp[h][0] << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from bisect import bisect_left
n = int(input())
W = list(map(int, input().split()))
half = sum(W)//2
Ws = []
for i in range(1, len(W)+1):
    Ws.append(sum(W[:i]))

p = bisect_left(Ws, half)
d1 = abs(sum(W[:p]) - sum(W[p:]))
d2 = abs(sum(W[:(p+1)]) - sum(W[(p+1):]))
print(min(d1, d2))

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

vector<pair<ll, ll>> factorization(ll n) {
  ll sq = sqrt(n);
  vector<pair<ll, ll>> f;
  for (int i = 2; i <= sq; i++) {
    if (n == 1) break;
    if (n % i) continue;
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    f.emplace_back(make_pair(i, cnt));
  }
  if (n > 1) f.emplace_back(make_pair(n, 1));
  return f;
}

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

  ll N; cin >> N;
  if (N == 1) {
    cout << 0 << '\n';
    return 0;
  }

  vector<pair<ll, ll>> f = factorization(N);

  ll ans = 0;
  for (auto p: f) {
    ll temp = p.second;
    for (ll i = 0; i < 1234567; i++) {
      if (temp < i * (i + 1) / 2) {
        ans += (i - 1);
        break;
      }
    }
    // cout << p.first << ' ' << p.second << '\n';
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3656
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m,s = list(map(int, input().split()))
cd = [None]*n
from collections import defaultdict
ns = defaultdict(set)
nns = defaultdict(set)
uvab = [None]*m
for i in range(m):
    u,v,a,b = list(map(int, input().split()))
    u -= 1
    v -= 1
    uvab[i] = (u,v,a,b)
    ns[u].add((a,b,v))
    ns[v].add((a,b,u))
for i in range(n):
    cd[i] = list(map(int, input().split()))

ms = max(item[2] for item in uvab)*(n-1)
for u in range(n):
    for ss in range(ms+1):
        for a,b,v in ns[u]:
            if ss>=a:
                nns[u,ss].add((b, (v,ss-a)))
        c,d = cd[u]
        if ss+c<=ms:
            nns[u,ss].add((d, (u,ss+c)))
ns = nns
def dijkstra(start):
    import heapq
    vals = {}
    h = [(0, start)] # (距離, ノード番号)
    vals[start] = 0
    while h:
        val, u = heapq.heappop(h)
        for d, v in ns[u]:
            if v not in vals or vals[v]>val+d:
                vals[v] = val+d
                heapq.heappush(h, (vals[v], v))
    return vals
s = min(s, ms)
vals = dijkstra((0,s))
ans = [None]*(n-1)
for u in range(1,n):
    ans[u-1] = min(vals[u,s] for s in range(ms+1))
write("\n".join(map(str, ans)))

Measured memory_bytes: 190780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc023_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  unordered_map<ll, ll> s;
  s[0]++;
  ll sum = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    sum += a;
    s[sum]++;
  }

  ll ans = 0;
  for (auto kv : s) {
    ans += (kv.second * (kv.second - 1)) / 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 11316
// A - Haiku

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int k,s;
    cin >> k >> s;
    int count = 0;

    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int rest = s - (i+j);
            if(rest >= 0 && rest <= k){
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */



#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <limits>




#include <ostream>
#include <sstream>


using namespace std;
class C {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
		long long int h, w, res, tmp;
    long long int a, b, c, mx, mn, total;
    in >> h >> w;
    total = res = h * w;
    if(h % 3 == 0 || w % 3 == 0){
      res = 0;
    }
    // cut in same dir
//    res = min(res, abs((h/3) * w - (h - 2 * (h / 3)) * w));
//    tmp = w;
//    w = h;
//    h = tmp;
//    res = min(res, abs((h/3) * w - (h - 2 * (h / 3)) * w));

    // cut in different dir
    for(long long int i = 0; i < w && res > 0; ++i){
      a = h * i;
      b = (h/2)*(w-i);
      c = (h-h/2)*(w-i);
      mx = max({a, b, c});
      mn = min({a, b, c});
      res = min(res, mx - mn);

      b = h * (w - (w - i)/2);
      c = total - a - b;
      mx = max({a, b, c});
      mn = min({a, b, c});
      res = min(res, mx - mn);

      b = h * ((w - i)/2);
      c = total - a - b;
      mx = max({a, b, c});
      mn = min({a, b, c});
      res = min(res, mx - mn);
    }
    tmp = w;
    w = h;
    h = tmp;
    for(long long int i = 0; i < w && res > 0; ++i){
      a = h * i;
      b = (h/2)*(w-i);
      c = (h-h/2)*(w-i);
      mx = max({a, b, c});
      mn = min({a, b, c});
      res = min(res, mx - mn);

      b = h * (w - (w - i)/2);
      c = total - a - b;
      mx = max({a, b, c});
      mn = min({a, b, c});
      res = min(res, mx - mn);

      b = h * ((w - i)/2);
      c = total - a - b;
      mx = max({a, b, c});
      mn = min({a, b, c});
      res = min(res, mx - mn);
    }
    out << res << endl;
	}
};


int main() {
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
ans=0
if n%2==0:
  for i in range(n//2):
    ans+=a[i]*2
    if i==0:
      ans-=a[i]
else:
  for i in range(n//2+1):
    ans+=a[i]*2
    if i==0:
      ans-=a[i]
    if i==n//2:
      ans-=a[i]
print(ans)

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

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (abs(a-c) <= d || abs(a-b) <= d && abs(c-b) <= d ? "Yes" : "No") << endl;
    return 0;
}

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

const int MAX_N = 100000;

int N, A[MAX_N], B[MAX_N], C[MAX_N];

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N) cin >> C[i];

    sort(A, A + N);
    sort(C, C + N);

    ll ans = 0;
    REP(i, N) {
        ll a = lower_bound(A, A + N, B[i]) - A;
        ll c = N - (lower_bound(C, C + N, B[i] + 1) - C);
        ans += a * c;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/env python3

def main():
    import sys

    def calc(A: list):
        score = 0
        for a, b, c, d in lst:
            if A[b - 1] - A[a - 1] == c:
                score += d
        return score

    def dfs(A: list):
        nonlocal ans
        if len(A) == N:
            ans = max(ans, calc(A))
        elif len(A) == 0:
            for nx in range(1, M + 1):
                dfs(A + [nx])
        else:
            for nx in range(A[-1], M + 1):
                dfs(A + [nx])

    input = sys.stdin.readline

    N, M, Q = map(int, input().split())
    lst = [list(map(int, input().split())) for _ in range(Q)]
    ans = 0
    dfs([])
    print(ans)


main()


Measured memory_bytes: 9132
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


double n;
double p;

int main() {
	cin >> n >> p;
	p /= 100.0;
	cout << fixed << setprecision(13) << ceil(n / 2) / p << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 10005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rev(a,n) reverse(a,a+n)
using namespace std;
int n,f[N];
int main() {
	//freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    cin>>n;
    rep1(i,1,100) rep1(j,1,100) rep1(k,1,100) {
    	int t=i*i+j*j+k*k+i*j+j*k+k*i;
    	if(t<=n)f[t]++;
	}
	rep1(i,1,n) cout<<f[i]<<"\n";
	return 0;
}


Measured memory_bytes: 3600
from math import sqrt
X = int(input())
flag = 0
if(X == 1 or X == 2):
  print(2)
else:
  ans = X 
  while(flag == 0):
    for i in range(int(sqrt(ans))):
      if(ans % (i + 2) == 0):
        ans += 1
        flag = 0
        break
      flag = 1
  print(ans)

Measured memory_bytes: 3060
import sys


def answer(A,B,C,D):
    flag = True
    while True:
        if(flag):
            C -= B
            if(C <= 0):
                return "Yes"
            else:
                flag = False
        else:
            A -= D
            if(A <= 0):
                return "No"
            else:
                flag = True


def main():
    A,B,C,D = map(int,input().split())
    # answer()
    print(answer(A,B,C,D))

if __name__ == '__main__':
   main()

Measured memory_bytes: 9200