akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

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

        // 入力(a)
        int a = sc.nextInt();
        // 入力(b)
        int b = sc.nextInt();
        // 入力(c)
        int c = sc.nextInt();
        int[] ary = {a, b, c};

        Arrays.sort(ary);
        System.out.println((ary[0] + ary[1] == ary[2] ? "Yes" : "No"));
        sc.close();
    }
}

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

int main()
{
	string s;
	int cnt = 0;
	cin >> s;
	if (s[0] == '1')  cnt++;
	if (s[1] == '1')  cnt++;
	if (s[2] == '1')  cnt++;

	cout << cnt << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repab(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define pb push_back
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()

typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

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

int main(){
  int n, k;
  cin >> n >> k;
  vec<int> h(n+1);
  rep(i, n) cin >> h[i+1];

  int dp[n+1];
  rep(i, n+1){
    dp[i] = 0;
  }
  dp[1] = 0;
  
  repab(i, 2, n){
    dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
    for(int j=2; j<=k; j++){
      if(i-j>=1) dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 4024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll segtree[816225][2],dp[225816];
bool delayed[816225];

void eval(int i, int l, int r){
	if(delayed[i]){
		segtree[i][0] = min(segtree[i][1],segtree[i][0]);
		if(r-l>1){
			segtree[2*i+1][1] = min(segtree[i][1],segtree[2*i+1][1]);
			delayed[2*i+1] = true;
			segtree[2*i+2][1] = min(segtree[i][1],segtree[2*i+2][1]);
			delayed[2*i+2] = true;
		}
		delayed[i] = false;
		segtree[i][1] = INFLL;
	}
}

void update(int a, int b, int i, int l, int r, ll v){
	eval(i,l,r);
	if(b<=l || r<=a){
		return;
	}
	if(a<=l && r<=b){
		segtree[i][1] = min(v,segtree[i][1]);
		delayed[i] = true;
		eval(i,l,r);
	}else{
		update(a,b,2*i+1,l,(l+r)/2,v);
		update(a,b,2*i+2,(l+r)/2,r,v);
		segtree[i][0] = min(segtree[2*i+1][0],segtree[2*i+2][0]);
	}
}

ll query(int a, int b, int i, int l, int r){
	ll vl,vr;
	eval(i,l,r);
	if(b<=l || r<=a){
		return INFLL;
	}
	if(a<=l && r<=b){
		return segtree[i][0];
	}else{
		vl = query(a,b,2*i+1,l,(l+r)/2);
		vr = query(a,b,2*i+2,(l+r)/2,r);
		return min(vl,vr);
	}
}

vector<P> t[100100];

int main(void){
	int n,m,l,r,i,j;
	ll c,ans=0ll;
	fill(dp,dp+225816,INFLL);
	fill(segtree[0],segtree[816225],INFLL);
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> l >> r >> c;
		t[r].push_back(P(l-1,c));
	}
	update(0,1,0,0,n,0ll);
	dp[1] = 0ll;
	for(r=1; r<=n; ++r){
		for(j=(t[r].l_ength()-1); j>=0; --j){
			l = t[r][j].first;
			c = t[r][j].second;
			dp[r] = min(dp[r],query(l,r,0,0,n)+c);
		}
		for(j=(t[r].l_ength()-1); j>=0; --j){
			l = t[r][j].first;
			update(l,r,0,0,n,dp[r]);
		}
	}
	cout << ((dp[n]<INFLL)?dp[n]:(-1ll)) << endl;
	return 0;
}


Measured memory_bytes: 20992
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	int N, X, T;
	int ans;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	X = atoi(ch);
	ch = strtok(NULL, " ");
	T = atoi(ch);

	ans = 0;
	ans += (N/X) * T;
	if(N % X != 0) {
		ans += T;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 2104
fun main(args: Array<String>) {
    //val N = readLine()!!.toInt()
    val (n,x) = readLine()!!.split(" ").map { s -> s.toInt() }
    val L = readLine()!!.split(" ").map { s -> s.toInt() }
    var d = 0
    var cnt = 1
    L.forEach{
        l -> d += l
        cnt += if (d <= x) 1 else 0 
    }
    println(cnt)
}


Measured memory_bytes: 37752
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        void Omame()
        {
            cin = new Scanner();
            int k = cin.nextInt();
            int s = cin.nextInt();

            int ans = 0;
            for (int i = 0; i <= k; i++)
            {
                for (int j = 0; j <= k; j++)
                {
                    int l = s - i - j;
                    if (0 <= l && l <= k) ans++;
                }
            }

            Console.WriteLine(ans);
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef double db;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vl;
typedef vector<pii> vpii; typedef vector<pll> vpll;
#define FOR(n) for(int i=0;i<n;++i)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }
const ll mod = 1e9 + 7; const ll inf = 0x3f3f3f3f;
ll qpow(ll a, ll b) { ll t = 1; while (b != 0) { if (b & 1)t = (t * a) % mod; a = (a * a) % mod; b >>= 1; }return t; }
int n, m;
string sr;
vector<string>s;
struct node {
	int x, y;
};
int a[1010][1010];
int t1[] = { 0,0,1,-1 };
int t2[] = { 1,-1,0,0 };
int x1, y11, x2, y2;
queue<pii>q;
int sd = 1;
vector<pii>vec;
void bfs() {
	while (!q.empty()) {
		pii t = q.front();
		q.pop();
		vec.push_back(t);
		int x = t.first, y = t.second;
		int i, j;
		for (i = 0; i < 4; ++i) {
			if (x + t1[i] < 0 || x + t1[i] >= n || y + t2[i] < 0 || y + t2[i] >= m)continue;
			if (a[x + t1[i]][y + t2[i]] || s[x + t1[i]][y + t2[i]] == '#')continue;
			a[x + t1[i]][y + t2[i]] = sd;
			q.push({ x + t1[i],y + t2[i] });
			vec.push_back({ x + t1[i],y + t2[i] });
		}
	}
	++sd;
	if (vec.empty())return;
	for (int k = 0; k < vec.size(); ++k) {
		for (int i = -2; i <= 2; ++i) {
			for (int j = -2; j <= 2; ++j) {
				int x = vec[k].first + i, y = vec[k].second + j;
				if (x < 0 || x >= n || y < 0 || y >= m)continue;
				if (a[x][y] || s[x][y] == '#')continue;
				q.push({ x, y });
				a[x][y] = sd;
			}
		}
	}
	vec.clear();
	bfs();
}
signed main() {
	cin >> n >> m;
	cin >> x1 >> y11;
	x1--, y11--;
	cin >> x2 >> y2;
	x2--, y2--;
	for (int i = 0; i < n; ++i) {
		cin >> sr;
		s.push_back(sr);
	}
	q.push({ x1,y11 });
	a[x1][y11] = 1;
	bfs();
	//for (int i = 0; i < n; ++i) {
	//	for (int j = 0; j < m; ++j) {
	//		cout << a[i][j] << " ";
	//	}cout << endl;
	//}
	cout << a[x2][y2] - 1 << endl;
	return 0;
}

Measured memory_bytes: 25976
fun main() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }.sortedDescending()
    val sum = a.sum()
    var ans = "Yes"
    if (a[m - 1] * m * 4 < sum) {
        ans = "No"
    }
    println(ans)
}

Measured memory_bytes: 40452
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;
int main() {
	int n, b[100];
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> b[i];
	}
	int a[100];
	a[0] = b[0];
	for (int i = 1; i < n - 1; i++) {
		a[i] = b[i - 1];
		if (a[i] > b[i]) {
			a[i] = b[i];
		}
	}
	a[n - 1] = b[n - 2];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt();
			int k = scanner.nextInt();
			Set<Integer> set = new HashSet<>();
			IntStream.range(a, Math.min(a + k, b)).forEach(set::add);
			IntStream.rangeClosed(Math.max(b - k + 1, a), b).forEach(set::add);
			set.stream().sorted().forEach(System.out::println);
		}
	}
}


Measured memory_bytes: 27092
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
  a, b = map(int, input().split())
  uf.union(a-1, b-1)
maxsize = 0
for j in range(N):
  s = uf.size(j)
  maxsize = max(maxsize, s)
print(maxsize)

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

int main(){
  int N, k;
  cin >> N >> k;
  vector<int> x(N);
  for(int i=0; i<N; i++){
    cin >> x.at(i);
  }
  int end_to_end, first, time, min_time;
  min_time = 3* pow(10,8);
  for(int i=0; i<=N-k; i++){
    end_to_end = x.at(i+k-1)-x.at(i);
    if(x.at(i+k-1) < 0) first = -x.at(i+k-1);
    else if(x.at(i) > 0) first = x.at(i);
    else first = min(-x.at(i), x.at(i+k-1));
    time = first + end_to_end;
    min_time = min(min_time, time);
  }
  cout << min_time;
}

Measured memory_bytes: 640
N,Q=map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N-1)]
PQ = [list(map(int,input().split())) for _ in range(Q)]
#AB.sort()
#PQ.sort()
l=[[] for _ in range(N)]
ans=[0]*N
for a,b in AB:
	l[a-1].append(b-1)
