akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long n = long.Parse(Console.ReadLine());
        long ans = 0;
        long max = 0, maxguy = 0;
        long min = int.MaxValue, minguy =0;
        for (long i = 0; i < n; i++)
        {
            long[] s = Read.longs();
            if (s[1] > max) { max = s[1]; maxguy = s[0]; }
            if (s[1] < min) { min = s[1]; minguy = s[0]; }

        }
        ans = min  + maxguy - 1;

        Console.WriteLine(ans+minguy-maxguy+1);
        Console.ReadLine();

        /*  int n = int.Parse(Console.ReadLine());
          for(int i = 1; i <= 1750; i++)
          {
              for (int j = 1; j <= 1750; j++)
              {
                  for (int k = 1; k <= 1750; k++)
                  {
                      if (n * (i * j + j * k + i * k) == 4 * i * j * k)
                      {
                          Console.WriteLine(i + " " + j + " " + k);
                          Console.ReadLine();
                          return;
                      }
                      int j1 = 3501 - j;
                      int i1 = 3501 - i;
                      int k1 = 3501 - k;
                      if (n * (i1 * j1 + j1 * k1 + i1 * k1) == 4 * i1 * j1 * k1)
                      {
                          Console.WriteLine(i1 + " " + j1 + " " + k1);
                          Console.ReadLine();
                          return;
                      }

                  }
              }
          }*/
    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a / gcd(a, b) * b;
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 17448
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] nums = new int[N];
    for (int i = 0; i < N; i++) {
      nums[i] = sc.nextInt();
    }

    int result =0;
    for (int i = 0; i < N; i++) {
      for (int j = i+1; j < N; j++) {
        result += nums[i] *nums[j];
      }
    }

    System.out.println(result);
  }





}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
template<typename ...Args> void read(Args&... args) { (cin >> ... >> args); }
template <typename...Args> void writeln(const Args &... args) { ((cout << args << " "), ...), cout << "\n"; }
template <typename...Args> void write(const Args &... args) { ((cout << args), ...), cout << "\n"; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> typename enable_if<is_same<decltype(declval<T>().size()), size_t>::value, int>::type operator~(const T& ct) { return (int)ct.size(); }
template <typename T, typename... Args> bool ckmax(T &a, const Args&... b) { return (a < max({b...})) ? (a = max({b...}), true) : false; }
template <typename T, typename... Args> bool ckmin(T &a, const Args&... b) { return (a > min({b...})) ? (a = min({b...}), true) : false; }
template <typename T> struct range {
    T u, v; bool inclusive;
    range(const T& _u, const T& _v, const bool& _inclusive = false) : u(_u), v(_v), inclusive(_inclusive) {}
    bool has(const T& w) { return (u <= w) and (inclusive ? (w <= v) : (w < v)); }
};
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vpii = vector<pii>;
using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T, vector<T>, less<T>>;
const int N = 200'010;
auto soln() {
    long long n; read(n);;
    ll sum = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; j+= i) {
            sum += (j);
        }
    }
    cout << sum << "\n";
}
signed main() {
    int t = 1;
    { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
    while (t--)
        soln();
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main() {
  int n_cats, n_cats_or_dogs, x;
  cin >> n_cats >> n_cats_or_dogs >> x;
  
  if (n_cats <= x && x <= n_cats + n_cats_or_dogs) {
    cout << "YES";
  }
  else {
    cout << "NO";
  }
}

Measured memory_bytes: 256
n = gets.to_i

s = {}

for i in 2..n
  t = i
  j = 2
  while j * j <= i
    while t % j == 0
      if s.has_key? j
        s[j] += 1
      else
        s[j] = 1
      end
      t /= j
    end
    j += 1
  end
  if t != 1
    if s.has_key? t
      s[t] += 1
    else
      s[t] = 1
    end
  end
end

sum = 1

s.each { |k, v|
  sum = (sum * (v+1)) % (10**9 + 7)
}

puts sum


Measured memory_bytes: 1788
package main

import "fmt"

type container struct {
	data []byte
}

func (c *container) push(v byte) {
	c.data = append(c.data, v)
}
func (c *container) isEmpty() bool {
	if len(c.data) == 0 {
		return true
	}
	return false
}
func (c *container) pop(v *byte) bool {
	if !c.isEmpty() {
		*v = c.data[len(c.data)-1]
		c.data = c.data[0 : len(c.data)-1]
		return true
	}
	return false
}
func (c *container) peek(v *byte) bool {
	if !c.isEmpty() {
		*v = c.data[len(c.data)-1]
		return true
	}
	return false
}

func main() {
	var S string
	fmt.Scan(&S)
	var stack container
	for i := 0; i < len(S); i++ {
		if S[i] == 'S' {
			stack.push(S[i])
		} else { // S[i] == 'T'
			var v byte
			if stack.peek(&v) && v == 'S' {
				stack.pop(&v) // 捨てる
			} else {
				stack.push('T')
			}
		}
	}
	fmt.Println(len(stack.data))
}


Measured memory_bytes: 3072
n, m, c = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a = [0] * n
cnt = 0
for i in range(n):
  a[i] = [int(k) for k in input().split()]
  ab = c
  for j in range(m):
    ab += a[i][j] * b[j]
  if ab > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define rep(ii, jj, ll, ss) for(int ii = jj; ii < ll; ii += ss)
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0;
#define get(vv, times) for(int ii = 0; ii < times; ++ii) {int jj; cin >> jj; (vv).pb(jj);}

int n, ans;
map <int, int> v;

int32_t main() {
	ans = 0;
	cin >> n;
	rep(i, 0, n, 1) {
		int x; cin >> x;
		++v[x];
	}
	for(auto it:v) {
		if (it.second % 2 == 1) ++ans;
	}
	cout << ans;
}

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

const int N = 1e5 + 5;

int col[N], cp[N];
vector<int> g[N];
bitset<N> vis;

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> edges;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
        edges.emplace_back(u, v);
    }
    int k = 0;
    map<pair<int, int>, int> col;
    queue<int> q;
    q.push(1);
    vis[1] = 1;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        k = max(k, (int) g[u].size());
        int c = 1;
        for (int v : g[u]) {
            if (vis[v]) continue;
            if (c == cp[u]) c++;
            cp[v] = col[{u, v}] = col[{v, u}] = c++;
            vis[v] = 1;
            q.push(v);
        }
    }     
    cout << k << '\n';
    for (auto pp : edges) {
        cout << col[pp] << '\n';
    }
}

