akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
    	cin >> a[i];
    }
    deque<pair<int,int> > dqmin, dqmax;
    int ans = 0;
    bool maki = 0;
    for(int i=0;i<k;i++){
    	while(!dqmin.empty() && dqmin.back().first > a[i]) dqmin.pop_back();
    	while(!dqmax.empty() && dqmax.back().first < a[i]) dqmax.pop_back();
    	dqmin.push_back({a[i], i});
    	dqmax.push_back({a[i], i});
    }
    if(dqmin.size() == k) maki = true;
    else ans++;

    for(int i=k;i<n;i++){
    	while(!dqmin.empty() && dqmin.back().first > a[i]) dqmin.pop_back();
    	while(!dqmax.empty() && dqmax.back().first < a[i]) dqmax.pop_back();
    	dqmin.push_back({a[i], i});
    	dqmax.push_back({a[i], i});
 
    	while(!dqmin.empty() && dqmin.front().second <= i - k) dqmin.pop_front();
    	while(!dqmax.empty() && dqmax.front().second <= i - k) dqmax.pop_front();
    	if(dqmin.size() == k) {maki = true; continue;}
    	if(dqmin.front().first > a[i-k] && dqmax.front().second == i) continue;
    	ans++;
    }
    if(maki) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2688
using System;
using System.Collections.Generic;
using System.Linq;

namespace CompCsharp
{
    class Program
    {
        private const double BTCJPY = 380000.0;
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<double> ret = new List<double>();
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                double x = double.Parse(s[0]);
                if (s[1] == "BTC")
                {
                    x *= BTCJPY;
                }
                ret.Add(x);
            }

            Console.WriteLine(ret.Sum());
                
        }
    }
}


Measured memory_bytes: 13268
def main():
    def factorization(num):
        result = []
        count = 0
        temp = num
        for i in range(2, int(num ** 0.5) + 1):
            if temp % i == 0:
                count = 0
                while temp % i == 0:
                    count += 1
                    temp /= i
                result.append([i, count])
        if temp != 1:
            result.append([int(temp), 1])
        if result == []:
            result.append([num, 1])
        return result

    n, p = map(int, input().split())
    factors = factorization(p)
    ans = 1
    for f, v in factors:
        ans *= f ** (v // n) if v >= n else 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9364
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M




void solve() {
	int n,x,t;
	cin>>n>>x>>t;
	int ans=(n/x)*t;
	if(n%x) ans+=t;
	cout<<ans;
		
}


signed 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: 3604
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int fun1(int n,int choice,int arr[][3],int dp[][3])
{
	if(n==-1)
		return 0;
	if(dp[n][choice]!=-1)
		return dp[n][choice];
	if(choice == 0)
	{
		return dp[n][choice] = arr[n][choice]+max(fun1(n-1,1,arr,dp),fun1(n-1,2,arr,dp));
	}
	if(choice == 1)
	{
		return dp[n][choice] = arr[n][choice]+max(fun1(n-1,0,arr,dp),fun1(n-1,2,arr,dp));
	}
	if(choice == 2)
	{
		return dp[n][choice] = arr[n][choice]+max(fun1(n-1,1,arr,dp),fun1(n-1,0,arr,dp));
	}
}
int main()
{
	int n;
	cin>>n;
	int arr[n][3];
	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<3;j++)
			cin>>arr[i][j];
	}
	int dp[n][3];
	memset(dp,-1,sizeof(arr));

	dp[0][0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];
	int val0 = fun1(n-1,0,arr,dp);
	int val1 = fun1(n-1,1,arr,dp);
	int val2 = fun1(n-1,2,arr,dp);
	

	cout<<max(val1,max(val2,val0))<<'\n';


}
  	