for p,q in PQ:
	ans[p-1]+=q
for i in range(N-1):
	for j in l[i]:
		ans[j]+=ans[i]
	
print(*ans)

Measured memory_bytes: 135392
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 112345;
const int mod = 1000000007;
int v[MAXN], dp[MAXN];
int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 1; i<=n; ++i) {
        scanf("%d", v+i);
    }
    dp[0] = 1; 
    for (int i = 1, j, sum, old; i<=n; ++i) {
        sum = 0;
        for (j = 0; j <= v[i] && k-j>=0; ++j) {
            sum+=dp[k-j];
            if (sum >= mod) sum -= mod;
        }

        for (j = k; j>=0; --j) {
            old = dp[j];
            dp[j] = sum;
            if (dp[j] >= mod) dp[j] -= mod;
            if (j-v[i]-1>=0) sum += dp[j-v[i]-1]; 
            sum -= old;
            if (sum >= mod) sum -= mod;
            if (sum < 0) sum += mod;
        }
    }
    printf("%d\n", dp[k]);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

string S;
ll n;
vector<ll> dp(200003,-1);
//S[x]以降
bool F(ll x){
    if(dp[x]!=-1)return dp[x];
    if(n-x<5)return dp[x]=0;
    if(n-x==5){
        if(S.substr(x)=="dream"||S.substr(x)=="erase")return dp[x]=1;
        else return dp[x]=0;
    }
    if(n-x==6){
        if(S.substr(x)=="eraser")return dp[x]=1;
        else return dp[x]=0;
    }
    if(n-x==7){
        if(S.substr(x)=="dreamer")return dp[x]=1;
        else return dp[x]=0;
    }
    if(S.substr(x,5)=="dream"&&F(x+5))return dp[x]=1;
    if(S.substr(x,7)=="dreamer"&&F(x+7))return dp[x]=1;
    if(S.substr(x,5)=="erase"&&F(x+5))return dp[x]=1;
    if(S.substr(x,6)=="eraser"&&F(x+6))return dp[x]=1;
    return dp[x]=0;


}

