akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    if(a <= 1){
        if(b <= 1) println(0)
        else println(b*(b-1)/2)
    }else{
        if(b <= 1) println(a*(a-1)/2)
        else println((a*(a-1) + b*(b-1))/2) 
    }
}

Measured memory_bytes: 38060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n;
  cin>>n;
  vector<int> r(n),l(n);
  rep(i,n)cin>>l[i]>>r[i];
  int sum=0;
  rep(i,n){
    sum+=r[i]-l[i]+1;
  }
  cout<<sum<<endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll X,Y;
    string S;
    cin >> X>>Y;

    if(Y%2==1){
        cout << "No" << endl;
    }
    else{
        ll a = 2 * X - Y / 2;
        ll b = Y / 2 - X;
        if(a<0||b<0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cmath>

int main(){
    int n;
    double x[100], y[100], d1, d2, d3, d8, t;
    scanf("%d", &n);
    for (int i = 0; i< n; i++){
        scanf("%lf", &x[i]);
    }
    for (int i = 0; i< n; i++){
        scanf("%lf", &y[i]);
    }
    d1 = d2 = d3 = d8 = 0;
    for (int i = 0; i<n; i++){
        t = std::abs(x[i] - y[i]);
        d1 += t;
        d2 += (t * t);
        d3 += (t * t * t);
        if(d8 < t){
            d8 = t;
        }
    }
    d2 = pow(d2, 1.0/2.0);
    d3 = pow(d3, 1.0/3.0);
    printf("%lf\n%lf\n%lf\n%lf\n", d1, d2, d3, d8);
    return 0;
}


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

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

	ll x = m;
	m -= 2 * n;

	if (m >= 0) cout << n + m / 4 << endl;
	else cout << x / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500010
#define INF 1e9
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N;
	cin >> N;

	vector<ll> v;
	v.push_back(1);

	ll six = 6;
	while(six <= N){
		v.push_back(six);
		six *= 6;
	}
	ll nine = 9;
	while(nine <= N){
		v.push_back(nine);
		nine *= 9;
	}

	sort(v.begin(),v.end());

	vector<ll> dp(N+1,INF);
	dp[0] = 0;
	rep(i,N){
		rep(j,v.size()){
			if(v[j] + i > N) break;
			dp[v[j]+i] = min(dp[v[j]+i], dp[i] + 1);
		}
	}
	cout << dp[N] << endl;
	return 0;
}

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

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define all(v)          v.begin(),v.end()

#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

// inline int setBit(int n,int pos) { return n = n | (1 << pos); }
// inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
// inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }

// int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
// int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// unsigned int num = rng();
// shuffle(V.begin(), V.end(), rng);

/******************************************************************************************/

const int MAX = 200010;
//const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;


inline int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
inline int mul(int a, int b) { return (a * 1LL * b) % MOD; }

int n;
vector <int> ed[MAX];

int fact[MAX];
int inv[MAX];

int bm(int a, int b) {
	if(b == 0) return 1;
	int ret = bm(a, b/2);
	ret = mul(ret, ret);
	if(b & 1) ret = mul(ret, a);
	return ret;
}

void pre() {
	fact[0] = 1;
	inv[0] = 1;
	for(int i=1;i<=n;i++) {
		fact[i] = mul(fact[i - 1], i);
		inv[i] = bm(fact[i], MOD - 2);
	}
}


int sz[MAX];
int ans[MAX];
int ways[MAX];

void dfs(int s, int p) {
	sz[s] = 1;
	ans[s] = 1;
	for(int x : ed[s]) {
		if(x == p) continue;
		dfs(x, s);
		ans[s] = mul(ans[s], ans[x]);
		ans[s] = mul(ans[s], inv[sz[x]]);
		sz[s] += sz[x];
	}
	ans[s] = mul(ans[s], fact[sz[s] - 1]);
}


void go(int s, int p, int up) {
	ways[s] = fact[n - 1];
	ways[s] = mul(ways[s], inv[n - sz[s]]);
	int tot = up;
	for(int x : ed[s]) {
		if(x == p) continue;
		tot = mul(tot, ans[x]);
		ways[s] = mul(ways[s], inv[sz[x]]); 
	}
	ways[s] = mul(ways[s], tot);
	for(int x : ed[s]) {
		if(x == p) continue;
		int send = ways[s];
		send = mul(send, inv[n - 1]);
		send = mul(send, fact[sz[x]]);
		send = mul(send, fact[n - 1 - sz[x]]);
		send = mul(send, bm(ans[x], MOD - 2));
		go(x, s, send);
	}
}


int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
	
    // freopen("in", "r", stdin);

	int u, v;
	cin >> n;
	for(int i=1;i<n;i++) {
		cin >> u >> v;
		ed[u].pb(v);
		ed[v].pb(u);
	}
	pre();
	int s = 1;
	dfs(s, -1);
	go(s, -1, 1);
	for(int i=1;i<=n;i++) cout << ways[i] << '\n';
    return 0;
}


