akhauriyash/Code-Regression huggingface dataset:
#include <cstddef>
#include <utility>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
namespace loquat {
using vertex_t = size_t;
}
namespace loquat {
namespace edge_param {
struct to_ {
	vertex_t to;
	explicit to_(vertex_t t = 0)
		: to(t)
	{ }
};
}
namespace detail {
template <typename T, typename... Params>
struct edge_param_wrapper : public T, edge_param_wrapper<Params...> {
};
template <typename T>
struct edge_param_wrapper<T> : public T {
	template <typename U>
	explicit edge_param_wrapper(U&& x)
		: T(std::forward<U>(x))
	{ }
};
}
template <typename... Params>
struct edge : public detail::edge_param_wrapper<edge_param::to_, Params...> {
	template <typename... Args>
	explicit edge(Args&&... args)
		: detail::edge_param_wrapper<edge_param::to_, Params...>(
			std::forward<Args>(args)...)
	{ }
};
}
namespace loquat {
template <typename EdgeType>
class adjacency_list {
public:
	using edge_type = EdgeType;
	using edge_list = std::vector<edge_type>;
private:
	std::vector<std::vector<EdgeType>> m_edges;
public:
	explicit adjacency_list(size_t n)
		: m_edges(n)
	{ }
	edge_list& operator[](vertex_t u){
		return m_edges[u];
	}
	template <typename... Args>
	void add_edge(vertex_t from, Args&&... args){
		m_edges[from].emplace_back(std::forward<Args>(args)...);
	}
};
}
using namespace std;
using pii = pair<int, int>;
using edge = loquat::edge<>;
int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> mat(n, vector<int>(n));
	for(int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		--a; --b;
		mat[a][b] = mat[b][a] = 1;
	}
	loquat::adjacency_list<edge> g(n);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(!mat[i][j] && i != j){ g.add_edge(i, j); }
		}
	}
	vector<int> done(n);
	vector<pii> sizes;
	bool possible = true;
	for(int r = 0; r < n; ++r){
		if(done[r] != 0){ continue; }
		queue<int> q;
		q.push((r << 1) | 0);
		done[r] |= 1;
		pii size(0, 0);
		while(!q.empty()){
			const int u = q.front() >> 1;
			const int s = q.front() & 1;
			if(s == 0){
				++size.first;
			}else{
				++size.second;
			}
			q.pop();
			for(const auto& e : g[u]){
				const int v = e.to;
				const int mask = (1 << (s ^ 1));
				if(done[v] & mask){ continue; }
				done[v] |= mask;
				q.push((v << 1) | (s ^ 1));
			}
		}
		if(done[r] != 1){ possible = false; }
		sizes.push_back(size);
	}
	if(!possible){
		cout << "-1" << endl;
		return 0;
	}
	vector<int> dp(n + 1);
	dp[0] = 1;
	for(const auto p : sizes){
		vector<int> next(n + 1);
		for(int i = n - p.first;  i >= 0; --i){ next[i + p.first]  |= dp[i]; }
		for(int i = n - p.second; i >= 0; --i){ next[i + p.second] |= dp[i]; }
		dp = next;
	}
	int best = n * n;
	for(int i = 0; i <= n; ++i){
		if(dp[i] == 0){ continue; }
		const int a = i, b = n - i;
		best = min(best, a * (a - 1) / 2 + b * (b - 1) / 2);
	}
	cout << best << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);

  for(int i = 0; i < N; i++) {
    cin >> card.at(i);
  }
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  int alice = 0;
  int bob = 0;
  for(int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += card.at(i);
    } else {
      bob += card.at(i);
    }
  }
  cout << alice - bob << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,n) for(auto& (x) : n)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define inf 1000000000
#define llinf 1000000000000000
#define MAX 1000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
typedef pair<int,pint> P;