int main(){
    cin >> S;
    n=S.size();

    if(F(0))print("YES");
    else print("NO");



    return 0;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

/*
ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

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

    ll sum = 0;
    for (ll a = 1; a <= k; a++) {
        for (ll b = 1; b <= k; b++) {
            for (ll c = 1; c <= k; c++) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    cout << sum << endl;
}

 */

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

    ll r = 0, g = 0, b = 0;
    for (char c : s) {
        if (c == 'R') r++;
        else if (c == 'G') g++;
        else if (c == 'B') b++;
    }


    ll all = r * g * b;
    ll none = 0;
    for (int i = 1; i < n; i++) {
        for (int start = 0; start + i + i < n; start++) {
            char j = s[start];
            char k = s[start + i];
            char l = s[start + i + i];
            if (j != k && k != l && l != j) none++;
        }
    }
    cout << all - none << endl;
}

Measured memory_bytes: 3640
a = []
STDIN.each{|x|
  data1 = x.chomp.to_i
  data2 = 10-(data1%10)
  if data2 == 10
    data2 = 0
  end
  a.push([data1, data2])
  }
a.sort!{|x,y| x[1]<=>y[1]}
sum = 0
a[0..3].each{|x|
  sum += x[0]+x[1]
  }
sum += a[4][0]
puts sum

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m[100],rm[100];
    for(int i=0;i<26;i++)
    {
        m[i]=-1;rm[i]=-1;
    }
    bool flag=true;
    for(int i=0;i<n;i++){
        if(m[s[i]-'a']<0)
        m[s[i]-'a']=t[i]-'a';
        else{
            if(m[s[i]-'a']!=t[i]-'a')
            flag=false;
        }
        if(rm[t[i]-'a']<0)
        rm[t[i]-'a']=s[i]-'a';
        else{
            if(rm[t[i]-'a']!=s[i]-'a')
            flag=false;
        }
        if(!flag)
        break;
    }
    if(flag)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int p[125252];
char s[252521];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",p+i);
  int it = 0;
  int cnt = 0;
  stack<int> S;
  REP(i,n){
    while(S.empty() || S.top() < p[i]){
      s[it++] = '(';
      S.push(++cnt);
    }
    if(S.top() != p[i]){
      puts(":("); return 0;
    }
    S.pop();
    s[it++] = ')';
  }
  if(S.size() > 0){
    puts(":("); return 0;
  }else{
    puts(s);
  }
  return 0;
}



Measured memory_bytes: 3740
#include<stdio.h>
#include<stdlib.h>

typedef long long int llu;