Measured memory_bytes: 17908
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cctype>

typedef long long int ll;
using namespace std;


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a <= c) && (c <= b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = list(reversed(sorted(list(map(int, input().split())))))
q = list(reversed(sorted(list(map(int, input().split())))))
r = list(reversed(sorted(list(map(int, input().split())))))
del p[x:]
del q[y:]
l = list(reversed(sorted(p + q + r)))
print(sum(l[:x + y]))

Measured memory_bytes: 22720
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};

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

ll lcm(ll a,ll b){
    ll g =gcd(a,b);
    return a/g*b;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll n,a;
    cin>>n>>a;
    ll x[100010];
    rep(i,n){
        cin>>x[i];
    }
    sort(x,x+n);
    if(n==1){
        cout<<abs(a-x[0])<<endl;
        return 0;
    }
    ll ans=x[1]-x[0];
    rep(i,n-1){
        ans=gcd(ans,x[i+1]-x[i]);
    }
    ll s=lower_bound(x,x+n,a)-x;
    if(s==0){
        ans=gcd(ans,x[0]-a);
    }
    else if(s==n){
        ans=gcd(ans,a-x[n-1]);
    }
    else{
        ans=gcd(ans,a-x[s-1]);
        ans=gcd(ans,x[s]-a);
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  String s = sc.next();
  int count = 0;
  System.out.print(s.charAt(0));
  for (int i = 1; i < s.length()-1; i++){
    count++;
  }
  System.out.print(count);
  System.out.print(s.charAt(s.length()-1));
  }
}


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