int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    reps(i,1,n+1){
        int point=i;
        double nowans=1.0/double(n);
        while(true){
            if(point>=k){
                ans+=nowans;
                break;
            }
            point*=2;
            nowans*=1.0/2.0;
            //cout<<point<<" "<<nowans<<endl;
        }
    }
    //cout<<ans<<endl;
    printf("%.11f\n",ans);

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
int A[3];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);

    if(A[0] == A[1] && A[0] == A[2]){
        cout<<0<<endl;
    }else if((A[2] - A[0]) == (A[2] - A[1])){
        cout<<A[2] - A[0]<<endl;
    }else{
        int a = A[2] - A[0];    //大きい
        int b = A[2] - A[1];

        int ans = b;

        if((a - b) % 2 == 0){
            ans += ((a - b)+1)/2;
        }else{
            ans += ((a - b)+1)/2 + 1;
        }

        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
def find(H1,M1,H2,M2,K):
    left = H1*60+M1
    right = H2*60+M2
    remain = right-left-K
    return max(remain,0)
H1,M1,H2,M2,K = list(map(int,input().strip().split()))
print(find(H1,M1,H2,M2,K))

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

using namespace std;

typedef long long ll;

ll D[101010], dp[101010];
ll T1[303030], T2[303030];
ll n, t, sz;

void update(ll* T, ll p, ll v)
{
	p += sz;
	T[p] = v;
	
	for(p>>=1;p;p>>=1){
		T[p] = min(T[p<<1], T[p<<1|1]);
	}
}

ll get_min(ll* T, ll l, ll r)
{
	ll ret = 1e18;
	l += sz, r += sz;
	
	for(;l<r;){
		if(l & 1) ret = min(ret, T[l]);
		if(~r & 1) ret = min(ret, T[r]);
		l = l+1>>1;
		r = r-1>>1;
	}
	if(l == r) ret = min(ret, T[l]);
	
	return ret;
}

int main()
{
	ll i, j;
	
	scanf("%lld", &n);
	scanf("%lld%lld", D+n+1, &t);
	
	for(i=1;i<=n;i++) scanf("%lld", D+i);
	
	for(sz=1;sz<=n;sz<<=1);
	
	for(i=1;i<=sz+n;i++){
		T1[i] = T2[i] = 1e18;
	}
	
	update(T1, 1, 0 - 2*D[1]);
	update(T2, 1, 0);
	for(i=1,j=1;i<=n;i++){
		for(;2 * (D[i]-D[j]) > t;j++);
		dp[i] = min(get_min(T1, 1, j-1) + 3*D[i], get_min(T2, j, i) + t + D[i]);
		update(T1, i+1, dp[i] - D[i] - 2*D[i+1]);
		update(T2, i+1, dp[i] - D[i]);
	}
	
	printf("%lld\n",dp[n] + D[n+1] - D[n]);
	
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    ll ans = 0;
    sort(X.begin(), X.end());
    ll p = round(accumulate(X.begin(), X.end(), 0.) / N);
    rep(i, N) {
        ans += abs(X[i] - p) * abs(X[i] - p);
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x;
    cin>>n>>d>>x;
    int a[110],wa=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(d%a[i]==0){
            wa=wa+(d/a[i]);
        }else{
            wa=wa+(d/a[i])+1;
        }
    }
    cout<<wa+x<<'\n';
    return(0);
}

Measured memory_bytes: 256
n = int(input())
h = [int(x) for x in input().split(' ')]

cnt = 0
a = 0
for c in range(n-1) :
    if (h[c] >= h[c+1]) :
        cnt += 1
    else :
        if a < cnt :
            a = cnt
        cnt = 0

if a < cnt :
    a = cnt


print(a)

Measured memory_bytes: 14252
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
s = inp.shift()
a = 700
a += s[0] == 'o' ? 100 : 0
a += s[1] == 'o' ? 100 : 0
a += s[2] == 'o' ? 100 : 0
console.log(a)

Measured memory_bytes: 21064
#include <stdio.h>


int min(int x, int y)
{
    return x < y? x: y;
}

int main(void)
{
    int h, w;
    int c[10][10];
    long long d[10];
    scanf("%d%d", &h, &w);
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            scanf("%d", &c[i][j]);
        }
    }
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    for (int i = 0; i < 10; i++) {
        d[i] = c[i][1];
    }
    long long ans = 0LL;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int a;
            scanf("%d", &a);
            if (~a) ans += d[a];
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007
#define tp tuple<ll,ll,ll>

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	if ((A - B) % 2 == 0) {
		ll U = (B - A) / 2;
		cout << U << endl;
	}
	else {
		ll S = A + (B - A - 1) / 2;
		ll T = N - B + 1 + (B - A - 1) / 2;
		cout << min(S, T) << endl;
	}
}

