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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ll h1,m1; cin >> h1 >> m1;
  ll h2,m2; cin >> h2 >> m2;
  ll k; cin >> k;
  cout << max(0LL,h2*60+m2 - h1*60-m1-k) << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    long long a[n+1] = {};
    long long count = 0; 
    for(int i = 0; i < n; i++){
        if(s[i] == '<'){
            count++;
            a[i+1] = count;
        }else{
            count = 0;
        }
    }
    count = 0;
    for(int i = n-1; i >= 0; i--){
        if(s[i] == '>'){
            count++;
            a[i] = max(a[i],count);
        }else{
            count = 0;
        }
    }
    long long sum = 0;
    for(int i = 0; i <= n; i++){
        sum += a[i];
        //cout << a[i] << endl;
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) break;

    int data[201];
    for(int i=0;i<=2*n;i++) data[i]=0;
    for(int i=0;i<n;i++){
      int temp;
      cin >> temp;
      data[temp]=1;
    }

    for(int i=1;i<=2*n;i++){
      if(data[i]==0) data[i]=2;
    }

    int flag=0;
    int m1=n;
    int m2=n;
    int junban=1;
    int mae=0;
    while(1){
      if(junban==1){
        int f=0;
        for(int i=1;i<=2*n;i++){
          if(data[i]==1 && i>mae){
            f=1;
            data[i]=0;
            mae=i;
            m1--;
            break;
          }
        }
        if(f==0) mae=0;
        junban=2;
      }
      else if(junban==2){
        int f=0;
        for(int i=1;i<=2*n;i++){
          if(data[i]==2 && i>mae){
            f=1;
            data[i]=0;
            mae=i;
            m2--;
            break;
          }
        }
        if(f==0) mae=0;
        junban=1;
      }
      if(m1<=0){
        flag=1;
        break;
      }
      else if(m2<=0){
        flag=2;
        break;
      }
    }

    int ans=0;
    if(flag==1){
      for(int i=1;i<=2*n;i++){
        if(data[i]==2) ans++;
      }
      cout << ans << endl;
      cout << '0' << endl;
    }
    else if(flag==2){
      for(int i=1;i<=2*n;i++){
        if(data[i]==1) ans++;
      }
      cout << '0' << endl;
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    vector<long long> s(N + 1);
    s[0] = 0;
    REP(i, N) {
        cin >> W[i];
        s[i + 1] = s[i] + W[i];
    }
    long long res = INF;
    REP(i, N) { res = min(res, (long long)abs(s[N] - s[i] - s[i])); }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[1001] = {INT_MAX};
int n, d = 0, ops;
bool dfs(int d)
{ // d := depth
    int mx = 0;
    for (int i = 0; i <= d; i++)
        mx = max(mx, p[i]);
    if ((mx << (ops - d)) < n)
        return false;

    if (p[d] == n)
        return true;
    if (d == ops)
        return false;

    for (int i = 0; i <= d; i++)
    {
        p[d + 1] = p[d] + p[i];
        if (dfs(d + 1))
            return true;
        p[d + 1] = p[d] - p[i];
        if (dfs(d + 1))
            return true;
    }

    return false;
}
int main()
{

    while (cin >> n && n)
    {
        for (int i = 0; i < 1005; i++)
        {
            p[i] = INT_MAX;
        }

        p[0] = 1;
        for (ops = log2(n);; ops++)
            if (dfs(0))
                break;
        if (n != 0)
            printf("%d\n", ops); // 印出題目要求答案
        else
            printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 3312
import bisect
import heapq
import sys


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class v:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def update(S, L, M):
    _, a, b = S
    M[0] += b

    if len(L[0]) == 0:
        L[0].append(-a)
        L[1].append(a)
    else:
        r0 = -1 * L[0][0]
        r1 = L[1][0]
        if a < r0:
            M[1] += r0 - a
        elif r1 < a:
            M[1] += a - r1

        if -1 * L[0][0] >= a:
            heapq.heappush(L[0], -a)
            t = -1 * heapq.heappushpop(L[0], -a)
            heapq.heappush(L[1], t)
        elif L[1][0] < a:
            heapq.heappush(L[1], a)
            t = heapq.heappushpop(L[1], a)
            heapq.heappush(L[0], -t)
        else:
            heapq.heappush(L[0], -a)
            heapq.heappush(L[1], a)
    # print(L, M)


def print_min(L, M):
    print(-1 * L[0][0], sum(M))


def main():
    Q = int(input())

    L = [[], []]
    M = [0, 0]
    for q in range(Q):
        S = read_list()
        if S[0] == 1:
            update(S, L, M)
        else:
            print_min(L, M)


if __name__ == "__main__":
    main()


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

int main(){
    int S;
    cin >> S;
    int a[100000][3];
    for(int i=0;i<S;i++){
        for(int j=0;j<3;j++) cin >> a[i][j];
    }

    int dp[100001][3]={0};
    
    for(int i=0;i<3;i++) dp[0][i] = a[0][i];

    for(int i=1;i<S;i++){
        for(int j=0;j<3;j++){ 
            for(int k=0;k<3;k++){
                if(j==k) continue;
                dp[i][k] = max(dp[i][k],dp[i-1][j]+a[i][k]);
            }
        }
    }

    cout << max({dp[S-1][0],dp[S-1][1],dp[S-1][2]}) << endl;
    return 0;
 }

Measured memory_bytes: 2560
N = int(input())
A = [int(a) for a in input().split()]
X = {}
for i,a in enumerate(A):
  v = i + a
  if not v in X:
    X[v] = [i]
  else:
    X[v].append(i)

#print(X)
out = 0
for i,a in enumerate(A):
  v = i - a
  #print("look for:", v, "index", i)
  if not v in X:
    continue
  cand = X[v]
  #print(cand)
  lb = 0
  ub = len(cand)
  while lb < ub:
    #print(lb, ub)
    m = (lb + ub)//2
    if cand[m] >= i:
      lb = m + 1
    else:
      ub = m
  #print(lb, ub)
  out += len(cand) - lb
print(out)

Measured memory_bytes: 60568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

const ld eps = 1e-5;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int a, b, c;
  cin >> a >> b >> c;
  ld sa = sqrt(ld(a));
  ld sb = sqrt(ld(b));
  if(1ll * a + 2 * sa * sb + 1ll * b < 1ll * c) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#define Rint register int
#define LL long long
#define F(x,y,z) for(Rint x=y;x<=z;++x)
#define D(x,y,z) for(Rint x=y;x>=z;--x)
using namespace std;
LL Min(LL x,LL y){return x<y?x:y;}
LL Max(LL x,LL y){return x>y?x:y;}
inline LL R(){
    char c='!';LL x=0,z=1;
    for( ; c>'9'||c<'0';c=getchar()) if(c=='-')z=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
    return x*z;
}
const int N=100010;
int n,m,minn=1000000000,sum;
int a[N];

int main(){
	n=R();m=R();
	F(i,1,n) a[i]=R(),minn=Min(minn,a[i]);
	F(i,1,n) if (a[i]!=minn) ++sum;
	if (!sum){
		printf("%d\n",0);
		return 0;
	}
	printf("%d\n",(sum-1)/(m-1)+1); 
	return 0;
}



Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
char a[50][51];
char b[50][51];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		scanf("%s", a[i]);
	}
	for (int i = 0; i < M; i++) {
		scanf("%s", b[i]);
	}
	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			bool OK = 1;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (a[i + k][j + l] != b[k][l]) {
						OK = 0;
						break;
					}
				}
				if (!OK) break;
			}
			if (OK) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vs S(N); rep(i, N) cin >> S[i];
    
    ll ans = 0;
    FOR(sub, -N+1, N){
        ll a = -1, b = -1;
        if(sub > 0){
            a = sub; b = 0;
        }
        else{
            a = 0; b = -sub;
        }
        bool ok = true;
        rep(i, N){
            ll ni = (i-a+N)%N;
            ll mj = (i-b+N)%N;
            rep(j, N){
                ll nj = (j-b+N)%N;
                ll mi = (j-a+N)%N;
                if(S[ni][nj] != S[mi][mj]){
                    ok = false; i = N; j = N;
                }
            }
        }
        if(ok) ans += N-abs(sub);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  string S,T;
  cin>>S>>T;
  ll ans=S.size();
  rep(i,S.size()-T.size()+1){
    ll sum=0;
    rep(j,T.size()){
      if(S[i+j]!=T[j]) sum++;
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	int n,a;
	vector<int> av;
	cin >> n;
	rep(i,n) {
		cin >> a;
		av.pb(a);
	}
	int ans=0;
	for(int i=0; i<n; i++) {
		if(ans+1 == av[i]) {
			ans++;
		}
	}
	if(ans == 0) cout << -1 << endl;
	else cout << n - ans << endl;
  return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<char> name;
    name.push_back('z');
    for(char i = 'a'; i <= 'y'; ++i){
        name.push_back(i);
    }
    vector<char> ans;
    while(n >= 1){
        int i = n % 26;
        ans.push_back(name[i]);
        // cout << i << " " << n << endl;
        n /= 26;
        if(i == 0) --n;
    }
    reverse(ans.begin(), ans.end());
    rep(i,ans.size()) cout << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3612
n, m = map(int, input().split())
query = [tuple(input().split()) for _ in range(m)]
 
wa = [0] * n
ac = [0] * n
for p, result in query:
    p = int(p) - 1
    if result == 'AC':
        ac[p] = 1
    if result == 'WA' and ac[p] == 0:
        wa[p] += 1
 
accept = 0
penalty = 0
for i in range(n):
    if ac[i]:
        penalty += wa[i]
        accept += 1
 
print(accept, penalty)

Measured memory_bytes: 22896
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

class UnionFind {
public:
    vector<ll> parent; //parent[i]はiの親
    vector<ll> siz; //素集合のサイズを表す配列(1で初期化)
    map<ll,vector<ll> > group;//素集合ごとに管理する連想配列(keyはそれぞれの素集合の親、valueはその素集合の要素の配列)

    //コンストラクタ
    UnionFind(ll n):parent(n),siz(n,1){ 
        //全ての要素の根が自身であるとして初期化
        for(ll i=0;i<n;i++){parent[i]=i;}
    }

    //データxの属する木の根を取得(経路圧縮も行う)
    ll root(ll x){
        if(parent[x]==x) return x;
        return parent[x]=root(parent[x]);//代入式の値は代入した変数の値なので、経路圧縮できる
    }

    //xとyの木を併合
    void unite(ll x,ll y){
        ll rx=root(x);//xの根
        ll ry=root(y);//yの根
        if(rx==ry) return;//同じ木にある時
        //小さい集合を大きい集合へと併合(ry→rxへ併合)
        if(siz[rx]<siz[ry]) swap(rx,ry);
        siz[rx]+=siz[ry];
        parent[ry]=rx;//xとyが同じ木にない時はyの根ryをxの根rxにつける
    }

    //xとyが属する木が同じかを判定
    bool same(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        return rx==ry;
    }

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

};

int main(){
    ll n, m;
    cin >> n >> m;
    UnionFind tree(n);
    rep1(i, m){
        ll a,b;
        cin >> a >> b;
        tree.unite(a-1, b-1);
    }
    ll ans = -1;
    rep0(i, n-1){
        ans = max(ans, tree.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6048
import sys

cnt = 0

def solve():
    while 1:
        w, h = map(int, sys.stdin.readline().split())

        if w == h == 0:
            return

        room = [list(sys.stdin.readline().rstrip()) for i in range(h)]

        for i in range(h):
            if '@' in room[i]:
                si = i
                sj = room[i].index('@')
                break

        global cnt
        cnt = 0
        dfs(w, h, room, si, sj)
        print(cnt)

def dfs(w, h, room, i, j):
    if i < 0 or i >= h or j < 0 or j >= w or (room[i][j] == '#'):
        return

    global cnt
    cnt += 1
    room[i][j] = '#'

    dfs(w, h, room, i + 1, j)
    dfs(w, h, room, i - 1, j)
    dfs(w, h, room, i, j + 1)
    dfs(w, h, room, i, j - 1)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7784
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

ll N, K;
vector<ll> A;


template <class T>
T find_min(T l, T r, bool f(T)) {
  T c;
  while (r - l > 1) {
    c = (r + l) / 2;
    if (f(c)) {
      r = c;
    } else {
      l = c;
    }
  }

  return r;
}


ll wari(ll a, ll b) {
  ll res = a / b;
  if (a == 0)
    return 0;

  if (a < 0 && (a % b != 0)) {
    if (b > 0)
      res--;
    else
      res++;
  }
  return res;
}

bool f(ll trial) {
  ll cnt = 0;

  rep(i, N) {
    if (A[i] * A[i] <= trial)
      cnt--;
  }

  rep(i, N) {
    if (A[i] == 0) {
      if (trial >= 0)
        cnt += N;
    } else if (A[i] > 0) {
      auto iter = upper_bound(all(A), wari(trial, A[i]));
      ll pos = distance(A.begin(), iter);
      cnt += pos;
    } else {
      auto iter = lower_bound(all(A), wari(trial, A[i]));
      ll pos = distance(A.begin(), iter);
      cnt += (N - pos);
    }
  }
  cnt /= 2;

  return cnt >= K;
}

signed main() {
  cin >> N >> K;
  A = vector<ll>(N);
  rep(i, N) {
    cin >> A[i];
  }
  sort(all(A));
  cout << find_min(-LINF, LINF, f) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <stdio.h>
#include <sstream>

using namespace std;
void swap(int &a, int &b);

int main()
{
	double a, b, C;
	cin >> a >> b >> C;
	cout << fixed << setprecision(9);

	double radian = C*M_PI / 180;

	double area = a*b*sin(radian)*0.5;
	double length = a + b + sqrt(a*a + b*b - 2 * a*b*cos(radian));
	double height = b*sin(radian);

	cout << area << endl << length << endl << height << endl;

	return 0;
}




Measured memory_bytes: 3568
// https://atcoder.jp/contests/abc156/tasks/abc156_e
// AtCoder Beginner Contest 156
// E - Roaming

/*
Problem.
n個の部屋に１人ずつ初期状態でいる時、1回の移動で1人が他の部屋に移動する。
k回の移動が発生する時、移動後の各部屋の人数の組み合わせとしてあり得るものは
何通りか？

Point.
空になる部屋の数v(0<=v<=min(n,k))についてsum({n-1Cn-v * n-1Cv})
重複組み合わせは nHr = n+r-1Cr であることに注意。
*/

#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;
using ll = long long;

const int maxn = 200000 + 10;
int fac[maxn], invfac[maxn];

#define MOD 1000000007
long long qpow(long long a, long long b){
    long long s = 1;
    while (b > 0) {
        if (b & 1)s = s * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return s;
}
void init() {
    int n = maxn - 1;
    fac[0] = 1;
    for (int i = 1; i <= n; ++i)
        fac[i] = 1ll * fac[i - 1] * i % MOD;
    invfac[n] = qpow(fac[n], MOD - 2);
    for (int i = n - 1; i >= 0; --i) {
        invfac[i] = 1ll * invfac[i + 1] * (i + 1) % MOD;
    }
}
long long comb(int n, int m) {
    if (n < m) return 0;
    return 1ll * fac[n] * invfac[m] % MOD * invfac[n - m] % MOD;
}
ll comb_rep(int n, int m){ //重複組み合わせ
  return comb(n+m-1, m);
}


int main(){
  init();
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(int i = 0; i <= min(n-1, k); i++){
    ans += comb(n, i) * comb_rep(n-i, i);
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
using namespace std;
const int mod = 1000000007;
const int N = 100005;
int abs(int x){
	if (x < 0) return -x;
	return x;
}
int main(){
	int n;
	cin>>n;
	int flag = 1; int t,x,y,tx,ty,a;
	t = tx = ty = 0;
	for (int i = 0;i < n; ++i){
		cin>>a>>x>>y;
		//printf("%d %d %d\n",a-t,abs(x - tx + y - ty),a - t - abs(x-tx + y - ty));
		if (a - t < abs(x-tx + y - ty)) flag = 0;
		else if (a - t > abs(x- tx + y- ty) && ((a - t - abs(x-tx + y - ty))%2 != 0)) flag = 0;
		tx = x,ty = y,t = a; 
	}
	if (flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  
  int N, X, T;
  int Batch = 0;
  scanf("%d %d %d", &N, &X, &T);
 
	while (N > 0){
		N -= X;
		Batch++;	
	}
  
  printf("%d", T * Batch);
  
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#define rep(n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int N;
  cin >> N;
  
  int result = 0;
  rep(N){
    int l,r;
    cin >> l >> r;
    result += r-l+1;
  }
  cout << result << endl;
}
  

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define P pair<int,int>


int main()
{
	int N, y;
	cin >> N >> y;
	const int x = 2e5;
	int cost[x];
	fill(cost, cost + x, INT_MAX);
	vector<int>d(N);
	vector<int>c(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> d[i] >> c[i];
	}
	priority_queue < P, vector<P>, greater<P> > que;
	cost[0] = 0;
	que.push(P(0, 0));
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		if (p.second == y)break;
		if (cost[p.second] < p.first)continue;
		for (int i = 0; i < N; i++)
		{
			if (p.second + d[i]<x&&cost[p.second + d[i]]>p.first + c[i])
			{
				cost[p.second + d[i]] = p.first + c[i];
				que.push(P(cost[p.second + d[i]], p.second + d[i]));
			}
			if (p.second - d[i] > 0 && cost[p.second - d[i]] > p.first + c[i])
			{
				cost[p.second - d[i]] = p.first + c[i];
				que.push(P(cost[p.second - d[i]], p.second - d[i]));
			}
		}
	}
	cout << (cost[y] == INT_MAX ? -1 : cost[y]) << endl;
}


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

int main(void)
{
    string S;
    int Q;
    cin >> S>> Q;
    vector<int> T(Q,0);
    vector<int> F(Q,0);
    vector<char> C(Q, 0);
    for(int i = 0; i < Q; i++){
        cin >> T[i];
        if(T[i] == 2){
            cin >> F[i] >> C[i];
        }
    }

    int sum = 0;
    for(int i = 0; i < Q; i++){
        sum += T[i];
        sum %= 2;
    }
    if(sum != 0){
        reverse(S.begin(), S.end());
    }

    string head = "";
    string tail = "";
    vector<int> flip(Q, 0);
    sum = 0;
    for(int i = 0; i < Q; i++){
        sum += T[Q - i - 1];
        sum %= 2;
        flip[Q - i - 1] = sum;
    }

    for(int i = 0; i < Q; i++){
        if(T[i] == 2){
            if(F[i] == 1){
                if(flip[i] == 0){
                    //head = C[i] + head;
                    head = head + C[i];
                } else {
                    tail = tail + C[i];
                }
            } else {
                if(flip[i] == 0){
                    tail = tail + C[i];
                } else {
                    // head = C[i] + head;
                    head = head + C[i];
                }
            }
        }
    }

    reverse(head.begin(), head.end());

    cout << head + S + tail << endl;

    return 0;
}


Measured memory_bytes: 7204
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n, ans = 0;
    cin >> n;
    REP(i, n){
        ll a;
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
}

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

int main(void){
    int n, k;
    int min = 0;
    int max = 0;
    int a = 0;
    cin >> n >> k;
    
    if(n / k >= 1){
        min = 1;
        max = n % k + min; 
    } else {
        min = max = 0;
    }
    cout << max - min << endl;
}

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

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

typedef long long int64;

int64 fn(int64 n) {

    if (n % 4 == 0)
        return n;
    if (n % 4 == 1)
        return 1;
    if (n % 4 == 2)
        return n + 1;
    return 0;

}

class DXORWorld {
 public:
  void solve(std::istream &in, std::ostream &out) {
      int64 a, b;
      in >> a >> b;

      int64 x = fn(b);
      int64 y = fn(a - 1);
      out << (x ^ y) << '\n';
  }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    DXORWorld solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int h = -1, w;
		cin >> h >> w;
		if (h < 0) return 0;
		vector<string> b(h);
		for (int i = 0; i < h; ++i) {
			cin >> b[i];
		}
		vector<vector<int>> d(h * w, vector<int>(h * w, 1 << 29));
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (b[i][j] != '.') continue;
				const int dx[] = { -1,1,0,0 };
				const int dy[] = { 0,0,-1,1 };
				for (int dir = 0; dir < 4; ++dir) {
					int ny = i + dy[dir], nx = j + dx[dir];
					if (ny >= 0 && ny < h && nx >= 0 && nx < w && b[ny][nx] == '.') {
						d[i * w + j][ny * w + nx] = 1;
						d[ny * w + nx][i * w + j] = 1;
					}
				}
			}
		}
		for (int k = 0; k < h * w; ++k) {
			for (int i = 0; i < h * w; ++i) {
				for (int j = 0; j < h * w; ++j) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < h * w; ++i) {
			for (int j = 0; j < h * w; ++j) {
				if (i != j && d[i][j] < (1 << 29)) {
					ans = max(ans, d[i][j]);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 896
//Decision's template
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<set>
using namespace std;

#define DP_maxn 16
#define maxn 1000000+10
#define INF 1000000007
#define mod 1000000007
#define mst(s,k) memset(s,k,sizeof(s))
#define eps 1e-12

typedef long long ll;

struct Edge{
    int from,to,dist;
    Edge(int u,int v,int d):from(u),to(v),dist(d){}
};

/*-------------------------------template End--------------------------------*/

char s[100];
int len,ans = 0,cnt = 0;

int main(){
	cin>>s;
	len = strlen(s);
	for(int i = 0;i<len;i++){
		if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G')
		{
			cnt++;
		}
		else{
			ans = max(ans,cnt);
			cnt = 0;
		}
	}
	ans = max(ans,cnt);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#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 cnt = 0;
int k;

void dfs(string s, int d, int md)
{
	if(md==d){
		cnt++;
		//cout << s << '\n';
		if(cnt==k) cout << s << '\n';
	}else{
		char st = max((char)(s.back()-1), '0');
		char en = min((char)(s.back()+1), '9');
		for(char c=st; c<=en; c++){
			dfs(s+c, d+1, md);
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> k;
	if(k<10){
		cout << k << '\n';
		return 0;
	}
	k -= 9;
	int d = 2; 
	while(cnt<k){ 
		FOR(i, 1, 10){
			dfs(to_string(i), 1, d);
		}
		d++;
	}
	return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if ((n + 1) / 2 >= k) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}



Measured memory_bytes: 256
function Main (input) {
  input = input.split(" ").map(inp => parseInt(inp, 10));
  console.log(gcd(input[0], input[1]));
}
function gcd (a,b) {
  var g = (n, m) => m ? g(m, n % m) : n;
  return a * b / g(a, b);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    cout << setprecision(20);
    double n;
    cin >> n;
    double c = 2* acos(-1) * n;
    cout << c << '\n'; 
}

Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>

int main(void)
{
    long long x, y;
    std::cin >> x >> y;
    if(x % y)
    {
        printf("%lld\n", x);
        return 0;
    }
    std::cout << -1 << std::endl;
    return 0;
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cuma = [0]
cumb  = [0]
for a in A:
    cuma.append(cuma[-1] + a)
for b in B:
    cumb.append(cumb[-1] + b)
from bisect import bisect_left
ans = 0
for i in range(n+1):
    if k < cuma[i]: continue
    idx = bisect_left(cumb, k - cuma[i] + 1)
    ans = max(ans, i + idx - 1)
for j in range(m+1):
    if k < cumb[j]: continue
    idx = bisect_left(cuma, k - cumb[j] + 1)
    ans = max(ans, j + idx - 1)
print(ans)

Measured memory_bytes: 47372
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S,T = LS2(),LS2()
a,b = len(S),len(T)

ans = 1000
for i in range(a-b+1):
    x = 0
    for j in range(b):
        if S[i+j] != T[j]:
            x += 1
    ans = min(ans,x)
print(ans)


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

int x[1000][5];//0=left,1=right,2=parent,3=sibling;

void S1(int u){
	if(u==-1){
		return;
	}
	cout<<' '<<u;
	S1(x[u][0]);
	S1(x[u][1]);
}

void S2(int u){
	if(u==-1){
		return;
	}
	S2(x[u][0]);
	cout<<' '<<u;
	S2(x[u][1]);
}

void S3(int u){
	if(u==-1){
		return;
	}
	S3(x[u][0]);
	S3(x[u][1]);
	cout<<' '<<u;
}

int main(){
	memset(x,-1,sizeof(x));
	int n,a,c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>x[a][0]>>x[a][1];
		x[x[a][0]][2]=a;
		x[x[a][1]][2]=a;
		x[x[a][0]][3]=x[a][1];
		x[x[a][1]][3]=x[a][0];
	}
	cout<<"Preorder"<<endl;
	for(int i=0;i<n;i++){
		if(x[i][2]==-1){
			c=i;
			break;
		}
	}
	S1(c);cout<<endl;
	cout<<"Inorder"<<endl;
	S2(c);cout<<endl;
	cout<<"Postorder"<<endl;
	S3(c);cout<<endl;
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string> 
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;

int main(){
   int n;cin>>n;string s;cin>>s;int ans=0;
   for(int i=0;i<n-2;i++){
       if(s.substr(i,3)=="ABC")ans++;
   }
   cout<<ans;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    ll a;
    a=s.size();
    int b=atoi(s.c_str());
    ll count1=0,count2=0;
    for(int i=0;i<a;i++){
        if(i%2==0){
            if(s[i]=='1')count1++;
            else count2++;
        }
        else{
          if(s[i]=='0')count1++;
            else count2++;  
        }
    }
        if(count1<count2)cout<<count1<<endl;
        else cout<<count2<<endl;
    
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int cx,cy,x,y;
string s;
int n;
vector<int>X,Y;
bitset<10005>B;
bool ok(vector<int>vec,int num){
	B.reset();
	B[0] = 1;
	int sum = 0;
	rep(i,vec.size()){
		B |= (B<<vec[i]);
		sum += vec[i];
	}
	rep(i,sum+1){
		if(sum-i*2 == num && B[i]) return 1;
	}
	return 0;
}
int main(){
	cin>>s>>x>>y; n = s.size();
	int cur = 0;
	bool beg = 0;
	rep(i,n){
		if(s[i] == 'F'){
		    if(beg) (cur==0?X:Y).back()++;
		    else x--;
		}
		else{
		    cur ^= 1;
		    beg = 1;
		    (cur==0?X:Y).pb(0);
		}
	}
	if(ok(X,x) && ok(Y,y)) puts("Yes"); 
	else puts("No");
}


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

#include <atcoder/all>

using namespace std;

using namespace atcoder;

int main() {
  int n, q;
  cin >> n >> q;
  dsu d(n);
  for (int i = 0; i < q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      d.merge(u, v);
    } else {
      cout << d.same(u, v) << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num_of_cells_on_one_side;
  int num_whole_cells;
  int num_black_cells;
  int num_white_cells;
  
  cin >> num_of_cells_on_one_side;
  cin >> num_black_cells;
  num_whole_cells = num_of_cells_on_one_side * num_of_cells_on_one_side;
  num_white_cells = num_whole_cells - num_black_cells;
  
  cout << num_white_cells << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    ll y;cin>>y;
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=n-i;j++){
            ll k=n-i-j;
            if(i*10000+j*5000+k*1000==y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n;cin >> n;
	vector<ll> v(n);
	REP(i, n)cin >> v[i];

	ll ans = 0;
	REP(i, n){
		REP(j, i){
			REP(k, j){
				if(v[i] == v[j])continue;
				if(v[i] == v[k])continue;
				if(v[k] == v[j])continue;
				if(v[i] + v[j] <= v[k])continue;
				if(v[i] + v[k] <= v[j])continue;
				if(v[k] + v[j] <= v[i])continue;
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

long long lcm(long long a , long long b) {
    return (a * 1ll * b) / __gcd(a , b);
}


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

    long long a , b , c , d;
    cin >> a >> b >> c >> d;

    long long ans = b - a + 1;
    ans -= b / c - (a - 1) / c;
    ans -= b / d - (a - 1) / d;
    ans += b / lcm(c , d) - (a - 1) / lcm(c , d);
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long

int main()
{
    set<string> st;
    int N;
    string c, v;

    cin >> N;
    REP(i, N)
    {
        cin >> c >> v;
        if(c.compare("insert") == 0)
        {
            st.insert(v);
        }
        else if(c.compare("find") == 0)
        {
            if(st.find(v) != st.end()) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>x(N);
	rep(i, N) {
		cin >> x.at(i);
	}
	int answer = 0;
	rep(i, N) {
		answer += min(abs(x.at(i) - 0), abs(K - x.at(i))) * 2;
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 105;
int n;
int a[maxn];

int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        scanf("%d", &a[i]);
    }
    int ans = 1e9;
    for(int i = -100;i <= 100;i++){
        int sum = 0;
        for(int j = 1;j <= n;j++){
            sum += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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


// # DEFINES # //
#define ll long long
#define M (ll)(1e9+7)
#define EPS 1e-9

using namespace std;

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

    ll a, b, x;

    cin >> a >> b >> x;

    if(a > x || (a+b) < x) 
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
# AOJ 1509 Rental DVD Shop NEO
# Python3 2018.7.13 bal4u

while True:
	a, b, c, d, e = map(int, input().split())
	if a == 0: break
	na, nb, nc = map(int, input().split())
	if nc >= d: ans = e*nc + b*nb + a*na
	else:
		ans = c*nc + b*nb + a*na
		k = d-nc;
		if k <= nb: nb -= k; k = 0
		else: k -= nb; nb = 0
		if k <= na: na -= k
		else: na = 0
		ans = min(ans, e*d + b*nb + a*na)
	print(ans)


Measured memory_bytes: 5596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,a,b,x;
  char s[LIMIT1];
  
  scanf("%lld %lld %lld",&a,&b,&x);
  result = (ll)floorl(b/x)-(ll)floorl((ld)(a-1)/x);
  printf("%lld", result);
  
  return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		if(a*b>c*d)
			System.out.println(a*b);
		else
			System.out.println(c*d);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int MAXN = 1000001;
vector<int> adj[MAXN];
int power(int x, int y, int p = mod){ 
    int res = 1; 
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0) {  
        if (y & 1) res = (res*x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
} 
int modFact(int n, int p = mod) 
{ 
    if (n >= p) 
        return 0; 
  
    int result = 1; 
    for (int i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result; 
} 
int32_t main(){
    SPEED;
    string s, t;
    cin >> s >> t;
    if(s == t){
        cout << "Yes" ;
    }
    else{
        int num = len(t);
        for(int i = 0; i < len(t); ++i){
            string temp = "";
            temp += t[num - 1];
            temp += t.substr(0, num - 1);
            t = temp;
            if(t == s){
                cout << "Yes" ;
                return 0;
            }
        }
        cout << "No" ;
    }
}
// check indices of loop
// check for overflow


Measured memory_bytes: 27076