akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = 1050000000;
constexpr auto MOD = 1000000007;


int main() {
	int n;
	cin >> n;
	set<int> l;

	rep(i, n) {
		int p;
		cin >> p;
		l.insert(p);
		if (*l.lower_bound(p-1)==p-1)l.erase(p - 1);
	}

	int mxl = *l.lower_bound(0);
	int ss = l.size() - 1;

	rep(i,ss) {
		int x, y;

		x = *l.lower_bound(0);
		y = *l.upper_bound(x);

		mxl = max(mxl,y-x);
		l.erase(x);
	}

	cout << n - mxl << endl;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

bool dpx[8000][16010] = { false };
bool dpy[8000][16010] = { false };

int main() {

	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;
	int cnt = 0;

	while (s[cnt] == 'F')cnt++;
	bool flag = true; // true ->Y , false -> X
	int cntx = 0, cnty = 0, sumx = cnt, sumy = 0;
	int temp = cnt;
	cnt = 0;

	temp != 0 ? dpx[0][8000 + temp] = true : dpx[0][8000] = true;
	dpy[0][8000] = true;

	for (int i = (temp == 0) ? 1 : temp + 1; i < s.length() + 1; i++) {
		if (s[i] == 'T' or i == s.length()) {
			if (flag) {
				sumy += cnt;
				cnty++;
				for (int j = 8000 - sumy; j <= 8000 + sumy; j++) {
					if (dpy[cnty - 1][j]) {
						dpy[cnty][j + cnt] = true;
						dpy[cnty][j - cnt] = true;
					}
				}
			}
			else {
				sumx += cnt;
				cntx++;
				for (int j = 8000 - sumx; j <= 8000 + sumx; j++) {
					if (dpx[cntx - 1][j]) {
						dpx[cntx][j + cnt] = true;
						dpx[cntx][j - cnt] = true;
					}
				}
			}
			flag = !flag;
			cnt = 0;
		}
		else cnt++;
	}

	dpx[cntx][x + 8000] and dpy[cnty][y + 8000] ? pr("Yes") : pr("No");

	//system("pause");
	return 0;
}

Measured memory_bytes: 125696
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  double t, x;
  cin >> t >> x;
  cout << t / x << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main=do
    n<-readLn :: IO Int
    as <-sort.unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine :: IO [Int]
    print $ if even n then chke as else chko as

chke = chk 1 1
chko (a:as)
    | a /= 0 = 0
    | True   = chk 1 2 as
                
chk p _ [] = p
chk p n (a:b:as)
    | a==n && b==n = chk ((p*2)`mod`1000000007) (n+2) as
    | True = 0


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

int main() {
  int n, d;
  cin >> n >> d;
  int x[n][d];
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < d; j++ ) {
      cin >> x[i][j];
    }
  }
  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    for ( int k = i+1; k < n; k++ ) {
      double dis = 0;
      for ( int j = 0; j < d; j++ ) { dis += pow(x[i][j]-x[k][j], 2); }
      dis = sqrt(dis);
      double a, b;
      b = modf(dis, &a);
      if ( b == 0.0 ) { ans++; }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
struct edge {
	int to, cost, id;
};
struct state {
	int pos, cost, used, id;
};
int N, M, s, t, a, b;
int main() {
	while (cin >> N, N) {
		cin >> s >> t >> M; s--, t--;
		vector<vector<edge> > G(N);
		for (int i = 0; i < M; i++) {
			cin >> a >> b; a--, b--;
			G[a].push_back({ b, 0, i });
			G[b].push_back({ a, 1, i });
		}
		vector<vector<pair<int, int> > > d(N, vector<pair<int, int> >(2, make_pair(999999999, -1)));
		queue<state> que; que.push(state{ s, 0, 0, -1 }); d[s][0] = make_pair(0, -1);
		while (!que.empty()) {
			state u = que.front(); que.pop();
			for (edge e : G[u.pos]) {
				pair<int, int> f = d[u.pos][u.used];
				f.first += 1;
				int z = u.used + e.cost;
				if (e.cost) f.second = e.id;
				if (z == 2) continue;
				if (d[e.to][z] > f) {
					d[e.to][z] = f;
					que.push(state{ e.to, f.first, z, f.second });
				}
			}
		}
		if (d[t][0].first <= d[t][1].first) cout << d[t][0].first << ' ' << 0 << endl;
		else cout << d[t][1].first << ' ' << d[t][1].second + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3340
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 100005
#include<queue>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
int n,num,k,head[MN],l[MN],r[MN],val[MN];bool flag=0;
struct edge{int to,next;}g[MN<<1];
void ins(int u,int v){g[++num].next=head[u];head[u]=num;g[num].to=v;}
void dfs(int u,int f){
	for(int i=head[u];i;i=g[i].next)if(g[i].to!=f){
		dfs(g[i].to,u);if(flag)return ;
		if(l[g[i].to]==-inf)continue;
		if(l[u]==-inf){
			l[u]=l[g[i].to]-1,r[u]=r[g[i].to]+1;
		}else if(!((l[g[i].to]^l[u])&1)){flag=1;return;}
		else l[u]=max(l[g[i].to]-1,l[u]),r[u]=min(r[u],r[g[i].to]+1);
	}
	if(l[u]>r[u])flag=1;
}
void calc(int u,int f){
	for(int i=head[u];i;i=g[i].next)if(g[i].to!=f){
		if(val[u]+1>=l[g[i].to]&&val[u]+1<=r[g[i].to])val[g[i].to]=val[u]+1,calc(g[i].to,u);
		else val[g[i].to]=val[u]-1,calc(g[i].to,u);
	}
}
int main(){
	scanf("%d",&n);int x,y;
	for(int i=1;i<n;i++)scanf("%d%d",&x,&y),ins(x,y),ins(y,x);
	scanf("%d",&k);
	for(int i=1;i<=n;i++)l[i]=-inf,r[i]=inf;
	for(int i=1;i<=k;i++)scanf("%d%d",&x,&y),l[x]=r[x]=y;dfs(1,1);
	if(flag)puts("No");
	else {
		puts("Yes");
		val[1]=l[1];calc(1,1);
		for(int i=1;i<=n;i++)printf("%d\n",val[i]);
	}
}


Measured memory_bytes: 8704
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdio>

using namespace std;

long long dp[51][51][2500]; long long n, a, x[50];
int main() {
  cin >> n >> a;
  for (int i = 0; i < n; i++)cin >> x[i];
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 2500; k++) {
	if (dp[i][j][k] == 0)continue;
	dp[i + 1][j+1][k + x[i]] += dp[i][j][k];
	dp[i + 1][j][k] += dp[i][j][k];
      }
    }
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++)sum += dp[n][i][a*i];
  cout << sum << endl;
}


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

