akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    I vec;
    REP(a,N){
        CIN(b);
        vec.push_back(b);
    }
    if(vec.size() == 1){
        COUT(1);
        return 0;
    }
    int ans = 0;
    int hoge = -1;
    if(vec.at(0) < vec.at(1)){
        hoge = 1;
    }
    if(vec.at(0) > vec.at(1)){
        hoge = 2;
    }
    if(vec.at(0) == vec.at(1)){
        hoge = -1;
    }
    REP(a,N-1){
        if(hoge == 1 && vec.at(a) > vec.at(a+1)){
            ans++;
            hoge = -1;
            continue;
        }
        if(hoge == 2 && vec.at(a) < vec.at(a+1)){
            ans++;
            hoge = -1;
            continue;
        }
        if(vec.at(a) < vec.at(a+1)){
            hoge = 1;
        }
        if(vec.at(a) > vec.at(a+1)){
            hoge = 2;
        }
    }
    COUT(ans+1);
    rt 0;
}


Measured memory_bytes: 892
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun main (str)
  (count #\1 str))


(princ (length (remove-duplicates (read-times (read)))))


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

	int N;
	cin >> N;

	vector<tuple<int, int, int>> v;
	FOR(i, 0, N) {
	    int x, y, h;
	    cin >> x >> y >> h;
        v.emplace_back(make_tuple(h, x, y));
	}
	sort(RALL(v));


	FOR(cx, 0, 101) {
	    FOR(cy, 0, 101) {

	        bool ok = true;
	        int H = abs(get<1>(v[0]) - cx) + abs(get<2>(v[0]) - cy) + get<0>(v[0]);
            FOR(i, 0, N) {
                int h, x, y;
                tie(h, x, y) = v[i];

                if (h != max(H - abs(x - cx) - abs(y - cy), 0)) {
                    ok = false;
                }
            }
            if (ok) {
                cout << cx << " " << cy << " " << H << endl;
            }
	    }
	}

	return 0;
}

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

using namespace std;

long long simulate(int N, const vector<int> &C, const vector<int> &S, const vector<int> &F, int x)
{
	long long t = 0;
	for (int i = x; i + 1 < N; ++i) {
		if (t < S[i]) {
			t = S[i];
		}
		else {
			t = (t + F[i] - 1) / F[i] * F[i];
		}
		t += C[i];
	}
	return t;
}