Measured memory_bytes: 19704
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> b(n - 1);
    cin >> b;
    ll ans = 0;
    for(int i = 0; i < n - 1; i++) {
        ans += min(b[i], i ? b[i-1] : b[i]);
    }
    cout << ans + b.back() << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

//1-indexであることに注意
template <typename T>
struct BIT {
    int n;
    vector<T> data;

    BIT(int n) : n(n), data(n + 1, 0) {}

    T sum(int i) {
        T s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, T x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }
};

ll solve(int x, vector<int>& a) {
    int n = a.size();
    vector<int> b(n + 1, 0);
    for (int i = 0; i < n; i++) {
        b[i + 1] = (a[i] >= x ? 1 : -1);
        b[i + 1] += b[i];
        b[i] += n;
    }
    b[n] += n;

    BIT<ll> bt(2 * n + 1);
    bt.add(b[0], 1);
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        res += bt.sum(b[i]);
        bt.add(b[i], 1);
    }
    return res;
}

ll solve2(int x, vector<int>& a) {
    int n = a.size();

    vector<int> b(n + 1, 0);
    for (int i = 0; i < n; i++) {
        b[i + 1] = (a[i] >= x ? 1 : -1);
        b[i + 1] += b[i];
        b[i] += n;
    }
    b[n] += n;

    vector<ll> c(2 * n + 1, 0);
    c[b[0]]++;
    ll sum = 1, res = 0;
    for (int i = 1; i <= n; i++) {
        if (b[i] < b[i - 1]) {
            sum -= c[b[i - 1]];
        } else {
            sum += c[b[i]];
        }
        res += sum;
        c[b[i]]++;
        sum++;
    }
    return res;
}