bool func(int n, string s){
  if(n%2 == 1){
    return false;
  }
  rep(i, n/2){
    if(s.at(i) != s.at(i+n/2)){
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(func(n, s)){
    cout << "Yes" << endl;
  }else{
	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
input = input()

flag = 0
kisu = 1

for i in input:
	if kisu == 1:
		if i == "L":
			flag = 1
		kisu = 0
	else:
		if i == "R":
			flag = 1
		kisu = 1
	

if flag == 1:
	print("No")
else:
	print("Yes")



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

    long long int a = 0,N,i;
    cin >> N;

    int n = N;
    for(i = 0; i < 100000000; i++) {
        a += n % 10;
        n /= 10;
    }

    

    if(N % a  == 0) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#define int long long
#define iris 1000000007
using namespace std;

char arr[32][32];
int dis[1024][1024];
int id[32][32];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m,i,j,k;
	cin>>n>>m;
	k=0;
	
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			id[i][j]=k++;
	
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>arr[i][j];
	
	for(i=0;i<k;i++)
		for(j=0;j<k;j++)
			if(i!=j)
				dis[i][j]=dis[j][i]=9999;
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(i+1<=n)
				dis[id[i][j]][id[i+1][j]]=dis[id[i+1][j]][id[i][j]]=1;
			if(i-1>=1)
				dis[id[i][j]][id[i-1][j]]=dis[id[i-1][j]][id[i][j]]=1;
			if(j+1<=m)
				dis[id[i][j]][id[i][j+1]]=dis[id[i][j+1]][id[i][j]]=1;
			if(j-1>=1)
				dis[id[i][j]][id[i][j-1]]=dis[id[i][j-1]][id[i][j]]=1;
		}
	}
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(arr[i][j]=='#')
			{
				if(i+1<=n)
					dis[id[i][j]][id[i+1][j]]=dis[id[i+1][j]][id[i][j]]=9999;
				if(i-1>=1)
					dis[id[i][j]][id[i-1][j]]=dis[id[i-1][j]][id[i][j]]=9999;
				if(j+1<=m)
					dis[id[i][j]][id[i][j+1]]=dis[id[i][j+1]][id[i][j]]=9999;
				if(j-1>=1)
					dis[id[i][j]][id[i][j-1]]=dis[id[i][j-1]][id[i][j]]=9999;
			}
		}
	}
	
	for(int ouo=0;ouo<k;ouo++)
	{
		for(i=0;i<k;i++)
		{
			for(j=0;j<k;j++)
			{
				dis[i][j]=min(dis[i][j],dis[i][ouo]+dis[ouo][j]);
			}
		}
	}
	int ans=0;
	for(i=0;i<k;i++)
	{
		for(j=0;j<k;j++)
		{
			if(dis[i][j]<9999)
			{
				ans=max(ans,dis[i][j]);
			}
		}
	}
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 3328
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
 