llu max(llu a, llu b) {
    if (a < b) {
        return b;
    } else {
        return a;
    }
}


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

    int w[N], v[N];
    for (int i = 0; i < N; ++i) {
        scanf("%d %d", &w[i], &v[i]);
    }


    llu dp[N+1][W+1];

    for (int i = 0; i <= N; ++i) {
        dp[i][0] = 0;
    }
    for (int j = 0; j <= W; ++j) {
        dp[0][j] = 0;
    }


    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (j < w[i-1]) {
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = max( dp[i-1][j-w[i-1]] + v[i-1] ,
                                dp[i-1][j] );
            }
        }
    }

    printf("%llu\n", dp[N][W]);
}



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

string a,b,c;

int main(){
	cin>>a>>b>>c;
	if(a[0]>96)a[0]-=32;
	if(b[0]>96)b[0]-=32;
	if(c[0]>96)c[0]-=32;
	cout<<a[0]<<b[0]<<c[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using N = System.Int64;

static class Program
{
    static public void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

public class Solver
{
    public void Solve()
    {
        N n = rn;
        N q = 0, r = 0;
        N ans = 0;
        for(N p = 1; p < n; p++)
        {
            q = n / p;
            r = n % p;
            if (r == 0)
            {
                ans += q - 1;
            }
            else
            {
                ans += q;
            }
        }
        Write(ans);
    }

    N Gcd(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length; i++) { p = Gcd(p, n[i]); } return p; }
    N Gcd(N a, N b) { return (a == 0) ? b : Gcd(b % a, a); }

    N rn { get { return sc.Integer(); } }
    double rd { get { return sc.Double(); } }
    string rs { get { return sc.Scan(); } }
    public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());

    void Write<T>(T t) { Console.WriteLine(t.ToString()); }
    void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}



public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char()
    {
        byte b = 0;
        do b = read();
        while (b < 33 || 126 < b);
        return (char)b;
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
            sb.Append(b);
        return sb.ToString();
    }
    public N Integer()
    {
        N ret = 0; byte b = 0; var ng = false;
        do b = read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-') { ng = true; b = read(); }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }
    public double Double() { return double.Parse(Scan()); }
}


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

using namespace std;

struct Node {
    bool is_word;
    int total;
    vector<Node*> children;
    vector<int> counts;
    Node(): is_word(false),
            total(0),
            children(26, nullptr),
            counts(26 ,0) {}
};

void insert(Node* root, const string& w, int offset = 0) {
    if (offset == w.size()) {
        root->is_word = true;
        root->total = 1;
        return;
    }
    int ind = w[offset] - 'a';
    if (root->children[ind] == nullptr) {
        root->children[ind] = new Node();
    }
    insert(root->children[ind], w, offset + 1);
}

long long compute_counts(Node* root) {
    long long ans = 0;
    for (int i = 0; i < 26; ++i) {
        Node *n = root->children[i];
        if (n == nullptr)
            continue;
        ans += compute_counts(n);
        root->total += n->total;
        for (int j = 0; j < 26; ++j) {
            if (j != i)
                root->counts[j] += n->counts[j];
        }
        root->counts[i] += n->total;
    }

    for (int i = 0; i < 26; ++i) {
        Node *n = root->children[i];
        if (n == nullptr)
            continue;
        if (n->is_word) {
            ans += root->counts[i] - 1;
//            cout << 'a' + i << " " << root->counts[i] - 1 << "\n";
        }
    }
    return ans;
}
int main() {
    int n;
    cin >> n;
    vector<string> words(n);
    Node* root = new Node();
    for (int i = 0; i < n; ++i) {
        cin >> words[i];
        reverse(words[i].begin(), words[i].end());
        insert(root, words[i], 0);
    }
    cout << compute_counts(root) << "\n";
    return 0;
}


Measured memory_bytes: 435692
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    val map = mutable.HashSet.empty[String]

    for(_ <- 0 until n) {
      map.add(in.readLine())
    }

    out.println(map.size)
    out.flush()
  }
}


Measured memory_bytes: 72176
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int m, d;
    cin >> m >> d;
    int ans = 0;

    for(int i = 1; i <= m; ++i){
        for(int j = 20; j <= d; ++j){
            if(j%10 >= 2){
                if((j%10)*(j/10) == i)++ans; 
            }
        }
    }

    cout << ans << endl;

}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    string S;
    cin >> S;

    stack<int> stk;
    for_(i,0,N) if (S[i] == 'R') stk.push(i);

    int ans = 0;
    for_(i,0,N) {
        while (!stk.empty() and stk.top() < i) stk.pop();

        if (S[i] == 'W') {
            if (!stk.empty()) {
                int j = stk.top(); stk.pop();
                swap(S[i], S[j]);
                ++ans;
            }
        }
    }
    
    cout << ans << endl;
}

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

