akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

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

    if(B == 1) cout << "0" << endl;
    else{
        int plug = B-A;
        if(plug > 0){
            ans++;
            // cout << ceil(double(plug) / (A-1)) << endl;
            ans += ceil(double(plug) / (A-1));
            cout << ans << endl;
        }else{
            cout << "1" << endl;
        }
        
    }

    

}

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

const int N = 1e4 + 5, M = 5005;

int n, djq, m, f[M][N], s[N], s2[N], ans;

int main()
{
	std::cin >> n >> djq;
	m = (n >> 1) + 1;
	f[m][0] = 1; if (n & 1) f[m][m] = 1;
	for (int i = m - 1; i >= 1; i--)
		for (int x = 0; x < i; x++)
		{
			for (int j = 0, k = x; k < n; j++, k += i)
			{
				s[j] = f[i + 1][k]; s2[j] = 1ll * j * f[i + 1][k] % djq;
				if (j) s[j] = (s[j] + s[j - 1]) % djq,
					s2[j] = (s2[j] + s2[j - 1]) % djq;
			}
			for (int j = 0, k = x; k < n; j++, k += i)
				f[i][k] = (1ll * (j + 1) * s[j] - s2[j] + 1ll * djq * djq) % djq;
		}
	for (int i = 0; i < n; i++) ans = (ans + f[1][i]) % djq;
	return std::cout << ans << std::endl, 0;
}

Measured memory_bytes: 97664
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    allxor = a[0]
    for i in range(1,n):
        allxor = allxor ^ a[i]
    b=[0]*n
    for i in range(n):
        b[i]=allxor ^ a[i]
    
    return b

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(' '.join(map(str,ans)))


