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

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

using namespace std;
using ll = long long;
typedef pair<int, int> Pair;

const int MOD = 1000000007;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) {
  int x = a.n + b.n;
  return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
  int x = a.n - b.n;
  return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) {
  check_fact(abs(n));
  return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
  check_fact(n);
  return n < 0 ? 0 : F_[n];
}
mint R(int n) {
  check_fact(n);
  return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

int main() {
  string S;
  cin >> S;
  bool flag = true;

  for (int i = 0; i < S.length(); i++) {
    if ((i + 1) % 2 != 0) {
      if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D'))  flag = false;
      } else {
        if (!(S[i] == 'L' || S[i] == 'U' || S[i] == 'D')) flag = false;
      }
    }
  cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int R,G,B,N,ans=0;
int main(){
	scanf("%d %d %d %d",&R,&G,&B,&N);
	for(int i=0;i*R<=N;i++) for(int j=0;j*G+i*R<=N;j++) if((N-i*R-j*G)%B==0) ans++; 
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int ans = a-1;
	if(a <= b) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<long long,long long>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const long long INF = (long long)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
}

int main() {
	kekek();
	int a, b;
	cin >> a >> b;
	int kek = 1;
	int ans = 0;
	while (kek < b) {
		kek -= 1;
		kek += a;
		ans += 1;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
const int MAX = 300000;
typedef pair<int, int> P;
int n;
bool IsPrime[MAX + 1];
bool flag(int x)
{
    if (x % 7 == 1 || x % 7 == 6)
        return true;
    else
        return false;
}
bool prime(int n)
{
    vector<int> v;
    for (int i = 2; i <= n; i++)
    {
        if (!IsPrime[i])
            continue;
        if (n % i != 0)
            continue;
        if (flag(i) && flag(n / i))
        {
            for (int j = i + i; j <= MAX; j += i)
            {
                IsPrime[j] = false;
            }
            v.push_back(i);
        }
    }
    for (int i = 0; i < v.size(); i++)
    {
        if (i < v.size() - 1)
            cout << v[i] << " ";
        else
            cout << v[v.size() - 1] << endl;
    }
}

int main()
{
    while (cin >> n)
    {
        if (n == 1)
        {
            return 0;
        }
        cout << n << ": ";
        memset(IsPrime, -1, sizeof(IsPrime));
        prime(n);
    }
}


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

int main() {
    ll H, W;
    cin >> H >> W;
    ll cnt;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }

    if (H % 2 == 0) {
        cnt = H / 2 * W;
    } else {
        int yoko;
        cnt = (H / 2 + 1) * W - (W / 2);
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    int *fib;
    cin>>n;
    fib=new int[n];
    fib[0]=fib[1]=1;
    for(int i=2;i<=n;i++){
        fib[i]=fib[i-1]+fib[i-2];
    }
    cout<<fib[n]<<endl;
}


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

int main() {
	int a;
	cin>>a;
	string w[a];
	for(int i=0;i<a;i++){
		cin>>w[i];
	}
	for(int i=1;i<a;i++){
		if(w[i-1].substr(w[i-1].size()-1,1)!=w[i].substr(0,1)){
			cout<<"No"<<endl;
			return 0;
		}
		for(int j=i-1;j>=0;j--){
			if(w[i]==w[j]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<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 S = cin.Read;
            var chars = S.ToCharArray();
            var easy = true;
            for (int i = 0; i < chars.Length; i++)
            {
                var c = chars[i];
                if (i % 2 != 0)
                {
                    if (!(c == 'L' || c == 'U' || c == 'D'))
                    {
                        easy = false;
                        break;
                    }
                }
                else
                {
                    if (!(c == 'R' || c == 'U' || c == 'D'))
                    {
                        easy = false;
                        break;
                    }
                }
            }
            if (easy)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

    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: 13268
#include<bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define ll         	long long int
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,n)   	for(ll i =0;i<n;i++)
#define inf 		INT_MAX
#define pll 		pair<ll,ll>
const ll INF = 1e18;
void init(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE 
		freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
}
const ll N = 1e5 + 10;
void solve(){

	ll x,n;
	cin>>x>>n;
	unordered_map<ll,ll> hash;
	vector<ll> a(n);
	for(ll i =0;i<n;i++){
		cin>>a[i];
		hash[a[i]] = 1;
	}

	ll curleft = x;
	ll curright = x;
	while(true){

		if(hash.find(curleft) == hash.end()){
			cout<<curleft<<endl;
			return;
		}
		if(hash.find(curright) == hash.end()){
			cout<<curright<<endl;
			return;
		}
		curleft--;
		curright++;
	}

}
int main(){
	
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cstdio>

using namespace std;

const int MAX_VALUE = 200000;
int R[MAX_VALUE];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &R[i]);

  int min_val = R[0];
  int max_val = -1000000001;
  for (int j = 1; j < n; j++) {
    max_val = max(max_val, R[j] - min_val);
    min_val = min(min_val, R[j]);
  }
  printf("%d\n", max_val);
}

Measured memory_bytes: 3440
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
if n==m:
  print('Yes' if a==b else 'No')
  exit()
for i in range(n-m):
  for k in range(n-m):
    if all(b[j] in a[i+j][k:k+m+1] for j in range(m)):
      print('Yes')
      exit()
print('No')

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	var as, bs, cs []int
	for i := 0; i < N; i++ {
		as = append(as, nextInt())
	}
	for i := 0; i < N; i++ {
		bs = append(bs, nextInt())
	}
	for i := 0; i < N; i++ {
		cs = append(cs, nextInt())
	}

	sort.Ints(as)
	sort.Ints(bs)
	sort.Ints(cs)

	count := 0
	for bPos := 0; bPos < N; bPos++ {
		a := sort.Search(N, func(i int) bool {
			return as[i] >= bs[bPos]
		})
		c := sort.Search(N, func(i int) bool {
			return cs[i] > bs[bPos]
		})
		
		count += a * (N - c)
	}

	fmt.Println(count)
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n;
  cin >> n;
  string s;
  for(int i=0; i<15; i++) {
    n--;
    s.push_back('a'+n%26);
    n /= 26;
    if(n<=0) break;
  }
  reverse(s.begin(),s.end());
  cout << s << ln;


  return 0;
}

Measured memory_bytes: 3600
n = int(input())
p = list(map(int, input().split()))

count = 0

for i in range(n -2):
  a = p[i];
  b = p[i+1];
  c = p[i+2];
  if(a < b and c > b ):
     count = count + 1 
  elif(c < b and a > b ):
     count = count + 1 

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



int main()
{
        ll N;
        cin >> N;
        vll a(N);
        rep(i, 0, N) cin >> a[i];
        ll ans = 0;
        rep(i, 0, N-1) {
                if (a[i] == a[i+1]) {
                        ++ans;
                        a[i+1] = inf;
                }
        }

        cout << ans << endl;
}


Measured memory_bytes: 3632
class Dice
  def dice_s(n)
    n[0],n[1],n[4],n[5] = n[4],n[0],n[5],n[1]
    return n
  end

  def dice_e(n)
    n[0],n[2],n[3],n[5] = n[3],n[0],n[5],n[2]
    return n
  end

  def dice_w(n)
    n[0],n[2],n[3],n[5] = n[2],n[5],n[0],n[3]
    return n
  end

  def dice_n(n)
    n[0],n[1],n[4],n[5] = n[1],n[5],n[0],n[4]
    return n
  end
end

n = gets.chomp.split.map(&:to_i)
d = gets.chomp.to_s
dice = Dice.new()

d.chars{ |i|
  if i == "S"
    dice.dice_s(n)
  elsif i == "E"
    dice.dice_e(n)
  elsif i == "W"
    dice.dice_w(n)
  else
    dice.dice_n(n)
  end
}
puts n[0]

Measured memory_bytes: 8676
n=int(input())
Rt=[]
for i in range(n):
	Rt.append(int(input()))

maxv=Rt[1]-Rt[0]
minv=Rt[0]
for j in range(1,n):
	maxv=max(maxv,Rt[j]-minv)
	minv=min(minv,Rt[j])
		
print(maxv)


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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())
#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int N;
vector<int> P;

int
main()
{
  cin >> N;
  REP(i, N) { int p; cin >> p; P.push_back(p); }

  RSORT(P);
  int ans = P[0] / 2;
  REP1(i, N) { ans += P[i]; }

  cout << ans << endl;
}


Measured memory_bytes: 3608
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()
INF = 10**9 + 1


def solve():
    N, K = map(int, input().split())
    S = np.array(list(input()), dtype='str')

    if N == 1:
        print(0)
        exit()

    ri = INF
    kc = 0
    fs = S[0]
    if fs == 'R':
        nfs = 'L'
    else:
        nfs = 'R'

    for i in range(N):
        if S[i] == nfs:
            ri = min(ri, i)
        elif S[i] == fs and ri != INF:
            S[ri:i] = fs
            ri = INF
            kc += 1
            if kc == K:
                break
    else:
        if ri != INF and S[-1] == nfs:
            S[ri:N] = fs

    # print(S)

    happy = 0
    for i in range(N - 1):
        if S[i] == S[i + 1]:
            happy += 1

    print(happy)


if __name__ == '__main__':
    solve()


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
int n, a, b;

int main(){
  cin >> n >> a >> b;
  cout << min(n*a, b)<<endl;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

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

    vector<ll> d(n);
    NREP() cin >> d[i];

    sort(ALL(d));

    ll before = d[n/2 - 1];
    ll after = d[n/2];
    MSG(after - before)

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

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


long long deg(long long x) {
    int s = 0;
    while (x > 0) {
        s += x % 10;
        x /= 10;
    }
    return s;
}


vector<long long> cands(long long x) {
    vector<long long> c;
    long long pw = 1;
    for (int i = 0; i < 18; i++) {
        long long a = (x / pw % 10);
        if (a != 9) {
            c.push_back(x + pw);
        }
        pw *= 10;
    }
    return c;
}


void solve(long long K) {
    vector<long long> data;
    for (int j = 1; j <= 10000; j++) {
        long long x = j;
        for (int i = 0; i <= 15; i++) {
            if( x > 1e16) break;
            bool ok = true;
            for (auto y: cands(x)) {
                if( 1. * x / deg(x) > 1. * y / deg(y)){
                    ok = false;
                    break;
                }
            }
            if(ok){
                data.push_back(x);
            }
            x = x * 10 + 9;
        }
    }
    sort(data.begin(), data.end());
    data.erase(unique(data.begin(), data.end()), data.end());


    for(int i = 0 ; i < K ; i++){
        cout << data[i] << endl;
    }

}

int main() {
    long long K;
    scanf("%lld", &K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
# AGC017 A Biscuits

n, p = map(int, input().split())
a_list = [int(x)%2 for x in input().split()]

dp = [[0] * 2 for x in range(n+1)]
if a_list[0] == 0:
    dp[0][0] = 1
else:
    dp[0][1] = 1

for i in range(n):
    _a = a_list[i]
    if _a == 0:
        dp[i+1][0] = dp[i][0]*2
        dp[i+1][1] = dp[i][1]*2
    else:
        dp[i+1][0] = dp[i][1]+dp[i][0]
        dp[i+1][1] = dp[i][1]+dp[i][0]
        
print(dp[n][p])        

Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

#include <atcoder/string>
using namespace atcoder;

int main() {
  string s; cin >> s;
  int n = s.length();
  ll ans = 1LL * n * (n + 1) / 2;
  for (int lcp : lcp_array(s, suffix_array(s))) ans -= lcp;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 15604
#include<stdio.h>
#include<math.h>
int main(){
  while(1){
    int x,h;
    double s;
    scanf("%d\n%d\n",&x,&h);
    if(x==0&&h==0)break;
    s=sqrt(((x*x)/4.0)+(h*h));
    printf("%.6f\n",(2.0*x*s)+(x*x));
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0;
  string s;
  std::cin >> x>>y;
  if(x==y)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
}


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();
		List<Integer> list = new ArrayList<>();
		list.add(a);
		list.add(b);
		list.add(c);

		Collections.sort(list);
		System.out.println(list.get(2)-list.get(0));
		int result =0;
		// スペース区切りの整数の入力







	}
}

Measured memory_bytes: 22996
#!/usr/bin/env python3
N=int(input())
p=list(map(int,input().split()))
LL = [0] + [i for i in range(N+1)]
RR = [i+1 for i in range(N+1)] + [N+1]
E = [(v, i+1) for i, v in enumerate(p)]
E.sort()
ans=0
for v, i in E:
  r0 = RR[i]
  r1 = RR[r0]
  l0 = LL[i]
  l1 = LL[l0]
  RR[l0] = r0
  LL[r0] = l0

  ans += ((r1 - r0)*(i-l0)+(r0-i)*(l0 - l1))*v

print(ans)


Measured memory_bytes: 25608
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;

llint n, m;
bool g[705][705];
vector<llint> G[705];
llint color[705];
llint bcnt, wcnt;

vector<P> vec;
bool dp[705][705];


bool dfs(int v, int p, int c)
{
	color[v] = c;
	if(c == 1) bcnt++;
	else wcnt++;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		if(color[G[v][i]] == -c) continue;
		if(color[G[v][i]] == c) return false;
		if(!dfs(G[v][i], v, -c)) return false;
	}
	return true;
}

int main(void)
{
	cin >> n >> m;
	llint u, v;
	for(int i = 1; i <= m; i++){
		cin >> u >> v;
		g[u][v] = true;
		g[v][u] = true;
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i == j) continue;
			if(!g[i][j]) G[i].push_back(j);
		}
	}
	
	for(int i = 1; i <= n; i++){
		if(color[i]) continue;
		bcnt = wcnt = 0;
		if(!dfs(i, -1, 1)){
			cout << -1 << endl;
			return 0;
		}
		vec.push_back(P(bcnt, wcnt));
	}
	
	dp[0][0] = true;
	for(int i = 0; i < (int)vec.size(); i++){
		for(int j = 0; j <= n; j++){
			if(!dp[i][j]) continue;
			dp[i+1][j+vec[i].first] = true;
			dp[i+1][j+vec[i].second] = true;
		}
	}
	llint ans = inf;
	for(int i = 0; i <= n; i++){
		if(dp[(int)vec.size()][i]) ans = min(ans, i*(i-1)/2+(n-i)*(n-i-1)/2);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 5888
from collections import*
from bisect import*
s=input()
n=len(s)
t=input()
d=defaultdict(list)
for i,c in enumerate(s):
    d[c].append(i)
m=-1
o=0
for c in t:
    if not d[c]:
        print(-1)
        exit()
    i=bisect(d[c],m)
    if len(d[c])==i:
        o+=1
        m=d[c][0]
    else:
        m=d[c][i]
print(o*n+m+1)

Measured memory_bytes: 45936
#include <bits/stdc++.h>
 
#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
 
template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}
 
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int N, Q;
    string S;
    cin >> N >> Q >> S;
 
    vector<int> acc(N + 1);
    acc[0] = 0;
    acc[1] = 0;
    FOR(i, 1, N) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            acc[i + 1] = acc[i] + 1;
        } else {
            acc[i + 1] = acc[i];
        }
        //printf("acc[%d] = %d\n", i + 1, acc[i + 1]);
    }
    
    REP(_, Q) {
        int l, r;
        cin >> l >> r;
        l--;
        int result = acc[r] - acc[l];
        if (acc[l] + 1 == acc[l + 1]) {
            result--;
        }
        cout << result << "\n";
    }
    cout << flush;
    return 0;
}

Measured memory_bytes: 1488
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	string s;
	cin >> s;
	int n = s.size();
	rep(i, n) {
		if (s[i] != s[n - i - 1]) {
			puts("No");
			ggr
		}
	}
	for (int i = 0; i < (n - 1) / 2; i++) {
		if (s[i] != s[(n - 1) / 2 - 1 - i]) {
			puts("No");
			ggr
		}
	}
	for (int i = (n + 3) / 2-1; i < n; i++) {
		if (s[i] != s[(n + 3) / 2-1 + n - 1 - i]) {
			puts("No");
			ggr
		}
	}
	puts("Yes");
	ggr
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7;

int n, q, bit[N];
int arr[N];
vector<pair<int, int>> query[N];

void add(int i, int v) {
    for(; i < N; i += (i & -i)) bit[i] += v;
}

int getpref(int i) {
    int ret = 0;
    while(i > 0) {
        ret += bit[i];
        i -= (i & -i);
    }
    return ret;
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        scanf("%d%d", &n, &q);
        for(int i = 1; i <= n; i++) scanf("%d", &arr[i]);
        for(int i = 0; i < q; i++) {
            int l, r; scanf("%d%d", &l, &r);
            query[r].push_back({l, i});
        }
        vector<int> where(N, 0);
        vector<int> ans(q);
        for(int i = 1; i <= n; i++) {
            add(i, 1);
            if(where[arr[i]]) add(where[arr[i]], -1);
            where[arr[i]] = i;
            for(auto x : query[i]) {
                ans[x.second] = getpref(i) - getpref(x.first - 1);
            }
        }
        for(int i = 0; i < q; i++) printf("%d\n", ans[i]);
    }
    return 0;
}

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

struct range {
	int l, r;
};

int main() {
	int q;
	cin >> q;
	vector<range> side(q);
	for (int i = 0; i < q; i++)
		cin >> side[i].l >> side[i].r;
	vector<int> a(100001, 1);
	for (int i = 2; i <= 100000; i++) {
		if(a[i]==1)
		for (int j = i * 2; j <= 100000; j += i)
			a[j] = 0;
	}
	// 1が格納されているaの添え字(>=2)が素数
	vector<int> b(100001, 0);
	b[1] = 0;
	for (int i = 3; i <= 100000; i+=2) {
		b[i] = b[i - 2];
		if (a[i] == 1 && a[(i + 1) / 2] == 1)
			b[i]++;
	}
	// bの添え字(奇数)までの2017数
	for (int i = 0; i < q; i++) {
		cout << b[side[i].r] - b[side[i].l - 2] << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val a = readLine()!!.split(" ").map(String::toInt)
    val b = readLine()!!.split(" ").map(String::toInt)
    val c = readLine()!!.split(" ").map(String::toInt)


    println(abc140b(n, a, b, c))
}

fun abc140b(
    n: Int,
    a: List<Int>,
    b: List<Int>,
    c: List<Int>
): Any? {

    var sum = 0
    var last = -1
    for (e in a) {

        sum += b[e - 1]

        if (last == e - 1) {
            sum += c[e - 1 - 1]
        }

        last = e
    }

    return sum
}


Measured memory_bytes: 37996
#include "stdio.h"

#define DEBT 100000
#define INTEREST 5

int main()
{
	int n, m1;
	double debt, interest;

	debt = DEBT;
	interest = 1 + INTEREST/100.0;

	scanf("%d", &n);

	if (n > 100) return 0;

	for (int i = 0; i < n; i++){
		debt = (int)(debt * interest);

		if ((int)debt%1000 > 0) debt += 1000;
		debt -= (int)debt % 1000;
	}

	printf("%d\n", (int)debt);
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll n;
    cin >> n;
    vector<ll> num(n);
    ll mini;
    for (ll i = 0;i < n;i++) {
        cin >> num[i];
        vector<ll> bits;
        ll p = num[i];
        ll count1 = 0;
        while(p >= 0) {
            ll rem = p % 2;
            p = p / 2;
            if (rem == 0) {
                count1++;
            } else {
                break;
            }
        }
        if (i == 0) {
            mini = count1;
        } else {
            mini = min(mini,count1);
        }
    }
    cout << mini << "\n";
}


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

typedef struct InfectedComputer{
	int time;
	int s;
	int d;
	bool operator<(const InfectedComputer& right) const {
		return time < right.time;
	}
}IC;

int main(){
	int N, M, t, s, d;
	while(1){
		int count = 0;
		bool temp[20100] = {0,1};
		IC infe[20100];
		cin>>N>>M;
		if(!N&&!M)break;
		for(int i = 1; i <= M; i++)	cin>>infe[i].time>>infe[i].s>>infe[i].d;
		sort(infe,infe+M+1);
		for(int i = 1; i <= M; i++)if(temp[infe[i].s])temp[infe[i].d]=true;
		for(int i = 1; i <= N; i++)if(temp[i])count++;
		cout<<count<<endl;
	}
	return 0;
}


Measured memory_bytes: 3400
#include <stdio.h>
     
int main() {
    int n, a, b, sum=0;
    scanf("%d %d %d", &n,&a,&b);
    for (int i=1; i <= n; i++) {
        int c = 0, t = i;
        for (int j = 0; j < 5; j++) {
          c += t % 10;
          t /= 10;
        }
		if (c >= a && c <= b) {
		sum += i;
		}
    }
      
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,flag=0;
	cin>>n>>m;
	char s[n][m];
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++)
			cin>>s[i][j];
	}
	for(int i=0;i<n;i++) {
		for (int j=0;j<m;j++) {
			if(s[i][j]=='#') {
				if(s[i+1][j] == '#' || s[i][j+1] == '#' || s[i-1][j] == '#' || s[i][j-1] == '#') {}
				else flag=1;
			}
			if(flag == 1) break;
		}
		if(flag == 1) break;
	}
	if(flag == 1) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = list(map(int, input().split()))
buka = np.zeros(N, dtype=int)  # 社員iの部下の数buka[i]
for i in range(len(A)):
    buka[A[i]-1] += 1
for i in range(N):
    print(buka[i])

Measured memory_bytes: 50908
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int gcd(int x,int y){
    if(x<y) swap(x,y);
    if(!(x%y)) return y;
    else return gcd(y,x%y);
}

int main(){
    int x,y; cin>>x>>y;
    cout<<gcd(x,y)<<endl;
    return 0;
}



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

 
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int ans=MOD;
    for(int i=-100;i<=100;i++){
        int sum=0;
        rep(j,n){
            sum+=pow(a[j]-i,2);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

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

int main() {
  int n;
  cin >> n;
  VEC<int> a(n);
  REP(i, 0, n) cin >> a[i];
  sort(ALL(a));
  int ans = 0;
  for (int nibeki = 1 << 30; nibeki > 1; nibeki >>= 1) {
    // DUMP(a);
    // DUMP("***", nibeki);
    for (int left = 0, right = n - 1; left < right;) {
      if (a[left] < 1) {
        ++left;
      } else if (a[right] < 1) {
        --right;
      } else {
        int target = nibeki - a[right];

        if (target == a[left]) {
          a[left] = a[right] = -1;
          --right;
          ++left;
          ++ans;
        } else if (target < a[left]) {
          --right;
        } else if (target > a[left])
          ++left;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, i, j;
    cin >> n >> k;
    int dp[k+1], a[n];
    for(i = 0; i <= k; ++i) dp[i] = 1;
    for(i = 0; i < n; ++i) cin >> a[i];
    for(i = 1; i <= k; ++i)
        for(j = 0; j < n; ++j)
            if(a[j] <= i && dp[i-a[j]] == 1) {
                dp[i] = 0;
                break;
            }
    cout << (dp[k] ? "Second" : "First");
    return 0;
}

Measured memory_bytes: 3980
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

const int MAXN = 100000 + 100;

long long a[MAXN];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i ++)
		cin >> a[i];

	long long max = 0;
	long long ans = 0;
	for (int i = 0; i < n; i ++) {
		long long cici = (a[i] - 1LL) / (max + 1LL);
		ans += cici;
		a[i] -= (max + 1LL) * cici;
		if (cici >= 1) a[i] = 1;
		if (a[i] > max) max = a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max((decltype(b))a, b)
#define chmin(a, b) (a) = min(a, b)

class UFTree {
  vector<int> m_parent;
  vector<int> m_height;
  vector<int> m_size;

 public:
  UFTree(int size) {
    for (int i = 0; i < size; i++) {
      m_parent.push_back(i);
      m_height.push_back(0);
      m_size.push_back(1);
    }
  }

  int root(int node) {
    if (m_parent[node] == node) {
      return node;
    }
    return m_parent[node] = root(m_parent[node]);
  }
  void merge(int n0, int n1) {
    int r0 = root(n0), r1 = root(n1);
    if (r0 == r1) {
      return;
    }
    if (m_height[r0] < m_height[r1]) swap(r0, r1);
    if (m_height[r0] == m_height[r1]) m_height[r0]++;
    m_parent[r1] = r0;
    m_size[r0] += m_size[r1];
  }
  int size(int node) { return m_size[root(node)]; }
};

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

  UFTree connectivity(V);
  int cnt = 0;
  rep(i, V) {
    string s;
    cin >> s;
    rep(j, V) {
      if (s[j] == 'Y') {
        connectivity.merge(i, j);
        cnt--;
      }
    }
  }
  cnt /= 2;

  int group = 0;
  int odd = 0;
  vector<bool> is_visited(V, false);
  rep(i, V) {
    if (!is_visited[connectivity.root(i)]) {
      is_visited[connectivity.root(i)] = true;
      const int s = connectivity.size(i);
      cnt += s * (s - 1) / 2;
      group++;
      if (s % 2 == 1) {
        odd++;
      }
    }
  }

  vector<vector<vector<bool>>> dp(
      group + 1, vector<vector<bool>>(group + 1, vector<bool>(2, false)));

  irep(j, 2) { dp[2][j][1] = true; }

  for (int i = 2; i < group; i++) {
    irep(j, i + 1) {
      rep(k, 2) {
        if (j - 2 >= 0) {
          dp[i + 1][j][k] = dp[i + 1][j][k] || !dp[i][j - 2][k];
        }
        if ((i + 1 - j >= 1 && j >= 1) || i + 1 - j >= 2) {
          dp[i + 1][j][k] = dp[i + 1][j][k] || !dp[i][j][(k + 1) % 2];
        }
      }
      dp[i + 1][j][1] = dp[i + 1][j][1] || !dp[i + 1][j][0];
    }
  }

  /*cerr << group << " " << odd << " " << cnt << "\n";
  irep(i, group) {
    irep(j, i) { cerr << "(" << dp[i][j][0] << ", " << dp[i][j][1] << ") "; }
    cerr << "\n";
  }*/

  // cerr << cnt << "\n";
  cout << (dp[group][odd][cnt % 2] ? "Taro" : "Hanako") << endl;
  return 0;
}


Measured memory_bytes: 73596
import java.io.PrintWriter

fun solve(out: PrintWriter): Boolean = with(out) {
    readLine()!!
    val sumInv = readLine()!!.split(" ")
        .map{ 1/it.toDouble() }
        .sum()
    println(1/sumInv)
    return false
}

fun main(args: Array<String>) = with(PrintWriter(System.out)){
    while(solve(this));
    flush()
}

Measured memory_bytes: 36028
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll w,h,n;
    cin >> w >> h >> n;
    ll b_x=0,b_y=0,b_x2=w,b_y2=h;
    for (ll i=0;i<n;++i){
        ll x,y,a;
        cin >> x >> y >> a;
        if (a==1){
            b_x=max(b_x,x);
        }else if(a==2){
            b_x2=min(b_x2,x);
        }else if(a==3){
            b_y=max(b_y,y);
        }else{
            b_y2=min(b_y2,y);
        }
    }
    ll zero=0;
    w=b_x2-b_x;
    w=max(w,zero);
    h=b_y2-b_y;
    h=max(h,zero);
    cout << h*w << endl;
    return 0;
}



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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  vector<int> ans(n, -1);
  REP(i, n) ans[a[i]-1] = i+1;
  REP(i, n) cout << ans[i] << ' ';
  return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++) {
        if(a+1 != b) a++;
        else {
            cout << "Borys" << endl;
            return 0;
        }
        if(b-1 != a) b--;
        else {
            cout << "Alice" << endl;
            return 0;
        }
    }

    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n,x,y;
  cin >> n;
  cin >> x >> y;
  cout << min(x,y) << " ";
  cout << max((x+y)-n,0) << endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val K = in.nextInt
  def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
  def gcd(a: Int, b: Int, c: Int): Int = gcd(gcd(a, b), c)

  val gcds = for {
    a <- 1 to K
    b <- 1 to K
    c <- 1 to K
  } yield gcd(a, b, c)

  println(gcds.sum)
}

Measured memory_bytes: 103740