Measured memory_bytes: 8832
#include<iostream>
int main(void){
    int n;
    scanf("%d",&n);
    int d[n+1];
    for(int i=1;i<=n;i++){
    scanf("%d",&d[i]);
    }
    int ans=0,a=1;
    for(int i=1;i<=n-1;i++){
        a=i+1;
        for(int l=a;l<=n;l++){
            ans=ans+d[i]*d[l];
        }
    }
    printf("%d",ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, a[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int count[100001] = {}, max = 0;
	for (i = 1; i <= N; i++) count[a[i]]++;
	for (i = 1; i < 100000; i++) {
		if (count[i-1] + count[i] + count[i+1] > max) max = count[i-1] + count[i] + count[i+1];
	}
	
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#define NOT(a) ((a)==1)?0:1
#define AND(a,b) ((a) && (b))?1:0
#define OR(a,b) ((a) || (b))?1:0
#define IMP(a,b) (!((a) && (!(b))))?1:0

int alpha[11];

int formula(char *str){
	if(*str == 'T'){
		//printf("T = 1\n");
		return 1;
	}else if(*str == 'F'){
		//printf("F = 0\n");
		return 0;
	}else if('a' <= *str && *str <= 'k'){
		//printf("alpha %c = %d\n",*str,alpha[*str - 'a']);
		return alpha[*str - 'a'];
	}else if(*str == '-'){
		//printf("f = %d\n",formula(str + 1));
		//printf("NOT(f) = %d\n",NOT(formula(str + 1)));
		return NOT(formula(str + 1));
	}else{
		int middle = 0;
		char *p;
		for(p = (str + 1);(*p != '*' && *p != '+' && !(*p == '-' && *(p + 1) == '>')) || middle != 0;p++){
			if(*p == '('){
				middle++;
			}else if(*p == ')'){
				middle--;
			}
		}
		if(*p == '*'){
			//printf("%d * %d = %d\n",formula(str + 1),formula(p + 1),AND(formula(str + 1),formula(p + 1)));
			return AND(formula(str + 1),formula(p + 1));
		}else if(*p == '+'){
			//printf("%d + %d = %d\n",formula(str + 1),formula(p + 1),OR(formula(str + 1),formula(p + 1)));
			return OR(formula(str + 1),formula(p + 1));
		}else{
			//printf("%d -> %d = %d\n",formula(str + 1),formula(p + 1),IMP(formula(str + 1),formula(p + 1)));
			return IMP(formula(str + 1),formula(p + 2));
		}
	}
}

int equation(char *str){
	int i, f1, f2;
	for(i = 0;str[i] != '=';i++);
	if((f1 = formula(str)) == (f2 = formula(str + i + 1))){
		//printf("%d %d\n",f1,f2);
		return 1;
	}else{
		//printf("%d %d\n",f1,f2);
		return 0;
	}
}



int main(void){
	int i, j;
	char str[1001], ans[4];
	while(1){
		strcpy(ans,"YES");
		scanf("%s",&str);
		if(!strcmp(str,"#")){
			break;
		}
		for(i = 0;i < 1 << 11;i++){
			for(j = 0;j < 11;j++){
				alpha[j] = (i >> j) & 1;
//				printf("%d ",(i >> j) & 1);
			}
//			printf("\n");
			if(!equation(str)){
				strcpy(ans,"NO");
			}
		}
		puts(ans);
	}
//	while(1);
	/*	for(i = 1;i >= 0;i--){
			for(j = 1;j >= 0;j--){
				printf("%d ",i);
				printf("%d ",j);
				printf("%d ",NOT(i));
				printf("%d ",AND(i,j));
				printf("%d ",OR(i,j));
				printf("%d ",IMP(i,j));
				printf("\n");
			}
		}
		while(1);*/
	return 0;
}

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

typedef long double ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	cin >> n;
	a=n*n*n;
	a/=27;

    std::cout << std::fixed;
    std::cout << std::setprecision(6);
	cout << a << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
int n;
int a[200001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	ll sum=a[n-1],nsum=a[n-1];
	stack<P> s;
	s.push(P(a[n-1],1));
	for(int i=n-2;i>=0;i--){
		P next=P(a[i],1);
		while(s.size() && s.top().first>next.first){
			next.second+=s.top().second;
			nsum-=s.top().first*s.top().second;
			s.pop();
		}
		nsum+=next.first*next.second;
		s.push(next);
		sum+=nsum;
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

    sort(a.begin(), a.end());
    int max = *max_element(a.begin(), a.end());
    int ans = 0;
    for(int i=0; i<n; i++) {
        if(abs(2*a[i]-max) < abs(2*ans-max)) ans = a[i];
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define All(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);
  Cins(int, n, a);

  int sum = accumulate(All(a), 0);
  int mean = (int)round((double)sum / sz(a));

  int ans = 0;
  for (auto e : a) ans += (e - mean) * (e - mean);
  cout << ans << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 6 - a - b;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n;
	for(;cin>>n,n;){
		int sum=0;
		while(n--){
			int x,y,h,w;
			cin>>x>>y>>h>>w;
			x+=y+h;
			if     (x<= 60 && w<= 2)	sum+=600;
			else if(x<= 80 && w<= 5)	sum+=800;
			else if(x<=100 && w<=10)	sum+=1000;
			else if(x<=120 && w<=15)	sum+=1200;
			else if(x<=140 && w<=20)	sum+=1400;
			else if(x<=160 && w<=25)	sum+=1600;
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
integer N
integer,allocatable,dimension(:)::L
integer ans
read*,N
allocate(L(2*N))
read*,L

call heapsort(2*N,L)

ans=0
do i=1,N
  ans=ans+L(2*i-1)
end do

print"(i0)",ans

contains

subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
  integer::i,k,j,l
  integer:: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end

Measured memory_bytes: 256
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a=[0]
b=[0]

for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])

ans = 0
j = M
for i in range(N+1):
  if(K < a[i]):break
  
  while(b[j] > K - a[i]):
    j -= 1
  if(ans < i+j):
    ans = i+j
print(ans)

Measured memory_bytes: 127200
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++){
        int sum=0;
        int tmp=i;
        for(int j=0;j<5;j++){
            sum+=tmp%10;
            tmp=tmp/10;
        }
        if(a<=sum&&sum<=b){
            ans+=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	unsigned long a, b, r, c, d;
	unsigned long ta, tb;
	int i = 0;


	while(cin>>a>>b) {
		
	if (a > b){
		ta = a;
		tb = b;
	} else {
		ta = b;
		tb = a;
	}
	

	while (1) {
	r = ta % tb;
	if (r == 0) break;
	ta = tb;
	tb = r;
	}
	c = tb;
	
	d = a * (b  / c);

	printf("%d %d\n", c, d);
	}

	

	return (0);
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	int N, j;
	cin >> N;
	for (int i = 1;i < 10;i++) {
		if (N % i == 0) {
			j = N / i;
			if (j < 10) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
v=n1()

v.sort()
ans=0

for i in range(n):
    if i!=0:
        ans+=v[i]/(2**(n-i))
    else:
        ans+=v[0]/(2**(n-1))
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int r, g, b=1000, c=0;
    scanf("%d",&g);
    for(int i=0;i<g;i++) {
        scanf("%d", &r);
        c = c>r?c:r;
        b = b<r?b:r;
    }
    printf("%d",c-b);
    return 0;
}

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

#define lint long long
#define P pair<int, int>

const int MAX_N = 100000;
const int MAX_Q = 100000;

int par[MAX_N + 1];
int ran[MAX_N + 1];

void init(int par[]){
    for(int i = 0; i < MAX_N + 1; ++i){
        par[i] = i;
        ran[i] = 0;
    }
}

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

void unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(ran[a] < ran[b]){
        par[b] = a;
    } else {
        par[a] = b;
        if(a == b){
            ran[a]++;
        }
    }
}

bool same(int a, int b){
    return find(a) == find(b);
}


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

    int X[M], Y[M], Z[M];
    bool used[N + 1];
    memset(used, false, sizeof used);

    init(par);

    for(int i = 0; i < M; ++i){
        cin >> X[i] >> Y[i] >> Z[i];
        used[X[i]] = true;
        used[Y[i]] = true;
        unite(X[i], Y[i]);
    }

    set<int> lis;
    int cnt = 0;
    for(int i = 1; i < N + 1; ++i){
        if(!used[i]){
            cnt++;
        }
    }

    for(int i = 1; i <= N; ++i){
        lis.insert(find(i));
    }

    
    cout << max((int)lis.size(), 0)  << endl;

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_d() {
    ll n, k;
	cin >> n >> k;

	string s;
	cin >> s;
	
	V lr;
	ll cnt = 0;
	ll first = 0;
	char now = s[0];
	rep(i, n) {
		if (now == s[i]) {
			cnt++;
		}
		else {
			lr.push_back(cnt);
			first += cnt - 1;
			cnt = 1;
			now = s[i];
		}
	}
	lr.push_back(cnt);
	first += cnt - 1;

	ll ans = min(first + 2 * k, n - 1);

	cout << ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vii vector<vi>

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi h(n); rep(i, n) cin >> h[i];
  vi dp(n);
  int ans = h[0];
  for (int i = 1; i < n; i++) {
    if(h[i] - h[i-1] > 0) ans += h[i] - h[i-1];
  }

  std::cout << ans << '\n';
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 106 A / Link: http://abc106.contest.atcoder.jp/tasks/abc106_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL A, B; cin >> A >> B;
	ans = (A - 1)*(B - 1);
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
while True:
    try:
        a,b,c,d,e,f = map(int,input().split(' '))
        z = a*e-b*d
        if z==0:
            break
        x = c*e-b*f
        y = a*f-c*d
        x /= z
        if -0.0004 < x < 0.0004:
            x = abs(x)
        y /= z
        if -0.0004 < y < 0.0004:
            y = abs(y)
        print('{:.3f} {:.3f}'.format(x,y))
    except:
        break

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

int n,a[16][16];
long long dp[1<<16];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;++i)
    for(int j=0;j<n;++j)
      scanf("%d",a[i]+j);
  for(int bm=1;bm<(1<<n);++bm){
    for(int i=0;i<n;++i)
      for(int j=i;j<n;++j)
        if((bm>>i&1)&&(bm>>j&1))
          dp[bm]+=a[i][j];
    for(int sub=bm;sub;sub=(sub-1)&bm)
      dp[bm]=max(dp[bm],dp[sub]+dp[bm-sub]);
  }
  printf("%lld\n",dp[(1<<n)-1]);
}


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

int main(){

    long long int N = 0;
    cin >> N;

    long long int sum = 0;
    rep (i, N){
        if ((i + 1) % 3 == 0 || (i + 1) % 5 == 0) continue;
        sum += i + 1;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3636
#if 0
date +%Y.%m.%d
 
题解先咕着。
#endif
#include <cstdio>
#include <set>
#include <queue>
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
inline int input() { int x; scanf("%d", &x); return x; }
 
const int maxn = 100005;
int fa[maxn];
std::multiset<int> A[maxn], B[maxn];
 
int find(int x) {
	if(fa[x] == x) return x;
	return fa[x] = find(fa[x]);
}
 
int main() {
	int n = input();
	for(int i = 1; i <= n; i ++)
		fa[i] = i;
	for(int i = 1; i < n; i ++) {
		int x = input(), y = input();
		A[x].insert(y);
		A[y].insert(x);
	}
	std::queue<int> q1, q2;
	for(int i = 1; i < n; i ++) {
		int x = input(), y = input();
		if(A[x].count(y)) {
			q1.push(x);
			q2.push(y);
		}
		B[y].insert(x);
		B[x].insert(y);
	}
	int tot = 0;
	while(not q1.empty()) {
		tot ++;
		int x = find(q1.front()), y = find(q2.front());
#if 0
		debug("%d %d\n", x, y);
		for(int z : A[x])
			debug("%d in A[%d]\n", z, x);
		for(int z : A[y])
			debug("%d in A[%d]\n", z, y);
		for(int z : B[x])
			debug("%d in B[%d]\n", z, x);
		for(int z : B[y])
			debug("%d in B[%d]\n", z, y);
#endif
		q1.pop();
		q2.pop();
		A[x].erase(y);
		A[y].erase(x);
		B[x].erase(y);
		B[y].erase(x);
		bool rev = A[x].size() + B[x].size() > A[y].size() + B[y].size();
		if(rev)
			std::swap(x, y);
		fa[x] = y;
#if 0
		debug("%d %d\n", x, y);
		for(int z : A[x])
			debug("%d in A[%d]\n", z, x);
		for(int z : A[y])
			debug("%d in A[%d]\n", z, y);
		for(int z : B[x])
			debug("%d in B[%d]\n", z, x);
		for(int z : B[y])
			debug("%d in B[%d]\n", z, y);
#endif
		for(int z : A[x])
			if(B[y].count(z)) {
				q1.push(y);
				q2.push(z);
			}
		for(int z : B[x])
			if(A[y].count(z)) {
				q1.push(y);
				q2.push(z);
			}
		for(int z : A[x]) {
			A[y].insert(z);
			while(A[z].count(rev ? x : x)) {
				A[z].erase(A[z].find(x));
				A[z].insert(y);
			}
		}
		for(int z : B[x]) {
			B[y].insert(z);
			while(B[z].count(rev ? x : x)) {
				B[z].erase(B[z].find(x));
				B[z].insert(y);
			}
		}
	}
	if(tot == n - 1)
		puts("YES");
	else
		puts("NO");
}

Measured memory_bytes: 30976
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	a,b = readline() |> split |> parseMap
	if a*b<0
		println("Zero")
	elseif b<0
		println((b-a+1)%2==0?"Positive":"Negative")
	else
		println("Positive")
	end
end
main()


Measured memory_bytes: 110716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n,a, ans = 0;
  cin >> n;
  rep(i,n)
  {
    cin >> a;
    ans += a - 1;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int dp[N];
bool check(string& str, int cur, string& s)
{
	if (cur + s.length() > str.length()) return false;
	for (int i = 0; i < s.length(); i++)
	{
		if (str[i + cur] != s[i]) return false;
	}
	return true;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<string> vs = { "dreamer","eraser", "dream","erase" };
	string str;
	cin >> str;
	dp[0] = 1;
	for (int i = 0; i < str.length(); i++)
	{
		if (dp[i] == 0) continue;
		int o = -1;
		for (int j = 0; j < vs.size(); j++)
		{
			if (check(str, i, vs[j]))
			{
				dp[i + vs[j].length()] = 1;
			}
		}
	}
	if (dp[str.length()]) puts("YES");
	else puts("NO");
	return 0;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a,b;
	char op;
	cin >> a >> op >> b;
	if(op == '+'){
		P(a+b);
	}else{
		P(a-b);
	}
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main() {
	int a = 0, b = 0;
	cin >> a >> b;
	if(b % a == 0) {
		cout <<  a + b << endl;
	}
	else {
		cout << b - a << endl;
	}
	

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;

int A[MAX_N], B[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<P> line;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        line.push_back(P(A[i], 0));
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
        line.push_back(P(B[i], 1));
    }
    sort(line.begin(), line.end());
    int a_cnt = 0, b_cnt = 0;
    ll ans = 1;
    for (int i = 0; i < line.size(); i++) {
        if (line[i].second == 0) {
            if (b_cnt > 0) {
                ans = (ans * b_cnt) % MOD;
                b_cnt--;
            }
            else a_cnt++;
        }
        else {
            if (a_cnt > 0) {
                ans = (ans * a_cnt) % MOD;
                a_cnt--;
            }
            else b_cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2932
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int[] alfa = new int[26];
		for (int i=0; i<S.length(); i++) {
			char c = S.charAt(i);
			alfa[(int)(c-'a')] = 1;
		}
		for (int i=0; i<26; i++) {
			if (alfa[i] == 0) {
				System.out.println((char)(i+'a'));
				return;
			}
		}
		System.out.println("None");
	}
}


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

using namespace std;

typedef long long int ll;

int n;
vector<map<int,int>> tree;

void add(int pos, int val){
	for(;pos < n ; pos = pos | (pos+1)){
		tree[pos][val]++;
	}
}

ll query(int pos,int val){
	ll res = 0;
	for(; pos >= 0; pos = (pos & (pos + 1)) - 1){
		res += (ll)tree[pos][val];
	}
	return res;
}


int main(){
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll sum = 0;
	map<int,ll> s;
	for(int i = 0; i < n; i++){
		sum += s[i-a[i]];
		s[i+a[i]]++;
	}
	cout << sum << "\n";
	return 0;
}


Measured memory_bytes: 26548
import math
N,D=map(int,input().split())
S = [list(map(int, input().split())) for _ in range(N)]
#print(S)
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        SUM=0
        for k in range(D):
            SUM+=(S[i][k]-S[j][k])**2
        #print(SUM)
        if math.sqrt(SUM)%1==0:
            ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int gcd(int a, int b) {
    while (b) {
        int c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    int k;
    ll z = 0;
    cin >> k;
    for (int i = 1; i <= k; i++) for (int j = 1; j <= k; j++) for (int l = 1; l <= k; l++) z += gcd(i, gcd(j, l));
    cout << z;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    int a,b,ans;
    ans = 0;
    cin >> a>>b;
    for (int i=0; i < 2; i++){
        if (a > b){
            ans += a;
            a -= 1;
        }
        else {
            ans += b;
            b -= 1;
        }
    }
    
    
    cout << ans << endl;
    
    
    
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<ctime>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;

int  N, A[200000];

int main() {
	S(N);
	R(i, N) scanf("%d", A + i);
	int ans = 0;
	int tr = 1;
	R(i, N) {
		if (A[i] == tr) tr++;
		else ans++;
	}
	if (tr != 1) P(ans);
	else P(-1);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int a[3300];
long dp[3300][3300];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++){
        for(int l = 0; l + i <= n; l++){
            int r = l + i;
            if(i % 2 == n % 2) dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r-1]);
            else dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r-1]);
        }
    }
    cout << dp[0][n] << endl;
}

Measured memory_bytes: 78080
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

ll k,ans[200000],digits = 1,index_ans = 0;

void dfs(ll n,ll i,ll digits,ll num){
    if(n == digits){
        ans[index_ans++] = num;
        return;
    }

    if(i-1 >= 0)dfs(n+1,i-1,digits,10*num + i-1);
    dfs(n+1,i,digits,10*num+i);
    if(i+1 <= 9)dfs(n+1,i+1,digits,10*num+i+1);

    return;
}

signed main(){
    cin >> k;

    while(index_ans <= k){
        rep(i,1,10){
            dfs(1,i,digits,i);
        }
        digits++;
    }

    cout << ans[k-1] << endl;

    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	vector<int> v(10);
	int v1, v2;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6],&v[7],&v[8],&v[9],&v1,&v2) != EOF){
		double sum = 0;
		rep(i, 10) sum += v[i];
		double n = sum*v1/(v1+v2);
		sum = 0;
		rep(i, 10) if(sum+v[i] >= n){cout << i+1 << endl; break;} else sum += v[i];
	}
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e15;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 1e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

int h[MAXN];
ll dp[MAXN];
void solve() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    dp[1] = 0;
    for(int i=1;i<=n;++i){
        cin >> h[i];
    }
    dp[0] = inf_ll;
    for(int i=2;i<=n;++i){
        dp[i] = inf_ll;
        for(int j = 1; j<=k;++j){
            if(i - j >= 1){
                dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
            }
        }
    }
    cout << dp[n]<<"\n";

}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;

    while (t--)
        solve();
    dout <<endl<< (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(s[n-1]=='s'){
    cout<<s+"es"<<endl;
  }else{
    cout<<s+"s"<<endl;
  }
  return 0;
}

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

int main(){
  long n,T;
  cin >> n >> T;
  long t[n];
  for(long i = 0;i < n;i++){
    cin >> t[i];
  }
  long yotei = T,kekka = T;
  for(int i = 1;i < n;i++){
    if(t[i] <= yotei){
      kekka += t[i] + T - yotei;
      yotei = t[i] + T;
    }
    else{
      kekka += T;
      yotei = t[i] + T;
    }
  }
  cout << kekka << endl;
}      

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int N, A[1 << 18], cnt;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 1 && i % 2 == 1) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3588
/*#pragma GCC optimize("O3")*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
//#define ordered_set tree<int, null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000001
#define PI 3.14159265358979323846
using namespace std;
string convert(string s)
{
	string ans="";
	int nb=0;
	bool seen=0;
	for(int i = 0; i < s.length(); i++)
	{
		if(seen)
		{
			nb++;
			
		}
		if(s[i]=='.')
			seen=true;
		else
			ans+=s[i];
	}
	while(nb < 9)
	{
		ans+='0';
		nb++;
	}
	return ans;
}
long long s_to_int(string s)
{
	long long x=0, p=1;
	for(int i = s.length()-1; i >= 0; i--)
	{
		x+=(s[i]-'0')*p;
		p*=10;
	}
	return x;
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	int tree[2*64+1][2*64+1];
	for(int i = 0; i < 2*64+1; i++)
		for(int j = 0; j < 2*64+1; j++)
			tree[i][j]=0;
	long long a[n];
	string s;
	long long mo=1000000000;
	for(int i = 0; i < n; i++)
	{
		cin >> s;
		a[i]=s_to_int(convert(s));
		//cout << a[i] << '\n';
	}
	long long ans=0;
	for(int i = n-1; i >= 0; i--)
	{
		int x=0, y=0, nb=0;
		while(a[i]%2==0)
		{
			x++;
			a[i]/=2;
		}
		while(a[i]%5==0)
		{
			y++;
			a[i]/=5;
		}
		//cout << x << ' ' << y << '\n';
		int x1=18-x+64, x2=63+64;
		while(x1 <= x2)
		{
			if(x1%2==1)
			{
				int y1=18-y+64, y2=63+64;
				while(y1 <= y2)
				{
					if(y1%2==1)
					{
						nb+=tree[x1][y1];
						y1++;
					}
					if(y2%2==0)
					{
						nb+=tree[x1][y2];
						y2--;
					}
					y1/=2;
					y2/=2;
				}
				x1++;
			}
			if(x2%2==0)
			{
				int y1=18-y+64, y2=63+64;
				while(y1 <= y2)
				{
					if(y1%2==1)
					{
						nb+=tree[x2][y1];
						y1++;
					}
					if(y2%2==0)
					{
						nb+=tree[x2][y2];
						y2--;
					}
					y1/=2;
					y2/=2;
				}
				x2--;
			}
			x1/=2;
			x2/=2;
		}
		ans+=nb;
		//cout << nb << '\n';
		x+=64;
		y+=64;
		while(x >= 1)
		{
			int yy = y;
			while(yy >= 1)
			{
				tree[x][yy]++;
				yy/=2;
			}
			x/=2;
		}
	}
	cout << ans << '\n';
}
//size

Measured memory_bytes: 5276
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
#define ll long long
using namespace std;
typedef pair<int,int>P;
signed main() {
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    r0
}


Measured memory_bytes: 256
/*
 * ID: adityaa
 * LANG: C++
 */
#include <bits/stdc++.h>
using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define fi first
#define se second
#define pb push_back
#define pii pair<int , int>
#define asdfg y1
#define int long long
#define double long double
#define endl '\n'
#define PI 3.14159265359

/*-----------------------------------------------------------------------*/

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

/*-----------------------------------------------------------------------*/

// check base cases n = 0 , n = 1
// max / min questions - check for binary search
const int maxn = (int) 3030;
const double EPS = 1e-9;
const int INF = (int)1e18 + 18;
const int mod = (int) 1e9 + 7;
int n;
double dp[maxn][maxn] , p[maxn];

signed main() {
    
    fio;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }
    
    dp[1][0] = 1.0L - p[1]; dp[1][1] = p[1];
    for(int i = 2; i <= n; i++){
        for(int j = 0; j < i; j++){
            dp[i][j] += (1.0L - p[i]) * dp[i - 1][j];
            dp[i][j + 1] += p[i] * dp[i - 1][j];
        }
    }
    
    double ans = 0;
    for(int i = n / 2 + 1; i <= n; i++){
        ans += dp[n][i];
    }
    
    cout.precision(17);
    cout << fixed << ans << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 141824
N, M = tuple(map(int, input().split()))

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if M < 2 and N < 2:
    print(0)
elif M < 2:
    print(comb(N,2))
elif N < 2:
    print(comb(M,2))
else:
    print(comb(N,2) + comb(M, 2))

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;

int keta(int n)
{
	int k = 1;
	while (n >= 10)
	{
		n /= 10;
		k++;
	}
	return k;
}


signed main()
{
	cin >> N;

	int ans = 0;
	int Nk = keta(N);
	int Na = (int)pow(10, Nk - 1);
	for (int i = 1; i <= N; i++)
	//int i = 2015;
	{
		int k = keta(i);
		int a = (int)pow(10, k - 1);
		int n = i / a;
		int m = i % 10;

		if (m == 0) continue;

		if (n == m) //1
		{
			if (n <= N)
			{
				ans++;
			}
		}

		if (m * 10 + n < N) //2
		{
			ans++;
		}

		if (Nk >= 3)
		{
			for (int j = 2; j < Nk - 1; j++)
			{
				int p = pow(10, j - 1);
				ans += p;
			}

			int e = m * Na + n;
			if (e <= N)
			{
				if (N / Na > m)
				{
					ans += (Na / 10);
				}
				else
				{
					int d = N;
					d %= Na;
					d /= 10;
					if (N % 10 < n)
					{
						d--;
					}
					if (d >= 0)
					{
						ans += d;
						ans++; //0
					}
				}
			}
		}
	}

	cout << ans;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {

           // Console.SetIn(new StreamReader("input.txt"));

            var ints = In.Ints().ToArray();
            var N = ints[0];
            var L = ints[1];

            List<S> list = new List<S>();
            for(int i  = 0; i < N; i++)
            {
                char[] c = In.Line().ToCharArray();

                list.Add(new S(c));
            }

            list.Sort();
            foreach(S s in list)
            {
                Console.Write(s.Tostring());

            }
            return;
        }
    }

    public class S : System.IComparable
    {
        public char[] data;
        public S(char[] data)
        {
            this.data = data;
        }

        public String Tostring()
        {
            return new String(this.data);
        }
        public int CompareTo(object obj)
        {
            S other = (S)obj;
            if (this.GetType() != obj.GetType())
            {
                throw new ArgumentException("別の型とは比較できません。", "obj");
            }

            for(int i = 0; i < this.data.Length; i++)
            {
                if( this.data[i] == other.data[i])
                {
                    continue;
                }
                if(this.data[i] > other.data[i])
                {
                    return 1;
                }else
                {
                    return -1;
                }
                
            }
            return 0;

        }

    }



    class In
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static IEnumerable<int> Ints()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i));
        }

        public static String Line()
        {
            return Console.ReadLine();
        }
    }
}


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