int main(void){

	int map[10][10],ink,x,y,max=0,count=0;
	int dx[] = {0,0,-1,1,-1,-1,1,1,0,0,-2,2};
	int dy[] = {-1,1,0,0,-1,1,-1,1,-2,2,0,0};


	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			map[i][j]=0;
		}
	}
	
	
	while(scanf("%d,%d,%d",&x,&y,&ink)!=EOF){
		map[y][x]++;
		for(int i=0;i<ink*4;i++){
			int mx=x+dx[i];
			int my=y+dy[i];
			if(mx>=0 && mx<10 && my>=0 && my<10){
				map[my][mx]++;
			}
		}
	}
	
	
	for(int y=0;y<10;y++){
		for(int x=0;x<10;x++){
			if(map[y][x]==0){
				count++;
			}
			if(map[y][x]>max){
				max=map[y][x];
			}
		}
	}
	printf("%d\n%d\n",count,max);
}

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

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    int x[n][m];
    int y[m][l];
    long long z[n][l] = {};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> x[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> y[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0 ; j < l; j++){
            for(int k = 0; k < m; k++){
                z[i][j] += x[i][k]*y[k][j];
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            if(j != l-1)cout << z[i][j] << " ";
            else cout << z[i][j] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3236
from math import factorial
N,A,B = map(int,input().split())
V = sorted(list(map(int,input().split())),reverse=True)
C = {}
for i in range(N):
    if V[i] not in C:
        C[V[i]] = 0
    C[V[i]] += 1
v = V[A-1]
avg = sum(V[:A])/A
print(avg)
cnt = V[:A].count(v)
if cnt<A:
    tot = factorial(C[v])//factorial(cnt)//factorial(C[v]-cnt)
else:#cnt==A
    tot = 0
    for j in range(A,min(B,C[v])+1):
        tot += factorial(C[v])//factorial(j)//factorial(C[v]-j)
print(tot)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

bool query(string x) {
  cout<<"? "<<x<<endl;
  string s;
  cin>>s;
  return s == "Y";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string prefix;
  REP(i,10) {
    int le = i > 0 ? 0 : 1;
    int gt = 10;
    while (gt - le > 1) {
      int mid = (gt + le) / 2;
      string q = prefix + to_string(mid);
      int rem = 18 - q.size();
      q += string(rem, '0');
      if (query(q)) {
        gt = mid;
      } else {
        le = mid;
      }
    }
    prefix += to_string(le);
  }
  ll p = stol(prefix);
  prefix = to_string(p+1);
  if (prefix.front() == '1') {
    string s = "9";
    FOR(i,1,10) {
      if (query(s)) {
        cout<<"! "<<prefix.substr(0, i)<<endl;
        return 0;
      }
      s += "0";
    }
    cout<<"! 1000000000"<<endl;
  } else {
    string s = "10";
    FOR(i,1,10) {
      if (!query(s)) {
        cout<<"! "<<prefix.substr(0, i)<<endl;
        return 0;
      }
      s += "0";
    }
  }
  return 0;
}


Measured memory_bytes: 628
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

const int CMax = 100002;

int n, A[CMax];
string sk;

int main(){
    cin >> sk;
    if (sk[0] == '9' || sk[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

int cnt[2100];
int dist[2100][2100];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, x, y, i;
    cin >> n >> x >> y;
    memset(dist, INF, sizeof(dist));
    xrep(i, 1, n + 1) {
        dist[i][i] = 0;
        dist[i][i+1] = dist[i+1][i] = 1;
    }
    int j;
    xrep(i, 2, n) {
        xrep(j, 1, n - i + 1) {
            dist[j][j + i] = dist[j+i][j] = dist[j][j+i-1] + 1;
        }
    }
    dist[x][y] = dist[y][x] = 1;
    xrep(i, 1, x + 1) {
        xrep(j, y, n + 1) {
            dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][x] + 1 + dist[y][j]);
        }
        for (j = y - 1; j > x; j--) {
            dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][x] + 1 + dist[y][j]);
        }
    }
    xrep(i, x + 1, y) {
        xrep(j, y, n + 1) {
            dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][x] + 1 + dist[y][j]);
        }
    }
    xrep(i, x + 1, y) for (j = y - 1; j > x; j--) {
        dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][x] + 1 + dist[y][j]);
    }

    xrep(i, 1, n) xrep(j, i + 1, n + 1) {
        cnt[dist[i][j]]++;
    }
    xrep(i, 1, n) cout << cnt[i] << endl;


}


