akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int main()
{
	string S; cin >> S;
	if (S == "SUN") {
		cout << 7 << endl;
	}
	if (S == "MON") {
		cout << 6 << endl;
	}
	if (S == "TUE") {
		cout << 5 << endl;
	}
	if (S == "WED") {
		cout << 4 << endl;
	}
	if (S == "THU") {
		cout << 3 << endl;
	}if (S == "FRI") {
		cout << 2 << endl;
	}
	if (S == "SAT") {
		cout << 1 << endl;
	}

}

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

using namespace std;

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3092
n = int(input())
nums = []
for i in range(n):
    nums.append(int(input()))

max_profit = nums[1] - nums[0]
min_price = nums[0]

for time in range(1, n):
    profit = nums[time] - min_price
    if profit > max_profit:
        max_profit = profit
    if nums[time] < min_price:
        min_price = nums[time]

print(max_profit)


Measured memory_bytes: 13592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a,b;
ll f(ll x){
	if(x%4==3||x==0)return 0;
	ll ans=0;
	rep(i,x/4*4,x+1)ans^=i;
	return ans;
}

int main(){
	scanf("%lld%lld",&a,&b);
	printf("%lld",f(b)^f(a-1));
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        x: usize
    };

    let res = if x == 0 { 1 } else { 0 };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2236
#include<bits/stdc++.h>
#include<string>
using namespace std;
//#define for(i,n) for(int i=0;i<n;i++)
#define test(t) int t;cin>>t;while(t--)
#define lli long long int
#define pb push_back
#define MAX 20001
#define mod 1000000007
bool vis[MAX];
vector<int>dist(MAX);
void init()
{
    for(int i=1;i<=MAX;i++)
    {
        dist[i]=0;
        vis[i]=false;
    }
}
int main()
{
  lli n,x,y;
   cin>>n>>x>>y;
   vector<int> adj[n+1];
   adj[x].pb(y);
   adj[y].pb(x);
  for(int i=1;i<n;i++)
     {
      adj[i].pb(i+1);
      adj[i+1].pb(i);
     }int s;
   map<lli,lli> m;
   for(int i=1;i<=n;i++)
   {  init();
        s=i;
       int k;
    queue <int> q;
    q.push(s);
    vis[s]=true;
    while(!q.empty())
    {  s=q.front();
        q.pop();
        for(int j=0;j<adj[s].size();j++)
        {   k=adj[s][j];
             if(!vis[k])
                {
                  q.push(k);
                  vis[k]=true;
                  dist[k]=dist[s]+1;
                }
        }

    }
     for(int j=1;j<=n;j++)
        m[dist[j]]++;
   }
   for(int i=1;i<n;i++)
     cout<<m[i]/2<<endl;
}







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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ispoor = 0;
    if (a == b && b != c) ispoor = 1;
    if (b == c && c != a) ispoor = 1;
    if (c == a && a != b) ispoor = 1;

    if (ispoor) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: a,b,c
    
    read*, a,b,c

    if (b-a == c-b) then
        print'(a)', 'YES'
    else
        print'(a)', 'NO'
    end if
    
end program main

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i[3],j,s=0;
    for(j=0;j<3;j++)
    {
        scanf("%d",&i[j]);
        s=s+i[j];
    }
    if (s<=21)
        printf("win\n");
    else printf("bust\n");
    return 0;
}


Measured memory_bytes: 256
import sys
import math

# Sieve of Eratosthenes
N = 50021
searchList = list(range(3, N + 1, 2))
primes = [2]
while True:
  top = searchList.pop(0)
  primes.append(top)
  if top > math.sqrt(N):
    break
  searchList = [s for s in searchList if s % top != 0]
primes.extend(searchList)

# solve
for line in sys.stdin:
  try:
    n = int(line)
    pre = 2
    for p in primes:
      if p < n:
        pre = p
      if p > n:
        print(pre, p)
        break
  except:
    break

Measured memory_bytes: 6660
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll NODE_SIZE = 1010;

ll N;  //グラフのノードの数
ll M;  //グラフの辺の数
vector< pair<ll, pair<ll, ll>> > edge;   //辺情報　<コスト, <formノード, toノード>>
ll d[NODE_SIZE];   //始点ノードからノードiへの最短距離(score)
ll start;  //開始ノード番号

bool negCloCir; //負の閉路があるかどうかのフラグ
bool negNode[NODE_SIZE];
/*==================================================*/