#include <thread>
#include <unordered_set>
#include <vector>
#include <memory.h>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <stdio.h>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <random>
#include <string>
#include <cassert>


#define getcx _getchar_nolock

using namespace std;
 
namespace std
{
	string to_string(string const& s) { return '"' + s + '"'; }
	string to_string(char c) { return string(1, c); }
	string to_string(const char* s) { return to_string((string)s); }
	string to_string(bool b) { return (b ? "true" : "false"); }
 
	template <class T1, class T2>
	string to_string(pair<T1, T2> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
 
	template <class T>
	string to_string(T c)
	{
		string s = "[";
		for (auto vvv : c) { s += to_string(vvv) + ","; }
		s += "]";
		return s;
	}
 
	void debug_impl() { cerr << endl; };
 
	template <typename T1, typename... T2>
	void debug_impl(T1 a, T2 ... b)
	{
		cerr << " " << to_string(a);
		debug_impl(b...);
	}
}
 
template <typename T>
struct reversion_wrapper
{
	T& iterable;
};
 
template <typename T>
auto begin(reversion_wrapper<T> w) { return std::rbegin(w.iterable); }
 
template <typename T>
auto end(reversion_wrapper<T> w) { return std::rend(w.iterable); }
 
template <typename T>
reversion_wrapper<T> reverse(T&& iterable) { return { iterable }; }
 
 
#ifdef __ASD__
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_impl(__VA_ARGS__)
//#define endl "\n"
#else
#define dbg(...) ;
//#define endl "\n"
#endif
 
#define lng long long

int main()
{
#ifdef __ASD__
	auto start_t = chrono::steady_clock::now();
	freopen("input.txt", "r", stdin);
	//freopen("nul", "w", stderr);
	//freopen("output.txt", "w",  stdout);
#else
	ios_base::sync_with_stdio(false);
#endif
	int n;
	cin >> n;
	int m;
	cin >> m;

	priority_queue<int, vector<int>, less<int>> pq;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		pq.push(x);
	}

	while(m--)
	{
		int x = pq.top();
		pq.pop();
		pq.push(x/2);
	}

	lng res = 0;
	while(!pq.empty())
	{
		res += pq.top();
		pq.pop();
	}
	cout<<res<<endl;
	
#ifdef __ASD__
	auto finish_t = chrono::steady_clock::now();
	cerr << "Elapsed " << chrono::duration_cast<chrono::milliseconds>(finish_t - start_t).count() << " ms" << endl;
#endif
	return 0;
}


Measured memory_bytes: 892
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    int x;
    int mmin=1e5;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        m-=x;
        mmin=min(mmin, x);
    }
    printf("%d\n",n+int(m/mmin));
    return 0;
}