int main()
{
	int N;
	cin >> N;
	vector<int> C(N), S(N), F(N);
	for (int i = 0; i < N - 1; ++i) {
		cin >> C[i] >> S[i] >> F[i];
	}
	for (int i = 0; i < N; ++i) {
		cout << simulate(N, C, S, F, i) << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    cout << (1900 * M + 100 * (N - M)) * pow(2, M) << endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";

function Main(input) {
    input = input.split("\n");

    input[0] = input[0].split(" ");
    const A = parseInt(input[0][0], 10);
    const B = parseInt(input[0][1], 10);
    const T = parseInt(input[0][2], 10);

    const answer = Math.floor((T + 0.5) / A) * B;

    console.log(answer);
}

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


Measured memory_bytes: 21064
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200050;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

void Yes() {
	cout<<"Yay!"<<endl; exit(0);
}
void No() {
	cout<<":("<<endl; exit(0);
}

void solve() {
	bool found = false;
	int X; cin >> X;
	FOR(i, 1, X) {
		int rem = X - 100 * i;
		if (0 <= rem && rem <= 5 * i) {
			found = true;
		}
	}
	if (found) {
		print(1);
	}
	else print(0);
}


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

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

class Program
{
    /**
    * a1 + a2 + a3 + ... + aN = M
    * D*1 + D*1 + D*1 + ... + D*1 = ND
    * したがって、M >= ND
    * また、約数の性質として√M以下のがペアのひとつになる。
    * ※M = a*b >= a*aより導かれる
    * M >= NDとなるものは任意に構成できるので
    * M / Nの最大値を考えればよい。
    */
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var M = long.Parse(inputs[1]);

        var max = 1L;
        for (long A = 1; A * A <= M; A++)
        {
            if (M % A != 0) continue;

            // M = A * N;
            if (A * N <= M) max = Math.Max(A, max);

            long B = M / A;
            if (B * N <= M) max = Math.Max(B, max);

        }

        Console.WriteLine(max);
    }



}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;	
typedef pair<pair<int,int>,int> PP;

bool operator<(PP &a, PP &b){return a.second<b.second;}

int main(){
	int n,ma,mb;	cin>>n>>ma>>mb;
	int a[n],b[n],c[n];	for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
	vector<PP> g1, g2; //group1(n=1,2,..,n/2); group2(n= n-(n/2)+1,...,n)
	PP p;
	int M=n/2;
	//making two possible groups
	for(int i=1; i<pow(2,M); i++){
		p.first.first=0; p.first.second=0; p.second=0;
		for(int j=0; j<M; j++){
			if(i & (1<<j)){
				p.first.first+=a[j];	p.first.second+=b[j];	p.second+=c[j];
			}
		}
		g1.push_back(p);
	}
	for(int i=1; i<pow(2,n-M); i++){
		p.first.first=0; p.first.second=0; p.second=0;
		for(int j=0; j<n-M; j++){
			if(i & (1<<j)){
				p.first.first+=a[M+j];	p.first.second+=b[M+j];	p.second+=c[M+j];
			}
		}
		g2.push_back(p);
	}

	//genocide
	int border = inf;
	for(int i=0; i<g1.size(); i++){	if(ma*g1[i].first.second == mb*g1[i].first.first)	border=min(border, g1[i].second);	}
	for(int i=0; i<g2.size(); i++){	if(ma*g2[i].first.second == mb*g2[i].first.first)	border=min(border, g2[i].second);	}
	sort(g1.begin(), g1.end());
	sort(g2.begin(), g2.end());
	while(g1.size()){	if(g1[g1.size()-1].second>border) g1.pop_back(); else break;	}
	while(g2.size()){	if(g2[g2.size()-1].second>border) g2.pop_back(); else break;	}

	//subdivision
	vector<PP> g1_a, g1_b, g2_a, g2_b;
	for(int i=0;i<g1.size();i++){
		if(ma*g1[i].first.second > mb*g1[i].first.first)g1_a.push_back(g1[i]);
		if(ma*g1[i].first.second < mb*g1[i].first.first)g1_b.push_back(g1[i]);
	}
	for(int i=0;i<g2.size();i++){
		if(ma*g2[i].first.second > mb*g2[i].first.first)g2_a.push_back(g2[i]);
		if(ma*g2[i].first.second < mb*g2[i].first.first)g2_b.push_back(g2[i]);
	}

	//last check
	int d, e, f;
	for(int i=0; i<g1_a.size(); i++){
	for(int j=0; j<g2_b.size(); j++){
		e = g1_a[i].first.first		+ g2_b[j].first.first;
		f = g1_a[i].first.second	+ g2_b[j].first.second;
		d = g1_a[i].second			+ g2_b[j].second;
		if(ma*f == mb*e)	border=min(border, d);
	}}
	for(int i=0; i<g1_b.size(); i++){
	for(int j=0; j<g2_a.size(); j++){
		e = g1_b[i].first.first		+ g2_a[j].first.first;
		f = g1_b[i].first.second	+ g2_a[j].first.second;
		d = g1_b[i].second			+ g2_a[j].second;
		if(ma*f == mb*e)	border=min(border, d);
	}}

	if(border==inf) cout<<-1<<endl;
	else cout<<border<<endl;

	return 0;
}

Measured memory_bytes: 32360
import collections

n = int(input())
lst = []
for _ in range(n):
    lst.append(input())
ans = []

cnt = collections.Counter(lst).most_common()

for i in range(len(cnt)):
    if cnt[i][1]==cnt[0][1]:
        ans.append(cnt[i][0])
    else:
        break

ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 122232
#include<stdio.h>

int main(void) {
	int M, D, m, d;
	scanf("%d%d", &M, &D);
	scanf("%d%d", &m, &d);
	if (M != m && d == 1) {
		printf("1");
	}
	else {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int n,m,ans = 0;
    cin >> n >> m;
    for(int i = 1;i*i <= m;i++){
        if(m % i == 0 && i <= (m/n)){
            ans = max(ans,i);
            if(m/i <= m/n) ans = max(ans,m/i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int main()
{
    ll n, x;
    cin >> n >> x;
    ll b[100002], l[100002], r[100002];
    ll g[100002];
    P p[100002];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> b[i] >> l[i] >> r[i];
        sum += b[i] * l[i];
        g[i] = r[i] * x - (r[i] - l[i]) * b[i];
//        cout << g[i] << endl;
        p[i] = P(g[i], i);
    }
    sort(p, p + n, greater<P>());
    ll now = 0;
    ll in = 0;
    for(; in < n; in++){
        now += p[in].first;
        if(now >= sum) break;
    }
//    cout << now << " " << sum << " " << in << endl;
    ll les = (in + 1) * x;
    for(int i = 0; i < in; i++){
        now -= p[i].first;
        ll dif = sum - now;
//        cout << (dif - 1) / l[p[i].second] + 1 << " "
//             << (dif + (r[p[i].second] - l[p[i].second]) * b[p[i].second] - 1) / r[p[i].second] + 1 << endl;
        les = min(les,
                  min(in * x + (dif + l[p[i].second] - 1) / l[p[i].second],
                      in * x + (dif + (r[p[i].second] - l[p[i].second]) * b[p[i].second] + r[p[i].second] - 1) / r[p[i].second]));
        now += p[i].first;
    }
    now -= p[in].first;
    ll dif = sum - now;
    for(int i = in; i < n; i++){
        les = min(les,
                  min(in * x + (dif + l[p[i].second] - 1) / l[p[i].second],
                      in * x + (dif + (r[p[i].second] - l[p[i].second]) * b[p[i].second] + r[p[i].second] - 1) / r[p[i].second]));
    }
    cout << les << endl;
}

Measured memory_bytes: 4096
def bubble_sort(c, n):
  l = c[:]
  for i in range(n-1):
    for j in reversed(range(i+1, N)):
      if l[j][1] < l[j-1][1]:
        l[j], l[j-1] = l[j-1], l[j]
  return l

def selection_sort(c, n):
  l = c[:]
  for i in range(n):
    min_x = i
    for j in range(i, n):
      if l[j][1] < l[min_x][1]:
        min_x = j
    l[i], l[min_x] = l[min_x], l[i]
  return l

def is_stable(in_arr, out_arr, n):
  for i in range(n):
    for j in range(i+1, n):
      for a in range(n):
        for b in range(a+1, n):
          if in_arr[i][1] == in_arr[j][1] and in_arr[i] == out_arr[b] and in_arr[j] == out_arr[a]:
            return False
  return True


N = int(input())
C = list(map(list, input().split()))

bubble_sorted_list = bubble_sort(C, N)
selection_sorted_list = selection_sort(C, N)

print(" ".join(map("".join, bubble_sorted_list)))
print("Stable" if is_stable(C, bubble_sorted_list, N) else "Not stable")
print(" ".join(map("".join, selection_sorted_list)))
print("Stable" if is_stable(C, selection_sorted_list, N) else "Not stable")



Measured memory_bytes: 5608
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        string s = Console.ReadLine();
        var a = s.Where((x, y) => y % 2 == 1).All(x => x == 'L' || x == 'U' || x == 'D');
        var b = s.Where((x, y) => y % 2 == 0).All(x => x == 'R' || x == 'U' || x == 'D');
        Console.WriteLine(a && b ? "Yes" : "No");
    }
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    int n=s.size()-1;

    ll ans=0;

    rep(bit,1<<n){
       ll kari=0,sum=0;
       rep(i,n){
           if(bit&(1<<i)){
               sum+=kari*10;
               sum+=s[i]-'0';
               kari=0;
           }
           else{
               kari*=10;
               kari+=s[i]-'0';
           }
       }
       sum+=kari*10;
       sum+=s[n]-'0';

       ans+=sum;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<algorithm>
using namespace std;
const int INF=0x3f3f3f3f;
int n,u,v,a[110000],s[110000],f[110000];
int edgenum,vet[410000],Next[410000],Head[110000];
char st[110000];
void addedge(int u,int v){
    vet[++edgenum]=v;
    Next[edgenum]=Head[u];
	Head[u]=edgenum;
}
void dfs(int u,int fa){
	s[u]=a[u]; f[u]=0;
	for (int e=Head[u];e;e=Next[e]){
		if (vet[e]==fa) continue;
		dfs(vet[e],u);
		s[u]+=s[vet[e]];
		f[u]+=f[vet[e]]+s[vet[e]];
	}
}
int dfs2(int u,int fa){
	int mx=0;
	for (int e=Head[u];e;e=Next[e]){
		if (vet[e]==fa) continue;
		if (mx==0||f[vet[e]]>f[mx]) mx=vet[e];
	}
	if (mx==0) return 0;
	int k=dfs2(mx,u)+s[mx];
	if (f[u]-f[mx]-s[mx]>=k) return f[u]&1;
	else return k-(f[u]-f[mx]-s[mx]);
}

int main(){
	scanf("%d%s",&n,st+1);
	for (int i=1;i<=n;i++) a[i]=st[i]-'0';
	for (int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	int ans=INF;
	for (int i=1;i<=n;i++){
		dfs(i,0);
		if (!dfs2(i,0)) ans=min(ans,f[i]/2);
	}
	if (ans==INF) puts("-1");
	else printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2304
// Problem : 
// 			A - Rainy Season
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	string s;
	cin>>s;
	int cnt=0,m=0,i;
	for(i=0;i<s.length();i++)
	{
		if(s[i]=='R')
			cnt++;
		else
			cnt=0;
		m=max(m,cnt);
	}
	cout<<m<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


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



int main(void){
    int x,a;
    cin >> x >> a;
    if(x>=a){
        cout << "10";
    }
    else{
        cout << "0";
    }
    return 0;
}






















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

int main()
{
ll n , m ;
cin >> n >> m ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
vector<vector<ll>> v(m+1);
ll ad=0,hv=0;
rep(i,n-1){
  v[a[i]].push_back(1);
  v[a[i+1]].push_back(a[i+1]>a[i] ? -a[i+1]+a[i]:-m+a[i]-a[i+1]);
  if(a[i+1]<a[i]){
    ad+=m-a[i]+1;
    hv++;
  }
  ans+=a[i+1]>a[i] ? a[i+1]-a[i]:m-a[i]+a[i+1];
}
ll an=ans;
rep(i,m){
  ans=min(ans,an-ad+hv);
  for(auto r:v[i+1]){
    if(r==1)hv++;
    else {
      hv--;
      ad+=r;
    }
  }
  ad+=hv;
}
cout << ans << endl;
return 0;
}

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

int main(){
    long N;
    cin >> N;
    long t[100010]={}, x[100010]={}, y[100010]={};
    for(long i=1; i<=N; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    
    long dt=0, distance=0;
    bool frag=true;
    
    for(long i=0; i<N; i++){
        dt=t[i+1]-t[i];
        distance=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if(dt<distance){
            frag=false;
            break;
        }
        if((dt-distance)%2==0){
            frag=true;
            continue;
        }else{
            frag=false;
            break;
        }
    }
    
    if(frag==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

vector<long> make_divisors(long n){
    vector<long> divisors;
    for (long i=1;i<sqrt(n)+1;i++){
        if (n % i == 0){
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main(){
    long n;
    cin >> n;
    auto divisors = make_divisors(n);

    int minimum_length = 10;
    for (auto d : divisors){
        int digits_size = to_string(max(d, n / d)).size();
        if (digits_size < minimum_length){
            minimum_length = digits_size;
        }
    }    
    cout << minimum_length << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;
            var X = cin.ReadInt;
            int ans = 0;
            for (int i=0; i<=A; ++i)
            {
                for (int j=0; j<=B; ++j)
                {
                    var rem = X - 500 * i - 100 * j;
                    if (rem >= 0 & rem % 50 == 0 & rem / 50 <= C)
                        ans += 1;
                }
            }
            WriteLine(ans);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define Mod 1000000007ll
#define Val(x) ((((long long)x) % Mod + Mod) % Mod)
using namespace std;
const int maxn = 300005 * 3;
int fac[maxn];
inline int Pow(int a,int n) {
	int ret = 1;
	int base = a;
	while(n) {
		if(n & 1)	ret = Val(ret*base);
		base = Val(base*base);
		n >>= 1;
	}
	return ret;
}
inline int inv(int a) {
	return Pow(a,Mod-2);
}
inline int C(int n,int m) {
	return Val(Val(fac[n]*inv(fac[m]))*inv(fac[n-m]));
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,k;
	cin >> n >> m >> k; 

	fac[0] = 1;
	for(int i=1;i<maxn;i++)
		fac[i] = Val(fac[i-1] * i);
	
	int ans = 0 , sum = 1 , u1 = 0 , u2 = 0;
	for(int L=0;L<=m+k;L++) {
		int now = Val( Val( Val( Val(fac[L+n-1] * inv(fac[n-1])) * inv(fac[L])) * Pow(3,m+k-L)) * sum);
		ans = Val(ans + now);
		
		sum = Val(sum * 2 - C(L,u1) - C(L,L-u2));
		if(u1 + 1 <= m) {
			u1++;
			sum = Val(sum + C(L+1,u1));
		}
		if(u2 + 1 <= k) {
			u2++;
			sum = Val(sum + C(L+1,L+1-u2));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

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

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  int k;
  cin >> k;
  ll ans = 0;
  for (int a = 1; a < k + 1; a++) {
    for (int b = 1; b < k + 1; b++) {
      for (int c = 1; c < k + 1; c++) {
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  P(ans);
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int t = sc.nextInt();
		
		if(t >= X){
			System.out.println(0);
		} else {
			System.out.println(X - t);
		}

	}

}


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

int main() {
  string s, t, ans;
  int n;
  cin >> n >> s >> t;
  rep(i, n) {
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
}

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

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

    int A[m], B[m];
    int N[n];
    for (i = 0; i <= n;i++){
        N[i] = 0;
    }

    for (i = 1; i <= m; i++)
    {
        scanf("%d %d", &A[i], &B[i]);
        N[A[i]]++;
        N[B[i]]++;
        }
    for (i = 1; i <= n;i++){
        printf("%d\n", N[i]);
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
maze = ["#"*(w+2)]
white_cnt = 0
for _ in range(h):
    row = input()
    white_cnt += row.count('.')
    maze.append("#"+row+"#")
else:
    maze.append("#"*(w+2))

w += 2
h += 2
INF = 10**9
dist = [[INF]*w for _ in range(h)]
dist[1][1] = 0
next_block = deque([(1, 1)])
dirc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
cnt = 0
while next_block:
    i, j = next_block.popleft()
    for x, y in dirc:
        if maze[i+x][j+y] == '#':
            continue
        if dist[i+x][j+y] <= dist[i][j]+1:
            continue
        dist[i+x][j+y] = dist[i][j]+1
        next_block.append((i+x, j+y))


if dist[-2][-2] == INF:
    print(-1)
else:
    print(white_cnt-dist[-2][-2]-1)


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

vector<vector<int>> p;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int k = 1;
  while (k < n) k <<= 1;
  if (k == n) {
    cout << "No" << endl;
    return 0;
  } else if (n == 3) {
    cout << "Yes" << endl;
    cout << "1 2" << endl;
    cout << "2 3" << endl;
    cout << "3 4" << endl;
    cout << "4 5" << endl;
    cout << "5 6" << endl;
    return 0;
  }
  k >>= 1;
  p.resize(n * 2);
  for (int i = 0; i < k - 1; i++) {
    if (i < k - 2) {
      p[i].push_back(i + 1);
      p[i + n].push_back(i + n + 1);
    } else {
      p[i].push_back(n);
    }
  }

  p[k - 1].push_back(n);
  p[k].push_back(k - 1);
  p[k + n].push_back(0);
  p[k - 1 + n].push_back(k + n);
  map<int, int> mp;

  int sum = k;
  for (int i = n; i < k + n - 1; i++) {
    sum = sum ^ (i - n + 1);
    mp[sum] = i;
  }
  sum = (k ^ 1);
  for (int i = k - 2; i >= 0; i--) {
    sum = sum ^ (i + 1);
    mp[sum] = i;
  }
  for (int i = k + 1; i < n; i++) {
    p[i].push_back(k - 1);
    p[i + n].push_back(mp[i + 1]);
  }
  cout << "Yes" << endl;
  for (int i = 0; i < 2 * n; i++) {
    for (auto &t : p[i]) {
      cout << (i + 1) << " " << (t + 1) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 16768
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    auto calc = [&](int n, int d) {
        long long m = n / d;
        return d * (m * (m + 1) / 2);
    };

    long long res = calc(n, 1) - calc(n, 3) - calc(n, 5) + calc(n, 15);

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret = false;
            int retint = 0;
            string retstr = string.Empty;
            var ins = Console.ReadLine().Split(' ');
            var num = ins.Select(x => c2i(x)).ToList();

            var ins2 = Console.ReadLine().Split(' ');
            var numwaza = ins2.Select(x => c2i(x)).ToList();
            var HP = num[0];
            var wazasuu = num[1];

            var sumAtack = 0;
            foreach (var at in numwaza)
            {
                sumAtack += at;
            }
            retstr = (sumAtack >= HP) ? "Yes" : "No";

            Console.WriteLine(retstr);
            //Console.ReadLine();
        }
            
        static int c2i(string c) { return int.Parse(c); }
    }
}


Measured memory_bytes: 17248
/* ex7_3
   UMAboogie */
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int height,width;
  char **grid;

  
  scanf("%d %d",&height,&width); //マスのたての数、横の数を入力
  
  //各行の配列へのポインタ分のメモリ領域を確保
  grid = (char**)calloc(height, sizeof(char*));
  if(grid == NULL){
    fprintf(stderr, "memory allocation error.\n");
    exit(1);
  }

  //各行の要素分のメモリ領域を確保
  for(int i=0;i<height;i++){
    grid[i] = (char*)calloc(width, sizeof(char));
    if(grid[i] == NULL){
      fprintf(stderr, "memory allocation error.¥n");
      exit(1);
    }
  }
  
  int row_exist[100] = {0}; //その行のマスに黒があるかの真偽値を入れる配列
  int col_exist[100] = {0}; //その列のマスに黒があるかの真偽値を入れる配列

  
  for(int i = 0;i < height;i++){
    for(int j = 0;j < width;j++){
      scanf(" %c",&grid[i][j]); //(i,j)の配色を入力
      if(grid[i][j] == '#'){ //もし黒であれば、各真偽値を1とする
        row_exist[i]=1;
        col_exist[j]=1;
      }
    }
  }
  for(int i = 0;i < height;i++){
    if(row_exist[i] == 1 ){ //まず黒がある行について
      for(int j = 0;j < width;j++){
        if(col_exist[j] == 1){ //黒がある列であれば
          printf("%c",grid[i][j]); //配色を出力
        }
      }
      printf("\n"); //行ごとに改行
    }
  }
  //メモリ領域の解放（逆順）
  for(int i = 0; i < height; i++){
          free(grid[i]);
  }
  free(grid);
  
  return 0;
}


Measured memory_bytes: 1632
def calc_challenge(baggages, capacity)
  track_no = 1
  baggage_index = 0
  loaded = 0

  while (baggage_index < baggages.size) do
    loaded += baggages[baggage_index]
    if (loaded > capacity) then
      track_no += 1
      loaded = 0
    else
      baggage_index += 1
    end
  end

  return track_no
end

MAX_BAGGAGE_WEIGHT = 10000
MAX_BAGGAGE_NUM = 100000

n, k = gets.chomp.split.map(&:to_i)
baggages = []
(n).times do |i|
  baggages << gets.chomp.to_i
end

max_weight = baggages.max

puts (max_weight..(MAX_BAGGAGE_WEIGHT * MAX_BAGGAGE_NUM)).bsearch{|x|
  calc_challenge(baggages, x) <= k
}

Measured memory_bytes: 7028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long N = in.nextLong();

			long w = -1;
			for (long h = 1; h <= 3500; h++) {
				for (long n = 1; n <= 3500; n++) {
					if ((4*h*n-N*n-N*h) != 0 && (N*h*n) % (4*h*n-N*n-N*h) == 0) {
						w = (N*h*n) / (4*h*n-N*n-N*h);
						if (w >= 1) {
							out.println(h+" "+n+" "+w);
							return;
						}
					}
				}
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23508
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	int h, n;cin >> h >>  n;
	int s = 0;
	forn(i, n){int x;cin >> x; s+= x;}
	if(s>=h )cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		long ans=0,a=0,b=0,c=0;
		for(int i = 0;i<n;i++) {
			string s=sc.S;
			for(int j = 0;j<s.Length-1;j++) {
				if(s[j]=='A'&&s[j+1]=='B'){ans++;}
			}
			if(s[s.Length-1]=='A'){a++;}
			if(s[0]=='B'){b++;}
			if(s[s.Length-1]=='A'&&s[0]=='B'){c++;}
		}
		if(b==c&&a==c&&c!=0){ans--;}
		Console.WriteLine("{0}",ans+Math.Min(a,b));
	}
}
public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

using namespace std;

int main() {
  vector<int> v(3);

  cin >> v[0];
  cin >> v[1];
  cin >> v[2];

  sort(v.begin(), v.end());
  cout << (v[0] + v[1] + v[2] * 10) << endl;
}



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

#define fto(i, x, y) for(auto i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(auto i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(auto i = (x); i <= (y); i += a)
#define ftoit(it, var) for (auto it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define ff first
#define ss second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound

#define oo 1000000007
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 1000007

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

    int mm = (s[0]-'0')*10+s[1]-'0';
    int yy = (s[2]-'0')*10+s[3]-'0';

    if (1 <= mm && mm <= 12 && 1 <= yy && yy <= 12) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    if (mm == 0 && yy == 0) {
        cout << "NA" << endl;
        return 0;
    }
    if (mm == 0) {
        if (yy <= 12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
        return 0;
    }
    if (yy == 0) {
        if (mm <= 12) cout << "MMYY" << endl;
        else cout << "NA" << endl;
        return 0;
    }
    if (mm <= 12) cout << "MMYY" << endl;
    else if (yy <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int n,m;
    cin>>n>>m;
    cout<<n-m-1<<endl;
}

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

int main() {
    string s;
    cin >> s;
    regex checker("A?KIHA?BA?RA?");
    if (regex_match(s, checker)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3700
// 16:39〜16:43

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	long long a, b, x;
	long long cnt;
	cin >> a >> b >> x;
	cnt = (b / x) - (a / x);
	if(a % x == 0) cnt++;
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

#define BIG_NUM (1000'000'007)

using namespace std;

long long B[100];

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;

	cin >> N;

	for(long long i = 0; i < N; i++){
		long long x;
		cin >> x;
		long long j = 0;
		while(x > 0){
			B[j] += x & 1;
			x >>= 1;
			j++;
		}
	}

	long long ans = 0;
	for(long long i = 0; i < 100; i++){
		ans += ((((N - B[i])*B[i]%BIG_NUM) * ((long long)pow(2, i) % BIG_NUM))) % BIG_NUM;
		ans %= BIG_NUM;
	}
	cout << ans << endl;

	Never To return 0;
}


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

using namespace std;

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

    int b[n];
    for (int i = 0; i < n-1; i++)
    {
        cin >> b[i];
    }
    int a_sum = 0;

    for (int i = 0; i < n - 2; i++)
    {
        a_sum += min(b[i], b[i+1]);
    }
    a_sum += b[0];
    a_sum += b[n-2];
    cout << a_sum << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n];
    map<ll, int> mp;
    REP(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a, a + n);
    reverse(a, a + n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(mp[a[i]] <= 0) continue;
        mp[a[i]]--;
        for(ll j = 40; j > 0; j--){
            if(pow(2LL, j) - a[i] <= 0) break;
            if(mp.count(pow(2LL, j) - a[i]) && mp[pow(2LL, j) - a[i]] > 0){
                ans++;
                mp[pow(2LL, j) - a[i]]--;
                goto find;
            }
        }
        find:;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>

using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M, T;
int X[101010], Y[101010];

bitset<50000> poss[50000];
bool activ[50000];

void subtask1()
{
	for (int i = 0; i < N; ++i) poss[i].set(i);
	for (int i = 0; i < M; ++i) {
		int x = X[i], y = Y[i];
		poss[x] = poss[x] | poss[y];
		poss[y] = poss[x];
	}
	int target = -1;
	for (int i = 0; i < N; ++i) {
		if (poss[i].count() == N) {
			target = i;
			break;
		}
	}
	if (target == -1) {
		puts("-1");
		return;
	}
	for (int i = 0; i < N; ++i) activ[i] = false;
	activ[target] = true;
	string ans;
	for (int i = M - 1; i >= 0; --i) {
		int x = X[i], y = Y[i];
		if (activ[x] && !activ[y]) {
			ans.push_back('^');
		} else {
			ans.push_back('v');
		}
		if (activ[x] || activ[y]) activ[x] = activ[y] = true;
	}
	reverse(ans.begin(), ans.end());
	printf("%s\n", ans.c_str());
}

void subtask2()
{
	if (N == 2) {
		puts("-1");
		return;
	}
	vector<int> exts;
	for (int i = 0; i < M; ++i) {
		if (Y[i] <= 2) {
			exts.push_back(3 - X[i] - Y[i]);
		}
	}
	vector<int> nn(exts.size(), -1);
	for (int i = 0; i < exts.size(); ++i) {
		int p = i;
		while (p < exts.size() && exts[p] == exts[i]) ++p;
		if (p == exts.size()) break;
		for (int j = i; j < p; ++j) nn[j] = exts[p];
	}
	string ans; int loc = 0;
	for (int i = 0; i < M; ++i) {
		if (Y[i] <= 2) {
			if (nn[loc] == -1) ans.push_back('^');
			else {
				if (X[i] == nn[loc]) ans.push_back('^');
				else ans.push_back('v');
			}
			++loc;
		} else {
			ans.push_back('^');
		}
	}
	printf("%s\n", ans.c_str());
}

int main()
{
	scanf("%d%d%d", &N, &M, &T);
	for (int i = 0; i < M; ++i) {
		scanf("%d%d", X + i, Y + i);
		--X[i]; --Y[i];
	}
	if (T == 1) subtask1();
	else subtask2();
	return 0;
}


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

char str[200001];

int main(void) {
    scanf("%s",str);
    int n=strlen(str);
    for(int i=0;i<n;i++) {
        if (str[i]=='P') {
            printf("P");
        }
        else {
            printf("D");
        }
    }
}

Measured memory_bytes: 3876
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 200010
using namespace std;
int p[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		p[a]=i;
	}
	int u=n-1;
	while(u && p[u]<p[u+1]) u--;
	if(!u){puts("0");return 0;}
	int ans=1,pre=u+1;
	for(;u;u--)
	{
		if(p[pre]<=p[u] && p[u]<=p[u+1]) continue;
		if(p[u]<=p[u+1] && p[u+1]<=p[pre]) continue;
		if(p[u+1]<=p[pre] && p[pre]<=p[u]) continue;
		ans++;
		pre=u+1;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1024