//引数unzipには圧縮前のvectorを入れる
int compress(vector<int>& unzip, map<int, int>& zip) {
    sort(unzip.begin(), unzip.end());
    unzip.erase(unique(unzip.begin(), unzip.end()), unzip.end());
    for (int i = 0; i < unzip.size(); i++) {
        zip[unzip[i]] = i;
    }
    return unzip.size();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll lim = ((ll)(n + 1) * n / 2 + 1) / 2;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
   
    vector<int> a2(a);
    map<int, int> dummy;

    int ok = 0, ng = compress(a2, dummy);
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        if (solve2(a2[mid], a) >= lim) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << a2[ok] << endl;
    return 0;
}

Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int numa, numb;
    cin >> numa >> numb;

    if(numb-numa>673){
        cout << "0" << endl;
    }else{
        double ans = 2020;
        for(int i=numa;i<numb;i++){
            for(int j=i+1;j<=numb;j++){
                int A = i%2019;
                int B = j%2019;
                if((A*B)%2019<ans){
                    ans = (A*B)%2019;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
while 1:
    n = int(raw_input())
    if n == 0: break
    a = b = 0 
    for i in range(n):
        x, y = map(int, raw_input().split())
        if x > y:
            x += y
            y = 0
        elif x < y:
            y += x
            x = 0
        a += x
        b += y
    print a, b

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

const long long MOD = 998244353;

class Math {
public:
    Math(int N = 0, long long mod = 1e9 + 7)
        : N_(N)
        , mod_(mod)
    {
    }

    long long pow(long long x, long long y)
    {
        ll ans = 1;
        while (y > 0) {
            if (y & 0x1) {
                ans = (ans * x) % mod_;
            }
            x = (x * x) % mod_;
            y >>= 1;
        }
        return ans;
    }

    long long combination(long long n, long long k)
    {
        if (k < 0 || k > n) {
            return 0;
        }
        if (fact_.empty()) {
            build_fact();
        }
        return fact_[n] * (fact_inv_[k] * fact_inv_[n - k] % mod_) % mod_;
    }

    static long long powm(long long x, long long y, long long mod = 1e9 + 7)
    {
        ll ans = 1;
        while (y > 0) {
            if (y & 0x1) {
                ans = (ans * x) % mod;
            }
            x = (x * x) % mod;
            y >>= 1;
        }
        return ans;
    }

private:
    void build_fact()
    {
        if (!fact_.empty()) {
            return;
        }
        fact_.resize(N_ + 1);
        fact_[0] = 1;
        for (ll i = 1; i <= N_; i++) {
            fact_[i] = fact_[i-1] * i % mod_;
        }
        fact_inv_.resize(N_ + 1);
        fact_inv_[N_] = pow(fact_[N_], mod_ - 2);
        for (ll i = N_ - 1; i >= 0; i--) {
            fact_inv_[i] = fact_inv_[i + 1] * (i + 1) % mod_;
        }
    }

    int N_;
    long long mod_;
    vector<long long> fact_;
    vector<long long> fact_inv_;
};

void solve(long long N, long long M, long long K)
{
    Math m(N, MOD);
    ll ans = 0;
    for (ll i = 0; i <= K; i++) {
        ll val = M * m.pow(M - 1, N - i - 1);
        val %= MOD;
        val *= m.combination(N - 1, i);
        val %= MOD;
        ans += val;
        ans %= MOD;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    long long K;
    scanf("%lld", &K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 6396
#include <iostream>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

using namespace std;

int main(void)
{
	while(1){
		int n;
		cin >> n;
		if (n == 0){
			break;
		}
		int s, sum=0, maxi, mini;
		cin >> s;
		maxi = s;
		mini = s;
		sum += s;
		for(int i=1;i<n;i++){
			cin >> s;
			maxi = max(maxi, s);
			mini = min(mini, s);
			sum += s;
		}
		sum -= (maxi + mini);
		cout << sum/(n-2) << endl;
	}
	return 0;
}


Measured memory_bytes: 3008
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int G[111];
set<int> s;
set<int>::iterator it;

int get(int x, int y) {
  if(x < y) return 0;
  int rem = x / y;
  s.clear();
  rep(i,1,rem+1) {
    s.insert(G[x - i]);
  }
  int cnt = 0;
  for(it = s.begin(); it != s.end(); it++) {
    if(*it != cnt) {
      return cnt;
    }
    cnt++;
  }
  return cnt;
}

void bf() {
  int k;
  S(k);
  rep(i,k,100) {
    G[i] = get(i,k);
    printf("%d. %d\n",i,G[i]);
  }
}

int grundy(int x, int y) {
  if(x < y) return 0;
  if(x % y == 0) return x / y;
  while(x >= y) {
    if(x % y == 0) return x / y;
    int diff = x / y;
    if(diff == 1) {
      if((x - y) % 2) return 0;
      else return 1;
    }
    x -= diff + 1;
    // printf("%d %d\n",x,y);
  }
  return 0;
}

int main() {
  int n;
  int g = 0;
  S(n);
  rep(i,0,n) {
    int x,y;
    S2(x,y);
    g ^= grundy(x, y);
  }
  if(g) printf("Takahashi\n");
  else printf("Aoki\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef struct{
    int A;
    int B;
}MAGIC;
#define INF 1E9;
int main(){
    int H,N;
    cin >> H >> N;
    MAGIC magic[N];
    for(int i=0; i<N; i++){
        cin >> magic[i].A >> magic[i].B;
    }
    int M=magic[0].A;
    MAGIC dp[H+1][N+1];
    for(int i=0; i<=N; i++){
        dp[0][i].A=0;
        dp[0][i].B=0;
    }
    for(int i=1; i<=H; i++){
        dp[i][0].A=0;
        dp[i][0].B=INF;
        for(int j=1; j<=N; j++){
            if(magic[j-1].A>=i){
                if(dp[i][j-1].B>magic[j-1].B){
                    dp[i][j]=magic[j-1];
                }else if(dp[i][j-1].B==magic[j-1].B){
                    dp[i][j].A=max(dp[i][j-1].A,magic[j-1].A);
                    dp[i][j].B=magic[j-1].B;
                }else{
                    dp[i][j]=dp[i][j-1];
                }
            }else if(i<=dp[i-1][j].A){
                if(dp[i][j-1].B<dp[i-1][j].B){
                    dp[i][j]=dp[i][j-1];
                }else if(dp[i][j-1].B==dp[i-1][j].B){
                    dp[i][j].A=max(dp[i][j-1].A,dp[i-1][j].A);
                    dp[i][j].B=dp[i][j-1].B;
                }else{
                    dp[i][j]=dp[i-1][j];
                }
            }else{
                if(dp[i][j-1].B<dp[i-magic[j-1].A][j].B+magic[j-1].B){
                    dp[i][j]=dp[i][j-1];
                }else if(dp[i][j-1].B==dp[i-magic[j-1].A][j].B+magic[j-1].B){
                    dp[i][j].A=max(dp[i][j-1].A,dp[i-magic[j-1].A][j].A+magic[j-1].A);
                    dp[i][j].B=dp[i][j-1].B;
                }else{
                    dp[i][j].A=dp[i-magic[j-1].A][j].A+magic[j-1].A;
                    dp[i][j].B=dp[i-magic[j-1].A][j].B+magic[j-1].B;
                }
            }
        }
    }
    cout << dp[H][N].B;
    return 0;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n , m , k ; cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    rep(i,n) cin >> a.at(i);
    rep(i,m) cin >> b.at(i);
    vector<ll> arui(n+1),brui(m);
    arui.at(0) = 0 , brui.at(0) = b.at(0);
    for(int i=1;i<=n;i++){
        arui.at(i) = arui.at(i-1) + a.at(i-1);
    }
    for(int i=1;i<m;i++){
        brui.at(i) = brui.at(i-1) + b.at(i);
    }
    ll ans = 0; //出力する答え

    for(int i=0;i<=n;i++){
        //Aの机からi冊目までを読む
        ll x = arui.at(i); //Aの机から選んだ本を読む時間
        ll y = k-x; //残り時間
        if(y<0) continue;
        auto it = upper_bound(brui.begin(),brui.end(),y);
        ans = max(ans,(ll)(i+(it-brui.begin())));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9576
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return ;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int d=read();
		n-=d;
	}
	if(n<0)puts("-1");
	else pr2(n);
	return 0;
}

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

 int main() {
   int H,W;
   int h,w;
   cin >> H >> W;
   cin >> h >> w;
  // cout << H << W << h << w << endl;
   int a = H * W;
   int ans = a - ((H *w) + ((W - w) * h));
   cout << ans << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans = 1;
    n -= k;
    while(n>0){
        ans++;
        n -= k-1;
    }
    cout << ans << endl;
}

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

int N, M;
map<int, set<int> > mp;
int ans = 0;
set<int> alp;

void dps(int nxt){
  alp.insert(nxt);
  if (alp.size() == N){
    ans++;
  }
  else{
    for (int x: mp[nxt]){
      if (alp.find(x) == alp.end()){
        dps(x);
      }
    }
  }
  alp.erase(nxt);
}

int main(){
  cin >> N >> M;
  for (int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    mp[a].insert(b);
    mp[b].insert(a);
  }
  dps(1);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

int main() {
    int n;
    cin >> n;
    int a = 0;
    int b = 0;
    REP(i,n) {
        string s,t;
        cin >> s >> t;
        if (s > t) {
            a += 3;
        }else if (t > s) {
            b += 3;
        }else {
            a += 1; b += 1;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 1000000007;

LL N,M,S,L;
LL a,b,c,d;
string s;
int main(){
    cin>>N>>L;
    LL sum=0;
    LL minA=N+30000;
    
    for(int i=1;i<=N;i++){
        if(minA>abs(L+i-1)){
            minA=abs(L+i-1);
            a=L+i-1;
        }
        sum+=L+i-1;
    }
    cout<<sum-a;
    return 0;
}


Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
top_red = p[-x:]
top_green = q[-y:]
final = top_red+top_green+r
final.sort()
print(sum(final[-(x+y):]))

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

int main(){
    int s, a, bcd[3], n = 3;
    cin >> s;
    a = s/1000;
    s %= 1000;
    bcd[0] = s/100;
    s %= 100;
    bcd[1] = s/10;
    bcd[2] = s%10;

    bool flg = false;
    int bit;
    for(bit=0;bit<(1<<n);bit++){
        int total = a;
        for(int i=0;i<n;i++){
            if(bit & (1<<i)){
                total += bcd[i];
            }
            else{
                total -= bcd[i];
            }
        }
        if(total == 7){
            break;
        }
    }

    cout << a;
    for(int i=0;i<n;i++){
        if(bit & (1<<i)){
            cout << "+" << bcd[i];
        }
        else{
            cout << "-" << bcd[i];
        }
    }
    cout << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    char n[5];

    scanf("%s",n);
    for(int i=0;i<3;i++)
    {
        if(n[i]=='1')
            n[i]='9';
        else if(n[i]=='9')
            n[i]='1';
    }
    printf("%s",n);







    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

map<ll,ll> factorize(ll x){
  map<ll,ll> ret;
  ll d, q;
  while(x>=4 && x%2==0){ret[2]++; x/=2;}
  d = 3; q = x/d;
  while(q>=d){
    if(x%d==0){ ret[d]++; x=q; }else{ d+=2; }
    q=x/d;
  }
  ret[x]++;
  return ret;
}

int main(){
  ll N, P;
  cin >> N >> P;

  map<ll,ll> ret = factorize(P);

  ll ans = 1;
  for(auto p : ret){
    if(p.second >= N){
      rep(i,p.second / N) ans *= p.first;
    }
  }

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <string>
typedef long long int ll;
using namespace std;

int main(){
	string s; cin >>s;
	for(int i=0;i< (1<<3);i++){
		int sum=s[0]-'0';
		for(int j=0;j<3;j++){
			if((i>>j) &1){
				sum+=(int)(s[1+j]-'0');
			}
			else{
				sum-=(int)(s[1+j]-'0');
			}
		}
		if(sum==7){
			for(int j=0;j<3;j++){
				cout << s[j];
				if(i>>j &1){
					cout << "+";
				}
				else cout << "-";
			}
			cout << s[3] << "=7" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int dp[11][2001];
int main(void)
{
	int i,j,k,l,n,m,hon[11][2001],c,g,sum,temp,max,flg,jan;
	scanf("%d %d",&n,&m);
	for(i=0;i<=10;i++){
		for(j=0;j<=n;j++){
			hon[i][j]=0;
			dp[i][j]=-1;
		}
	}
	jan=0;
	for(i=1;i<=n;i++){
		scanf("%d %d",&c,&g);
		hon[g][i]=c;
		if(jan<g) jan=g;
	}
/*	for(i=0;i<=jan;i++){
		for(j=0;j<=m;j++) printf("%d ",hon[i][j]);
		printf("\n");
	}*/
	for(i=1;i<=jan;i++){
		for(j=1;j<n;j++){
			for(k=j+1;k<=n;k++){
				if(hon[i][j]<hon[i][k]){
					temp=hon[i][j];
					hon[i][j]=hon[i][k];
					hon[i][k]=temp;
				}
			}
		}
	}
	dp[0][0]=0;
	for(i=0;i<jan;i++){
		for(j=0;j<=m;j++){
			if(dp[i][j]!=-1){
				for(k=0;k<=m;k++){
					if(j+k<=m){
						sum=0;
						flg=1;
						if(k<2){
							for(l=1;l<=k;l++){
								if(hon[i+1][l]==0){
									flg=0;
									break;
								}
								sum+=hon[i+1][l];
							}
							if(dp[i+1][j+k]<dp[i][j]+sum&&flg!=0){
								if(dp[i+1][j+k]==-1)dp[i+1][j+k]=0;
								dp[i+1][j+k]=dp[i][j]+sum;
							}
						}
						else {
							for(l=1;l<=k;l++){
								if(hon[i+1][l]==0){ 
									flg=0;
									break;
								}
								sum+=hon[i+1][l]+(k-1);
							}
							if(dp[i+1][j+k]<dp[i][j]+sum&&flg!=0){
								if(dp[i+1][j+k]==-1)dp[i+1][j+k]=0;
								dp[i+1][j+k]=dp[i][j]+sum;
							}
						}
					}
				}
			}
		}
	}
/*	for(i=0;i<=jan;i++){
		for(j=0;j<=m;j++) printf("%d ",dp[i][j]);
		printf("\n");
	}*/
	max=-1;
	for(i=0;i<=m;i++){
		if(max<dp[jan][i]) max=dp[jan][i];
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    string a, b;
    cin >> a >> b;
    if (a.size() != b.size()) {
        if (a.size() > b.size()) {
            cout << "GREATER" << "\n";
        } else {
            cout << "LESS" << "\n";
        }
        return;
    }
    for (int i = 0; i < a.size(); ++i) {
        if (a[i] == b[i]) {
            continue;
        }
        if (a[i] > b[i]) {
            cout << "GREATER" << "\n";
        } else {
            cout << "LESS" << "\n";
        }
        return;
    }
    cout << "EQUAL" << "\n";

}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

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

int main() {
	long long int h, w;
	cin >> h >> w;

	long long int result;
	long long int tmp = h * w;
	if (h == 1 || w == 1) {
		result = 1;
	}
	else if (tmp % 2 == 0) {
		result = tmp / 2;
	}
	else {
		result = tmp / 2 + 1;
	}

	cout << result << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int x = scan.nextInt();
		if (0 <= x - a && x - a <= b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,a[100005];
ll t[42];
int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
    {
        int pos=0;
        while(a[i])
        {
            if(a[i]&1) t[pos]++;
            pos++;
            a[i]>>=1;
        }
    }
    ll ans=0;
    for(int i=41;i>=0;i--)
    {
        ll s=1ll<<i;
        if(t[i]>=n-t[i])
        {
            ans+=t[i]*s;
        }
        else
        {
            if(k>=s) ans+=(n-t[i])*s,k-=s;
            else ans+=t[i]*s;
        }
    }
    cout<<ans<<endl;
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
ll gcd(long a,long b)
{
  while(b>0) {
    a=a%b;
    a=a^b;
    b=b^a;
    a=a^b;
  }
  return a;
}
ll lcm(long a,long b)
{
  long x=(a*b)/gcd(a,b);
  return x;
}


int main(int argc, char** argv) {
  int N;
  ll M;
  cin >> N >> M;
  vll A(N);
  for (auto& a : A) {
    cin >> a;
  }
  REP(i, N) {
    A[i] /= 2;
  }

  ll L = A[0];
  REP(i, 1, N) {
    L = lcm(L, A[i]);
  }

  for (auto a : A) {
    ll x = L/a;
    if (x%2==0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll x = M/L;
  cout << (x+1)/2 << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int k, x;
    cin >> k >> x;
    cout << (500*k >= x ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 384
// D - Ki
#include <bits/stdc++.h>
using namespace std;

vector<int> ans(200000);
vector<vector<int>> ab(200000);

void dfs(int p, int c){
	ans[c] += ans[p];
	for(int cc:ab[c]) if(cc!=p) dfs(c,cc);
}

int in(){int x;scanf("%d",&x);return x;}

int main(){
	int n=in(), q=in();

	for(int i=0; i<n-1; i++){
		int a=in()-1, b=in()-1;
		ab[a].push_back(b);
		ab[b].push_back(a);
	}

	for(int i=0; i<q; i++){
		int p=in()-1;
		ans[p] += in();
	}

	for(int c:ab[0]) if(c) dfs(0,c);
	for(int i=0; i<n; i++) cout<< ans[i] <<(i<n-1?" ":"\n");
}

Measured memory_bytes: 23424
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int maxn=100001;
int n,m;
int a[maxn];

struct bbb{
	int t;
	int num;
};
bbb b[maxn];

bool cmp(bbb x,bbb y){
	return x.num>y.num;
}

int main(){
	long long ans=0;
	cin>>n>>m;
	for (int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i];
	}for (int i=0;i<m;i++){
		cin>>b[i].t>>b[i].num;
	}
	sort(a,a+n);
	sort(b,b+m,cmp);
	int c=0;
	for (int i=0;i<m;i++){
		int cc=c;
		for (int j=cc;j<b[i].t+cc;j++){
			if(j==n) break;
			if (a[j]<b[i].num){
				ans+=b[i].num-a[j];
				c=j+1;
			}else break;
		}
	}
	cout<<ans<<endl;
	return 0;
} 

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ll now = 100;
  while(now < x){
    now += now / 100;
    ans++;
  }
  cout << ans << endl;
}

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

using namespace std;



inline char op(char c)
{
    return c == 'S' ? 'W' : 'S';
}

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

    int n;
    cin >> n;
    string a;
    cin >> a;

    string t;
    for (int i = 0; i <= n; i++) {
        t.push_back(' ');
    }
    for (int f = 0; f < 2; f++) {
        for (int s = 0; s < 2; s++) {
            t[0] = (f == 0 ? 'S' : 'W');
            t[1] = (s == 0 ? 'S' : 'W');

            for (int i = 1; i < n; i++) {
                if (t[i] == 'S') {
                    if (a[i] == 'o') {
                        t[i + 1] = t[i - 1];
                    } else {
                        t[i + 1] = op(t[i - 1]);
                    }
                } else {
                    if (a[i] == 'o') {
                        t[i + 1] = op(t[i - 1]);
                    } else {
                        t[i + 1] = t[i - 1];
                    }
                }
            }
            bool ok = false;
            if (t[0] == 'S') {
                    if (a[0] == 'o') {
                        ok = t[n - 1] == t[1];
                    } else {
                        ok = t[n - 1] == op(t[1]);
                    }
                } else {
                    if (a[0] == 'o') {
                                    ok = t[n - 1] == op(t[1]);
                    } else {
                                                ok = t[n - 1] == t[1];

                    }
                }

            if (t[n] == t[0] and ok) {
                t.resize(n);
                cout << t << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 720
using System;
using System.IO;
using System.Collections.Generic;

namespace AGC028A
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(long.Parse);
            var M = ss.Next(long.Parse);
            var S = ss.Next(String);
            var T = ss.Next(String);

            var lcm = MathX.Lcm(N, M);
            var dic = new Dictionary<long, char>();
            var ans = true;
            for (var i = 0; i < N; i++) dic.Add(i * lcm / N, S[i]);
            for (var i = 0; i < M; i++) ans &= !dic.ContainsKey(i * lcm / M) || dic[i * lcm / M] == T[i];

            sw.WriteLine(ans ? lcm : -1);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public static partial class MathX
    {
        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long Lcm(long a, long b)
        {
            return a * (b / Gcd(a, b));
        }
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 19808
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(p, q, r):
    # 3 -> 3 * 60 = 180
    # 4 -> 4 * 90 = 360
    # 5 -> 5 *
    # 360 / 5 = 180 - 72 = 108 = 54 * 2 * 5
    # (180 - (360 / 5)) * 5
    #p, q, r
    e = max(p, q, r)
    if e == p: return q + r
    elif e == q: return p + r
    elif e == r: return p + q
    else:
        assert(True)



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    # k = int(parsed_lines[0][1])
    # S = parsed_lines[1][0]
    # return n, k, S
    return n


if not do_submit:
    n = input_parse("""
    3
    """)
    print(sol(n))

    n = input_parse("""
    100
    """)
    print(sol(n))

else:
    p, q, r= list(map(int, input().split()))
    # S = input().split()
    # print(sol(n, k, S))
    #n = int(input().strip())
    # S = input().strip()
    print(sol(p, q, r))



Measured memory_bytes: 3688
#include<bits/stdc++.h>
//#define int long long int
//#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<(int)n;i++)
#define rev(i,n,init) for(int i=(int)n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }

using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int32_t MOD=MOD1;



int32_t main()
{ 
      getFaster;
      int tests=1; 
      //cin>>tests;
      rep(ii,0,tests)
      {
            int n;
            cin>>n;
            int a[n];
            rep(i,0,n)cin>>a[i];
            sort(a,a+n);
            int cnt=0;
            rep(i,0,n)
            {
                  rep(j,i+1,n)
                  {
                        rep(k,j+1,n)
                        {
                              if(a[i]!=a[j] && a[j]!=a[k] && a[i]+a[j]>a[k])
                              {
                                    cnt++;
                              }
                        }
                  }
            }
            cout<<cnt<<endl;
      } 
      return 0;                         
}

Measured memory_bytes: 3652
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s)
	{
		a--;
	 } 
	 else
	 {
	 	b--;
	 }
	 cout<<a<<' '<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
typedef pair<long,long> P;
int main(){
	int n,m;
	cin >> n >> m;
	P drink[n];
	for(int i=0;i<n;i++) cin >> drink[i].first >> drink[i].second;
	sort(drink,drink+n);

	long ans=0;
	int cur=0;
	while(m){
		if(m>drink[cur].second){
			ans+=drink[cur].first*drink[cur].second;
			m-=drink[cur].second;
			cur++;
		}else{
			ans+=drink[cur].first*m;
			m-=m;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	string s;
	cin>>a>>b>>s;
	f(i,s.size()){
		if(i==b-1)cout<<(char)(s[i]+32);
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
n-=1

for l in range(1,15):
    if n >= 26 ** l:
        n -= 26 ** l
        continue

    ans = ""
    for i in range(l):
        d = n % 26
        ans += chr(d + ord('a'))
        n //= 26
    ans = ans[::-1]
    break

print(ans)
    
        

Measured memory_bytes: 9196
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	int n;
	char s[150];
	scanf("%d",&n);
	scanf("%s",s);
	
	int x=0,max=0;
	for(int i=0; i<n; i++){
		if(s[i]=='I'){
			x++;
			if(max<x)max=x;
		}
		else x--;
	}
	printf("%d\n",max);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
 
int main( ) {
    int n;
    while(cin >> n) {
        int count = 0;
        for(int a=0; a<=9; a++) {
            for(int b=0; b<=9; b++) {
                for(int c=0; c<=9; c++) {
                    for(int d=0; d<=9; d++) {
                        if(a+b+c+d == n) {
                            count++;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
			int x, y, z, a, b, c;
		Scanner sc = new Scanner(System.in);
		a = 0;
		x = sc.nextInt();
		y = sc.nextInt();

		y = y / 1000;

		if (y < x) {
			System.out.println("-1 -1 -1");
		} else if (y == x) {
			System.out.println( "0 0 "+y);
		} else {
			z = y - x;
			while (z % 9 != 0) {
				z = z - 4;
				a++;

			}
			// a=a;
			b = z / 9;
			c = x - a - b;

			if (a < 0 || b < 0 || c < 0) {
				System.out.println("-1 -1 -1");

			} else {
				System.out.println(b + " " + a + " " + c);
			}
		}

	}
}


Measured memory_bytes: 23508
# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
demands = [
    tuple(map(int,
              line.strip().split())) for line in sys.stdin.readlines()
]
demands.sort(key=lambda demand: demand[1])

bridge = -1
cnt = 0
for ai, bi in demands:

    if ai <= bridge:
        continue

    else:
        bridge = bi - 1
        cnt += 1

print(cnt)


Measured memory_bytes: 23728
N = gets.to_i
a = gets.split.map{|n| n.to_i}
alice = bob = 0

(N/2).times do
	alice += a.max
	a.delete_at(a.index(a.max))
	bob += a.max
	a.delete_at(a.index(a.max))
end

if N % 2 != 0 then
	alice += a.max
end

puts alice - bob

Measured memory_bytes: 1788