Measured memory_bytes: 128
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()
    s = input()

    now = 0
    for c in s[1:]:
        if c == 'E':
            now += 1

    ans = now

    for i in range(n - 1):
        if s[i] == 'W':
            now += 1
        if s[i+1] == 'E':
            now -= 1
        ans = min(now, ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4340
Imports System.Console
Module Module1
    Dim L, R, d As Int64
    Dim ans As Int64
    Sub Main()
        Dim s() As String = ReadLine().Split
        L = s(0)
        R = s(1)
        d = s(2)
        For i = L To R
            If i Mod d = 0 Then
                ans += 1
            End If
        Next
        WriteLine(ans)
    End Sub
End Module


Measured memory_bytes: 28308
! 2020.1.19
!
      program answer
      implicit none
      integer :: a,b,i
      integer :: ans
      read(*,*) a,b
      ans = 0
      if(a > b) then
        do i=1,a
          ans = ans + b*10**(i-1)
        end do
      else
        do i=1,b
          ans = ans+a*10**(i-1)
        end do 
      end if
      write(*,*) ans
      end program answer

Measured memory_bytes: 768
def check(num,arr)
    str = num.to_s.split('')
    f = false
    str.each{|x|
        arr.each{|y|
            f = f || x==y
        }
    }
    return f
end

n,k = gets.chomp.split.map(&:to_i)
d = gets.chomp.split

loop do
    if !check(n,d)
        puts n
        break
    else
        n += 1
    end
end

Measured memory_bytes: 2044
import java.util.*;
import java.io.*;
 
public class Main {
 
	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}
 
	private long solve() {
 
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long [] array = new long[N+1];
		for(int i=1;i<=N;i++){
			array[i] = sc.nextLong();
		}
 
		long [][] sum = preProcess(array, N);
		long [][] dp = new long[500][500];
		return solve(sum, 1, N, dp);
	}
 
	private long[][] preProcess(long[] array, int N) {
		long [][] sum = new long[500][500];
		for(int i=1;i<=N;i++){
			for(int j=i;j<=N;j++) {
				sum[i][j] = array[j] + ((i==j) ? 0 : sum[i][j-1]);
			}
		}
		return sum;
	}
 
	private long solve(long[][] sum, int i, int j, long[][] dp) {
		if (i==j) return 0;
		if (dp[i][j] != 0) return dp[i][j];
		long answer = (long) 1e14+7;
		for(int k=i;k<j;k++) {
			long currAns = sum[i][j] + solve(sum, i, k, dp) + solve(sum, k+1, j, dp);
			answer = Math.min(currAns, answer);
		}
		dp[i][j] = answer;
		return answer;
	}
 
}

Measured memory_bytes: 41616
/* Tuan Kkura */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 2000005

int pos[1005][1005];
bool vi[MAXN];
int len[MAXN];
vector <int> S;
vector <int> DSK[MAXN];

void DFS(int u)
{
    vi[u] = true;
    REP(i, 0, DSK[u].size())
    {
        int v = DSK[u][i];
        if(!vi[v])
            DFS(v);
    }
    S.pb(u);
}

int Num[MAXN];
int Low[MAXN];
int c = 0;
stack <int> C;
int Max = 0;

void Tarjan(int u)
{
    Num[u] = Low[u] = ++c;
    C.push(u);
    for(int i = 0; i < DSK[u].size(); i++)
    {
        int w = DSK[u][i];
        if(Num[w])   Low[u] = min(Low[u], Num[w]);
        else{
            Tarjan(w);
            Low[u] = min(Low[u], Low[w]);
        }
    }
    if(Num[u] == Low[u])
    {
        int v;
        int sz = 0;
        do{
            v = C.top();
            C.pop();
            sz++;
            Num[v] = Low[v] = INT_MAX;
        }while(v!=u);
        Max = max(Max, sz);
    }
}

int main()
{
    _io
    int n; cin >> n;
    int cnt = 0;
    FOR(i, 1, n)
        FOR(j, i+1, n)
            pos[i][j] = ++cnt;
    FOR(i, 1, n)
    {
        int pre = 0;
        FOR(j, 1, n-1)
        {
            int x;
            cin >> x;
            int u = min(i, x);
            int v = max(i, x);
            int val = pos[u][v];
            if(j > 1)
                DSK[pre].pb(val);
            pre = val;
        }
    }
    FOR(i, 1, cnt)
        if(!vi[i])  DFS(i);
    FOR(i, 1, cnt)
        if(!Num[i]) Tarjan(i);
    if(Max > 1) return cout << -1, 0;
    fill(vi+1, vi+1+n, false);
    FOR(i, 1, cnt)
        len[i] = 1;
    int res = 0;
    FORs(i, S.size()-1, 0)
    {
        res = max(res, len[S[i]]);
        REP(j, 0, DSK[S[i]].size())
        {
            int v = DSK[S[i]][j];
            len[v] = max(len[v], len[S[i]] + 1);
        }
        vi[S[i]] = true;
    }
    cout << res;
}


Measured memory_bytes: 81908
package main

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

var scanner *bufio.Scanner