Measured memory_bytes: 256
def main():
    # N <= 4000
    # if full search, O(4000^3) = O(10^10). it's not realistic choice.
    N = int(input())
    S = input()

    count = 0
    for i in range(N):
        first = S[i]
        for j in range(i+1, N):
            second = S[j]
            if first == second:
                continue
            else:
                for k in range(j+1, N):
                    third = S[k]
                    if (first == third
                        or second == third):
                            continue
                    else:
                        if j - i == k - j:
                            continue
                        else:
                            count += 1

    print(count)


class BIT:

    def __init__(self, x):
        """
        Args:
            x (list)
        """
        len_array = len(x)
        self.tree = [0] * (len_array + 1)
        
        # update BIT
        for i, _x in enumerate(x, 1):
            while i <= len_array:
                self.tree[i] += _x
                i += i&-i

    def __call__(self, i, j):
        """
        return the sum from i to j including i and j.
        """
        ret = self.cumsum(j) - self.cumsum(i-1)
        return ret

    def cumsum(self, i):
        """
        cumulative sum from 1 to i.
        """
        ret = 0
        while i > 0:
            ret += self.tree[i]
            i -= i&-i
        return ret


def main():
    # count first
    # calc the combinations
    # create three BIT and count the num
    # if S[0] == 'R', S[1] == 'G', then I have to count the number of 'B' in S[3:].
    # O(4000 * 4000 * log4000) = O(10^8). it's gonna be a realistic choice.
    N = int(input())
    S = input()

    BIT_R = [0] * N
    BIT_G = [0] * N
    BIT_B = [0] * N
    for i, s in enumerate(S):
        if s == 'R':
            BIT_R[i] = 1
        elif s == 'G':
            BIT_G[i] = 1
        else:
            BIT_B[i] = 1
    BIT_R = BIT(BIT_R)
    BIT_G = BIT(BIT_G)
    BIT_B = BIT(BIT_B)

    count = 0
    for i in range(N):
        first = S[i]
        for j in range(i+1, N):
            second = S[j]
            if first == second:
                continue
            else:
                exclude_i = 2 * j - i
                if {first, second} == {'R', 'G'}:
                    _count = BIT_B(j+1, N)
                    if (exclude_i < N 
                        and S[exclude_i] == 'B'):
                        _count -= 1
                    
                elif {first, second} == {'R', 'B'}:
                    _count = BIT_G(j+1, N)
                    if (exclude_i < N 
                        and S[exclude_i] == 'G'):
                        _count -= 1

                else:
                    _count = BIT_R(j+1, N)
                    if (exclude_i < N 
                        and S[exclude_i] == 'R'):
                        _count -= 1
                
                count += _count

    print(count)


if __name__=='__main__':
    main()


Measured memory_bytes: 75072
input = gets(nil).chomp

def bottom(s)
  return s if s.size == 1
  bs = []
  s.split("").each_cons(2) do |a, b|
    bs.push ((a.to_i + b.to_i) % 10).to_s
  end
  return bottom(bs.join) if bs.size > 1
  bs.join
end

input.split("\n").each do |line|
  puts bottom(line)
end

Measured memory_bytes: 6112
#include <iostream>
#include <vector>
#include <algorithm> //sort,二分探査など
//#include<bitset>
//#include<cmath>//pow,logなど
//#include<deque>
//#include<functional>
//#include<iterator>
//#include<map>
//#include<numeric>//gcd,lcm
//#include<queue>
//#include<set>
//#include<stack>
//#include<string>
//#include<utility>//pair

//QCFium法
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

//浮動小数点処理高速化
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;

constexpr i64 INF = 1010000000000000017LL;
constexpr u64 MOD = 1000000007LL;
constexpr f80 PI = 3.14159265358979323846;

#define _overload3(_1, _2, _3, name, ...) name
#define repi(i, start, end) for (int i = (int)(start); i < (int)(end); ++i)
#define _rep(i, n) repi(i, 0, n)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(i, start, end) for (int i = (int)(start); i > (int)(end); --i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>

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 <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
  rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
  for (T &in : v)
    is >> in;
  return is;
}

//sort(rng(P),[](const vi &a, const vi &b){return a[1]<b[1];});