int main(){
	string str;
	string codefes = "CODEFESTIVAL2016";
	cin >> str;
	int cnt = 0;
	for(int i = 0;i < codefes.length();i++){
		if(codefes[i] != str[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define ll long long int
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};
int D[2]={1,-1};
int main() {
int a,b,c,d,x;
cin>>x;
a=x/1000;
b=(x%1000)/100;
c=(x%100)/10;
d=(x%10);
int ans=7-a;
int n,u,m;
rep(i,0,2){
  rep(j,0,2){
    rep(k,0,2){
      if(ans==b*D[i]+c*D[j]+d*D[k]){
        n=i;
        u=j;
        m=k;
      }
    }
  }
}
char op;
if(n==1)op='-';
else op='+';
cout<<a<<op<<b;
if(u==1)op='-';
else op='+';
cout<<op<<c;
if(m==1)op='-';
else op='+';
cout<<op<<d<<"=7";
return 0;
}


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

int main(){
  int N,M,sum,S;
  cin >> N >> M;
  if(N>=M) cout << 0 << endl;
  else{
    vector<int> X(M),Y(M-1);
    for(int i=0; i<M; ++i) cin >> X.at(i);
    sort(X.begin(),X.end());
    for(int i=0; i<M-1;++i) Y.at(i)=X.at(i+1)-X.at(i);
    sort(Y.begin(),Y.end());
    reverse(Y.begin(),Y.end());
    sum=X.at(M-1)-X.at(0);
    for(int i=0; i<N-1; ++i) S += Y.at(i);
    cout << sum-S << endl;
  }
}


Measured memory_bytes: 1024
package main

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

// １桁になったら終わり
// 基本は桁数-1で、和を10で割った数だけ追加で予選を行える

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	inputList, _ := toIntArray(splitInput(scanner, " "))
	m := int(inputList[0])
	dArray := make([]int64, m)
	cArray := make([]int64, m)
	for i := 0; i < m; i++ {
		inputList, _ := toIntArray(splitInput(scanner, " "))
		dArray[i] = inputList[0]
		cArray[i] = inputList[1]
	}

	var sumVal int64 = 0
	var sumDigit int64 = 0
	for i := 0; i < m; i++ {
		sumVal += dArray[i] * cArray[i]
		sumDigit += cArray[i]
	}

	var rem int64 = sumVal % 10
	var nextDigitNum int64 = 0
	for sumVal > 9 {
		sumVal /= 10
		nextDigitNum += sumVal
		sumVal += rem
		rem = sumVal % 10
	}
	if sumDigit > 1 {
		fmt.Println(sumDigit - 1 + nextDigitNum)
	} else {
		fmt.Println(1)
	}
}

func splitInput(scanner *bufio.Scanner, sep string) []string {
	scanner.Scan()
	return strings.Split(scanner.Text(), sep)
}

func toIntArray(str []string) ([]int64, error) {
	length := len(str)
	resVal := make([]int64, length)
	var err error
	for i := 0; i < length; i++ {
		resVal[i], err = strconv.ParseInt(str[i], 10, 64)
		if err != nil {
			return nil, err
		}
	}
	return resVal, nil
}


Measured memory_bytes: 7808
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	int N;
	cin >> N;
	string S, T;
	
	cin >> S >>T;
	
	string temp;
	
	for (int i = 0; i<N; i++)
	{
		temp.push_back(S[i]);
		temp.push_back(T[i]);
	}
	
	cout << temp <<endl;
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
#define endl '\n'

void solve() {
    ll x;
    cin >> x;

    // vector<ll> val;
    // val.push_back(0);
    // for (int i = 1; i <= 100; ++i) {
    //     val.push_back(pow(i, 5));
    //     val.push_back(pow(-1*i, 5));
    // }

    // int k = val.size();
    ll a = 0, b = 0;
    // sort(val.begin(), val.end());
    bool done = false;
    for (int i = 0; i <= 1000; ++i) {
        for (int j = 0; j <= 1000; ++j) {
            ll v1 = pow(i, 5);
            ll v2 = pow(j, 5);
            if (v1 - v2 == x) {
                a = i;
                b = j;
                done = true;
                break;
            }
            if (-1*v1 - v2 == x) {
                a = -1*i;
                b = j;
                done = true;
                break;
            }
            if (v1 + v2 == x) {
                a = i;
                b = -1*j;
                done = true;
                break;
            }
            if (-1*v1 + v2 == x) {
                a = -1*i;
                b = -1*j;
                done = true;
                break;
            }
        }
        if (done) {
            break;
        }
    }
    cout << a << " " << b << endl;
}

int main() {
    FAST_IO;

    int t;
    // cin >> t;
    t = 1;

    while (t--) {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int s,w; cin>>s>>w;
    if (w>=s) {
        cout << "unsafe" << '\n';
    }
    else cout << "safe" << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
const int MOD = 1e9 + 7;
using namespace std;

int main(void){

  int N;  cin >> N;
  ll ans = 1;
  for(int i = 2 ; i <= N ; i++){
	ans *= i;
    ans %= MOD;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        x:i64,
        y:i64,
        z:i64,
        k:i64,
        an:[i64;x],
        bn:[i64;y],
        cn:[i64;z],
    }
    let mut cn = cn;
    cn.sort();
    cn.reverse();
    let mut abn = vec![];
    for i in 0..x as usize{
        for j in 0..y as usize{
            abn.push(an[i] + bn[j]);
        }
    }
    abn.sort();
    abn.reverse();
    let rep =  std::cmp::min(k, x*y);
    let mut ans = vec![];
    for j in 0..rep as usize{
        for k in 0..z as usize {
            ans.push(abn[j] + cn[k]);
        }
    }
    ans.sort();
    ans.reverse();
    for j in 0..k as usize{
        println!("{}",ans[j]);
    }
}

Measured memory_bytes: 44280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if(b.substring(0, b.length()-1).equals(a)) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 26960
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

vvll to;
vll len;

ll dfs(ll u){
  if (len[u] != -1) return len[u];
  len[u] = 0;
  for (ll v : to[u]) {
    dfs(v);
    chmax(len[u], len[v] + 1);
  }
  return len[u];
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll x, a, b;
  cin >> x >> a >> b;

  cout << (x - a) % b << endl;

  return 0;
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int sum = 0;
  int count = 0;
  for (int i=0; i<=A; ++i) {
    for (int j=0; j<=B; ++j) {
      for (int k=0; k<=C; ++k) {
        sum = 500 * i + 100 * j + 50 * k;
        if (sum == X)  ++count;
      }
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
struct TeamData {
	int id;
	int total_time;
	int rank;
};

int main(void) {
	struct TeamData *p, temp;
	int n, m1, s1, m2, s2, m3, s3, m4, s4;
	int i, j;

	while (1) {
		scanf("%d", &n);
		if (n == 0)break;
		struct TeamData data[n];
		p = data;
		for (i = 0; i < n; i++) {
			scanf("%d %d %d %d %d %d %d %d %d", &data[i].id, &m1, &s1, &m2, &s2, &m3, &s3, &m4, &s4);
			data[i].total_time = (m1 + m2 + m3 + m4) * 60 + s1 + s2 + s3 + s4;
		}

		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				if ((p + i)->total_time > (p + j)->total_time) {
					temp = *(p + i);
					*(p + i) = *(p + j);
					*(p + j) = temp;
				}
			}
		}
		for (i = 0; i < n; i++)
			for (i = 0; i < n; i++)
				(p + i)->rank = i + 1;

			for (i = 0; i < n; i++) {
				if ((p + i)->rank == 1 || (p + i)->rank == 2 || (p + i)->rank == n - 1)
					printf("%d\n", (p + i)->id);
			}
	}
	return 0;
}

Measured memory_bytes: 656
(function(input) {
    var p = input.split('\n');
    var n = Number(p.shift());
    var A = p.shift().split(' ').map(Number);

    var i = partition(A, 0, A.length - 1);
    console.log(A.map(function(e, index) {
        if (index === i) {
            return '[' + e + ']';
        }
        return e;
    }).join(' '));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function partition(A, p, r) {
    var x = A[r];
    var i = p - 1;
    for (var j = p; j <= r - 1; j++) {
        if (A[j] <= x) {
            i++;
            var tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    var tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;

    return i + 1;
}

Measured memory_bytes: 22936
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<Int, Int>;
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

// template <template <class, class...> class TT, class... Args>
// ostream& operator<<(ostream& out, TT<Args...> const& cont) {
//     for (auto&& elem : cont) out << elem << " ";
//     return out;
// }
// template <class T> ostream& operator<<(ostream& out, const vector<vector<T>>& vs) {
//     for (auto&& v : vs) cout << v << endl;
//     return out;
// }
// template <class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> const& val) {
//     return (out << "{" << val.first << " " << val.second << "}");
// }

void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) {
    cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...);
}
#ifdef _MY_DEBUG
#define dump(...)                                                                                                    \
    cerr << "/* " << #__VA_ARGS__ << " [" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), \
        cerr << "*/\n\n";
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: CREATED_TIMESTAMP
 **/

vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
signed main() {
    string s;
    cin >> s;
    cout << 7 - (find(ALL(days), s) - days.begin()) << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;


public class Main {

	public static void main(String[] args) throws Exception {
		new Main().solve();
	}
	@SuppressWarnings("unchecked")
	void solve() throws Exception {
		FastScanner in = new FastScanner(System.in);

		// long mod = 1000000007;
		// int a = in.nextInt();
		// int b = in.nextInt();
		BigInteger a = new BigInteger(in.next());
		BigInteger b = new BigInteger(in.next());

		int c = a.compareTo(b);
		String s;
		if (c > 0) {
			s = "GREATER";
		} else if (c == 0) {
			s = "EQUAL";
		} else {
			s = "LESS";
		}
		System.out.println(s);
	}
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	class FastScanner {

		private InputStream _stream;
		private byte[] _buf = new byte[1024];
		private int _curChar;
		private int _numChars;
		private StringBuilder _sb = new StringBuilder();

		FastScanner(InputStream stream) {
			this._stream = stream;
		}

		public int read() {
			if (_numChars == -1) throw new InputMismatchException();
			if (_curChar >= _numChars) {
				_curChar = 0;
				try {
					_numChars = _stream.read(_buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (_numChars <= 0) return -1;
			}
			return _buf[_curChar++];
		}

		public String next() {
			int c = read();
			while (isWhitespace(c)) {
				c = read();
			}
			_sb.setLength(0);
			do {
				_sb.appendCodePoint(c);
				c = read();
			} while (!isWhitespace(c));
			return _sb.toString();
		}

		public int nextInt() {
			return (int) nextLong();
		}
		public long nextLong() {
			int c = read();
			while (isWhitespace(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9') throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isWhitespace(c));
			return res * sgn;
		}

		public boolean isWhitespace(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//


Measured memory_bytes: 22356
from collections import defaultdict

N, M, K = map(int, input().split())
friends = defaultdict(list)
blocked = defaultdict(list)
for i in range(M):
    a, b = map(int, input().split())
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
for j in range(K):
    c, d = map(int, input().split())
    blocked[c - 1].append(d - 1)
    blocked[d - 1].append(c - 1)

groups = {}
for i in range(N):
    if i in groups:
        continue
    group = {i}
    stack = [(i, None)]
    while stack:
        j, parent_id = stack.pop()
        group.add(j)
        groups[j] = group
        for k in friends[j]:
            if k != parent_id and k not in groups:
                stack.append((k, j))

ans = []
for i in range(N):
    g = groups[i]
    res = len(g) - len(friends[i]) - 1
    for b in blocked[i]:
        if groups[b] is g:
            res -= 1
    ans.append(res)
print(*ans)


Measured memory_bytes: 124504
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>

using namespace std;
vector<int> vec;

int main() {
	//input
	int a,b,c;
	cin >> a >> b >> c;

	vec.push_back(a);
	vec.push_back(b);
	vec.push_back(c);

	sort(vec.begin(), vec.end());

	int ans = 0;
	ans = vec[2] * 10 + vec[1] + vec[0];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
#list from 2 to n
alist=list(map(int,input().split()))

jodic={}

for i in alist:
    if i in jodic:
        jodic[i]=jodic[i]+1
    else:
        jodic[i]=1

for j in range(n):
    if j+1 in jodic:
        print(jodic[j+1])
    else:
        print("0")



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

using namespace std;

typedef pair < int, int > PII;

const int NMAX = 1e2 + 5, INF = 1e9;

int N, M;

char A[NMAX][NMAX];
int d[NMAX][NMAX];

static inline void Read ()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N >> M;

    for(int i = 1; i <= N; ++i)
        cin >> (A[i] + 1);

    return;
}

static inline void Solve ()
{
    if(A[1][1] == '#')
        d[1][1] = 1;
    else
        d[1][1] = 0;

    for(int j = 0; j <= M; ++j)
        d[0][j] = d[N + 1][j] = INF;

    for(int i = 1; i <= N; ++i)
        d[i][0] = d[i][M + 1] = INF;

    for(int i = 1; i <= N; ++i)
        for(int j = 1; j <= M; ++j)
            if(i != 1 || j != 1)
                if(A[i][j] == '#')
                    d[i][j] = min(1 + d[i - 1][j] - (A[i - 1][j] == '#'), 1 + d[i][j - 1] - (A[i][j - 1] == '#'));
                else
                    d[i][j] = min(d[i - 1][j], d[i][j - 1]);

    cout << d[N][M] << '\n';

    return;
}

int main()
{
    Read();

    Solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
#define MOD 1000000000+7
typedef long long ll;

using namespace std;

int main(){
    ll N;
    cin >> N;
    ll A[100010] = {0};
    for (int i = 1; i <= N; i++){
	ll a;
	cin >> a;
	A[a]++;
    }

    bool can = true;
    for (int i = 0; i < N; i++){
	if (N%2 == 0){
	    if ((i%2 == 1) && (A[i] != 2)){
		can = false;
	    } else if ((i%2 == 0) && (A[i] != 0)){
		can = false;
	    }
	} else {
	    if (A[0] == 1) continue;
	    if ((i%2 == 0) && (A[i] != 2)){
		can = false;
	    } else if ((i%2 == 1) && (A[i] != 0)){
		can = false;
	    }
	}
    }

    if (!can){
	cout << 0 << endl;
	return 0;
    }

    ll res = 1;
    for (int i = 0; i < N/2; i++){
	res *= 2;
	res %= MOD;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;//print
typedef long long ll;
using namespace std;


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<ll> a;
    rep(i,n){
        ll aa;
        cin >> aa;
        a.push_back(aa);
    }
    sort(a.begin(),a.end());
    int ans=0;
    int tmp=1;
    ll now = a.front();
    REP(i,1,n){
        if(now == a[i]){
            if(tmp==1){
                tmp=0;
            }else{
                tmp=1;
            }
        }else{
            now = a[i];
            ans += tmp;
            tmp = 1;
        }
    }
    ans += tmp;
    P(ans);
}

Measured memory_bytes: 1400
/*input
2 5 5
1 1 3
2 4 20
1 2 1
1 3 4
1 4 2
*/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
void chmax(ll &a, ll b, ll c) { a = max({a, b, c});}

const int N = 3005;
ll dp0[N][N], dp1[N][N], dp2[N][N], dp3[N][N];

int main() {
    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<int>> v(r, vector<int>(c));
    rep(i, k) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        v[a][b] = c;
    }

    dp1[r-1][c-1] = v[r-1][c-1];
    dp2[r-1][c-1] = v[r-1][c-1];
    dp3[r-1][c-1] = v[r-1][c-1];
    for (int i = r-1; i >= 0; i--) {
        for (int j = c-1; j >= 0; j--) {
            if (i+1 <= r-1) {
                dp0[i][j] = dp3[i+1][j];
                dp1[i][j] = dp2[i][j] = dp3[i][j] = v[i][j]+dp3[i+1][j];
            }
            if (j+1 <= c-1) {
                chmax(dp1[i][j], dp1[i][j+1], v[i][j]+dp0[i][j+1]);
                chmax(dp2[i][j], dp2[i][j+1], v[i][j]+dp1[i][j+1]);
                chmax(dp3[i][j], dp3[i][j+1], v[i][j]+dp2[i][j+1]);
            }
        }
    }
    cout << dp3[0][0] << endl;
}

Measured memory_bytes: 319792
#include<stdio.h>
int main(){
  int h,w;
  scanf("%d %d",&h,&w);
  char s[h][w],dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
  for(int i = 0;i < h;i++){
    scanf("%s",&s[i]);
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(s[i][j] == '#'){
        int c = 0;
        for(int d = 0;d < 4;d++){
          int x = i + dx[d],y = j + dy[d];
          if(-1 < x && x < h && -1 < y && y < w && s[x][y] == '#'){
            c = 1;
          }
        }
        if(c < 1){
          printf("No\n");
          return 0;
        }
      }
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N,x;
  int a[100];
  cin>>N>>x;
  for(int i=0;i<N;i++)
    cin>>a[i];
  sort(a,a+N);
  int ans;
  for(int i=0;i<N;i++){
    x-=a[i];
    ans=i;
    if(x<0) break;
    else if(x==0){
      ans++;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<lint>());
    lint ans = 0;
    ans+=a[0];
    for(int i=2;i<n;i++)ans+=a[i/2];
    cout << ans << endl;
}

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

#define M 40
#define max(a,b) (a>b?a:b)

typedef unsigned int uint;

typedef vector<int> Graph;

Graph g[M];
int power[M], sum[M], n, ans;

int solve(int s, int del[M], int pw) {
	int del2[M], res = 0, r;
	pw += power[s];
	for(int i=0; i<n; ++i) del2[i] = del[i];
	for(uint i=0; i<g[s].size(); ++i) {
		del2[g[s][i]] = 1;
	}
	for(int i=s+1; i<n; ++i) {
		if(pw+sum[n-1]-sum[i-1]<=ans) break;
		if(!del2[i]) {
			r = solve(i, del2, pw);
			res = max(r, res);
		}
	}
	ans = max(pw+res, ans);
	return res;
}

int main() {
	map<string, int> kuni;
	string name, near_n;
	int nc, del[M];
	while(1) {
		cin >> n;
		if(!n) break;
		for(int i=0; i<n; ++i) g[i].clear();
		kuni.clear();
		for(int i=0, c=0; i<n; ++i) {
			cin >> name;
			if(!kuni.count(name)) {
				kuni[name] = c++;
			}
			cin >> power[kuni[name]] >> nc;
			for(int j=0; j<nc; ++j) {
				cin >> near_n;
				if(!kuni.count(near_n)) {
					kuni[near_n] = c++;
				}
				g[kuni[name]].push_back(kuni[near_n]);
				g[kuni[near_n]].push_back(kuni[name]);
			}
		}
		for(int i=0; i<n; ++i) sum[i] = !i ? power[0] : sum[i-1]+power[i];
		for(int i=0; i<n; ++i) del[i] = 0;
		ans = 0; solve(0, del, 0);
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int const N = 100 * 1000 + 16;

int n;
int cnt[N];
vector<int> g[N];

void dfs(int u) {
  vector<int> vec; vec.reserve(g[u].size());
  for(int v : g[u]) {
    dfs(v);
    vec.push_back(cnt[v]);
  }

  sort(vec.begin(), vec.end());
  for(auto x : vec)
    cnt[u] = 1 + max(cnt[u], x);
}

int main() {
  scanf("%d",&n);
  for(int v = 2; v <= n; ++v) {
    int u;
    scanf("%d", &u);
    g[u].emplace_back(v);
  }
  dfs(1);
  cout << cnt[1];
}

Measured memory_bytes: 17024
N = int(input())
A=[]
count=1
ss=0
for i in range(0,N):
    A.append(list(input()))
    A[i].sort()
A.sort()
A.append('0')
for j in range(1,N+1):
    if A[j-1]==A[j]:
        count+=1
        j+=1
    else:
        ss+=count*(count-1)/2
        count = 1
        j+=1

print(int(ss))


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

using namespace std;

int main()
{
    int n;
    long long int tmp_a, tmp_b, tmp_sum = 0;
    cin >> n;
    vector<pair<long long int, long long int> > a(n);
    for (int i = 0; i < n; ++i) {
        cin >> tmp_a >> tmp_b;
        a[i] = make_pair(tmp_b, tmp_a);
    }
    sort(a.begin(), a.end());
/*
    for (int i = 0; i < n; ++i)
    {
        cout << a[i].first << ' ' << a[i].second << endl;
    }
*/
    for (auto s:a) {
        tmp_sum += s.second;
        if (tmp_sum > s.first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
 
#define int long long

template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string&);

string to_string(const char* s);

string to_string(bool b);

template <typename A>
string to_string(A v);

template <typename A, typename B>
string to_string(pair<A, B> p);

void debug_out(); 

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T);

vector<string> vec_splitter(string s);
void debug_var(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 

template <typename Head, typename... Tail>
void debug_var(vector<string>, int, int, Head, Tail...);

#ifndef ONLINE_JUDGE
#define var(...) debug_var(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#define stl(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define var(x...)
#define stl(...) 
#endif

const int mod = 1e9 + 7;
const int N = 1e6 + 5; 

void solve() {
  int n;
  cin >> n;
  vector<int> h(n + 1);
  for (int i = 2; i <= n; ++i) {
    int x;
    cin >> x;
    h[x]++;
  }
  for (int i = 1; i <= n; ++i) {
    cout << h[i] << '\n';
  }
}

signed main() {
  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  // int T = 1; cin >> T; for (int i = 1; i <= T; ++i)
  solve();
  return 0;
}

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "T" : "F");
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename Head, typename... Tail>
void debug_var(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << "): ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_var(args, idx + 1, LINE_NUM, T...);
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

void debug_out() { cerr << endl; }

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

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}


   


int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    
    vector<ll>l(n+1);
    l[0]=2; l[1]=1;

    for(int i =2;i<=n;i++){
        l[i]=l[i-1] +l[i-2];
    }
cout<< l[n]<<endl;
}




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

int main(){
    int N; cin >> N;
    vector<long long> A(N);
    long long mx = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        mx = max(mx,A[i]);
    }
    long long ans = 0;
    long long df = 1LL << 30;
    for(int i = 0; i < N; i++){
        if(df > abs(mx/2-A[i])&&mx != A[i]){
            ans = A[i];
            df = abs(mx/2-A[i]);
        }
    }
    cout << mx << " " << ans << endl;
    
}

Measured memory_bytes: 4056
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 52;
const int MAX_V = 50;
int N, A, x[MAX_N];

long long dp[MAX_N][MAX_N][MAX_V * MAX_N] = {};

int main(int argc, char **argv) {
    std::cin >> N >> A;

    for (int i = 1; i <= N; i++) {
        std::cin >> x[i];
    }

    int sum = 0;

    for (int i = 1; i <= N; i++) {
        sum += x[i];
    }
    
    dp[0][0][0] = 1;

    for (int i = 1; i <= N; i++) {
        for (int k = 0; k <= i; k++) {
            for (int a = 0; a <= sum; a++) {
                dp[i][k][a] += dp[i-1][k][a];
                if (1 <= k && x[i] <= a) {
                    dp[i][k][a] += dp[i - 1][k - 1][a - x[i]];
                }
            }
        }
    }

    long long ret = 0;
    for (int k = 1; k <= N; k++) {
        ret += dp[N][k][A*k];
    }

    std::cout << ret << std::endl;
    return 0;

}



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

int main()
{
  int h1, m1, s1, h2, m2, s2;
  for (int i = 0; i < 3; ++i) {
    cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
    int sec = (h2 - h1)*3600 + (m2 - m1)*60 + (s2 - s1);
    cout << sec/3600 << " " << (sec%3600)/ 60 << " " << sec%60 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <cstdio>
#include <cstring>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <iostream>
#include <queue>
#include <set>
using namespace std;

vector<string> g;
int h, w;

int dp[10][10][3][59049 + 10];
const int mod = 100000007;

void decode(int val, int *ret){
  REP(i,w){
    ret[i] = val % 3;
    val /= 3;
  }
}

int encode(int *a){
  int ret = 0;
  REP(i,w){
    ret *= 3;
    ret += a[w - 1 - i];
  }
  return ret;
}

bool valid(int a, int b, int c, int d){
  int sum = a + b + c + d;
  int mx = max(max(a,b),max(c,d));
  return mx <= sum - mx;
}

int solve(int y, int x, int prev, int val){
  assert(val < 59049 + 10);
  if(y == h && x == 0){
    return val == 0 ? 1 : 0;
  }
  if(x == w){
    if(prev != 0) return 0;
    return solve(y + 1, 0, 0, val);
  }

  if(dp[y][x][prev][val] != -1)
    return dp[y][x][prev][val];

  int a[w + 1]; decode(val, a);
  int in = prev + a[0];

  int ret = 0;

  if(g[y][x] == '.'){
    /*
    REP(migi, 3) REP(sita, 3){
      if((migi + sita + in) % 2 != 0) continue;
      if(!valid(migi, sita, a[0], prev)) continue;

      if(y == h - 1 && sita != 0) continue;
      if(x == w - 1 && migi != 0) continue;

      printf("%d, %d (ue:%d, migi:%d sita:%d, hidari:%d)\n", y, x, a[0], migi, sita, prev);

      a[w] = sita;
      ret += solve(y, x + 1, migi, encode(a + 1));
      ret %= mod;
    }
    */
    if(prev > 0 && a[0] > 0) return 0;
    if(prev > 0){
      if(x != w - 1){
	a[w] = 0;
	ret += solve(y, x + 1, prev, encode(a + 1));
      }
    }else if(a[0] > 0){
      if(y != h - 1){
	a[w] = a[0];
	ret += solve(y, x + 1, 0, encode(a + 1));
      }
    }else{
      a[w] = 0;
      ret += solve(y, x + 1, 0, encode(a + 1));
    }
  }else{
    const int expected = g[y][x] - '0';

    REP(migi, 3){
      const int sita = expected - in - migi;

      if(y == h - 1 && sita != 0) continue;
      if(x == w - 1 && migi != 0) continue;

      if(0 <= sita && sita <= 2){
	// printf("%d, %d (ue:%d, migi:%d sita:%d, hidari:%d)\n", y, x, a[0], migi, sita, prev);

	a[w] = sita;
	ret += solve(y, x + 1, migi, encode(a + 1));
	ret %= mod;
      }
    }
  }

  return dp[y][x][prev][val] = ret;
}


int main(){
  cin >> h >> w;
  g = vector<string>(h);
  REP(i,h) cin >> g[i];

  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0, 0, 0) << endl;

  return 0;
}

Measured memory_bytes: 70448
import java.util.Arrays;
import java.util.Scanner;

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

    static void solve(Scanner sc) {
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        Arrays.sort(a);
        Arrays.sort(b);
        String as = String.valueOf(a);
        String bs = new StringBuilder(String.valueOf(b)).reverse().toString();
        System.out.println(as.compareTo(bs) < 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    
    int n;
    
    cin >> n;
    
    double x = 0;
    double y = 0;
    double sum = 0;
    
    int xnum[n];
    int ynum[n];
    int sumnum[n];
    
    double sum1 = 0;
    double sum2 = 0;
    double sum3 = 0;
    double suminf = -1;
    
    
    
    // x input
    for (int i = 0; i < n; i ++) {
        
        cin >> x;
        
        xnum[i] = x;
        
        
        
    }
    
    // y input
    for (int i = 0; i < n; i ++) {
        
        cin >> y;
        
        ynum[i] = y;
        
    }
    
    // | x - y |
    for (int i = 0; i < n; i ++) {
        
        sum = fabs(xnum[i] - ynum[i]);
        
        sumnum[i] = sum;
        
    }
    
    
    // p = 1,2,3,inf
    for (int i = 0; i < n; i ++) {
        
        sum1 += sumnum[i];
        
        sum2 += pow(sumnum[i],2);
        
        sum3 += pow(sumnum[i],3);
        
        if (sumnum[i] > suminf) {
            
            suminf = sumnum[i];
            
        }
        
        
        
    }
    
    sum2 = sqrt(sum2);
    
    sum3 = cbrt(sum3);
    
    printf("%.8f\n", sum1);
    printf("%.8f\n", sum2);
    printf("%.8f\n", sum3);
    printf("%.8f\n", suminf);
    
    
    return 0;
    
}



Measured memory_bytes: 3468