func printIt() {
	a := nextInt()
	b := nextInt()
	c := nextInt()
	ans := 0
	for i := a; i <= b; i++ {
		if c%i == 0 {
			ans++
		}
	}
	fmt.Println(ans)
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1112
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long a[1000000];
long long ans;
int main()
{
	int m,n;
	cin>>m>>n;
	for(int i=1;i<=m;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1); 
	if(a[1]>=0)
	{
		cout<<a[n]<<endl;
	    return 0;
	}
	ans=999999999;
	for(int i=1;i<=m-n+1;i++)
	{
		if(a[i]<=0&&a[i+n-1]>=0)
		{
			ans=min(ans,2*a[i+n-1]-a[i]);
			ans=min(ans,abs(a[i])+a[i+n-1]-a[i]);
		}
	}
	int temp1=-1;
	for(int i=1;i<=m;i++)
	{
		if(a[i]<=0&&a[i+1]>=0)
		{
			temp1=i;
			break;
		}
	}
	long long temp2=999999999,temp3=999999999;
	if(temp1-n+1>=1)
	temp2=abs(a[temp1-n+1]);
	if(temp1+n<=m)
	temp3=abs(a[temp1+n]);
	cout<<min(min(ans,temp2),temp3)<<endl;
}

Measured memory_bytes: 1024
#pragma optimization_level 3
#include <bits/stdc++.h>
#define  f               first
#define  s               second
#define  sym(s)          s = "#" + s + "#";
#define  all(x)          (x).begin(), (x).end()
#define  alll(x,n)       x+1, x+n+1
#define  newl            cout<<"\n";
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}

using namespace std;
using ll              =  long long;
using ld              =  long double;
const ll   MOD        =  1e+9 + 7;
const ll   INF        =  LLONG_MAX;
const int  N          =  (int)1e+6 + 8;

ll n, x, m, a[N], pre[N];

void brute(ll n, ll x, ll m) {
    ll p = x;
    cout << p << " ";
    for (int i = 2; i <= n; i++) {
        ll nx = p * p % m;
        cout << nx << " ";
        p = nx;
    }
    newl;
}

map<ll,ll> vis;

void MAIN(int tc) {
    cin >> n >> x >> m;
    //brute(n, x, m);

    a[1] = pre[1] = x;

    ll before = 0, p = x, k = 0;
    before += p;
    for (int i = 2; i <= 1e6; i++) {
        ll nxt = p * p % m;
        if (k == 0 && vis.find(nxt)!=vis.end()) k = i;
        if (k == 0) before += nxt;
        a[i] = nxt;
        pre[i] = pre[i-1] + a[i];
        p = nxt;
        vis[a[i]] = 1;
    }

    
    if (n <= k) {
        cout << pre[n];
        return;
    }

    ll repeat = 0, ok = 0, j = 1;
    p = a[k];
    repeat += p;

    for(int i = k; i <= n; i++, j++){
        ll nxt = p * p % m;
        if(nxt == a[k]) {
            ok = 1;
            break;
        }
        repeat += nxt;
        p = nxt;
    }

    if (ok == 0) {
        cout << before + repeat;
        return;
    }

    ll after = 0;
    ll left = (n - k + 1) % j;
    for(int i = k; i < k + left; i++){
        after += a[i];
    }

    //deb3(k, j, left);
    //deb3(before, repeat, after);
    cout << before + ((n - k + 1) / j ) * repeat + after;

}

int main() {
    ios:: sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cout << fixed; cout << setprecision(10);

    int test_cases = 1;
    //cin>>test_cases;
    for (int i = 1; i <= test_cases; i++) {
        MAIN(i);
    }
}

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

int main(){
  int n;
  cin>>n;
  vector<P> p(n);
  rep(i,n){
    ll x, l;
    cin >> x >> l;
    p[i] = make_pair(x-l,x+l);
  }
  sort(p.begin(),p.end());
  int ans=n;
  ll right=p[0].second;
  for(int i=1; i < n; i++){
    if(right <= p[i].first) right=p[i].second;
    else if(p[i].second < right){
      right=p[i].second;
      ans--;
    }else ans--;
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define DIM 200009
#define INF 1e18+9
#define MODULO 1000000007
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<int,int>
#define fi first
#define se second
#define ld long double

long long i,j,k,l,n,m;

long long dp[DIM][2];

vector<long long>a[DIM];

long long dfs(long long v,long long type,long long par){
    if(dp[v][type]!=0)return dp[v][type];
    dp[v][type]=1;
    for(auto to:a[v]){
        if(to==par)continue;
        if(type==0)dp[v][type]=(dp[v][type]*dfs(to,1,v))%MODULO;
        if(type==1)dp[v][1]=(((dfs(to,0,v)+dfs(to,1,v))%MODULO)*dp[v][1])%MODULO;
    }
  //  cout<<v<<' '<<type<<' '<<dp[v][type]<<endl;
    return dp[v][type];
}

int main()
{
    cin>>n;
    for(i=1;i<n;i++){
        cin>>k>>l;
        a[k].push_back(l);
        a[l].push_back(k);
    }

    cout<<(dfs(1,0,-1)+dfs(1,1,-1))%MODULO<<endl;

    return 0;
}


Measured memory_bytes: 16640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x  = in.nextInt();
		int syou = x/500;
		int amari = x%500;
		int amari2 = amari/5;
		int result = (syou*1000)+(amari2*5);
		System.out.println(result);
	}
}


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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static int[][] mtx ;
        static List<int>[] tm;
        static int n;
        static int[] results;
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s == "Sunny") Console.WriteLine("Cloudy");
            else if (s == "Cloudy") Console.WriteLine("Rainy");
            else Console.WriteLine("Sunny");

