akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int ball[15],chk;
void dfs(int k, int r, int l);
int main(){
  int n;
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 10; j++){
      scanf("%d",&ball[j]);
    }
    chk = 0;
    dfs(0,0,0);
    if(chk == 1)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}
void dfs(int k, int r, int l){
  if(k == 10){
    chk = 1;
    return ;
  }
  if(l < ball[k])dfs(k + 1, r,ball[k]);
  if(r < ball[k])dfs(k + 1,ball[k], l);
}

Measured memory_bytes: 1200
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

vector<int> xs;
vector<int> ys;

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

    xs.resize(N);
    ys.resize(N);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        xs[i] = x;
        ys[i] = x;
    }

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

    int left = ys[(int) ys.size() / 2 - 1];
    int right = ys[(int) ys.size() / 2];
    // printf("left: %d, right: %d\n", left, right);

    for (int i = 0; i < N; i++) {
        if (xs[i] <= left) {
            printf("%d\n", right);
        } else {
            printf("%d\n", left);
        }
    }

    return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main() {
	double a, b;
	cin >> a >> b;
	if (a/0.08<(b+1)/0.1&&((b+1)/0.1)-1<(a+1)/0.08&&b/0.1<=a/0.08) {
		cout << ceil(a / 0.08) << endl;

	}
	else if ((a+1) / 0.08 > b / 0.1&&((a+1)/0.08)-1<(b+1)/0.1&&a/0.08<=b/0.1) {
		cout << ceil(b / 0.1) << endl;
	}
	else if (a / 0.08 <= b / 0.1&&(b+1)/0.1<(a+1)/0.08) {
		cout << ceil(b / 0.1) << endl;
	}
	else if (a / 0.08 >= b / 0.1&&(a+1)/0.08<(b+1)/0.1) {
		cout << ceil(a / 0.08) << endl;
	}
	else {
		cout << "-1" << endl;
	}
	return 0;
}


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

int is_sharhad(int n){
    string s = to_string(n);
    int sum_n = 0;
    for (int i = 0; i < s.length(); i++){
        string rank;
        rank = s.substr(i, 1);
        sum_n += stoi(rank);
    } 
    if (n % sum_n == 0) return true;
    else return false;
}