Measured memory_bytes: 17536
import bisect
# from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=sorted(list(map(int,input().split())))
    B=list(map(int,input().split()))
    C=sorted(list(map(int,input().split())))

    cnt=0
    for i in B:
        a=bisect.bisect_left(A,i)
        c=N-bisect.bisect_right(C,i)
        cnt+=a*c

    print(cnt)





resolve()

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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=3007;

ll dp[N][N],a[N];

int main(){
	int n=input();
	for(int i=1;i<=n;i++) a[i]=input();

	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			int l=j-i+1,r=j;
			dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
		}
	}
	printf("%lld\n",dp[1][n]);
}

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

int main(){
    int n;
  cin >> n ;
  
  int a,b;
  vector <bool> d;
  bool t=false;
  
  rep(i,n){
    cin >> a >> b;
    if(a==b)
      d.push_back(true);
    else
	d.push_back(false);
  }
  
  rep(i,n-2){
    if(d.at(i) && d.at(i+1) && d.at(i+2))
      t=true;
  }
  
  if(t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}



Measured memory_bytes: 3628
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a; i < b; i++)

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

	vector<string> w(n);
	rep(i, 0, n) cin >> w[i];

	char last = w[0][0];
	map<string, int> m;
	rep(i, 0, n) {
		if (m[w[i]] == 0) m[w[i]] = 1;
		else {
			cout << "No" << endl;
			return 0;
		}
		int x = w[i].size();
		if (last != w[i][0]) {
			cout << "No" << endl;
			return 0;
		}
		last = w[i][x - 1];
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
import heapq

def dijkstra(G, s):
    n = len(G)
    INF = float("inf")
    d = [INF] * n
    d[s] = 0
    pq = []
    heapq.heappush(pq, (0, s)) # (cost, vertex)
    while pq:
        c, v = heapq.heappop(pq)
        if d[v] < c:
            continue
        for nv, nc in G[v]:
            if d[nv] > d[v] + nc:
                d[nv] = d[v] + nc
                heapq.heappush(pq, (d[nv], nv))
    return d

n = input()
G = [[] for i in xrange(n)]
for i in xrange(n):
    li = map(int, raw_input().split())
    for j in xrange(li[1]):
        G[i].append((li[2 * (j + 1)], li[2 * (j + 1) + 1]))

d = dijkstra(G, 0)
for i, c in enumerate(d):
    print i, c

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

int main(){
	long long A, B, C, K;
    cin >> A >> B >> C >> K;
    long long ans = 0;

    if(A <= K){
        ans += A;
        if((A+B) <= K){
            ans -= K - (A+B);
        }
    }
    else{
        ans = K;
    }

    cout << ans << endl;

    
}	

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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

unordered_map<ll,ll> m;
ll n, a, b, c, d;

ll f(ll p){

	if(p == 0){
		return 0;
	}

	if(p == 1){
		return d;
	}

	ll x, y, cost;
	ll get = LLONG_MAX;

	if(p != n and m[p] != 0){
		return	m[p]; 
	}

	x = (p/2)*2;
	y = x + 2;
	cost = (p - x) * d + a;
	if((x/2)!=p)	get = min(get, cost + f(x/2));
	cost = (y - p) * d + a;
	if((y/2)!=p)	get = min(get, cost + f(y/2));

	x = (p/3)*3;
	y = x + 3;
	cost = (p - x) * d + b;
	if((x/3)!=p)	get = min(get, cost + f(x/3));
	cost = (y - p) * d + b;
	if((y/3)!=p)	get = min(get, cost + f(y/3));

	x = (p/5)*5;
	y = x + 5;
	cost = (p - x) * d + c;
	if((x/5)!=p)	get = min(get, cost + f(x/5));
	cost = (y - p) * d + c;
	if((y/5)!=p)	get = min(get, cost + f(y/5));

	if(p < INF/d)	get = min(get, p * d);
	m[p] = get;

	return get;
}

void solve(){
	m.clear();
	cin >> n >> a >> b >> c >> d;
	m[n] = 0;
	ll ans = f(n);
	cout << ans << endl;
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	cin>>no;
	// no = 1;
	while(no--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 4132
import copy
while 1:
    try:
        s = input().split('=')
        t = s[0].split('+')
        t.append(s[1])
        copy_t = copy.copy(t)
        flag = 0
        check = 0
        for i in range(3):
            if (t[i][0] == 'X' and len(t[i]) >= 2):
                check = 1
        for i in range(10):
            if check == 1 and i == 0:
                continue
            for j in range(3):
                t[j] = t[j].replace('X', str(i))
            if int(t[0]) + int(t[1]) == int(t[2]):
                flag = 1
                print(i)
                break
            t = copy.copy(copy_t)

        if flag == 0:
            print('NA')
    except:
        break



Measured memory_bytes: 6332
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

class C {
	int N;
	int a[2][100];
public:
	void solve()
	{
		int ans[2][101];
		memset(ans, 0, sizeof ans);
		ans[0][0] = a[0][0];

		for (int x{ 0 }; x < N; x++)
		{
			ans[0][x + 1] = ans[0][x] + a[0][x + 1];

			ans[1][x] = ans[0][x] + a[1][x];

			if (x)
			{
				ans[1][x] = max(ans[1][x], ans[1][x - 1] + a[1][x]);
			}
		}
		cout << ans[1][N - 1] << endl;
	}

	C()
	{
		cin >> N;
		for (int i{ 0 }; i < N; i++)
			cin >> a[0][i] ;
		for (int i{ 0 }; i < N; i++)
			cin >> a[1][i] ;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

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

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<ll, ll>;
using mint = modint1000000007;

// UnionFind木(サイズ持ち)
class UnionFind {
    public : 

        vector<int> par;

        UnionFind(int N){
            par = vector<int>(N, -1);
        }

        int parent(int x){
            return par[x];
        }

        int root(int x){
            if(par[x] < 0)return x;
            return par[x] = root(par[x]);
        }

        int size(int x){
            return -par[root(x)];
        }

        void connect(int x, int y){
            int rx = root(x);
            int ry = root(y);
            if(rx == ry)return;

            if(size(rx) < size(ry))swap(rx, ry);

            par[rx] += par[ry];
            par[ry] = rx;

            return;
        }

        bool same(int x, int y){
            return root(x) == root(y);
        }
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;b--;
        uf.connect(a, b);
    }
    set<int> st;
    rep(i, n)st.insert(uf.root(i));
    ll res = st.size() - 1;
    if(res < 0)res = 0;
    cout << res << endl;
}

Measured memory_bytes: 7540
#include<iostream>
#include<algorithm>
using namespace std;
const int INF = 1 << 30;
int main(){
  int a[4], b[4], n;
  while(cin >> n, n){
    while(n--){
      for(int i = 0 ; i < 4 ; i++ ) cin >> a[i];
      for(int i = 0 ; i < 4 ; i++ ) cin >> b[i];
      cout << a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3] << " "
           << a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2] << " "
           << a[0] * b[2] + a[2] * b[0] - a[1] * b[3] + a[3] * b[1] << " "
           << a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1] << endl;
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() ll int t;cin>>t;while(t--)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll x=c-a;
ll y=d-b;
for(int i=1;i<=y;i++)
{
  cout<<"U";
}
for(int i=1;i<=x;i++)
{
  cout<<"R";
}
for(int i=1;i<=y;i++)
{
  cout<<"D";
}
for(int i=1;i<=x;i++)
{
  cout<<"L";
}
cout<<"L";
for(int i=1;i<=y+1;i++)
{
  cout<<"U";
}
for(int i=1;i<=x+1;i++)
{
  cout<<"R";
}
cout<<"D";
cout<<"R";
for(int i=1;i<=y+1;i++)
{
  cout<<"D";
}
for(int i=1;i<=x+1;i++)
{
  cout<<"L";
}
cout<<"U";
cout<<endl;
return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
p = LIST()

if p == sorted(p):
  print("YES")
  exit()

for i in range(N-1):
  for j in range(i+1, N):
    q = p.copy()
    q[i] = p[j]
    q[j] = p[i]
   
    if q == sorted(p):
      print("YES")
      exit()
      
print("NO")
    

Measured memory_bytes: 5268
#include <iostream>
#include <iomanip>
#include <cstring>

using namespace std;

int main(){
  int n,x,y;
  while(cin>>n&&n){
    x=n/2;y=n/2+1;
    int m[n][n];
    memset(m,0,sizeof(m));
    for(int i=1;i<=n*n;++i){
      if(m[y][x]==0) m[y][x]=i;
      else{
	while(1){
	  x=(x+n-1)%n;y=(y+1)%n;
	  if(m[y][x]==0){
	    m[y][x]=i;break;
	  }
	}
      }
      x=(x+1)%n;y=(y+1)%n;
    }
    for(int i=0;i<n;++i){
      for(int j=0;j<n;++j) cout<<setw(4)<<right<<m[i][j];
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

string S;
int N;

int main(){
    cin>>S;
    N=S.size();

    ll ans=0;
    rep(i,1<<N-1){
        ll sum=0;
        ll x=S[0]-'0';
        rep(j,N-1){
            if(i>>j&1){
                sum+=x;
                //cout<<x<<' ';
                x=S[j+1]-'0';
            }else{
                int m=S[j+1]-'0';
                x=x*10+m;
            }
        }
        sum+=x;
        //cout<<x<<endl;
        ans+=sum;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

template<typename T>
map<T, int> primeFactor(T n){
    map<T, int> mp;
    for(T i=2; i*i<=n; i++){
        if(n == 1) break;
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    // prime
    if(n != 1) mp[n]++;
    return mp;
}

int main(){
    ll n, res = 0, tem = 0;
    cin >> n;
    map<ll, int> mp;
    mp = primeFactor(n);
    for (const auto& [key, value] : mp){
        tem = value;
        for(ll i=1; i<1000; i++){
            tem -=i;
            if(tem < 0){
                break;
            }
            res++;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string abc;
	cin >> abc;
	int ff = 1;
	
	if (abc.length()%2==1)
	{
		cout << "No\n";
		exit(0);
		ff = 0;
	} 
	else
	{
		for (int i = 0; i < abc.length(); i++)
		{
			if (i%2==0 && abc[i] != 'h') 
			{
				cout << "No\n";
				exit(0);
				ff = 0;
			}
			if (i%2==1 && abc[i] != 'i')
			{
				cout << "No\n";
				exit(0);
				ff = 0;
			}
		}
	}
	if (ff) cout << "Yes\n";	
} 

Measured memory_bytes: 256
a,b,k=map(int,input().split())
l=[]
for i in range(a,min(b+1,a+k)):
    l.append(i)
for i in range(max(a,b-k+1),b+1):
    l.append(i)
l=sorted(set(l))
for i in l:print(i)

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

int main(){
  int n, t;
  cin >> n >> t;
  vector<int> A(n);
  for (int i=0; i<n; i++) cin >> A[i];

  vector<int> sell(n);
  sell[n-1] = A[n-1];
  for (int i=n-2; i>=0; i--) sell[i] = max(sell[i+1], A[i]);

  vector<int> buy(n);
  buy[0] = A[0];
  for (int i=0; i<n-1; i++) buy[i+1] = min(buy[i], A[i+1]);

  int sell_price = sell[0], ans = 1, max_price = sell[0] - buy[0];
  for (int i=1; i<n; i++){
    if (max_price == sell[i] - buy[i]){
      if (sell_price != sell[i]){
        ans++;
        sell_price = sell[i];
      }
    }
    else if (max_price < sell[i] - buy[i]){
      sell_price = sell[i];
      ans = 1;
      max_price = sell[i] - buy[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    long long N,A,B;
    cin >> N >> A >> B;
    vector<long long> X;
    for(int i=0; i<N; i++){
        long long j;
        cin >> j;
        X.push_back(j);
    }
    sort(X.begin(), X.end());
    long long sum=0;
    for(int i = 0; i < N-1; i++){
        long long distance = X[i+1] - X[i];
        if(distance*A < B){
            sum += distance*A;
        }else{
            sum += B;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 1400
// B - Collatz Problem
#include <bits/stdc++.h>
using namespace std;

int main(){
	int s; cin>>s;
	set<int> S;
	while(!S.count(s)){
		S.insert(s);
		s = s%2? 3*s+1: s/2;
	}
	cout<< S.size()+1 <<endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine();

        int strCnt = int.Parse(input.Split(' ')[0]);
        int strLength = int.Parse(input.Split(' ')[1]);

        var list = new List<string>();

        for (int i = 0; i < strCnt; i++)
        {
            list.Add(Console.ReadLine());
        }

        list.Sort();

        list.ForEach(x => Console.Write(x));

        Console.ReadLine();
    }
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
#define int long long
using namespace std;
double dp[3000][3000];

signed main() {
  int N;cin>>N;
  std::vector<double> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)dp[i][j]=0;
  dp[0][0]=1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=N;j++){
      dp[i][j]+=dp[i-1][j]*(1-v[i-1]);
      if(j)dp[i][j]+=dp[i-1][j-1]*v[i-1];
    }
  }
  double ans=0;
  for(int j=N/2+1;j<=N;j++)ans+=dp[N][j];
  //for(int i=0;i<=N;i++){
  //  for(int j=0;j<=N;j++)cout<<dp[i][j]<<" ";
  //  cout<<endl;
  //}
  cout<<fixed<<setprecision(12)<<ans<<endl;
}


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

int main () {
	int n, h; cin >> n >> h;
	int b[n]; int ta, best = 0;
	for (int i = 0; i < n; i++) {
		cin >> ta >> b[i];
		best = max(best, ta);
	}
	sort(b,b+n,greater<int>());
	int ans = 0;
	for (int i = 0; i < n and h > 0 and b[i] > best; i++) {
		ans++;
		h -= b[i];
	}
	if (h > 0) ans += h/best + (h%best != 0 ? 1 : 0);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640