/*
            //int n = int.Parse(Console.ReadLine());
            string[] s1 = Console.ReadLine().Split(' ');

            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = int.Parse(s1[i]);
            }


            Console.WriteLine(rec(p, 0, n-1, 1000000));
            */
        }

 
        static int rec(int[] n, int i, int j, int x)
        {
            if (i+1 == j)
            {
                return Math.Min(n[j], x);
            }
            return rec(n, i + 1, j, n[i]) + rec(n, i, j - 1, n[j]);
        }
    }

}

Measured memory_bytes: 13140
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
      
n,m=map(int, input().split())
path=[]
for i in range(m):
    a,b=map(int, input().split())
    path.append([a-1,b-1])
    
count=0
for i in range(m):
    path2=path[:]
    path2.pop(i)
    uf1=UnionFind(n)
    for a,b in path2:
        uf1.union(a,b)
    if not uf1.is_same(path[i][0],path[i][1]): count+=1
print(count)

Measured memory_bytes: 3064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "complex"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;


long long int N, M, K, H, W, L, R;



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

	cin >> N;
	cin >> K;
	vector<long long int>v(N);
	for (int i = 0; i < N; i++)cin >> v[i];
	sort(v.begin(), v.end());
	int ans = 0;
	for (auto i : v) {
		if (K >= i) {
			K -= i;
			ans++;
		}
	}
	if (K&&ans == N)ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e5+5;