int main() {
    int n;
    cin >> n;
    if (is_sharhad(n)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    int n, a[100005] = {0};
    bool used[100005] = {false};

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

    int i = 0, ans = 0;
    used[0] = true;

    while (i != 1) {
        i = a[i];
        if (used[i]) break;
        used[i] = true;
        ans++;
    }

    if (i == 1) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}

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

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

    int cur = 0;
    for(int i=0; i<s.size(); i++){
        cur += (s[i] - '0');
    }

    cout<<(cur % 9 == 0 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3756
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static int e;
	
	public static void main(String[] args)
	{
		Scanner sca = new Scanner(System.in);
		while(true)
		{
			e = sca.nextInt();
			if(e == 0) break;
			
			int x, y, z;
			int min = Integer.MAX_VALUE;
			int a, b;
			
			for(z = 0;z <= 100;z++)
			{
				for(y = 0;y <= 1000;y++)
				{
					a = z*z*z+y*y;
					
					if(a > e) continue;
					x = e - a;
					b = z + y + x;
					
					if(b < min) min = b;
				}
			}
			
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 24604
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n, k, x, y;

int main() {
    fast_io; cout_precision;
    cin >> n >> k >> x >> y;
    cout << x * min(n, k) + y * max(n - k, ll(0)) << endl;
}

Measured memory_bytes: 256
// author : Kartikey Tewari
// date: 2020-02-22   18:08:22
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
#define pii pair<int,int>
using namespace std;

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

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

    sort(arr,arr+n);
    int ans=INT_MAX;
    for (int i=arr[0];i<=arr[n-1];i++)
    {
        int alpha=i;
        int total=0;
        for (int j=0;j<=n-1;j++)
        {
            int local=pow((arr[j]-alpha),2);
            total=total+local;
        }

       // cout << "total= " << total << endl;
        ans=min(ans,total);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,sum,i;
	while(scanf("%d %d",&a,&b)!=-1)
	{
		sum=a+b;
		for(i=0;sum!=0;i++)
		{
			sum=sum/10;
		}
			printf("%d\n",i);
		}
	return 0;
}

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

int main(){
  int W, a, b;
  cin >> W >> a >> b;

  if (a>b){
    if (a>b+W){
      cout << a-(b+W) << endl;
    }else{
      cout << 0 << endl;
    }
  }else{
    if (b>a+W){
      cout << b-(a+W) << endl;
    }else{
      cout << 0 << endl;
    }
  }
  return 0;
}


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

int main() {
  int Y, M, D;
  char c1, c2;
  cin >> Y >> c1 >> M >> c2 >> D;
  if (M < 5) {
    cout << "Heisei" << endl;
  }
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, A, B) = readLine()!!.split(" ").map(String::toLong)
    val ans = MInt(2).pow(N) - MInt(1) - combination(N, A) - combination(N, B)
    println(ans)
}

class MInt {
    private val MOD = 1000000007L
    var v: Long

    constructor(v: Long) {
        this.v = v % MOD
    }

    constructor(v: Int) {
        this.v = v.toLong() % MOD
    }

    operator fun plus(b: MInt): MInt {
        val a = MInt(v)
        a += b
        return a
    }

    operator fun minus(b: MInt): MInt {
        val a = MInt(v)
        a -= b
        return a
    }

    operator fun times(b: MInt): MInt {
        val a = MInt(v)
        a *= b
        return a
    }

    operator fun div(b: MInt): MInt {
        val a = MInt(v)
        a /= b
        return a
    }

    operator fun plusAssign(b: MInt) {
        v += b.v
        if (v >= MOD) v -= MOD
    }

    operator fun minusAssign(b: MInt) {
        v -= b.v
        if (v < 0) v += MOD
    }

    operator fun timesAssign(b: MInt) {
        v *= b.v
        v %= MOD
    }

    operator fun divAssign(b: MInt) {
        this *= b.inv()
    }

    fun inv(): MInt {
        var a = v
        var b = MOD
        var u = 1L
        var w = 0L
        while (b != 0L) {
            val t = a / b
            a -= t * b
            u -= t * w
            var tmp = a
            a = b
            b = tmp
            tmp = u
            u = w
            w = tmp
        }
        u %= MOD
        if (u < 0) u += MOD
        return MInt(u)
    }

    fun pow(N: Long): MInt {
        var ans = MInt(1)
        var a = this
        var n = N
        while (n > 0) {
            if (n.and(1) == 1L) {
                ans = ans * a
            }
            a = a * a
            n = n.shr(1)
        }
        return ans
    }

    override fun toString(): String {
        return v.toString()
    }
}

fun combination(n: Long, k: Long): MInt {
    var a = MInt(1)
    var b = MInt(1)
    val min = Math.min(n - k, k)
    for (i in n - min + 1..n) {
        a = a * MInt(i)
    }
    for (i in 1..min) {
        b = b * MInt(i)
    }
    return a / b
}

Measured memory_bytes: 50564
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
int k,a,b;
cin>>k;
cin>>a>>b;
rep(i,1000){

if (a<=k*i && k*i<=b)
	{cout<<"OK"<<endl;
return 0;
	}
}

 cout<<"NG"<<endl;




	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main(){
  int n; cin >> n;
  vector<int> num(n);
  bool ans = true;
  rep(i,n){
    cin >> num[i];
  }
  rep(i,n){
    if(num[i] % 2 == 0){
      if(num[i] % 3 != 0 && num[i] % 5 != 0) {
        ans = false;
      }
    }
  }

  if(ans) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}

const ll MOD = 998244353;

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

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

const int MAX_N = 210;
int X[MAX_N];
int Y[MAX_N];

// (x1, y1) -- (x2, y2) を通る直線の方程式 ax + by + c == 0 の {a,b,c} を返す
vector<int> line(int x1, int y1, int x2, int y2) {
  if (x1 == x2) {
    return {1, 0, -x1};
  }
  if (y1 == y2) {
    return {0, 1, -y1};
  }
  int a = (y2 - y1);
  int b = (x1 - x2);
  int c = y1*x2 - x1*y2;
  if (a < 0) {
    a *= -1;
    b *= -1;
    c *= -1;
  }
  int g = gcd(a, gcd(abs(b), abs(c)));
  a /= g;
  b /= g;
  c /= g;
  return {a, b, c};
}

ll two[100000];

int main2() {
  two[0] = 1;
  for (int i = 1; i < 100000; i++) two[i] = 2 * two[i-1] % MOD;

  int N = nextInt();
  REP(i, N) {
    X[i] = nextInt();
    Y[i] = nextInt();
  }
  map<vector<int>, int> mp;
  REP(i, N) REP(j, i) {
    vector<int> l = line(X[i], Y[i], X[j], Y[j]);
    ++mp[l];
  }

  ll ans = two[N] - 1 - N - N*(N-1)/2;
  for(auto it = mp.begin(); it != mp.end(); ++it) {
    int m = (1 + (int)sqrt(1.5 + 8 * (it->second))) / 2;
    ans -= two[m] - 1 - m - (m)*(m-1)/2;
    ans = (ans % MOD + MOD) % MOD;
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    string s = in();

    int ans = 0;
    rep(i, 1000)
    {
        string t = to_string(i);
        while (t.length() < 3)
            t.insert(t.begin(), '0');
        int cnt = 0;
        rep(j, n)
        {
            if (s[j] == t[cnt])
                ++cnt;
            if (cnt == 3)
                break;
        }
        if (cnt == 3)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;

// 最大公約数
ll gcd(ll a, ll b) {
	while (a && b) {
		if (a >= b) {
			a %= b;
		}
		else {
			b %= a;
		}
	}
	return a + b;
}

int main()
{
	ll num;
	ll ans=0;
	cin >> num;

	for(int i = 1;i <= num; i++){
		for (int j = 1; j <= num; j++) {
			for (int k = 1; k <= num; k++) {
				ans += gcd(gcd(i, j), k);
			}

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


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  string A, B;
  cin >> A >> B;
  if (A.size() == B.size()) {
    rep(i, A.size())
    {
      if (A.at(i) == B.at(i))
        continue;
      if (A.at(i) > B.at(i)) {
        cout << "GREATER" << endl;
      } else {
        cout << "LESS" << endl;
      }
      return 0;
    }
    cout << "EQUAL" << endl;
  } else if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  } else {
    cout << "LESS" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int dp[41][401][401];
int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    VI a(n), b(n), c(n);
    FOR(i, n)cin >> a[i] >> b[i] >> c[i];

    eFOR(i, n)FOR(j, 401)FOR(k, 401)dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    FOR(i, n)FOR(j, 401)FOR(k, 401) {
        if (dp[i][j][k] == INF)continue;
        chmin(dp[i + 1][j][k], dp[i][j][k]);
        chmin(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] +  c[i]);
    }
    int ans = INF;
    FOR1(i, 401)FOR1(j, 401)if (i * mb == j * ma) {
        chmin(ans, dp[n][i][j]);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}


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

using namespace std;

struct Team
{
    int id, cnt, time;
    vector<bool> b;
    vector<int> es;
};


int main()
{
    int T, P, R;
    while(cin >> T >> P >> R, T){
        vector<Team> ts{};
        
        for(int i=0;i<T;++i){
            Team t = {i+1, 0, 0, vector<bool>(P, false), vector<int>(P, 0)};
            ts.emplace_back(move(t));
        }
        
        for(int i=0;i<R;++i){
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            auto& t = ts[tid-1];
            if(msg == "CORRECT"){
                t.b[pid-1] = true;
                t.time += t.es[pid-1]*1200 + time;
                t.cnt += 1;
            }else{
                t.es[pid-1] += 1;
            }
        }
        
        sort(ts.begin(), ts.end(), [&](Team const& t1, Team const& t2){
            if(t1.cnt == t2.cnt){
                if(t1.time == t2.time) return t1.id < t2.id;
                else return t1.time < t2.time;
            }else return t1.cnt > t2.cnt;
        });
        
        for(auto& e: ts){
            cout << e.id << ' ' << e.cnt << ' ' << e.time << endl;
        }
    }
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
	int r;
	char str[1000];
 
	fgets(str, sizeof(str), stdin);
	r=atoi(str);
  
	printf("%lf\n",6.28318*r);
 
	return 0;
}

Measured memory_bytes: 1732
/*
	Name: 
	Copyright: gwj's
	Author: GaryMr
	Date: 02/06/19 19:34
	Description: 
*/
/*######################################################################
	是否可以简化问题：
	二分答案!
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
	分析样例：奇数or偶数
	偶数
	线段离散化
	make_pair 慢
	坐标离散化
	不同子序列: dp[i]=dp[i-1]*2-dp[last[i]-1]
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<LL,LL> mp;
typedef pair<mp,mp> superpair;
LL MM[200010];
LL changdu[200010];
LL Achangdu[200010];
vector<superpair > ever;
int main(){
	string s;
	cin>>s;
	LL len=s.length();
	if(len<3) {
		cout<<0;
		return 0;
	}
	rb(i,1,len-1){
		if(s[i]=='C'&&s[i-1]=='B'){
			MM[i-1]=1;
		}
	}
	rl(i,len-2,0){
		if(MM[i]){
			changdu[i]=changdu[i+2]+1;
		}
	}
	if(s[0]=='A') Achangdu[0]=1;
	rb(i,1,len-1){
		if(s[i]!='A') Achangdu[i]=0;
		else
		Achangdu[i]=Achangdu[i-1]+1;
	}
	LL res=0;
	rb(i,0,len-2){
		if(Achangdu[i]*changdu[i+1]){
			res+=Achangdu[i]*changdu[i+1];
			ever.PB(II(II(i-Achangdu[i]+1,i),II(i+1,i+1+changdu[i+1]*2-1)));
		}
		
	}
	LL SZ=ever.size();
//	bool OK=0;
	rb(i,0,SZ-2){
		LL lenA=0;
		for(i;ever[i].SEC.SEC==ever[i+1].FIR.FIR-1;i++){
			lenA+= ever[i].FIR.SEC-ever[i].FIR.FIR+1;//OK=1;
			res+=(lenA)*((ever[i+1].SEC.SEC-ever[i+1].SEC.FIR+1)/2);
			if(i==SZ-2) break;
		}
	}
//	if(OK) while(1){
//	}
	printf("%lld",res);
	return 0;
}


Measured memory_bytes: 7288
from collections import defaultdict
n_str=input()
n_int=int(n_str)
cnt=[[0]*9 for i in range(9)]

for i in range(1,n_int+1):
    if i%10==0:continue
    temp=str(i)
    cnt[int(temp[0])-1][int(temp[-1])-1]+=1

ans=0
for i in range(9):
    for j in range(9):
        if cnt[i][j]==0:continue
        if i==j:
            temp=cnt[i][j]
            ans+=temp**2
        else:
            ans+=cnt[i][j]*cnt[j][i]
print(ans)
#print(*cnt,sep='\n')

Measured memory_bytes: 3316
function Main(input) {
	const S = input.split("\n");
	
	const A = S[0];
	const B = S[1];
	var C = "";

	if (A == "1") {
		if(B == "2") {
			C = "3";
		} else if (B == "3") {
			C = "2";
		}
	} else if (A == "2") {
		if(B == "1") {
			C = "3";
		} else if (B == "3") {
			C = "1";
		}
	} else if (A == "3") {
		if(B == "1") {
			C = "2";
		} else if (B == "2") {
			C = "1";
		}
	}
	
	console.log(C);
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21956
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}//ここから始めよう
signed main(){
    int n;cin>>n;
    int x[111],y[111],h[111];rep(i,0,n)cin>>x[i]>>y[i]>>h[i];
    rep(i,0,101)rep(j,0,101){
        vector<int>v,u;v.clear();u.clear();
        rep(k,0,n){
            int a=abs(i-x[k])+abs(j-y[k]);
                if(h[k]==0)v.ps(a);
                else u.ps(h[k]+a);
        }
        sort(u.begin(),u.end());
        sort(v.begin(),v.end());
        if(u[0]!=u[u.size()-1])continue;
        else if(v.size()>0&&u[0]>v[0])continue;
        else {
            cout<<i<<" "<<j<<" "<<u[0]<<endl;return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import os
import math


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = map(int, sys.stdin.readline().split())

    ret = -1
    for a in range(1, 1250):
        tmpA = math.floor(a * 0.08)
        tmpB = math.floor(a * 0.1)
        if (tmpA == A and tmpB == B):
            ret = a
            break

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// そすうささんのブログを読んだ
#include<iostream>
using namespace std;

int a[302][302], yoko[302][302] = {}, tate[302][302] = {};

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> a[i][j];
            yoko[i][j] = a[i][j]+yoko[i][j-1];
            tate[i][j] = a[i][j]+tate[i-1][j];
        }
    }
    int ans = -1000;
    // line
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j++){
            for(int k = 1; k <= n; k++){
                ans = max(ans, yoko[k][j]-yoko[k][i-1]);
                ans = max(ans, tate[j][k]-tate[i-1][k]);
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            int all = yoko[i][n]+yoko[j][n];
            int submax = (tate[j-1][1]-tate[i][1]) - yoko[j][0] - yoko[i][0];
            for(int k = 2; k <= n; k++){
                int right = tate[j-1][k]-tate[i][k] - (yoko[j][n]-yoko[j][k]) - (yoko[i][n]-yoko[i][k]);
                ans = max(ans, all+submax+right);
                // cout << i << " "<< j << " " << k << " " << all << " " << submax << " " << right << endl;
                submax = max(submax, (tate[j-1][k]-tate[i][k])-yoko[j][k-1]-yoko[i][k-1]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4160
N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [0]*N
for i in range(1,N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    for j in range(max(0,i-K),i):
        dp[i] = min(dp[j]+abs(h[i]-h[j]),dp[i])
print(dp[N-1])


Measured memory_bytes: 52468
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

vector<ll> factors(ll N) {
	vector<ll> ret;

	if (N % 2 == 0) {
		ret.push_back(2);
		while (N % 2 == 0) N /= 2;
	}

	ll root = sqrt(N);
	for (ll p = 3; p <= root; p += 2) {
		if (N % p) continue;
		ret.push_back(p);
		while (N % p == 0) N /= p;
	}

	if (N > 1) ret.push_back(N);
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false);
	ll N; cin >> N;

	ll score = 0;
	for (ll p: factors(N)) {
		// divide out increasing powers of p
		for (ll q = p; N % q == 0; q *= p) {
			N /= q;
			score++;
		}
		// leftover powers of p
		while (N % p == 0) N /= p;
	}

	assert(N == 1);
	cout << score << endl;
}


Measured memory_bytes: 3520
icase=104
if icase==104:
    s=input()
    yn=""
    if s[0]!="A":
        yn="WA"
    elif not s[1].islower():
        yn="WA"
    else:
        icnt=0
        for i in range(2,len(s)-1):
            if s[i]=="C":
                icnt+=1
            elif not s[i].islower():
                yn="WA"
                break
        if icnt!=1:
            yn="WA"                
        if not s[-1].islower():
            yn="WA"
    if yn=="WA":
        print("WA")
    else:
        print("AC")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio; //remove for interactive
    ll i, j, k, n, m, t;

    cin>>i>>j;
    cout<<i*j<<endl;
        
    return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

const int MOD = (int)1e9 + 7, MAXN = (int)1e5 + 10;
int n;
VI A;

int mul(int a, int b) {
	return (1ll * a * b) % MOD;
}

int sub(int a, int b) {
	a -= b;
	return a < 0 ? a + MOD : a;
}

int exp(int b, int e)
{
	int ret = 1;
	while(e > 0)
	{
		if(e & 1)
			ret = mul(ret, b);
		b = mul(b, b); e /= 2;		
	}
	return ret;
}

int modinv(int v) {
	return exp(v, MOD - 2);
}


int fact[MAXN], finv[MAXN];
void precalc()
{
	fact[0] = fact[1] = 1;
	finv[0] = finv[1] = 1;
	for(int i = 2; i < MAXN; ++i) {
		fact[i] = mul(fact[i - 1], i);
		finv[i] = modinv(fact[i]);
	}
}

int comb(int n, int r)
{
	if(n < r) return 0;
	return mul(fact[n], mul(finv[r], finv[n - r]));
}

void solve()
{
	precalc();

	int dist;
	VI pos(MAXN + 1, -1);
	for(int i = 0; i < n + 1; ++i) {
		if(pos[A[i]] != -1) {
			dist = i - pos[A[i]];
			break;
		}
		pos[A[i]] = i;
	}
	
	for(int len = 1; len <= n + 1; ++len) {
		int whole = comb(n + 1, len), remain = comb(n - dist, len - 1);
		cout << sub(whole, remain) << '\n';
	}
	cout << flush;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> n;

	A = VI(n + 1, 0);
	REP(i, 0, n + 1) cin >> A[i];

	solve(); 

	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N;
    cin >> N;
    vector<pair<int,int>> vec(N);
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        vec.at(i) = make_pair(A,i + 1);
    }
    sort(vec.begin(),vec.end());
    for(int i = 0;i < N;i++) {
        cout << vec.at(i).second << " ";
    }
  	cout << endl;
}

Measured memory_bytes: 2432
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
    }

    let mut z = vec![];
    for _ in 0..N {
        input! {
            x:i64,
            y:i64,
        }
        z.push((x, y));
    }
    let mut ans: i64 = 0;
    let mut a = vec![];
    let mut b = vec![];
    let mut c = vec![];
    let mut d = vec![];
    for k in 0..N {
        let (x, y) = z[k];
        a.push((x + y, k));
        b.push((x - y, k));
        c.push((-x + y, k));
        d.push((-x - y, k));
    }
    a.sort_by_key(|x| x.0);
    b.sort_by_key(|x| x.0);
    c.sort_by_key(|x| x.0);
    d.sort_by_key(|x| x.0);
    a.reverse();
    b.reverse();
    c.reverse();
    d.reverse();
    ans = a[0].0 + d[0].0;
    ans = max(ans, b[0].0 + c[0].0);
    ans = max(ans, c[0].0 + b[0].0);
    ans = max(ans, d[0].0 + a[0].0);
    echo!(ans);
}


Measured memory_bytes: 23016
import java.util.Scanner;

public class Main {
	static int[][] f = new int[21][21];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n==0)break;
			
			for(int i=0;i<=20;i++) {
				for(int j=0;j<=20;j++)
					f[i][j] = 0;
			}
			boolean ans = true;
			for(int i=0;i<n;i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				f[x][y] = 1;
			}
		
			int m = sc.nextInt();
			int x=10;
			int y=10;
			for(int i=0;i<m;i++) {
				char a = sc.next().charAt(0);
				int d = sc.nextInt();
				switch(a) {
				case 'N':
					for(int k=y;k<=y+d;k++) {	
						f[x][k] = 0;
					}
					y += d;
					break;
				case 'E':
					for(int k=x;k<=x+d;k++) {
						f[k][y] = 0;
					}
					x += d;
					break;
				case 'S':
					for(int k=y;k>=y-d;k--) {
						f[x][k] =0;
					}
					y -= d;
					break;
				case 'W':
					for(int k=x;k>=x-d;k--) {
						f[k][y] =0;
					}
					x -= d;
					break;
				}
			}
			
			for(int i=0;i<=20;i++) {
				for(int j=0;j<=20;j++)
					if(f[i][j] != 0) {
						ans = false;
						break;
					}
				if(!ans)break;
			}
		
			if(ans)System.out.println("Yes");
			else System.out.println("No");
			
		}
		
	}
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author wh1t3_r0s3
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        ArrayList<Integer>[] g;
        int[] size;
        int[] level;
        int[] parent;

        void dfs(int u, int p, int curr) {
            size[u] = 1;
            level[u] = curr;
            parent[u] = p;
            for (int x : g[u]) {
                if (x != p) {
                    dfs(x, u, curr + 1);
                    size[u] += size[x];
                }
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            g = new ArrayList[n];
            for (int i = 0; i < n; i++) {
                g[i] = new ArrayList<Integer>();
            }
            for (int i = 1; i < n; i++) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                g[u].add(v);
                g[v].add(u);
            }
            level = new int[n];
            size = new int[n];
            parent = new int[n];
            dfs(0, -1, 1);
            int dis = level[n - 1] - level[0] - 1;
            int now = dis / 2, curr = n - 1;
            while (now > 0) {
                curr = parent[curr];
                now--;
            }
            int v1 = size[curr], v2 = n - v1;
            out.println(v1 >= v2 ? "Snuke" : "Fennec");

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 76072
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define int long long
const int N = 2e5 + 7, mod = 1e9 + 7, K = 3007;
int f[N], inv[N], d[K];
pair<int, int> a[K];
int binpow (int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) (res *= a) %= mod, --b;
		else (a *= a) %= mod, b >>= 1;
	}
	return res;
}
int inverse (int x) {
	return binpow(x, mod - 2);
}
void preset() {
	f[0] = 1, inv[0] = 1;
	for (int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % mod, inv[i] = inverse(f[i]);
}
int C (int k, int n) {
	if (k > n) return 0;
	return ((f[n] * inv[k]) % mod) * inv[n - k] % mod;
}
signed main() {
	preset();
	int h, w, n;
	cin >> h >> w >> n;
	for(int i=0; i<n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	a[n] = make_pair(h, w);
	sort(a, a+n);
	for(int i=0; i<=n; i++) {
		d[i] = C(a[i].first - 1, a[i].first + a[i].second - 2);
		for(int j=i-1; j>=0; j--) {
			int to = C(a[i].first - a[j].first, a[i].first + a[i].second - a[j].first - a[j].second);
			d[i] = (d[i] - d[j] * to) % mod;
			d[i] = (d[i] + mod) % mod;
		}
	}
	cout << d[n] << endl;
}


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

namespace ABC128_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];

            var k = new int[M][];
            for (int i = 0; i < M; i++)
            {
                k[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }

            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0;
            var s = new bool[M];
            for (int i = 0; i < Math.Pow(2,N); i++)
            {
                var str = Convert.ToString(i, 2);
                while (str.Length < N)
                {
                    str = "0" + str;
                }
                var canturn = true;
                for (int j = 0; j < M; j++)
                {
                    var numofturn = 0;
                    for (int l = 1; l < k[j].Length; l++)
                    {
                        int item = k[j][l];
                        if (str[item - 1] ==  '1')
                            numofturn++;
                    }
                    if (numofturn % 2 != p[j])
                    {
                        canturn = false;
                    }
                }

                if (canturn)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
  return 0;
}

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

int main()
{
    int n;
    cin>>n;
    if(n==25) cout<<"Christmas";
    else if(n==24) cout<<"Christmas Eve";
    else if(n==23) cout<<"Christmas Eve Eve";
    else cout<<"Christmas Eve Eve Eve";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=105,mod=1e9+7,M=205;
char ch[N];
ll c[M][M];
int s[N],ans,n,len,sum[N];
ll dp[N][N];
ll hf(int a,int b){
	return a>=0&&b>=0?c[a+b-1][b-1]:0;
}
inline void add(int &a,ll b){
	a=(a+b)%mod;
	//cout<<a<<" "<<b<<endl;
}
bool vis[N];
int sss[N];
void woliekai(int x,int y){
	if(x+y==0){
		ans++; return;
	}
	memset(vis,0,sizeof(vis));
	vector<int> F,G;
	for(int i=1,ff=0;i<=len;i++)if(ch[i]=='r'){
		if(F.size()<y){F.pb(i); vis[i]=1;}
	}else {
		if(G.size()<F.size()){G.pb(i); vis[i]=1;}
		//if(y==2)cout<<sss[i+1]<<"faspogpoa"<<endl;
		//assert(sss[i]+1!=len-i+2);
	}
	int X=0;
	For(i,1,len)if(X<x&&!vis[i]&&ch[i]=='r'){vis[i]=1; X++;}
	if(X<x||G.size()<y)return;
	Rep(i,len,1)sss[i]=sss[i+1]+1-vis[i];
	For(i,1,y)sum[i]=sss[G[i-1]+1];
	reverse(sum+1,sum+y+1);
	//For(i,1,y)wri(sum[i]); puts("gfashiognoa"); 
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	For(i,2,(n+3)/2){
		Rep(k,y,0)Rep(j,n,0)if(dp[j][k]){
			int dk=k,dj=j;
			For(l,1,y-k){
				dk++; dj+=i*2-3;
				//if(l==2)cout<<l<<" "<<sum[dk]<<" "<<dj<<endl;
				//assert((dj+3*dk)%2==0);
				if(sum[dk]<(dj+3*dk)/2-2*dk||dj>n)break;
				//cout<<i<<" "<<l<<" "<<dj<<" "<<dk<<endl;
				
				dp[dj][dk]=(dp[dj][dk]+dp[j][k]*hf(l,k+1))%mod;
			}
		}
	}
	//cout<<dp[0][0]<<endl;
	Rep(j,n,0)if(dp[j][y]){
		//cout<<hf(x,y+1)<<" "<<n-(x+y-1)-j<<" "<<x+y+1+j+2*y<<" "<<hf(5,2)<<endl;
		ans=(ans+hf(x,y+1)*hf(n-(x+y-1)-j-x,x+y+1+j+x+2*y)%mod*dp[j][y])%mod;//x+y-1段w非空,x+j段非空,2段空,2y空 
		//cout<<dp[j][y]<<" "<<j<<" "<<y<<" "<<ans<< " "<<n-(x+y-1)-j-x<<" "<<x+y+1+j+x+2*y<<endl;
	}
	///if(y==2)exit(0);
//cout<<x<<" "<<y<<" "<<ans<<endl; //exit(0);
}
signed main(){
	//freopen("cover.in","r",stdin); freopen("cover.out","w",stdout);
	n=read(),len=read();
	For(i,0,M-1)For(j,c[i][0]=1,i)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	scanf("%s",ch+1);
	For(i,0,(n+1)/2){
		For(j,0,(n+1)/2-i)woliekai(i,j);
		//cout<<ans<<endl;
		//For(j,1,len)wri(vis[j]); puts("");
	}
	cout<<ans<<endl;
}
/*
7 5
rrbrb

*/

Measured memory_bytes: 768
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int a,b,c,d;
	cin >> a >> b >> c >> d;

	if(c < a)
	{
		swap(c , a);
		swap(b , d);
	}
	
	int temp1 = min(b,d);
	int temp2 = max(a,c);
	if(temp2 >= temp1)
	{
	    cout << "0";
	    return 0;
	}
	cout << abs(min(b,d)-max(a,c));
	return 0;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 1001001001;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll a, b, t, ans = 0;
    cin >> a >> b >> t;
    ll time = a;
    while(time <= t) {
        ans += b;
        time += a;
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 100
 
typedef struct{
  int width;
  int height;
}CAKE;
 
bool operator<( const CAKE& left, const CAKE& right ) {
  return left.width * left.height< right.width * right.height;
}
 
int main() {
  int n,w,d;
 
  while( cin >> n >> w >> d, n || w || d ) {
 
    vector< CAKE > cake;
    CAKE tmp = {w,d};
    cake.push_back(tmp);
    int p,s;
    while( n-- ){
      cin >> p >> s;
      p--;
 
      int cnt = 0;
      while( true ){
    assert( s!=cake[p].width);
        if ( s-cake[p].width <= 0) break;
        s -= cake[p].width;
        cnt++;
 
    assert( s!=cake[p].height);
        if ( s-cake[p].height <= 0) break;
        s -= cake[p].height;
        cnt++;
      }
 
 
      cnt %= 4;
      pair < CAKE,CAKE > P;
      if ( cnt % 2 == 0 ) {
 
        CAKE tmp = {s,cake[p].height};
        P.first = tmp;
        tmp.width = cake[p].width - s;
        P.second = tmp;
 
      } else {
        CAKE tmp = {cake[p].width,s};
        P.first = tmp;
        tmp.height = cake[p].height - s;
        P.second = tmp;
      }
 
      if (  P.first.width * P.first.height > P.second.width * P.second.height ) {
        cake.push_back(P.second);
        cake.push_back(P.first);
    cake.erase(cake.begin()+p);
      }else{
        cake.push_back(P.first);
        cake.push_back(P.second);
    cake.erase(cake.begin()+p);
      }
 
    }
 
    sort( cake.begin(),cake.end() );
 
    for ( int i = 0; i < cake.size()-1; i++ ) {
      cout << cake[i].width * cake[i].height << " ";
    }
    cout << cake[cake.size()-1].width * cake[cake.size()-1].height << endl;
 
 
  }
 
  return 0;
}

Measured memory_bytes: 1224