using VI = vector<long>;

int main() {
  while (1) {
    long n;
    cin >> n;
    if (!n) {
      return 0;
    }
    VI v;
    for (int i = 0; i < n; i++) {
      long a;
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(), v.end());
    long diff = 1e9;
    for (int i = 1; i < n; i++) {
      diff = min(diff, v[i] - v[i - 1]);
    }
    cout << diff << endl;
  }
}



Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

const int inf = 1000000009;

int main() {
    vector<int> memo(1000000, inf);     memo[0] = 0;
    vector<int> odd_memo(1000000, inf); odd_memo[0] = 0;

    for (int i=0; i<1000000; i++) {
        memo[i]     = i;
        odd_memo[i] = i;
    }

    for (int l=2; l<200; l++) {
        const int n = (l*(l+1)*(l+2))/6;
        for (int i=0; i<1000000; i++) {
            if (i-n >= 0) {
                memo[i] = min(memo[i-n]+1, memo[i]);
                if (n%2==1) {
                    odd_memo[i] = min(odd_memo[i-n]+1, odd_memo[i]);
                }
            }
        }
    }

    int n; 
    while (cin >> n, n!=0) {
        cout << memo[n] << " " << odd_memo[n] << endl;
    }
}



Measured memory_bytes: 10476
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


int main(){
	  
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		
		int in[5555];
		rep(i,n)cin>>in[i];
		
		
		int ans = -1000000000;
		reps(i,1,n+1){
			
			int sum = 0;
			rep(j,i)sum += in[j];
			
			ans = max(ans,sum);
			reps(j,i,n){
				sum-=in[j-i];
				sum+=in[j];
				ans = max(ans,sum);
			}
		}
		printf("%d\n",ans);
	}
	
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

    int ans = 0, cnt = 0;
    for(char c : S){
        if( c == 'A' || c == 'C' || c == 'G' || c == 'T' ){
            cnt++;
        } else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back

using namespace std;
typedef pair<int, int> pii;

#define MAX 1000000

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

    int num = 0;

    for (int i = 1; i <= MAX; i++) {
        for (int j = 1; j <= MAX; j++) {
            if (i * j >= n) break;
            num++;
        }
    }
    cout << num;
}