//long long int a[N];
int main()
{

  long long  int i,j,n,sum=0,x,y,a,b,sum1=0,p,m=0,h;
 cin>>x>>y>>a;




       if(x==y||x==a||y==a)
       {
           if(x!=y||x!=a||y!=a)
           {
                 cout<<"Yes"<<endl;
           }
           else
            cout<<"No"<<endl;
       }
       else
       {
           cout<<"No"<<endl;
       }


    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

long double dp[3000][3000];

int main(){
	int n; cin>>n;
	long double p[3000];
	FOR(i,0,n) cin>>p[i];
	dp[0][0]=1;
	FOR(i,0,n){
		FOR(j,0,n){
			if(i<j) continue;
			dp[i+1][j+1]+=dp[i][j]*p[i];
			dp[i+1][j]+=dp[i][j]*(1-p[i]);
		}
	}
	long double ans=0;
	FOR(i,n/2+1,n+1){
		ans+=dp[n][i];
	}
	fcout<<ans<<endl;
}


Measured memory_bytes: 139136
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define fo(i,n)         for(i=0; i<n; i++)
#define fo1(i,n)        for(i=1; i<=n; i++)
#define Fo(i,k,n)       for(i=k; k<=n?i<=n:i>=n; k<=n?i++:i--)
#define all(x)          x.begin(), x.end()
#define rall(x)         x.rbegin(), x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x, 0, sizeof(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr = new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x){cout<<x;}
void __print(float x){cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base, int exp){ int res = 1; base %= mod; while(exp > 0){ if(exp & 1) res = (res * base) % mod; base = (base * base) % mod; exp = exp >> 1; } return res; }
int inv(int x){ return power(x, mod - 2) % mod; }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N = 1e6 + 6, M = N;
int i, j;

void solve(){
    
    int idx;
    fo1(i,5){ int x; cin>>x; if(x==0) idx=i;} 
    
    cout<<idx;
    
    
}




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

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
#include<algorithm>
int main()
{
	int sta[101]={},stb[101]={},ju[101]={};
	int A,B,C,D,i,n,m,j;
	cin>>n;
	for(i=1;i<=n;i++){
		sta[i]=i;
	}
	m=n*(n-1)/2;
	for(i=0;i<m;i++){
		cin>>A>>B>>C>>D;
		if(C>D){
			stb[A]+=3;
		}
		else if(C<D){
			stb[B]+=3;
		}
		else{
			stb[B]++;
			stb[A]++;
		}
	}
	for(i=1;i<=n-1;i++){
		for(j=i+1;j<=n;j++){
			if(stb[i]<stb[j]){
				m=stb[i];
				stb[i]=stb[j];
				stb[j]=m;
				m=sta[i];
				sta[i]=sta[j];
				sta[j]=m;       

			}
		}
	}
	for(i=1;i<=n;i++){
			if(stb[i]==stb[i-1]){
				ju[sta[i]]=ju[sta[i-1]];
			}
			else {
				ju[sta[i]]=i;
			}
	}
	for(i=1;i<=n;i++){
		cout<<ju[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string A, B, C;
    cin >> A >> B >> C;
    cout << (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0] ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define ff first
#define int long long
#define pi pair<int,int>
#define ss second 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

int32_t main() { 
    boost;
    int n;
    cin>>n;
    set<string>s;
    for(int i=0;i<n;i++){
        string tmp;
        cin>>tmp;
        s.insert(tmp);
    }
    cout<<s.size()<<endl;
}
 



Measured memory_bytes: 19236
#include<bits/stdc++.h>
using namespace std;
vector<vector<double>>dp;
double f(int i,int t,int &x,vector<double>&p)
{
    if(t>x)
    return 0;
    if(i==p.size())
    return 1;
    if(dp[i][t]!=-1)
    return dp[i][t];
    double x1=((double)p[i])*f(i+1,t,x,p);
    double y=((double)(1-p[i]))*f(i+1,t+1,x,p);
    return dp[i][t]=x1+y;
}

int main()
{
    int n;
    cin>>n;
    vector<double>p(n);
    for(auto &i:p)
    cin>>i;
    int x=(n)/2;
    dp.resize(n+1,vector<double>(x+1,-1));
    cout<< fixed << setprecision(10) <<f(0,0,x,p);
}

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

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

    char dif='A'-'a';
 
    cout<<(char)(a[0]+dif)<<(char)(b[0]+dif)<<(char)(c[0]+dif)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5,MAX_H=1e9;
int N;
ll A,B;
ll h[MAX_N];
bool C(ll x){
	ll cnt=0;
	REP(i,N){
		cnt+=max((h[i]-x*B+A-B-1)/(A-B),0ll);
	}
	return cnt<=x;
}
int main(){
	cin>>N;
	cin>>A>>B;
	REP(i,N){
		cin>>h[i];
	}
	ll lb=-1,ub=1e9;
	while((ub-lb)>1){
		ll mid=(lb+ub)>>1;
		if (C(mid)){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	cout<<ub<<endl;
	return 0;
}

Measured memory_bytes: 1024
let char_list_of_string str = 
  let rec f0 i a =
    if i<0 then a else f0 (i-1) (str.[i]::a)
	in f0 (String.length str - 1) []
let string_of_char_list ls = 
	List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls

let () =
	let s = read_line () |> char_list_of_string |> List.rev
	in let hoge a = a|>List.rev|>string_of_char_list
	in let rec f0 a = match a with
	| [] -> "YES"
	|	p::q::r::s::t::u::v::tl when "dreamer" = hoge [p;q;r;s;t;u;v] -> f0 tl
	| p::q::r::s::t::u::tl when "eraser" = hoge [p;q;r;s;t;u] -> f0 tl
	| p::q::r::s::t::tl when let h = hoge [p;q;r;s;t] in "dream" = h || "erase" = h -> f0 tl
	| _ -> "NO"
	in print_endline @@ f0 s

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i, 0, N) cin >> s[i];

  int cnt_a = 0;
  int cnt_b = 0;
  int cnt_ab = 0;
  int ans = 0;

  rep(i, 0, N)
  {
    int ssize = s[i].size();
    if (s[i][ssize - 1] == 'A' && s[i][0] == 'B')
      cnt_ab++;
    else if (s[i][ssize - 1] == 'A')
      cnt_a++;
    else if (s[i][0] == 'B')
      cnt_b++;
    rep(j, 1, ssize)
    {
      if (s[i][j - 1] == 'A' && s[i][j] == 'B')
        ans++;
    }
  }

  if (cnt_a > 0 || cnt_b > 0) {
    ans += cnt_ab;
    ans += min({cnt_a, cnt_b});
  } else {
    ans += max(0, cnt_ab - 1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

ll cnt[26] = {};

int main() {
	IOS();
	ll n, a, b;
	cin >> n >> a >> b;
	ll M = min(a, b);
	ll m = max((a + b) - n, 0ll);
	cout << M << " " << m << endl;
}

Measured memory_bytes: 256
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
 
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5]; ll visit[] = {};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	cout<<(char)(s1[0]-'a'+'A');
	cout<<(char)(s2[0]-'a'+'A');
	cout<<(char)(s3[0]-'a'+'A');
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
const int mxN=1e5+5,M=1e9+7;
//did u check when n=1?
//is mxN correct?

int n,k;
int dp[2][mxN];
int v[105];
int solve(int p,int res){
    //cout<<p<<" "<<res<<"\n";
    if(res==0)
      return dp[p][res]=0;
    if(dp[p][res]!=-1)
      return dp[p][res];

    for(int i=0;i<n;i++){
        if(v[i]<=res && !solve((p+1)%2,res-v[i]))
        return dp[p][res]=1;
    }
    return dp[p][res]=0; 
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>v[i];
    solve(0,k);
    cout<<(solve(0,k)==1?"First":"Second");

}


Measured memory_bytes: 9868
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>

using namespace std;

char str[105];

int main()
{
	int n;
	scanf("%d",&n);
	string s,t;
	scanf("%s",&str);
	s=str;
	scanf("%s",&str);
	t=str;
	int ret=0;
	for(int i=0;i<=s.size();i++)
	{
		bool up=true;
		for(int j=i;j<s.size();j++)
		{
			if(s[j]!=t[j-i])
			{
				up=false;
			}
		}
		if(up)
		{
			ret=i+n;
			break;
		}
	}
	printf("%d\n",ret);
	return 0;
}


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;


struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): 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)];}
  int factor_size() {
    int ans=0;
    rep(i,d.size()){
      if (d[i]<0) {ans++;}
    }
    return ans;
  }
  
};
  
int main(){ 
  ll n,m,k,q;
  cin >> n;

  ll s[n+1];
  s[0]=0;
  rep(i, n ){
    cin >> q;
    s[i+1] = s[i] + q;
  }

  ll ans = 0;
  sort(s, s+n+1);

  map<ll, ll> cnt;

  rep(i,n+1) cnt[s[i]]++;

  for (auto c: cnt) ans += c.second*(c.second-1)/2;

  cout << ans <<endl;
}



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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1) {
        cout << "No" << EOL;
        return;
    }
    cout << (s.substr(0, n / 2) == s.substr(n / 2) ? "Yes" : "No") << EOL;
}