void Main()
{
  i64 N;
  cin >> N;
  vv(i64) xy(N, v(i64)(2));
  cin >> xy;

  i64 ans = -1 * INF;

  i64 l = INF;
  i64 r = -1 * INF;
  rep(i, N)
  {
    chmax(r, xy[i][0] + xy[i][1]);
    chmin(l, xy[i][0] + xy[i][1]);
  }
  chmax(ans, r - l);

  l = INF;
  r = -1 * INF;
  rep(i, N)
  {
    chmax(r, xy[i][0] - xy[i][1]);
    chmin(l, xy[i][0] - xy[i][1]);
  }
  chmax(ans, r - l);

  l = INF;
  r = -1 * INF;
  rep(i, N)
  {
    chmax(r, -1 * xy[i][0] + xy[i][1]);
    chmin(l, -1 * xy[i][0] + xy[i][1]);
  }
  chmax(ans, r - l);

  l = INF;
  r = -1 * INF;
  rep(i, N)
  {
    chmax(r, -1 * xy[i][0] - xy[i][1]);
    chmin(l, -1 * xy[i][0] - xy[i][1]);
  }
  chmax(ans, r - l);

  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //  cout << fixed << setprecision(15);
  Main();
}

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

int main(void){
    string s; cin >> s;
    int i=0;
    while(i<s.size()){
        if(s.substr(i,6)=="eraser") i += 6;
        else if(s.substr(i,5)=="erase") i += 5;
        else if(s.substr(i,7)=="dreamer" && s.substr(i+5,5)!="erase") i += 7;
        else if(s.substr(i,5)=="dream") i += 5;
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
N=int(input())

m = -1
ans = None
for i in range(N):
    j = i+1
    sum = 0
    while True:
        if j%2 == 0:
            j //= 2
            sum+=1
        else:
            break
    if sum > m:
        m = sum
        ans = i+1

print(ans)

Measured memory_bytes: 61912
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;

#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second

int a, b;

int main() {
    cin >> a >> b;
    for (int i = 0; i <= 1000000; i++) {
        double now = i;
        if ((int)(now*0.08) == a && (int)(now*0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 384
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#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))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element : vec) {
        is >> element;
    }
    return is;
}
template <class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main(std::istream &in, std::ostream &out) {
    int K, N;
    in >> K >> N;
    vi a(N);
    cin >> a;

    int diff = K - a[N - 1] + a[0];
    REP(i, N - 1) {
        chmax(diff, a[i + 1] - a[i]);
    }
    out << K - diff;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    Main(in, out);
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 4764
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    int result = 0;
    for (int i = 0; i < N; i++) {
        int total = C;
        int A;
        for (int j = 0; j < M; j++) {
            cin >> A;
            total += B[j] * A;
        }
        // cout << total << endl;
        if (total > 0) {
            result++;
        }
    }

    cout << result << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int tot=0;
    FOR(i,1,n+1)
    {
        // cout << "i: " << i << " " << (int)log10(i) << endl;
        if(((int)log10(i))%2==0)
        {
            tot++;
            // if(pow(10,((int)log10(i)))==i)
                // tot--;
        }
        // cout << tot << endl;
    }
    cout << tot;

    return 0;
}


Measured memory_bytes: 512
I=Hash["A",0,"B",1,"C",2,"D",4,"E",5,"F",6,"G",8,"H",9,"I",10]
$<.each{|p|p.chop.chars.each_cons(2){|f,t|d=(I[f]-I[t]).abs;p=nil if d!=1&&d!=4};puts p if p}

Measured memory_bytes: 6104
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	int A, B, X;
	cin >> X >> A >> B;
	if (A >= B) {
		cout << "delicious" << endl;
	}
	else if (A + X >= B) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
	return 0;

}

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

using namespace std;

int n;

int sec[100010];
int tr[100010<<2];

void update(int x)
{
    tr[x]=__gcd(tr[x<<1],tr[x<<1|1]);
}

void build(int now,int nl,int nr)
{
    if(nl==nr)
    {
        tr[now]=sec[nl];
        return;
    }
    int mid=nl+nr>>1;
    build(now<<1,nl,mid);
    build(now<<1|1,mid+1,nr);
    update(now);
}

int query(int now,int nl,int nr,int ql,int qr)
{
    if(nl>=ql&&nr<=qr)
    {
        return tr[now];
    }
    int mid=nl+nr>>1;
    if(qr<=mid) return query(now<<1,nl,mid,ql,qr);
    else if(ql>mid) return query(now<<1|1,mid+1,nr,ql,qr);
    else return __gcd(query(now<<1,nl,mid,ql,qr),query(now<<1|1,mid+1,nr,ql,qr));
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>sec[i];
    }
    build(1,1,n);
    int ans=0;
    for(int i=2;i<n;i++)
    {
        ans=max(ans,__gcd(query(1,1,n,1,i-1),query(1,1,n,i+1,n)));
    }
    ans=max(ans,query(1,1,n,2,n));
    ans=max(ans,query(1,1,n,1,n-1));
    cout<<ans<<'\n';
}


Measured memory_bytes: 1664
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int solve (int n, int q, string s, char [2] [] orders)
{
	int lo = 0;
	int hi = s.length.to !(int) - 1;

	int go (int pos)
	{
		foreach (const ref order; orders)
		{
			if (order[0] == s[pos])
			{
				pos += ((order[1] == 'L') ? -1 : +1);
			}
		}
		return pos;
	}

	int lo1 = lo;
	int hi1 = hi;
	while (lo1 < hi1)
	{
		int me1 = (lo1 + hi1 + 1) / 2;
		if (go (me1) == 0)
		{
			lo1 = me1;
		}
		else
		{
			hi1 = me1 - 1;
		}
	}

	int lo2 = lo;
	int hi2 = hi;
	while (lo2 < hi2)
	{
		int me2 = (lo2 + hi2 + 0) / 2;
		if (go (me2) == hi)
		{
			hi2 = me2;
		}
		else
		{
			lo2 = me2 + 1;
		}
	}
	return max (0, lo2 - lo1 - 1);
}

void main ()
{
	int n, q;
	while (readf (" %s %s", &n, &q) > 0)
	{
		readln;
		auto s = readln.strip;
		s = '*' ~ s ~ '*';
		auto orders = new char [2] [q];
		foreach (ref order; orders)
		{
			readf (" %c %c", &order[0], &order[1]);
		}
		writeln (solve (n, q, s, orders));
	}
}


Measured memory_bytes: 3196
# coding: utf-8

a, b, c = map(int, raw_input().split())
cnt = 0

if a == b and b == c:
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        print -1
    else:
        print 0
    exit()

while True:
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        cnt += 1
        a_t = a / 2
        b_t = b / 2
        c_t = c / 2
        a = b_t + c_t
        b = a_t + c_t
        c = a_t + b_t
    else:
        break

print cnt


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
    string S; cin >> S;
    int sizeS = S.size();
    rep(i,sizeS) {
        cout << 'x';
    }
    cout << endl;

}

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

int main(){
  unsigned int N;
  std::cin >> N;
  std::vector<unsigned int> H(N,0u);
  for(auto& h: H){
    std::cin >> h;
  }
  unsigned int max = 0u;
  unsigned int pos = 0u;
  for(unsigned int i = 1; i < N; ++i){
    if(H[i-1] >= H[i]){
      ++pos;
      if(max < pos){
	max = pos;
      }
    }
    else{
      if(max < pos or max == 0u){
	max = pos;
      }
      pos = 0u;
    }
  }
  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 640
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=2000002;

void solve(){
	vector<int>a(3);
	cin>>a;
	sort(all(a));	
	if(a[0]==a[1]&&a[1]!=a[2]){
		cout<<"Yes";
	}
	else if(a[0]!=a[1]&&a[1]==a[2]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}	
}  
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


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

int main() {
    int n; cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    map<pair<int, int>, int> d;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            pair<int, int> p = make_pair(x[i] - x[j], y[i] - y[j]);
            d[p] += 1;
        }
    }
    int counter = 0;
    for (auto it = d.begin(); it != d.end(); it++) {
        counter = max(counter, (*it).second);
    }
    cout << n - counter << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

string shuffle(string str, int h) {
	string head = str.substr(0, h);
	string tail = str.substr(h, str.size() - h);
	return tail + head;
}

int main()
{
	string cards;
	int m, h;

	while (1) {
		cin >> cards;
		if (cards == "-")break;

		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> h;
			cards = shuffle(cards, h);
		}
		cout << cards << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

char S[123];
int K;

int main() {

	scanf("%s%d", S, &K);

	int l = strlen(S);

	char cc = S[0];
	rep(i, l + 1) {
		if (i == l) {
			printf("%lld\n", (ll)l * K / 2);
			return 0;
		}
		if (cc != S[i]) break;
	}

	ll count = 0, add = 0;
	if (S[0] == S[l - 1]) {
		for (int t = 0; S[t] == cc; ++t, ++count) S[t] = t % 2;
		add += count / 2;
		int p = count;
		for (int t = l - 1; S[t] == cc; --t, ++count) S[t] = t % 2 + 2;
		add += (count - p) / 2;
	}

	ll c = 0;
	rep(i, l - 1) {
		if (S[i] == S[i + 1]) {
			S[i + 1] = 0;
			c++;
		}
	}


	printf("%lld\n", c * K + add + (count / 2) * (K - 1));


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>
typedef long long LL;
#define rep(i,N) for(int i=0;i<(LL)N;i++)
int compare(const int*a,const int*b){if(*a<*b)return -1;else if(*a==*b)return 0;else return 1;}
const int sz=1<<17;
inline char CH()
{
  static char buf[1<<17],*c1=buf+sz,c2;
  if(c1-buf==sz)fread_unlocked(buf,1,sz,stdin),c1=buf;
  return *c1++;
}
inline LL IN(void)
{
  LL x=0;short f=0,c=CH();
  while(c<48||c>57)f^=c==45,c=CH();
  while(c>47&&c<58)x=x*10+c-48,c=CH();
  return f?-x:x;
}
signed main(void)
{
  int N,NG,OK,BASE,minus;
  LL K,L=-pow(16,16)/16,M,R=LLONG_MAX/3,count;
  N=IN(),K=IN();
  int A[N];
  rep(i,N)A[i]=IN();
  qsort(A,N,sizeof(int),(int(*)(const void*,const void*))compare);
  while(R-L>1)
  {
    M=(L+R)/2,count=0;
    rep(i,N)
    {
      NG=i,OK=N,minus=(A[i]<0);
      while(OK-NG>1)
      {
        BASE=(NG+OK)/2;
        if((LL)A[i]*A[BASE]<=M){if(minus)OK=BASE;else NG=BASE;}
        else{if(minus)NG=BASE;else OK=BASE;}
      }
      count+=(minus)?N-OK:NG-i;
    }
    if(count<K)L=M;else R=M;
  }
  return printf("%lld\n",R),0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------


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

	int n,a;
	cin>>n>>a;
	cout<<n*n-a<<endl;

	return 0;
}


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

auto trace = [&](vector<int> A) {
    for (size_t i = 0; i < A.size(); ++i) {
        cout << A[i];
        if (i == A.size() - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
};

void insertionSort(vector<int> &A, int N) {
    trace(A);
    for (int i = 1; i < N; ++i) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A);
    }
}

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

    int loop;
    cin >> loop;
    vector<int> vi(loop);
    rep(i, loop) cin >> vi[i];
    insertionSort(vi, loop);
    return 0;
}



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

class probe {
public:
	int x, y, n, m, d;
	probe() {
		x = y = n = m = d = 0;
	}
	probe(int _n ,int _m) {
		n = _n;
		m = _m;
		x = y = 0;
		d = 1;
	}
	void next() {
		if (d == 1) {
			if (x == n-1) {
				y += 1;
				d = -1;
			} else {
				x ++;
			}
		} else {
			if (!x) {
				y += 1;
				d = 1;
			} else {
				x --;
			}
		}
	}
};

int main () {
	int n, m, c;
	scanf ("%d %d %d", &n, &m, &c);

	int b[n][m];
	int a;
	probe x = probe(n, m);

	for (int i=1;i<=c;i++) {
		scanf ("%d", &a);
		while (a--) {
			b[x.x][x.y] = i;
			x.next();
		}
	}

	for (int i=0;i<n;i++) {
		for (int j=0;j<m;j++) {
			printf ("%d ",b[i][j]);
		}
		printf ("\n");
	}

	return 0;
}

Measured memory_bytes: 384
n,m,k=map(int,input().split())
arr=list(map(int,input().split()))
brr=list(map(int,input().split()))

sumA=sum(arr)
bpointer=0
ans=0
sumB=0
for i in range(len(arr),-1,-1):
    if i<n:
        sumA-=arr[i]
    if sumA<=k:
        while bpointer<m and sumA+sumB+brr[bpointer]<=k:
            sumB+=brr[bpointer]
            bpointer+=1
        ans=max(ans,i+bpointer)
print(ans)


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

inline void swap(int *a, int *b){ int t = *a; *a = *b; *b = t; }
template <class C>
void print_container(C con)
{
  int n=con.size();
  for (int i=0; i<con.size(); i++)
  {
    cout << con[i];
    if (i<n-1) cout << ' ';
  }
  cout << endl;
}

int main()
{
  int n;
  int a;
  vector<int> A;

  cin >> n;
  for (int i = 0; i<n; i++)
  {
    cin >> a;
    A.push_back(a);
  }
  print_container(A);
  for (int i = 1; i<n; i++)
  {
    int key = A[i];
    int j = i-1;
    while ((j>=0) && (A[j]>key))
    {
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
    print_container(A);
  }
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int64_t> x(n);
  vector<int64_t> y(n);
  int p;
  int64_t f=0;
  for(int i=0;i<n;i++){
    cin>>x.at(i)>>y.at(i);
    if(i==0)
      p=abs(x.at(0)+y.at(0))%2;
    else if(p!=abs(x.at(i)+y.at(i))%2){
      cout<<-1<<endl;
      return 0;
    }
    f=max(f,abs(x.at(i)+y.at(i)));
  }
  vector<int64_t> d;
  int64_t b=1;
  while(b<=f){
    if(p==0&&b==1)
      d.push_back(1);
    d.push_back(b);
    b*=2;
  }
  reverse(d.begin(),d.end());
  cout<<d.size()<<endl;
  for(int i=0;i<d.size();i++)
    cout<<d.at(i)<<(i+1<d.size()?" ":"");
  cout<<endl;
  for(int i=0;i<n;i++){
    for(int j=0;j<d.size();j++){
      if(y.at(i)+x.at(i)>=0){
        if(y.at(i)-x.at(i)>=0){
          cout<<'U';
          y.at(i)-=d.at(j);
        }else{
          cout<<'R';
          x.at(i)-=d.at(j);
        }
      }else{
        if(y.at(i)-x.at(i)>=0){
          cout<<'L';
          x.at(i)+=d.at(j);
        }else{
          cout<<'D';
          y.at(i)+=d.at(j);
        }
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	string S;
	cin>>S;
	int rcnt = 0;
	int lcnt = 0;
	rep(i,N){
		if(S[i] == '(')rcnt++;
		else{
			if(rcnt == 0)lcnt++;
			else {
				rcnt--;
			}
		}
	}
	string T = "";
	rep(i,lcnt){
		T.push_back('(');
	}
	S = T+S;
	rep(i,rcnt){
		S.push_back(')');
	}
	cout<<S<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a+b==c||b+c==a||c+a==b){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 9812
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


#if 1

int main()
{
	int a,b;
	scanf("%d %d", &a, &b);

	vector <string> vs;
	for (int y = 0; y < 100; ++y)
	{
		vs.push_back(string(50, '.') + string(50, '#'));
	}

	a--;
	b--;

	{
		int y = 1, x = 1;
		while (b>0)
		{
			vs[y][x] = '#';
			x += 2;
			if (x>=49)
			{
				x = 1;
				y += 2;
			}
			b--;
		}
	}

	{
		int y = 1, x = 51;
		while (a > 0)
		{
			vs[y][x] = '.';
			x += 2;
			if (x >= 99)
			{
				x = 51;
				y += 2;
			}
			a--;
		}
	}

	printf("%d %d\n", 100, 100);
	for (int y = 0; y < 100; ++y)
	{
		cout << vs[y] << endl;
	}


	return 0;
}

#elif 1

int main()
{
	int n;
	scanf("%d", &n);

	int sum = 0;
	vector <int> a;
	a.push_back(0);
	for (int i = 0; i < n; ++i)
	{
		int tmp;
		scanf("%d", &tmp);
		a.push_back(tmp);
	}
	a.push_back(0);

	for (int i = 0; i < SZ(a)-1; ++i)
	{
		sum += abs(a[i + 1] - a[i]);
	}

	for (int i = 0; i < n; ++i)
	{
		int ret = 0;
		if (a[i] <= a[i + 2])
		{
			if (INRANGE(a[i + 1], a[i], a[i + 2]))
			{
				ret = sum;
			}
			else if (a[i] > a[i + 1])
			{
				ret = - 2 * abs(a[i + 1] - a[i]) + sum;
			}
			else
			{
				ret = -2 * abs(a[i + 1] - a[i+2]) + sum;
			}
		}
		else
		{
			if (INRANGE(a[i + 1], a[i+2], a[i]))
			{
				ret = sum;
			}
			else if (a[i] < a[i + 1])
			{
				ret = -2 * abs(a[i + 1] - a[i]) + sum;
			}
			else
			{
				ret = -2 * abs(a[i + 1] - a[i + 2]) + sum;
			}

		}

		printf("%d\n", ret);
	}




	return 0;
}

#endif

Measured memory_bytes: 256
# include <iostream>
# include <cstdio>
# define int long long
using namespace std;
const int N=2e5+10;
int n,s1[N],s2[N];
int get(int pos)
{
	int l=pos,r=n,ans;
	while (l<=r) {
		int mid=(l+r)>>1;
		if ((s1[mid]-s1[pos-1])==(s2[mid]^s2[pos-1])) ans=mid,l=mid+1;
		else r=mid-1;
	}
	return ans;
}
signed main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) {
		int x; scanf("%lld",&x);
		s1[i]=s1[i-1]+x;
		s2[i]=s2[i-1]^x;
	}
	int ans=0;
	for (int i=1;i<=n;i++) ans+=get(i)-i+1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main()
{
    int w,a,b,c,d;
    cin>>w>>a>>b;
    c=a+w;
    d=b+w;
    if(c<b){
        cout<<b-c<<endl;
    }
    else if(a>d){
        cout<<a-d<<endl;
    }
    else{
        cout<<"0"<<endl;
    }
}

Measured memory_bytes: 3612
# AOJ ITP1_7_D

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    a = numinput()
    n = a[0]; m = a[1]; l = a[2]
    A = []; B = []; C = []

    for i in range(n):
        A.append(numinput())
    for j in range(m):
        B.append(numinput())

    for i in range(n):
        list = []
        for k in range(l):
            sum = 0
            for j in range(m):
                sum += A[i][j] * B[j][k]
            list.append(sum)
        C.append(list)

    for i in range(n):
        _str_ = ""
        for k in range(l - 1):
            _str_ += str(C[i][k]) + " "
        _str_ += str(C[i][l - 1])
        print(_str_)

if __name__ == "__main__":
    main()


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

int main(){
string S;
  cin>>S;
  
  sort(S.begin(), S.end());
  vector<int>count(S.size()-1);
  for(int i=0; i<S.size(); i++){
    count[S[i]]++;
  }
  bool ans=true;
  for(int i=0; i<S.size(); i++){
    if(count[S[i]]>=2){ans=false;};
  }
  
  if(!ans){cout<<"no";}
  else{cout<<"yes";}
}

Measured memory_bytes: 256
import java.util.*;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int buf = 0;
    int ans = 0;

    for(int i = Math.min(a, b); i > 0; i--){
      if(a % i == 0 && b % i == 0){
        buf += 1;
        if(buf == k){
          ans = i;
          break;
        }
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 25556
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut ps = vec![(0.0, 0, 0); n];
    for i in 0..n {
        ps[i].1 = read::<i64>();
        ps[i].2 = read::<i64>();
        ps[i].0 = (ps[i].2 as f64).atan2(ps[i].1 as f64);
    }
    ps.sort_by(|a, b| a.partial_cmp(b).unwrap());
    let mut ans = 0;
    for left in 0..n {
        let mut x = 0;
        let mut y = 0;
        for i in 0..n {
            x += ps[(left + i) % n].1;
            y += ps[(left + i) % n].2;
            ans = std::cmp::max(ans, x * x + y * y);
        }
    }
    println!("{:.12}", (ans as f64).sqrt());
}


Measured memory_bytes: 4352
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      Collections.sort(one, Comparator.reverseOrder());
      myout(one.get(0) * 10 + one.get(1) + one.get(2));
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32944
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a[101],b[101],count=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  if(n<3){
    cout<<0<<endl;
    exit(0);
  }
  sort(a,a+n);

  cout<<endl;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int u=j+1;u<n;u++){
        if((a[i]+a[j])>a[u]){
          if((a[i]!=a[j])&&(a[j]!=a[u]))count++;
        }

      }
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3572