Measured memory_bytes: 3648
g = [[1,3,5,7,8,10,12], [4,6,9,11], [2]]

s = input().split(' ')
x = int(s[0])
y = int(s[1])
lx = list(map(lambda a: x in a, g))
ly = list(map(lambda b: y in b, g))
if lx==ly:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <stdio.h>
using namespace std;

int main(){
    int m,f,h,r=0;
    char g;
    for(int i=0;i<50;i++){
        scanf("%d %d %d",&m,&f,&h);
        r=m+f;
        if(r==-2&& h==-1)break;
        if(m==-1||f==-1||r<30)g='F';
        else if(r<50)g=h>=50?'C':'D';
        else if(r<65)g='C';
        else if(r<80)g='B';
        else g='A';
        printf("%c\n",g);
    }    
}


Measured memory_bytes: 2668
n,k = map(int,input().split())
mod = 10**9+7
a = list(map(int,input().split()))
c = [0]*n
b = []
import bisect
for i in range(n-1,-1,-1):
    c[i] = bisect.bisect_left(b,a[i])
    bisect.insort_left(b,a[i])
    
ans = 0
for i in c:
    ans += i*k

for i in range(n):
    c[i] = bisect.bisect_left(b,a[i])
    
sk = k*(k-1)//2
for i in c:
    ans += i*sk