Measured memory_bytes: 256
/*
   Aizu Vol0 0155: Spider Jin
   2017.8.16 bal4u@uu
   ??????????????????
*/
#include <stdio.h>
#include <math.h>

#define MAX 100

int x[MAX + 5], y[MAX + 5], N;
long long d[MAX + 5][MAX + 5];
int p[MAX + 5];

char visited[MAX + 5];
#define INF 1.0e20
double total[MAX + 5];

void search(int s, int g)
{
	int  i, j, next;
	double min, t;

	for (i = 1; i <= N; i++) visited[i] = 0, total[i] = INF;
	total[s] = 0, next = s;
	do {
		i = next, visited[i] = 1, min = INF;
		for (j = 1; j <= N; j++) {
			if (visited[j]) continue;
			if (d[i][j] > 0 && total[i] + (t = sqrt((double)d[i][j])) < total[j])
				total[j] = total[i] + t, p[j] = i;
			if (total[j] < min) min = total[j], next = j;
		}
	} while (min < INF);
}

int main()
{
	int m, s, g;
	int i, j;
	long long dx, dy;

	while (1) {
		scanf("%d", &N); if (!N) break;
		for (i = 0; i < N; i++) {
			scanf("%d", &j);
			scanf("%d%d", x + j, y + j);
		}
		for (i = 1; i <= N; i++) for (j = i + 1; j <= N; j++) {
			dx = x[i] - x[j], dy = y[i] - y[j];
			if (dx*dx + dy*dy <= 2500) d[i][j] = d[j][i] = dx*dx + dy*dy;
			else d[i][j] = d[j][i] = 0;
		}

		scanf("%d", &m);
		while (m-- > 0) {
			scanf("%d%d", &s, &g);
			if (s == g) { printf("%d\n", s); continue; }
			search(s, g);
			if (total[g] == INF) puts("NA");
			else {
				int a[MAX + 5];
				a[0] = g, i = 0;
				while (g != s) g = p[g], a[++i] = g;
				printf("%d", s);
				while (--i >= 0) printf(" %d", a[i]);
				putchar('\n');
			}
		}
	}
	return 0;
}

Measured memory_bytes: 704
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef pair<ll, ll> pll;

const int INF = 1000000010;
const ll MOD = 1000000007;

int main() {FIN
	
	int i, s = 0;
	string num;
	cin >> num;
	for(i = 0; i < (int)num.size(); i++)
		s += (num[i]-'0');
		
	cout << (s%9 == 0 ? "Yes" : "No") << "\n";
		
	return 0;
}


Measured memory_bytes: 3780