//ベルマン・フォード法
bool bellman_ford() {
    bool update;
    REP(i,0,N){
        update = false;
        for(auto e:edge){
            ll from = e.second.first;
            ll to = e.second.second;
            if(d[from] != INF && d[to] > d[from] + e.first){
                d[to] = d[from] + e.first;
                update = true;

            }
        }
        if(!update) break;
    }
    return update; //true: 負の閉路が存在
}

void check_negative() {
    REP(i,0,N+1){
        for(auto e:edge){
            ll from = e.second.first;
            ll to = e.second.second;
            if(d[from] != INF && d[to] > d[from] + e.first){
                d[to] = d[from] + e.first;
                negNode[from] = negNode[to] = true;
            }
        }
    }
}


/*==================================================*/
int main(){
    while(cin>>N>>M) {
        //ここでグラフの生成
        edge.clear();
        REP(i, 0, N) d[i] = INF;
        REP(i, 0, M) {
            ll a, b, c;
            cin >> a >> b >> c;
            a--;
            b--;
            edge.push_back({-c, {a, b}});
        }
        start = 0;
        d[start] = 0;
        negCloCir = bellman_ford();

        if (negCloCir) {
            //負の閉路がある場合の処理
            //例: 負の閉路によって更新されてしまうノードチェック(ABC061 D)
            REP(i,0,N) negNode[i]=false;
            check_negative();
            if(negNode[N-1]){
                p("inf");
            }else{
                p(-d[N - 1]);
            }
        } else {
            p(-d[N - 1]);
        }
        return 0;
    }
    return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main(void){
   int n;
   scanf("%d",&n);
   int x[n], y[n];
   long double ans = 0.0;
   int m=1, h=1;
   for(int i=0;i<n;i++){
     scanf("%d %d",&x[i],&y[i]);
     m *= i+1;
   } 
   h = m/n;
   
   for(int i=0;i<n;i++){
       for(int k=0;k<n;k++){
           if(i == k) continue;
           else {
               ans += sqrt( (x[i]-x[k])*(x[i]-x[k]) + (y[i]-y[k])*(y[i]-y[k]) ) * h;
           }
       }
   }
   
   printf("%.10Lf\n", ans/m);
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;

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

    long long row, col, result=n;
    for(long long i=1; i*i<=n; i++){
        if(n%i==0){
            row = i;
            col = n/i;
            result = min(result, row+col-2);
        }
    }

    cout << result  << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
b=sum(A)//N
a=b+1
c=b+1

x=0
y=0
z=0
for i in A:
  x+=(a-i)**2
  y+=(b-i)**2
  z+=(c-i)**2
print(min(x,y,z))

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll p;
string s;
void solve() {
    cin >> n >> p >> s;

    ll ans = 0;
    if (p == 2 || p == 5) {
        rep(i, n) {
            ll val = s[i] - '0';
            if (val % p == 0) {
                ans += i + 1;
            }
        }
    }
    else {
        map<ll, ll> mp;
        ll val = 0;
        ll tmp = 1;
        repd(i, n) {
            val = (val + (s[i] - '0') * tmp) % p;
            tmp = (tmp * 10) % p;
            ++mp[val];
        }

        ans += mp[0];
        for (auto& pp : mp) {
            ans += pp.second * (pp.second - 1) / 2;
        }

    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 1044
//Name: Nature of Prime Numbers
//Level: 1
//Category: やるだけ
//Note: 問題文が読みにくい

/**
 * 問題文がかなり分かりにくいが、要するに
 * ・a_i = i^2 mod n (1 ≦ i < n)
 * ・S = unique set of a_i
 * ・d_j = (a - b) mod n (a, b ∈ S, a≠b)
 * ・e_j = max(0, min(d_j, n-d_j))
 * としたとき、e_jのヒストグラムを作れば良い。
 * 問題文の残りの部分は、nが素数かつn≡3 (mod 4) のときに、e_jのヒストグラムが
 * 平らになることを主張している。
 */
#include <iostream>
#include <vector>
#include <set>

using namespace std;

bool solve(bool first) {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    set<int> s;
    for(int i = 0; i < N-1; ++i) {
        s.insert((i+1)*(i+1) % N);
    }
    vector<int> hist((N-1)/2, 0);
    for(auto it1 = begin(s); it1 != end(s); ++it1) {
        for(auto it2 = begin(s); it2 != it1; ++it2) {
            int e = (*it1 - *it2 + N) % N;
            if(e > (N-1)/2) e = N - e;
            hist[e-1]++;
        }
    }
    for(int i : hist) {
        cout << i*2 << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(2);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1456
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
/*bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}*/

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ***************************CODE**********************//



int main(){


        ll N,k;
        cin >> N >> k;

        ll sum = 0;
        for(ll j = 1; j <= N; j++){
                if(j <= k) continue;
                sum += (N/j) * (j-k);
                if(N % j - (k-1) > 0){
                        sum += N % j - (k-1);
                }

        }

        if(k == 0){
                sum = N * N;
        }

        cout << sum << endl;
        return 0;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(a); sll(b);
	if(b%a == 0)	pll(a+b);
	else	pll(b-a);
}


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

int main(){
  int n,i,j,ne,age[10];
 

  while(1){
 for(i=0;i<10;i++){
    age[i]=0;
  }
    cin >> n;
    if(n == 0)break;

    for(i=0;i<n;i++){
      cin>>ne;
      if(ne<10)age[0]+=1;
      else if(ne>=10 && ne<20)age[1]+=1;
      else if(ne>=20 && ne<30)age[2]+=1;
      else if(ne>=30 && ne<40)age[3]+=1;
      else if(ne>=40 && ne<50)age[4]+=1;
      else if(ne>=50 && ne<60)age[5]+=1;
      else if(ne>=60)age[6]+=1;
    }
    for(i=0;i<7;i++){
      cout << age[i] << endl;
    }



  }






}

Measured memory_bytes: 0
def solve():
    q = int(input())
    l, r = [], []
    for _ in range(q):
        tmp_l, tmp_r = list(map(int, input().split(" ")))
        l.append(tmp_l)
        r.append(tmp_r)

    p = [True for i in range(100000)]
    p[0] = p[1] = False
    for i in range(2, 100000):
        if p[i]:
            for j in range(2 * i, 100000, i):
                p[j] = False

    s = [0 for i in range(100000)]
    for i in range(1, 100000, 2):
        if p[i] and p[(i + 1) // 2]:
            s[i] = 1

    for i in range(100000 - 1):
        s[i + 1] += s[i]

    for i in range(q):
        print(s[r[i]] - s[l[i] - 1])


solve()

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

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

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

    if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]){
        cout << "Yes" <<endl;
    }

    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int t = sc.nextInt();
		
		int[] cc = new int[n];
		int[] tt = new int[n]; 
		
		for(int i=0;i<n;i++){
			cc[i] = sc.nextInt();
			tt[i] = sc.nextInt();
		}
		
		int min = Integer.MAX_VALUE;
		for(int i=0;i<n;i++){
			if(tt[i]<=t && cc[i]<min)
				min=cc[i];
		}
		
		System.out.println(min==Integer.MAX_VALUE ? "TLE" : min);
	}
}
/*
3 70
7 60
1 80
4 50
*/

Measured memory_bytes: 23508
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = 10**7

for i in range(2**d):
    tmp = []
    a, n = 0, 0
    for j in range(d):
        if i >> j & 1:
            tmp.append(j)
    for j in tmp:
        a += (j+1) * 100 * pc[j][0] + pc[j][1]
        n += pc[j][0]
    if a >= g:
        ans = min(ans, n)
    else:
        for j in range(d):
            if not j in tmp:
                alpha = 0
                for k in range(1, pc[j][0]+1):
                    alpha += (j+1) * 100
                    if a + alpha >= g:
                        if n + k < ans:
                            a += alpha
                            n += k
                            ans = n
                            break

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;

const int N = 5e5+1;
const int inf = 0x7fffffff;
ll p[N],len,n,tong[257];
char s[N];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	ll ans=(n-1)*n/2;
	for(int i=1;i<=n;++i)tong[s[i]]++;
	for(int i='a';i<='z';++i)
	{
		ans-=tong[i]*(tong[i]-1)/2;
	}
	cout<<ans+1;
}

Measured memory_bytes: 384
def main():
    # 文字列の入力
    sr = input()

    rc_cnt = 0
    rc_ans = 0

    for s in sr:
        if (s == 'S'):
            rc_cnt = 0
        elif (s == 'R'):
            rc_cnt = rc_cnt + 1
            if (rc_cnt > rc_ans):
                rc_ans = rc_cnt
    
    print(rc_ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(int argc, const char *argv[])
{
    string s;
    cin >> s;

    map<char, int> m;

    for (auto c : s)
    {
        if (m.count(c) <= 0)
            m[c] = 1;
        else
            m[c]++;
    }

    if (m.size() != 2)
    {
        cout << "No" << endl;
        return 0;
    }

    for (auto const x : m)
    {
        if (x.second >= 2)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

int main() {
    int n;
    string s;

    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {

        set<char> l, r;

        for (int k = 0; k < s.size(); k++) {
            if (k < i) {
                l.insert(s[k]);
            } else {
                r.insert(s[k]);
            }
        }

        int now = 0;
        for (char c : l) {
            if (r.find(c) != r.end()) {
                now++;
            }
        }

        cmax(ans, now);

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <functional>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int c[9];

int main()
{
    for (int i = 0; i < 9; i++)
    {
        cin >> c[i];
    }
    if (c[0] - c[1] == c[3] - c[4] && c[0] - c[1] == c[6] - c[7])
    {
        if (c[0] - c[2] == c[3] - c[5] && c[0] - c[2] == c[6] - c[8])
        {
            if (c[2] - c[1] == c[5] - c[4] && c[2] - c[1] == c[8] - c[7])
            {
                if (c[0] - c[3] == c[1] - c[4] && c[0] - c[3] == c[2] - c[5])
                {
                    if (c[0] - c[6] == c[1] - c[7] && c[0] - c[6] == c[2] - c[8])
                    {
                        if (c[6] - c[3] == c[7] - c[4] && c[6] - c[3] == c[8] - c[5])
                        {
                            cout << "Yes" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

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

void solve()
{
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<s.length();i++)
  {
    sum+=s[i]-'0';
  }
  if(sum%9==0)
    cout<<"Yes";
  else
    cout<<"No";
  return;
  
  
}
int main()

{
   solve();
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  ll a,b;
  cin>>n>>a>>b;
  vector<ll> x(n);
  rep(i,n)cin>>x[i];
  ll ans=0;
  rep(i,n-1) {
    ans+=min((x[i+1]-x[i])*a,b);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);
    int N;
    while(cin>>N){
        vector<int> vt;
        while(N--){
            int W;
            cin>>W;
            vt.push_back(W);
        }
        int M = INT_MAX;
        for(int i=0; i<vt.size();i++){
            int S1=0;
            int S2=0;
            for(int x=0; x<=i; x++)
                S1 += vt[x];
            for(int y=i+1; y<vt.size();y++)
                S2 += vt[y];
            if(M>abs(S1-S2))
                M = abs(S1-S2);
        }
        cout<<M<<endl;
    }
	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto H = RD;
	auto W = RD;
	auto a = new string[](H);
	foreach (i; 0..H)
		a[i] = RD!string;
	
	auto ws = new bool[](W);
	auto hs = new bool[](H);
	foreach (y; 0..H)
	{
		foreach (x; 0..W)
		{
			if (a[y][x] == '#')
			{
				ws[x] = 1;
				hs[y] = 1;
			}
		}
	}

	foreach (y; 0..H)
	{
		bool writed;
		foreach (x; 0..W)
		{
			if (ws[x] == 1 && hs[y] == 1)
			{
				write(a[y][x]);
				writed = true;
			}
		}
		if (writed) writeln();
	}
	
	stdout.flush();
	debug readln();
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

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

  ll ans = 0;
  ll p = x[0];
  for (ll i = 1; i < n; ++i) {
    ll mul = x[i] - p;
    p = x[i];

    ll d = a*mul;
    if (d > b) d = b;
    ans += d;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    a42(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a42(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val numList = args[0].split(" ").map { it.toInt() }.sorted()
    println(if (numList[0] == 5 && numList[1] == 5 && numList[2] == 7) "YES" else "NO")
}


Measured memory_bytes: 38176
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;

vector<int> g[MAX];
int C[MAX];
int a = -1;
int b = -1;
bool isLoop;
bool odd;
int VAL[MAX];
int n, m;

void dfs(int v, int c, int p)
{
	C[v] = c;
	FOR(i, 0, SZ(g[v]))
	{
		int to = g[v][i];
		if (to == p) continue;
		if (C[to] != -1)
		{
			if (a == -1)
			{
				isLoop = true;
				if (C[to] != c ^ 1) odd = true;
				a = v;
				b = to;
			}

			continue;
		}

		dfs(to, c ^ 1, v);
	}
}

void imp()
{
	cout << -1 << endl;
	exit(0);
}

void rem(int a, int b)
{
	int ind = -1;
	FOR(i, 0, SZ(g[a]))
	{
		if (g[a][i] == b)
		{
			ind = i;
			break;
		}
	}

	g[a].erase(g[a].begin() + ind);
}

LL ans = 0;
LL dfs1(int v, int p)
{
	LL bal = VAL[v];
	FOR(i, 0, SZ(g[v]))
	{
		int to = g[v][i];
		if (to != p)
		{
			bal += dfs1(to, v);
		}
	}
	
	ans += abs(bal);
	return bal;
}

LL f(int c)
{
	ans = 0;
	VAL[a] += c;
	VAL[b] -= c;
	dfs1(0, 0);
	VAL[a] -= c;
	VAL[b] += c;
	return ans + abs(c);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> n >> m;
	FOR(i, 0, m)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	if (n % 2) imp();
	FILL(C, -1);
	dfs(0, 0, 0);
	int cnt = 0;
	FOR(i, 0, n)
	{
		cnt += C[i];
		VAL[i] = C[i] == 0 ? -1 : 1;
	}

	if (!isLoop)
	{
		if (cnt * 2 != n) imp();
		ans = 0;
		dfs1(0, 0);
		cout << ans << endl;
		return 0;
	}

	rem(a, b);
	rem(b, a);

	if (odd)
	{
		int val = (n - 2 * cnt) / 2;
		VAL[a] += val;
		VAL[b] += val;
		ans = 0;
		dfs1(0, 0);
		cout << ans + abs(val) << endl;
		return 0;
	}

	//FOR(i, 0, n)
	//{
	//	cout << VAL[i] << " ";
	//}
	
	//cout << endl;
	if (cnt * 2 != n) imp();
	int l = -n, r = n;
	while (r - l > 2)
	{
		int l1 = l + (r - l) / 3;
		int r1 = l + 2 * (r - l) / 3;
		if (f(l1) > f(r1))
		{
			l = l1;
		}
		else
		{
			r = r1;
		}
	}

	//cout << f(l) << " " << f(l + 1) << " " << f(l + 2) << endl;
	LL ans = min(f(l), min(f(l + 1), f(l + 2)));
	cout << ans << endl;
}

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

int main(void){
    char s[105];
    cin >> s;
    long long k;
    cin >> k;
    
    long long i = 0;
    for(i = 0; i <= k - 1; i++){
        if(s[i] == '1'){
            continue;
        }else{
            cout << s[i] - '0' << endl;
            return 0;
        }
    }
    
    cout << 1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) {
    t = v;
}

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, K;
    cin>>N>>K;
    vll x(N), y(N);
    for (size_t i = 0; i < N; i++)
    {
        cin>>x[i]>>y[i];
    }
    ll ans=INF;
    for (size_t i = 0; i < N; i++)
    {
        ll xMax=x[i];
        for (size_t j = 0; j < N; j++)
        {
            if(xMax < x[j])continue;
            ll xMin = x[j];
            for (size_t k = 0; k < N; k++)
            {
                ll yMax = y[k];
                for (size_t l = 0; l < N; l++)
                {
                    if(yMax < y[l])continue;
                    ll yMin = y[l];
                    int cnt=0;
                    for (size_t m = 0; m < N; m++)
                    {
                        if(x[m] <= xMax and xMin <= x[m] and y[m] <= yMax and yMin <= y[m])
                        cnt++;
                    }
                    if(cnt>=K)
                    chmin(ans,(xMax-xMin)*(yMax-yMin));
                }
                
            }
            
        }
        
    }
    cout<<ans;


    return 0;
}

Measured memory_bytes: 3648
from bisect import *
N,K=map(int,input().split())
A=list(map(int,input().split()))
siz=200814
Y=[[] for i in range(siz)]
p=[]
for i in range(N):
  Y[A[i]].append(i)
  p.append(i)
for i in range(N):
  Y[A[i]].append(N+i)
  p.append(i)
def f(x):
  S=set()
  r=[]
  for i in range(x,N):
    if A[i] in S:
      while True:
        S.discard(r[-1])
        if r[-1]==A[i]:
          del r[-1]
          break
        del r[-1]
    else:
      r.append(A[i])
      S.add(A[i])
  return r

Z=-1
R=0
V=0
while True:
  Z+=1
  V=Y[A[p[Z]]][bisect_right(Y[A[p[Z]]],Z)]
  if V>=N and R==K-1:
    print(*f(Z))
    exit()
  if V>=N:
    R+=1
    V=p[V]
  Z=V
  if Z==N-1:
    K%=(R+1)
    Z=-1
    R=0
    break
if K==0:
  print()
  exit()
while True:
  Z+=1
  V=Y[A[p[Z]]][bisect_right(Y[A[p[Z]]],Z)]
  if V>=N and R==K-1:
    print(*f(Z))
    exit()
  if V>=N:
    R+=1
    V=p[V]
  Z=V

Measured memory_bytes: 183988
#include<stdio.h>
#include<string.h>
int main()
{
	char s[300],t[300],a[200];
	int i,j;
	scanf("%s %s",s,t);
	strcat(t,s);
/*	for( i=0;t[i]!='\0';i++)

		a[i]=t[i];
	for( j=0;s[j]!='\0';j++)
		a[i+j]=s[j];
*/	printf("%s\n",t);
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys
import os

for s in sys.stdin:
    a, b, n = map(int, s.split())
    lst = []
    r = a % b
    for i in range(100):
        v = 10 * r // b
        r = 10 * r % b
        lst.append(v)
    print(sum(lst[:n]))

Measured memory_bytes: 7572
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      char c=s[i];
      for(int j=0;j<s.size();j++){
        if(j<i){
          if(t[i]==s[j]){
            cout<<"No";
            return 0;
          }
        }
        if(s[j]==c){
          s[j]=t[i];
        }else if(s[j]==t[i]){
          s[j]=c;
        }
      }
    }
  }
  if(s==t)
    cout<<"Yes";
  else
    cout<<"No";
}


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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

string table[12]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};

int N,M;
int T[50010];
int S[50010];

bool ok;
bool dfs(int n,int m){
    if(m==M){
        if(N-n<=2){
            ok=true;
            return true;
        }
        return false;
    }
    if(ok)return true;

    if((N-n+1)/2>M-m+1)return false;
    if(n>0&&(T[n-1]+11)%12==S[m]){
        if(dfs(n-1,m+1)){
            ok=true;
            return true;
        }
    }

    if(n+1<N&&T[n+1]==S[m]){
        if(dfs(n+1,m+1)){
            ok=true;
            return true;
        }
    }
    if(n+2<N&&(T[n+2]+1)%12==S[m]){
        if(dfs(n+2,m+1)){
            ok=true;
            return true;
        }
    }
    return false;
}



void solve(){
    cin>>N>>M;
    string hoge;
    rep(i,N){
        cin>>hoge;
        T[i]=find(table,table+12,hoge)-table;
    }
    rep(i,M){
        cin>>hoge;
        S[i]=find(table,table+12,hoge)-table;
    }

    ok=false;
    if(dfs(-1,0))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

signed main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int T;cin>>T;
    while(T--)solve();
    return 0;
}

Measured memory_bytes: 5500
/* ex7_3
   cy_an  */

#include <stdio.h>
#include <stdlib.h>

int main(void){

    // 変数の宣言
    char **memory;
    int num_r, num_c, i, j, r_flag, c_flag, printflag;

    // numの入力
    scanf("%d %d", &num_r, &num_c);

    // 二次元配列領域の動的確保
    memory = (char**)calloc(num_r, sizeof(char*));
    if(memory == NULL){
        fprintf(stderr, "memory allocation error.\n");
        exit(1);
    }
    for(i=0; i<num_r; i++){
        memory[i] = (char*)calloc(num_c, sizeof(char));
        if(memory[i] == NULL){
            fprintf(stderr, "memory allocation error.\n");
            exit(1);
        }
    }

    // raw,colの入力
    for(i=0; i<num_r; i++){
        for(j=0; j<num_c; j++){
            scanf(" %c", &memory[i][j]);
        }
    }


    // 行の削除
    for(i=0; i<num_r; i++){
        r_flag = 1;
        for(j=0; j<num_c; j++){
            if(memory[i][j] == '#'){
                r_flag = 0;
                break;
            }
        }
        // 全て'.'のとき
        if(r_flag){
            for(j=0; j<num_c; j++){
                memory[i][j] = '-';
            }
        }
    }
    // 列の削除
    for(j=0; j<num_c; j++){
        c_flag = 1;
        for(i=0; i<num_r; i++){
            if(memory[i][j] == '#'){
                c_flag = 0;
                break;
            }
        }
        // 全て'.'のとき
        if(c_flag){
            for(i=0; i<num_r; i++){
                memory[i][j] = '-';
            }
        }
    }

    // memoryの出力
    for(i=0; i<num_r; i++){
        printflag = 0;
        for(j=0; j<num_c; j++){
            if(memory[i][j] != '-'){
                printf("%c", memory[i][j]);
                printflag = 1;
            }
        }
        if(printflag){
            printf("\n");
        }
    }

    // メモリの解法
    for(i=0; i<num_r; i++){
        free(memory[i]);
    }
    free(memory);

    return 0;
}

Measured memory_bytes: 1636
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer[] a = new Integer[n];
		for(int i=0;i<n;++i) a[i] = sc.nextInt();
		Arrays.sort(a);
		long sum = 0;
		for(int i=0;i<n;++i){
			if(n-i > k)
			sum+=a[i];
		}
	
		 System.out.print(sum);
		
	}
}

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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	double s = 0;
	for (int i = 0; i < n; ++i) {
		double a; cin >> a;
		s += 1 / a;
	}
	cout << fixed << setprecision(10) << 1/s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e6 + 17;

struct pt
{
	int x, y;
	pt() { }
};

struct fenwick
{
	int n;
	map<int, int> F;

	fenwick() { n = inf, F.clear(); }

	void upd(int i, int x)
	{
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	}

	int get(int i)
	{
		int res = 0;

		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);

		return res;
	}
};

int n;
pt s, f;
pt p[maxn];

bool read()
{
	if (scanf("%d %d %d %d %d", &s.x, &s.y, &f.x, &f.y, &n) != 5)
		return false;

	forn (i, n)
		scanf("%d %d", &p[i].x, &p[i].y);

	return true;
}

bool cmp(pt a, pt b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }

void solve()
{
	if (s.x > f.x)
		swap(s, f);

	if (s.y > f.y)
	{
		f.y = 2 * s.y - f.y;

		forn (i, n)
			p[i].y = 2 * s.y - p[i].y;
	}

	vector<pt> pp;

	forn (i, n)
		if (s.x <= p[i].x && p[i].x <= f.x && s.y <= p[i].y && p[i].y <= f.y)
			pp.push_back(p[i]);

	sort(pp.begin(), pp.end(), cmp);
	fenwick dp;

	forn (i, size(pp))
		dp.upd(pp[i].y, dp.get(pp[i].y) + 1);

	int lis = dp.get(inf);
	long double ans = 0;

	if (lis != min(f.y - s.y, f.x - s.x) + 1)
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * lis;
	else
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * (lis - 1) + 10 * M_PI;

	printf("%.15f\n", (double) ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 79344
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
using namespace std;

typedef long long ll;

const int INF = 1<<30;
const ll INFL = 1LL<<60;
#define rep(i, n) for(int i = 0; i < (n); i++)

int N, K, S;
int x[2010], y[2010], z[2010];

int atari(int i, int j){
  return abs(x[i] - x[j]) < S && abs(y[i] - y[j]) < S && abs(z[i] - z[j]) < S;
}

int inter(int i, int j){
  if(!atari(i, j)) return -1;
  int X = S - abs(x[i] - x[j]);
  int Y = S - abs(y[i] - y[j]);
  int Z = S - abs(z[i] - z[j]);
  return 2 * (X*Y+Y*Z+Z*X);
}

struct edge{int to, cost;};
vector<edge> E[2010];
int used[2010];
vector<int> xs;
void dfs(int now){
  if(used[now]) return;
  xs.push_back(now);
  used[now] = 1;
  for(edge e: E[now]){
    dfs(e.to);
  }
}
int sub(){
  int res = 0;
  //xsでなんかやる
  int v = xs.size();
  int e = 0;
  rep(i, v) e += E[xs[i]].size();
  e /= 2;
  if(v == e){//円
    if(v == K){//全て使う
      int sum = 0;
      rep(i, v) for(edge e: E[xs[i]])if(xs[i] > e.to) sum += e.cost;
      res = sum;
    }else{//一部だけ使う
      int now = xs[0], from = -1;
      int ne;
      vector<int> costs;
      rep(_, v){
        for(edge nv: E[now])if(nv.to != from){
          ne = nv.to;
          costs.push_back(nv.cost);
        }
        from = now;
        now = ne;
        ne = -1;
      }
      int sum = 0;
      rep(i, K-1){
        sum += costs[i];
      }
      res = sum;
      rep(i, v){
        sum += costs[(i+K-1)%v] - costs[i];
        res = max(res, sum);
      }
    }
  }else{//直線
    int s = -1;
    rep(i, v)if(E[xs[i]].size() == 1) s = xs[i];
    int now = s, from = -1;
    int ne;
    vector<int> costs;
    rep(_, v-1){
      for(edge nv: E[now])if(nv.to != from){
        ne = nv.to;
        costs.push_back(nv.cost);
      }
      from = now;
      now = ne;
      ne = -1;
    }
    int sum = 0;
    rep(i, K-1){
      sum += costs[i];
    }
    res = sum;
    for(int i = K-1; i < costs.size(); i++){
      sum += costs[i] - costs[i-K+1];
      res = max(res, sum);
    }
  }
  return res;
}

void solve(){
  rep(i, N)rep(j, N)if(i != j){
    int m = inter(i, j);
    if(m != -1){
      E[i].push_back({j, m});
    }
  }
  int ans = -INF;
  rep(i, N){
    if(used[i]) continue;
    xs.resize(0);
    dfs(i);
    if((int)xs.size() < K) continue;
    ans = max(ans, sub());
  }
  if(ans == -INF) cout << -1 << endl;
  else cout << S * S * 6 * K - ans << endl;
}


int main(){
  while(true){
    cin >> N >> K >> S;
    if(N + K + S == 0) return 0;
    rep(i, N) cin >> x[i] >> y[i] >> z[i];
    solve();
    rep(i, N) used[i] = 0;
    rep(i, N) E[i].resize(0);
  }
}



Measured memory_bytes: 3216
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif

        int a, b;
        cin >> a >> b;
        ll temp = 0;
        repone(i, b - a) {
            temp += i;
        }
        cout << temp - b << endl;
        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>

typedef long long ll;
using namespace std;

int main(){
  int n;

  cin >> n;
  if(n<1200){
    cout << "ABC" << endl;
  }
  else if(n>=2800){
    cout << "AGC" << endl;
  }
  else{
    cout << "ARC" << endl;
  }



  return 0;
}



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

int main()
{

int A,B,C;
cin >> A>> B>> C;

if (A==B && A==C){
cout<<"No"<<endl;
}    

else if( A==B||A==C||B==C){
cout <<"Yes"<< endl;
}   
    
else{
cout<<"No"<<endl;
 }      
         
 }   
    
    

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

int main(){
	int n,k;
	
	cin >> n >> k;
	long long a[n];
	long long ans[n]; 
	
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	
	ans[0] = 0;
	for(int i = 1;i < n;i++){
		long long m = LLONG_MAX;
		for(int j = i-1;j>=i-k&&j>=0;j--){
			m = min(m,ans[j]+abs(a[i]-a[j]));
		}
		ans[i] = m;
	}
	
	cout << ans[n-1];
}

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

int main()
{
    ll X; cin >> X;
    ll r = 0;
    if (X >= 400 && X <= 599) {
        r = 8;
    }
    else if (X >= 600 && X <= 799) {
        r = 7;
    }
     else if (X >= 800 && X <= 999) {
        r = 6;
    }
     else if (X >= 1000 && X <= 1199) {
        r = 5;
    }
     else if (X >= 1200 && X <= 1399) {
        r = 4;
    }
     else if (X >= 1400 && X <= 1599) {
        r = 3;
    }
     else if (X >= 1600 && X <= 1799) {
        r = 2;
    }
     else if (X >= 1800 && X <= 1999) {
        r = 1;
    }
    cout << r << endl;


}


Measured memory_bytes: 3644
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var shiin = new string [] { "w","", "k" , "s" ,"t" ,"n" ,"h" ,"m" , "y" ,"r" };
        var boin = new char[] { 'T', 'L', 'U', 'R', 'D' };
        var boin2 = new string[] { "a", "i", "u", "e", "o" };
        var d = new Dictionary<char, string>();
        for (int i = 0; i < 5; i++) d[boin[i]] = boin2[i];
        var s = Console.ReadLine().Trim();
        Console.WriteLine(GetStr(d, shiin, s));
    }
    public static string GetStr (Dictionary<char,string> d ,string[] shiin , string s)
    {
        var ans = "";
        for (int i = 0; i < s.Length; i+=2)
        {
            var a = int.Parse(s[i].ToString());
            ans += shiin[a] + d[s[i + 1]];
        }
        var ans2 = ans.Replace("wu", "nn");
        return ans2;
    }
}

Measured memory_bytes: 9792