print(ans%mod)

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b){
	return b != 0 ? gcd(b, a%b) : a;
}

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

#define N_MAX 200000
#define MOD 1000000007

int N, tail;
int C[N_MAX], Cx[N_MAX];
vector<int> table[N_MAX];
int nextindex[N_MAX];

lli memo[N_MAX];
lli func(int index)
{
	if (-1 == index){
		return 0;
	}
	if (tail - 1 == index){
		return 1;
	}

	if (-1 != memo[index]){
		return memo[index];
	}

	lli ret = 1;
	ret = (ret + func(index + 1) - 1) % MOD;
	ret = (ret + func(nextindex[index])) % MOD;

	return memo[index] = ret;
}

void solv()
{
	scanf("%d", &N);
	int cmax = 0;
	for (int i = 0; i < N; i++){
		scanf("%d", C + i);
		cmax = max(cmax, C[i]);
	}

	tail = 0;
	Cx[tail] = C[0]; tail++;
	for (int i = 1; i < N; i++){
		if (C[i - 1] == C[i]){
			continue;
		}
		Cx[tail] = C[i];
		tail++;
	}

	table[Cx[0] - 1].push_back(0);
	for (int i = 1; i < tail; i++){
		table[Cx[i] - 1].push_back(i);
	}

	fill(nextindex, nextindex + N, -1);
	for (int i = 0; i < cmax; i++){
		for (int j = 1; j < table[i].size(); j++){
			nextindex[table[i][j - 1]] = table[i][j];
		}
	}

	fill(memo, memo + N, -1);
	printf("%lld", func(0));

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 21376