Measured memory_bytes: 41808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll l, r, d;
  cin >> l >> r >> d;
  ll ans = 0;
  FOR(i, l, r + 1) {
    if (i % d == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

 
// aのb乗をO(log b)で計算する
LL pow_mod(LL a, LL b, LL mod){
    if(b == 0) return 1;
    LL res = pow_mod(a * a % mod, b / 2, mod);
    if(b & 1) res = res * a % mod;
    return res;
}

int main(){
LL a, b;
cin >> a >> b;
cout << pow_mod(a, b, 1000000007) << endl;
}

Measured memory_bytes: 1160
import sys
from collections import deque

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

def land_check(y,x,W):
    tansaku = deque()
    tansaku.append([y,x])
    che_land = 0
    while tansaku:
        l_y,l_x = tansaku.pop()
        if l_x in visited_land[l_y]:
            continue
        for i in range(l_x-1,l_x+2):
                for j in range(l_y-1,l_y+2):
                    if 0 <= i <= w-1 and 0 <= j <= h-1  and W[j][i] == 1:
                        tansaku.append([j,i])
        visited_land[l_y].add(l_x)
        che_land += 1
    return che_land


def answer(h,w):

    res = 0
    ans = 0
    for i in range(h):
        for j in range(w):
            if tizu[i][j] == 0 or j in visited_land[i]:
                continue
            res += land_check(i,j,tizu)
            ans += 1
            if res == land_count:
                break
        else:
            continue
        break
    return ans

if __name__ == '__main__':
    kotae = []
    while True:
        w,h = nm()
        if [h,w] == [0,0]:
            break
        visited_land = {i:set() for i in range(h)}
        tizu = []
        land_count = 0
        for i in range(h):
            temp = nl()
            land_count += temp.count(1)
            tizu.append(temp)
        kotae.append(answer(h,w))
    [print(i) for i in kotae]


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

using lint = long long;

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

    std::vector<int> cnt(n, 0);
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        ++cnt[--a];
    }
    std::sort(cnt.begin(), cnt.end());
    cnt.push_back(n + 1);  // 番兵

    std::vector<int> get(n + 1, -1);
    // 各整数を高々m枚選べるとき，最大何枚選べるか
    int m = 0, sum = 0;
    for (int i = 0; i <= n; ++i) {
        while (m <= n && m < cnt[i]) {
            get[m] = sum + (n - i) * m;
            ++m;
        }
        sum += cnt[i];
    }

    for (int k = 1; k <= n; ++k) {
        lint ok = 0, ng = n + 1;
        while (ng - ok > 1) {
            lint mid = (ok + ng) / 2;
            // mid * k枚選ばなくてはならない
            (mid * k <= get[mid] ? ok : ng) = mid;
        }
        std::cout << ok << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3184
n,t = map(int,input().split())
t_li = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    dum = t_li[i+1]-t_li[i]
    if dum < t:
        ans += dum
    else:
        ans += t
print(ans+t)

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

bool solve(const vector<string> w){
  for(int i=0;i<w.size()-1;i++){
    if(w[i].back() != w[i+1].front()){
      return false;
    }
    for(int j=w.size()-1;j>i;j--){
      if(w[j] == w[i]){
        return false;
      }
    }
  }
  return true;
}

int main(){
  int n; cin>>n;
  vector<string> w(n);
  for(int i=0;i<n;i++){
    cin>>w.at(i);
  }
  if(solve(w)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 1100000;
int n, m;
int fac[N], inv[N], ans;
int powi(int a, int b)
{
    int c = 1;
    for (; b; b >>= 1, a = 1ll * a * a % MOD)
        if (b & 1) c = 1ll * c * a % MOD;
    return c;
}
int main()
{
    cin >> n >> m;
    if (n < m) swap(n, m);
    fac[0] = 1;
    for (int i = 1; i <= n + m; ++ i) fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[n + m] = powi(fac[n + m], MOD - 2);
    for (int i = n + m - 1; ~i; -- i) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
    ans = n;
    for (int i = 1; i <= m; ++ i)
    {
        int A = 1ll * fac[2 * i] * inv[i] % MOD * inv[i] % MOD;
        int B = 1ll * fac[n + m - 2 * i] * inv[n - i] % MOD * inv[m - i] % MOD;
        int C = 1ll * fac[n] * fac[m] % MOD * inv[n + m] % MOD;
        ans = (ans + (1ll * A * B % MOD * C % MOD * ((MOD + 1) / 2) % MOD)) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {
	static int primeNum(int[] arr)
	{
		int counter=arr.length;
		for(int i=0; i<arr.length; i++)
		{
			for(int j=2; j<= Math.sqrt(arr[i]); j++)
			{				
				if(arr[i]%j==0)
				{					
					counter--;
					break;
				}				
			}			
		}
		return counter;
	}
	
	public static void main(String argv[]) {
        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();
        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        System.out.println(primeNum(intArray1));
        in.close();
	}
}



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


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

    if (a == 0) cout << 1 << endl;
    if (b == 0) cout << 2 << endl;
    if (c == 0) cout << 3 << endl;
    if (d == 0) cout << 4 << endl;
    if (e == 0) cout << 5 << endl;

    return 0;

}


Measured memory_bytes: 3564
X=int(input())
Y=int(X**0.5)
for B in range(-Y,Y):
    A = B**5+X;
    if A<B:
        continue
    A = A**0.2
    Ai = int(A)
    if Ai**5-B**5==X:
        print(Ai,B)
        break


Measured memory_bytes: 9428
#include <iostream>
#include <vector>

using ll = long long;

int main(int argc, char** argv) {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a == b && a != c) {
    std::cout << "Yes\n";
  } else if (a == c && a != b) {
    std::cout << "Yes\n";
  } else if (b == c && a != b) {
    std::cout << "Yes\n";
  } else {
    std::cout << "No\n";
  }
}


Measured memory_bytes: 888
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::unordered_map<int, int> type_occurences;
typedef std::set<int> type_set_int;

struct abc_170_d {
	type_occurences occ;
	type_set_int numbers;

	std::vector<int> divisors(int x) {
		std::vector<int> v;

		for(int i = 1; i * i <= x; ++i) {
			if(x % i == 0) {
				v.push_back(i);
				if(i*i != x) v.push_back(x/i);
			}
		}
		return v;
	}

	bool no_divisors(int x) {
		std::vector<int> xdivisors = divisors(x);

		for(auto it = xdivisors.begin(); it != xdivisors.end(); ++it) {
			if(*it == x) {
				continue;
			}
			;
			auto div_it = numbers.find(*it);
			if(div_it != numbers.end()){
				// divisor is found
				return false;
			}
		}
		return true;
	}

	int run(int N, std::vector<int> A) {
		int cnt = 0;
		int count1 = 0;
		for(int i = 0; i < N; ++i) {
			if(A[i] == 1) {
				count1++;
			}
			occ[A[i]]++;
			numbers.emplace(A[i]);
		}

		// 1 case
		if(count1 == 1) {
			return 1;
		}else if (count1 > 1) {
			return 0;
		}

		for(int i = 0; i < N; ++i) {
			if(occ[A[i]] > 1) {
				continue;
			}
			if(no_divisors(A[i])) {
				cnt++;
			}
		}

		for(int i = 0; i < N; ++i) {
		}
		// dummy
		return cnt;
	}
};

int main(void) {
	abc_170_d solver;
	int N, t;
	std::vector<int> A;

	std::cin >> N;

	for(int i = 0; i < N; ++i) {
		std::cin >> t;
		A.push_back(t);
	}

	std::cout << solver.run(N, A) << std::endl;

	return 0;
}


Measured memory_bytes: 22332
#include <iostream>
#include <string>
#include <vector>

constexpr int sz = 26;

int main() {
	std::string s;
	std::vector<int> count(sz, 0);
	
	while (std::cin >> s) {
		for (const char &c : s) {
			if (('a' <= c and c <= 'z') or ('A' <= c and c <= 'Z')) {
				count[tolower(c) - 'a']++;
			}
		}
	}
	
	for (char c = 'a'; c <= 'z'; c++) {
		int i = (c - 'a');
		std::cout << c << " : " << count[i] << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
 
using ld = long double;
using ll = long long;
using ii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vii = vector <ii>;
using vpll = vector<pll>;


int main(){
 
  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  
  int x;
  cin >> x;
  if(x >=30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
int n;
void print(int x,int y)
{
    printf("%d %d\n",x,y);
}
int main()
{
    scanf("%d",&n);
    int tmp=n;
    while (tmp%2==0) tmp/=2;
    if (tmp==1)
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    print(1,2);
    print(2,3);
    print(3,n+1);
    print(n+1,n+2);
    print(n+2,n+3);
    for (int i=4;i<n;i+=2)
    {
        print(i,i+1);
        print(i+1,n+2);
        print(n+3,n+i);
        print(n+i,n+i+1);
    }
    if (n%2==0)
    {
        print(n-1,n);
        int r=(n-1)^n;
        if (r==3) print(n+1,n+n);
        else
        {
            r^=1;
            print(n+r,n+n);
        }
    }
    return 0;
}

Measured memory_bytes: 3832
from itertools import product


def solve(N, A, B, C, Ls):
    ans = 10000
    for p in product("ABCD", repeat=N):
        if "A" not in p or "B" not in p or "C" not in p:
            continue
        As = sum(Ls[i] for i in range(N) if p[i] == "A")
        Bs = sum(Ls[i] for i in range(N) if p[i] == "B")
        Cs = sum(Ls[i] for i in range(N) if p[i] == "C")
        tans = abs(As - A) + abs(Bs - B) + abs(Cs - C) + \
               (p.count("A") - 1) * 10 + (p.count("B") - 1) * 10 + (p.count("C") - 1) * 10
        ans = min(ans, tans)
    return ans

if __name__ == "__main__":
    N, A, B, C = tuple(map(int, input().split(" ")))
    Ls = [int(input()) for _ in range(N)]
    print(solve(N, A, B, C, Ls))


Measured memory_bytes: 3064
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;

vector<int> g[N];

bool vis[N][3];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    while(m-- > 0) {
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(v);
    }
    int s, t;
    cin >> s >> t;
    queue<pair<pair<int, int>, int>> q;
    q.push(make_pair(make_pair(s, 0), 0));
    vis[s][0] = 1;
    while(!q.empty()) {
        auto it = q.front();
        q.pop();
        int nd = (it.first.second + 1) % 3;
        for(auto v : g[it.first.first]) {
            if(!vis[v][nd]) {
                vis[v][nd] = 1;
                q.push(make_pair(make_pair(v, nd), it.second + 1));
                if(v == t && nd == 0) {
                    cout << (it.second + 1) / 3 << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
struct data{
    int l,r;
}a[100001];
int end=INT_MIN,n,ans;
bool cmp(data x,data y){
    return x.r<y.r;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        a[i].l=x-y,a[i].r=x+y;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++){
        if(end<=a[i].l){
            ans++;
            end=a[i].r;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int L[2 * N];
  for (int i = 0; i < 2 * N; i++) {
    cin >> L[i];
  }
  sort(L,L+(2*N));
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += L[2 * i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    int n,m = 0;
    cin >> n >> m;
    vector<vector<int>> s(m,vector<int>(n));
    for(int i = 0;i < m;i++){
        for(int j = 0;j < n;j++){
            s[i][j] = 0;
        }
    }
    for(int i = 0;i < m;i++){
        int k = 0;
        cin >> k;
        for(int j = 0;j < k;j++){
            int tmp = 0;
            cin >> tmp;
            s[i][tmp - 1] = 1;
        }
    }
    //cout << endl;
    for(int i = 0;i < m;i++){
        for(int j = 0;j < n;j++){
            //cout << s[i][j] << " ";
        }
        //cout << endl;
    }
    
    vector<int> p(m);
    for(int i = 0;i < m;i++){
        cin >> p[i];
    }
    int cnt = 0;
    for(int i = 0;i < (1<<n);i++){
        vector<int> c(m);
        bool flag = false;
        for(int j = 0;j < m;j++){
            c[j] = 0;
        }
        for(int j = 0;j < n;j++){
            if(i & (1<<j)){
                for(int k = 0;k < m;k++){
                    if(s[k][j] == 1){
                        c[k] ++;
                    }
                }
            }
        }
        //cout << "c" << i << " ";
        for(int j = 0;j < m;j++){
            //cout << c[j] << " ";
        }
        //cout << endl;
        for(int j = 0;j < m;j++){
            if(c[j] % 2 == p[j]){
                flag = true;
            }else{
                flag = false;
                break;
            }
        }
        
        if(flag){
            //cout << "ok" << endl;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3584
//
#include <iostream>
#include <algorithm>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int x, x2, y, y2;
void cal(int a, int b, int c){
  if(c == 1){
    x = max(x, a);
  }else if(c == 2){
    x2 = min(x2, a);
  }else if(c == 3){
    y = max(y, b);
  }else{
    y2 = min(y2, b);
  }
}

int main() {
  int h, w, n;
  cin >> w >> h >> n;
  x = 0;
  x2 = w;
  y = 0;
  y2 = h;
  for(int i = 0; i < n; i++){
    int w, w2, w3;
    cin >> w >> w2 >> w3;
    cal(w, w2, w3);
  }
  //cout << "x:" << x << " x2:" << x2 << " y:" << y << " y2:" << y2 << endl;

  cout << max(0, (y2-y)) * max(0, (x2-x)) << endl;
}


Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

class UnionFind {
    private:
        vi par;    // x の親ノード
        vi rank;   // 木の高さ
        vi mem;    // メンバの数
        int sz;             // 集合の個数
    public:
        UnionFind(int n) :
            par(n, -1), rank(n, 0), mem(n, 1), sz(n) {
            REP(i,n) par[i] = i;
        }
    
    int size() { return sz; }

    // 集合の追加
    void makeset() {
        par.pb(par.size());
        rank.pb(0);
        mem.pb(1);
        sz++;
    }

    int find(int x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    int member(int x){
        x = find(x);
        return mem[x];
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]){
            par[x] = y;
            mem[x] += mem[y];
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
            mem[y] += mem[x];
        }
        sz--;
    }

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

int n,m,a[100010],x,y;
ll ret;

int main(){
    I(n); I(m);
    REP(i,n) I(a[i]);
    UnionFind uf = UnionFind(n);
    REP(i,m){
        I(x); I(y);
        uf.unite(x,y);
    }

    if(n-m - n/2 > 1) {
        cout << "Impossible" << endl;
        return 0;
    }
    if(n-1 == m){
        cout << 0 << endl;
        return 0;
    } 
    
    priority_queue<int,vi,greater<int> > pq;
    vvi ufgroup(n);
    REP(i,n) ufgroup[uf.find(i)].pb(a[i]);
    int counter = 0;
    for ( auto lis : ufgroup){
        if (lis.size() == 0) continue;
        sort(lis.begin(),lis.end());
        ret += lis[0];
        FOR(j,1,lis.size()){
            pq.push(lis[j]);
        }
        counter++;
    }
    REP(i,counter-2){
        ret += pq.top();
        pq.pop();
    }
    cout << ret << endl;

}

Measured memory_bytes: 6272
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
using namespace std;
typedef long long int lli;
const long long int MaxN=3005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	
	
	void solve(){
		lli N,i,j,p,q,res;
		cin>>N;
		N--;
		cout<<(N*(N+1))/2<<"\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t; 
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}

Measured memory_bytes: 3196
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	std::size_t N;
	std::cin >> N;
	std::vector<std::pair<std::int64_t, std::int64_t>> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v.first >> v.second;
	}
	std::int64_t min = 0, max = 0;
	if (N % 2 == 0)
	{
		boost::sort(vec);
		min = vec[N / 2 - 1].first + vec[N / 2].first;
		boost::sort(vec, lib::order_by([&](auto p) {return p.second; }));
		max = vec[N / 2 - 1].second + vec[N / 2].second;
	}
	else
	{
		boost::sort(vec);
		min = vec[N / 2].first;
		boost::sort(vec, lib::order_by([&](auto p) {return p.second; }));
		max = vec[N / 2].second;
	}
	std::cout << max - min + 1 << std::endl;
}

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

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

const int INF = 1e18;
const int MOD = 1e9 + 7;

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

    if( s.size() <= 2 ){
        cout << s.size() << endl;
    }else{
        int ans = 0;
        char tmp = ' ';
        REP( i, s.size() ){
            if( tmp != s[i] ){
                tmp = s[i];
            }else if( tmp == s[i] ){
                if( i == s.size() - 1 ){
                    break;
                }else{
                    tmp = ' ';
                    i++;
                }
            }

            ans++;
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 644
import Control.Monad

parse :: String -> ([Int] , Int , Int)
parse xs = case read ("(" ++ xs ++ ")") of
    (l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2) -> ([l1,l2,l3,l4,l5,l6,l7,l8,l9,l10],v1,v2)
    
meetAt :: Int -> Int -> Int -> Double
meetAt l v1 v2 = fromIntegral (v1 * l) / fromIntegral (v1 + v2)

station :: [Int] -> Double -> Int
station (l:ls) x
    | fromIntegral l < x = 1 + station ls (x - fromIntegral l)
    | otherwise = 1

solve :: ([Int] , Int , Int) -> IO ()
solve (ls , v1 , v2) = print $ station ls $ meetAt (sum ls) v1 v2
    
main :: IO ()
main = getContents
    >>= mapM_ solve . map parse . lines

-- L1 = v1 * t
-- L2 = v2 * t
-- L1 + L2 = l
-- v1 * t + v2 * t = l
-- (v1 + v2) * t = l
-- t = l / (v1 + v2)
-- L1 = v1 * (l / (v1 + v2))

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

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a[100],i,n;
    int sum=0;
    int count=0;

    cin>>n;

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

    for(i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
            count++;


        if(a[i]%3==0 || a[i]%5==0)
        {
            sum++;
        }

    }

    }

    if(sum==count)
    {
        cout<<"APPROVED";
    }
    else{

        cout<<"DENIED";
    }




}



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

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i,N) cin >> P[i];
    int max_len = 1;
    map<int,int> mp;
    rep(i,N){
        mp[P[i]] = mp[P[i] - 1] + 1;
    }
    for (map<int,int>::iterator itr = mp.begin(); itr != mp.end(); itr++){
        max_len = max(max_len, itr->second);
    }
    cout << N - max_len << endl;
}


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

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int ans=1;
		int o=0;
		int[] a = new int[x];
		for (int i = 0; i < x; i++) {
			a[i] = scanner.nextInt();
		}
		Arrays.sort(a);
		for (int i = 0; i < x; i++) {
			if (i + 1 < x){
				if (a[i] == a[i + 1]) {
					o++;
				}else{
					ans++;
				}
			}
		}
		if(o%2==0) {
			System.out.println(ans);
		}else{
			System.out.println(ans-1);
		}
	}
}

Measured memory_bytes: 32220
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//#define forn(i,n) for(int i = 0; i< n;++i)
ll MOD = 1e9;
ll INF = 1e17 + 9;

//currMask is new no. of total used rabbits, group set biit denotes used rabbits in this group
void rec(int mask,int currMask,int i,vector<int>& free,vector<ll>& pre,vector<ll>& dp, int group){
	if(i == (int)free.size()){
		dp[currMask] = max(dp[currMask], dp[mask] + pre[group]);
		return;
	}
	rec(mask,currMask,i+1,free,pre,dp,group);
	rec(mask, currMask | 1 << free[i], i+1, free,pre,dp,group | (1 << free[i]));
}

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

	int n;
	cin >> n;
		
	vector<vector<int>> A(n,vector<int> (n,0));
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			cin >> A[i][j];
		}
	}
	
	//map<vector<int>,ll> dp;
	
	//cout <<  maxScore(0,0,0,(1<<n) - 1,n,A,dp) << endl;
	vector<ll> pre(1 << n, 0);
	vector<int> free;
	vector<ll> dp(1 << n, 0);  // dp[mask] -> max score to group rabbits with set bits
	//dp[mask]  0, init as it is possible to make each rabbit in one group, so atleast we get 0 score
	for(int mask = 0; mask < (1 << n); ++mask){
		
		for(int bit = 0; bit < n; ++bit){
			if((mask >> bit) & 1){
				for(int j = bit + 1; j < n; ++j){
					if((mask >> j) & 1){
						pre[mask] += A[bit][j];
					}
				}
			}
		}
	}
	// O(2^n * 2^n)
	for(int mask = 0; mask < (1 << n) ; ++mask){
		
		for(int bit = 0; bit < n; ++bit){
			if(!((mask >> bit) & 1)){
				free.push_back(bit);
			}
		}
		
		//dp[mask] -> score of using set rabbits for grouping
		
		rec(mask,mask,0,free,pre,dp,0);
		
		free.clear();
		
		
	}
	
	cout << dp[(1<<n) - 1] <<  endl;
		
}




Measured memory_bytes: 1280
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
typedef pair<ll,string> Ps;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
double n;
double dp[310][310][310];
double rec(int i,int j,int k){
   if(dp[i][j][k]>=0.0)return dp[i][j][k];
   if(i==0&&j==0&&k==0)return 0.0;
   double res=0.0;
   if(i!=0)res+=rec(i-1,j,k)*(double)i;
   if(j!=0)res+=rec(i+1,j-1,k)*(double)j;
   if(k!=0)res+=rec(i,j+1,k-1)*(double)k;
   res+=n;res/=(double)(i+j+k);
   return dp[i][j][k]=res;
}
int main(){
    memset(dp,-1.0,sizeof(dp));
    cin>>n;
    int one=0,two=0,three=0;
    int m=n;
    for(int i=0;i<m;i++){
         int c;cin>>c;
         if(c==1)one++;
         else if(c==2)two++;
         else three++;
    }
    cout<<rec(one,two,three)<<endl;
}




Measured memory_bytes: 233088
function main()
  
  (W, H, x, y) = map(x -> parse(Int, x), split(readline()))
  
  A = W * H
  
  if 2x == W && 2y == H
    println(A / 2, " ", 1)
  else
    println(A / 2, " ", 0)
  end
  
end

main()

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

int main(){
  int n,x[302][302]={},y[302][302]={};
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin>>y[i][j],x[i][j]=y[i][j];
  
  int ans=max(y[0][n-1],y[n-1][0]);
  for(int i=0;i<n;i++)
    for(int j=n-2;j>=0;j--) {
      x[i][j]+=x[i][j+1];
      y[j][i]+=y[j+1][i];
    }

  
  int sum[302][302],K[2][302][302]={},t=0,f=1;
  while(f){
    t++,f=0;
    for(int i=0;i<n;i++) //yoko
      for(int j=i+1;j<n;j++) {//yoko
	int a=K[t%2][i][j],&b=K[(t+1)%2][i][j];
	b=a+1;
	sum[i][j]=-10000000;

	for(int k=a+1;k<n;k++) { //tate
	  int X=(x[a][i]-x[a][j+1])+(x[k][i]-x[k][j+1]);
	  int Y=(y[a+1][i]-y[k][i])+(y[a+1][j]-y[k][j]);
	  if(sum[i][j]<=X+Y)sum[i][j]=X+Y,b=k;
	}
	
	if(b<=n-1)f=1;
	ans=max(ans,sum[i][j]);
	for(int k=a+1;k<b;k++){//tate
	  sum[i][j]+=(x[k][i+1]-x[k][j])-(x[k-1][i]-x[k-1][j+1]);
	  ans=max(ans,sum[i][j]);
	}
      }
  }
  cout <<ans<<endl;
	  
  return 0; 
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int attack1 = ceil((double) C / B);
    int attack2 = ceil((double) A / D);

    if (attack1 <= attack2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1001001001;
const double EPS = 1e-10;
struct Edge { ll to, cost; };
using Graph = vector<vector<Edge>>;

struct edge{ll from,to; double cost;};

bool comp(edge& e1, edge& e2){return e1.cost<e2.cost;}

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int root(int x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -d[root(x)]; }
};

double kruskal(int n,vector<edge> g){
    sort(g.begin(),g.end(),comp);
    UnionFind uf(n);
    double res=0;
    for(auto e:g){
        ll a=e.from,b=e.to;
        double c=e.cost;
        if(!uf.same(a,b)){
            uf.unite(a,b);
            res+=c;
        }
    }
    return res;
}

double getDist(double x1,double x2,double y1,double y2,double z1,double z2,double r1, double r2){
    return sqrt(pow(x1-x2,2)+pow(y1-y2,2)+pow(z1-z2,2))-(r1+r2);
}

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

    int n;
    while(cin>>n&&n){
        vector<edge> g;
        double x[n],y[n],z[n],r[n];
        for(int i=0;i<n;i++){
            cin>>x[i]>>y[i]>>z[i]>>r[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                double t=getDist(x[i],x[j],y[i],y[j],z[i],z[j],r[i],r[j]);
                if(t<EPS){
                    g.emplace_back((edge){i,j,0});
                    g.emplace_back((edge){j,i,0});
                }else{
                    g.emplace_back((edge){i,j,t});
                    g.emplace_back((edge){j,i,t});
                }
            }
        }
        double ans=kruskal(n,g);
        cout<<fixed<<setprecision(3)<<ans<<endl;
    }
}


Measured memory_bytes: 4292
n = int(input())
s = input()
R,G,B = [0],[0],[0]
r,g,b = 0,0,0
ans = 0
for i in s[::-1]:
    if i == "R":
        r += 1
    elif i == "G":
        g += 1
    else:
        b += 1
    R.append(r)
    G.append(g)
    B.append(b)
R.reverse()
G.reverse()
B.reverse()
for ki,i in enumerate(s):
    for kj,j in enumerate(s[ki+1:],ki+1):
        INDEX = 2 * kj - ki
        if i == j:
            continue
        if i != "R" and j != "R":
            mini_ans = R[kj+1]
            if INDEX < n and s[INDEX] == "R":
                mini_ans -= 1
            ans += mini_ans
        elif i != "G" and j != "G":
            mini_ans = G[kj+1]
            if INDEX < n and s[INDEX] == "G":
                mini_ans -= 1
            ans += mini_ans
        elif i != "B" and j != "B":
            mini_ans = B[kj+1]
            if INDEX < n and s[INDEX] == "B":
                mini_ans -= 1
            ans += mini_ans
print(ans)

Measured memory_bytes: 68996
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define rre(v){for(auto &_re : v) for(auto &_rre : _re) cin >> _rre;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
#define eb emplace_back
using namespace std;
const ll M = 1e9 + 7;
const ll mod = 998244353;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define int long long
const ll INF = 1e18;
ll n, C;
vector<ll> h;
struct line{
	ll a, b; // ax + b
	ll eval(ll x){
		return a * x + b;
	}
	long double intersect(const line &l){
		return (long double) (l.b - b) / (a - l.a);
	}
};
void solve(){
	cin >> n >> C;
	h.resize(n);
	re(h);
	ll dp[n];
	dp[0] = 0;
	deque<line> cht;
	cht.push_front({-2LL*h[0], h[0]*h[0] + dp[0]});
	for(int i=1;i<n;i++){
		/*//cout << cht.back().a << endl;
		dp[i] = 1e18;
		cout << i << ": ";
		for(int j=0;j<q;j++){
			dp[i] = min(dp[i], cht[j].eval(h[i]));
			cout << cht[j].eval(h[i]) << " ";
		}		
		cout << endl;*/
		int l = 1, r = cht.size() - 1, m;
		int ans = 0;
		while(l<=r){
			m = l + r >> 1;
			if(cht[m].eval(h[i]) < cht[m-1].eval(h[i])){
				ans = m;
				l = m + 1;
			}
			else r = m - 1;
		}
		dp[i] = cht[ans].eval(h[i]) + h[i] * h[i] + C;
		line to_add = {-2LL * h[i], h[i] * h[i] + dp[i]};
		while(cht.size() >= 2 && to_add.intersect(cht[1]) < cht[0].intersect(cht[1])){
			cht.pop_front();
		}
		cht.push_front(to_add);
	}
	/*for(int j=0;j<cht.size();j++){
		cout << cht[j].a << " " << cht[j].b << endl;
	}*/
	cout << dp[n-1] << endl;
}
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}

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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define MAX_V        20004

const ll inf = 1e15;
const ll mod = 1e9+7;

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

struct edge {
    ll to, cap, rev;
    edge(ll t, ll c, ll r): to(t), cap(c), rev(r){}
};

vector<edge> G[MAX_V];
ll level[MAX_V];
ll iter[MAX_V];

void add_edge(ll from, ll to, ll cap) {
    G[from].push_back(edge(to, cap, G[to].size()));
    G[to].push_back(edge(from, 0, G[from].size() - 1));
}

void bfs(ll s) {
    memset(level, -1, sizeof(level));
    queue<ll> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        ll v = que.front(); que.pop();
        rep(i, G[v].size()) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

ll dfs(ll v, ll t, ll f) {
    if (v == t) return f;
    ll &i = iter[v];
    while (i < G[v].size()) {
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]) {
            ll d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
        i++;
    }
    return 0;
}

ll max_flow(ll s, ll t) {
    ll flow = 0;
    while (true) {
        bfs(s);
        if (level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        ll f;
        while ((f = dfs(s, t, inf)) > 0) {
            flow += f;
        }
    }
}

char field[101][101];
int main() {
    ll H, W; cin >> H >> W;
    rep(i, H) rep(j, W) {
        cin >> field[i][j];
        if (field[i][j] == 'X' && (i == 0 || i == H-1 || j == 0 || j == W-1)) {//淵に牛がいたら-1を出力
            cout << -1 << endl;
            return 0;
        }
    }
    
    ll S = 2 * H * W;//sorce 
    ll T = 2 * H * W + 1;//sink
    rep(i, H) rep(j, W) {
        if (field[i][j] == 'X') add_edge(S, i * W + j, inf);//sorceと牛がいるところに重みinfの辺を張る
        if (i == 0 || i == H-1 || j == 0 || j == W-1) add_edge(H * W + i * W + j, T, inf);//淵とsinkに重みinfの辺を張る
        add_edge(i * W + j, H * W + i * W + j, field[i][j] == 'X' ? inf : 1);//牛がいるgridの内部に重みinfの辺を張り、そうでないgridに重み1の辺を張る
        rep(k, 4) {//(i,j).outから隣接4grid.inに辺を張る
            if (i+dy[k] < 0 || H-1 < i+dy[k] || j+dx[k] < 0 || W-1 < j+dx[k]) continue;
            add_edge(H * W + i * W + j, (i+dy[k]) * W + (j+dx[k]), inf);
        }
    }
    cout << max_flow(S, T) << endl;
    
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
 
using namespace std;
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

const int NN = 1 << 11;

void ins(VI& xs, int x){
  xs.insert(upper_bound(ALL(xs), x), x);
}
bool del(VI& xs, int x){
  auto it = lower_bound(ALL(xs), x);
  if(it == end(xs) || *it != x) return false;
  xs.erase(it);
  return true;
}
int num(VI& xs, int l, int u){
  return lower_bound(ALL(xs), u) - lower_bound(ALL(xs), l);
}

class SegT{
private:
  VI dat[2 * NN - 1];

public:
  SegT(){
  }

  // dat[idx] = a, 0-indexed
  void update(int x, int y){
	int idx = x + NN - 1;
	ins(dat[idx], y);
	while(idx > 0){
	  idx = (idx - 1) / 2;
	  ins(dat[idx], y);
	}
  }

  void erase(int x, int y){
	int idx = x + NN - 1;
	if(!del(dat[idx], y)) return;
	while(idx > 0){
	  idx = (idx - 1) / 2;
	  if(!del(dat[idx], y)) return;
	}
  }

  int query(int lx, int ux, int ly, int uy, int k, int l, int r){
	if(r <= lx || ux <= l) return 0;
	if(lx <= l && r <= ux)
	  return num(dat[k], ly, uy);
	else{
	  int vl = query(lx, ux, ly, uy, k*2+1, l, (l+r)/2);
	  int vr = query(lx, ux, ly, uy, k*2+2, (l+r)/2, r);
	  return vl + vr;
	}
  }

  int query(int lx, int ly, int ux, int uy){
	return query(lx, ux, ly, uy, 0, 0, NN);
  }
};

int main(){
  int H, W, T, Q;
  scanf("%d%d%d%d", &H, &W, &T, &Q);
  using TP = tuple<double,int,PII,PII>;
  vector<TP> qs;
  REP(q,Q){
	double t;
	int c, h, w, h1 = -1, w1 = -1;
	scanf("%lf%d%d%d", &t, &c, &h, &w);
	--h;
	--w;
	if(c == 0){
	  qs.push_back(make_tuple(t, 0, MP(h,w), MP(h1, w1)));
	  t += T - 0.1;
	  c = 3;
	}
	else if(c == 2){
	  scanf("%d%d", &h1, &w1);
	}
	qs.push_back(make_tuple(t, c, MP(h,w), MP(h1, w1)));
  }

  SORT(qs);
  SegT s1, s2;
  for(auto& tp: qs){
	double t;
	int c;
	PII p1, p2;
	tie(t, c, p1, p2) = tp;
	if(c == 0){
	  s1.update(p1.SS, p1.FF);
	}
	else if(c == 1){
	  s2.erase(p1.SS, p1.FF);
	}
	else if(c == 2){
	  printf("%d %d\n",
			 s2.query(p1.SS, p1.FF, p2.SS, p2.FF),
			 s1.query(p1.SS, p1.FF, p2.SS, p2.FF));
	}
	else{
	  s1.erase(p1.SS, p1.FF);
	  s2.update(p1.SS, p1.FF);
	}
  }
  
  return 0;
}

Measured memory_bytes: 20928
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007

// for using in pairs
#define F first
#define S second

// Macros
#define all(x) begin(x), end(x)

// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Operator overloads.
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

#define int long long

//////////////////////////////////////////////////////////////////////////////////


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

	sort(a, a + n);

	int ans = 0;
	for (int i = 0; i < n - 2; i++)
	{
		for (int j = i + 1; j < n - 1; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k])
					continue;
				if (a[i] + a[j] > a[k])
					ans++;
			}
		}
	}

	cout << ans;
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

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

	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 3656
n = int(input())

L = [[0]*10 for j in range(10)]

for i in range(1, n+1):
    p = int(str(i)[0])
    s = int(str(i)[-1])
    L[p][s] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += L[i][j] * L[j][i]
print(ans)

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

#define MAX(x,y) (((x)<(y))?(y):(x))

int main(void){
  int n,m,i,j,k,cases;
  int *dp[3],a[1000],b[1000];
  for(i=0;i<2;i++) dp[i]=(int *)calloc(10001,sizeof(int));
  for(cases=1;  scanf("%d%*c",&n) && n;cases++){
    for(i=0;i<2;i++) memset(dp[i],0,10001*sizeof(int));
    scanf("%d%*c",&m);
    for(i=0;i<m;i++) scanf("%d%*c%d%*c",&b[i],&a[i]);
    for(i=0;i<=n;i++) dp[0][i]=(a[0]<=i)?b[0]:0;
    for(i=1;i<m;i++){
      for(j=0;j<=n;j++){
	if(j<a[i]) dp[1][j]=dp[0][j];
	else dp[1][j]=MAX(dp[0][j-a[i]]+b[i],dp[0][j]);
      }
      dp[2]=dp[1];
      dp[1]=dp[0];
      dp[0]=dp[2];
    }
    for(k=0;k<=n;k++) if(dp[0][n]==dp[0][k]) break;
    printf("Case %d:\n%d\n%d\n",cases,dp[0][n],k);
  }
  for(i=0;i<2;i++) free(dp[i]);
  return 0;
}

Measured memory_bytes: 696
#include <bits/stdc++.h>
using namespace std;
const int N=101;

string arr[N];
int solve()
{
    long long n;
    cin>>n;
    cout<<n*(n+1)/2;
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt" ,"r" ,stdin);
    //freopen("output.txt" ,"w" ,stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   // int t;
   // cin>>t;
   // while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int h,n;

  cin >> h >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  REP(i,n){
    h -= a[i];
  }

  cout << (h > 0 ? "No" : "Yes") << endl;

  return 0;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

in gcd(in a, in b) {return b != 0 ? gcd(b, a % b) : a;}//最大公約数

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in k;
    cin>>k;
    in sum=0;
    in gc;
    REP(i,1ll,k+1ll){
        REP(j,1ll,k+1ll){
            gc=gcd(i,j);
            REP(m,1ll,k+1ll){
                sum +=gcd(gc,m);
            }
        }
    }
    cout<<sum<<endl;
}
//./problem.exe


Measured memory_bytes: 3616
#include<iostream>
#include<cstdint>
using namespace std;
//実行時間制限TLE
int main(){
  //(A+B)*10^100
  //先頭からN個のボール
  //AAABBBB | AAABBB
  //long long int N,A,B;
  uint64_t N,A,B;
  cin >> N >> A >> B;
  //long long int blue_num = N / (A+B);
  //long long int reminder = N % (A+B);
  uint64_t blue_num = N / (A+B);
  uint64_t reminder = N % (A+B);
  //cout << "blue_num" << blue_num << endl;
  //cout << "reminder" << reminder << endl;
  if(A < reminder){
	//cout << "case 1" << endl;
	cout << blue_num*A+A << endl;
  }
  else{
	//cout << "case 2" << endl;
	cout << blue_num*A+reminder << endl;
  }
  //cout << sizeof(long long int) << endl;
  //cout << sizeof(int64_t) << endl;
  //cout << sizeof(uint64_t) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < 100 / 0.08; i++){
    if (floor(i * 0.08) == a && floor(i * 0.1) == b){
      return cout << i << endl, 0;
    }
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 256