akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int e[27];
int main(){
	string s;
	cin>>s;
	int a=-1,b=-1,c,d;
	for(int i=0;i<4;i++){
		e[s[i]-'A']++;
	}
	for(int i=0;i<26;i++){
		if(e[i]==2&&a==-1)
			a=i;
		else if(e[i]==2)
			b=i;
	}
	if(a!=-1&&b!=-1)
		puts("Yes");
	else puts("No");	
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		long[] score=new long[N];
		long[] su=new  long[N+1];
		for(int i=0; i<N; i++) {
			score[i]=sc.nextLong();
		}
		long[] hosei=new long[N];
		for(int i=0; i<N; i++) {
			hosei[i]=Math.max(0, score[i]);
		}
		long[] ruisekiwa=new long[N+1];
		Arrays.fill(ruisekiwa, 0);
		Arrays.fill(su,0);
		for(int i=1; i<=N; i++) {
			ruisekiwa[i]=hosei[i-1];
			su[i]=score[i-1];
		}
		for(int i=1; i<=N; i++) {
			ruisekiwa[i]=ruisekiwa[i-1]+ruisekiwa[i];
			su[i]=su[i-1]+su[i];
		}
		long max=0;
		for(int i=0; i<=N-K; i++) {
			long tmp1=su[i+K]-su[i];
			tmp1+=(ruisekiwa[N]-ruisekiwa[i+K]);
			tmp1+=(ruisekiwa[i]-ruisekiwa[0]);
			long tmp2=0;
			tmp2+=(ruisekiwa[N]-ruisekiwa[i+K]);
			tmp2+=(ruisekiwa[i]-ruisekiwa[0]);
			max=Math.max(Math.max(tmp1,tmp2), max);
		}
		pl(max);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 47384
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
int main()
{
	int n,i;
	cin>>n;
	int a[n],cnt[2][N];
	for(i=0;i<N;++i)
	{
		cnt[0][i] = cnt[1][i] = 0;
	}
	for(i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
		cnt[i%2][a[i]]++;
	}
	int m1=0,m2=0,i1,i2,m3=0,m4=0,i3,i4;
	for(i=0;i<N;++i)
	{
		if(cnt[0][i]>=m1)
		{
			m2 = m1;
			i2 = i1;
			m1 = cnt[0][i];
			i1 = i;
		}
		else if(cnt[0][i]>=m2)
		{
			m2 = cnt[0][i];
			i2 = i;
		}
		if(cnt[1][i]>=m3)
		{
			m4 = m3;
			i4 = i3;
			m3 = cnt[1][i];
			i3 = i;
		}
		else if(cnt[1][i]>=m4)
		{
			m4 = cnt[1][i];
			i4 = i;
		}
	}
	if(i1==i3)
	{
		printf("%d",min(n-m1-m4,n-m2-m3));
	}
	else
	{
		printf("%d",n-m1-m3);
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

int n, ans = 0;
vector<int> digits, cur;

bool check() {
	bool f1 = false, f2 = false, f3 = false;
	for (int i = 0; i < cur.size(); ++i)
		if (cur[i] == 3)
			f1 = true;
		else
			if (cur[i] == 5)
				f2 = true;
			else
				if (cur[i] == 7)
					f3 = true;

	return f1 && f2 && f3;
}

void dfs(int idx, bool isSmaller) {
	if (idx == digits.size()) {
		if (check())
			++ans;
		return;
	}

	if (isSmaller) {
		cur[idx] = 3;
		dfs(idx+1, isSmaller);
		cur[idx] = 5;
		dfs(idx+1, isSmaller);
		cur[idx] = 7;
		dfs(idx+1, isSmaller);
	} else {
		if (digits[idx] < 3)
			return;

		cur[idx] = 3;
		dfs(idx+1, (digits[idx] > 3));

		if (digits[idx] < 5)
			return;

		cur[idx] = 5;
		dfs(idx+1, (digits[idx] > 5));

		if (digits[idx] < 7)
			return;

		cur[idx] = 7;
		dfs(idx+1, (digits[idx] > 7));
	}
}

int main() {

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

	cin >> n;

	if (n < 357) {
		cout << 0 << endl;
		return 0;
	}

	int tmp = n;
	while (tmp > 0) {
		digits.push_back(tmp%10);
		tmp /= 10;
	}

	reverse(digits.begin(),digits.end());

	int len = digits.size();
	
	int fac3 = 27;
	for (int i = 3; i < len; ++i) {
		ans += fac3 - 3 - 3 * ((1<<i) - 2);
		fac3 *= 3;
	}

	cur = digits;
	dfs(0, false);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    ll sum = 0, mn = 1e9+10;
    int cnt = 0;
    rep(i,n) {
        ll a; cin >> a;
        sum += abs(a);
        chmin(mn, abs(a));
        if (a<0) cnt++;
    }
    if (cnt%2==1) cout << sum-2*mn << endl;
    else cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
k,a,b = map(int,input().split())

if b-a <= 2:
    print(1+k)
else:
    if k < a+1:
        print(1+k)
    else:
        p = (k-a)//2
        if (k-a-1)%2 == 0:
            print((1+p)*b-p*a)
        else:
            p -= 1
            print((1+p)*b-p*a+1)


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

long long int getres(long long int p, long long int q, long long int r, long long int s)
{
	return max(max(p, q), max(r, s)) - min(min(p, q), min(r, s));
}

int main()
{
	int n;
	cin >> n;
	long long int suma[200010]= {}; // suma[i] = a[0] + ... a[i - 1];
	for(int i = 1; i <= n; i++){
		long long int a;
		cin >> a;
		suma[i] = suma[i - 1] + a;
	}
	long long int ans = mod;
	for(int mid = 2; mid < n - 1; mid++){
		// cout << mid << " : " << endl;
		// a[0] ~ a[mid - 1] までがBとCの分
		// a[mid] ~ a[n - 1] までがDとEの分
		int b = lower_bound(suma + 1, suma + mid, suma[mid] / 2) - suma;
		int d = lower_bound(suma + mid + 1, suma + n, (suma[n] - suma[mid]) / 2 + suma[mid]) - suma;
		long long int p1 = suma[b];
		long long int q1 = suma[mid] - suma[b];
		long long int p2 = suma[b - 1];
		long long int q2 = suma[mid] - suma[b - 1];
		// cout << p1 << " " << q1 << " " << p2 << " " << q2 << endl;
		long long int r1 = suma[d] - suma[mid];
		long long int s1 = suma[n] - suma[d];
		long long int r2 = suma[d - 1] - suma[mid];
		long long int s2 = suma[n] - suma[d - 1];
		// cout << r1 << " " << s1 << " " << r2 << " " << s2 << endl;
		long long int res = min(min(getres(p1, q1, r1, s1), getres(p1, q1, r2, s2)), min(getres(p2, q2, r1, s1), getres(p2, q2, r2, s2)));
		ans = min(ans, res);
	}
	cout << ans << endl;
}

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

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - h * W - w * H + h * w << endl;
}

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

typedef long long ll;
#define int ll

using namespace std;

const int N=2e5+10;

int a[N];

signed main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0,k=0;i<n;i++)
        if(a[i]>i-k||(i>0&&a[i]>a[i-1]+1))
            cout<<-1,exit(0);
        else if(a[i]==0)
            k=i;
    int ans=0;
    for(int i=1;i<n;i++)
        if(a[i]==a[i-1]+1)
            ans++;
        else
            ans+=a[i];
    cout<<ans;
}


Measured memory_bytes: 1792
using System;

class B
{
	static long[] Read() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	static void Main()
	{
		var av = Read();
		long a = av[0], v = av[1];
		var bw = Read();
		long b = bw[0], w = bw[1];
		var t = long.Parse(Console.ReadLine());

		if (a > b) (a, b) = (-a, -b);
		Console.WriteLine(b + w * t <= a + v * t ? "YES" : "NO");
	}
}


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

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

Measured memory_bytes: 3632
n,m=map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
lst = []
for i in range(m):
  b, c = map(int, input().split())
  lst.append((b,c))

lst = sorted(lst, key=lambda x: x[1], reverse=True)
kakikae_list = [0]*n
idx = 0
for i in range(m):
  b, c = lst[i]
  for j in range(b):
    if idx+j >= n:
      break
    kakikae_list[idx+j] = c
  idx += b
kakikae_kist = sorted(kakikae_list)
count=0
for i in range(n):
  count += max(a[i], kakikae_list[i])
print(count)

Measured memory_bytes: 23260
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;


//A-Changing a Character
void solve_main()
{
	DWORD N, K;
	string strInput;

	cin >> N >> K;
	cin >> strInput;

	strInput[K - 1] = strInput[K - 1] + 32;

	cout << strInput << endl;
}


int main()		
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template<typename T>
struct edge{
    int f,t;
    T c;
    int id;
    edge(){};
    edge(int f,int t,T c,int id = 0):f(f),t(t),c(c),id(id){};
    bool operator< (const edge &s){
        return c < s.c;
    }
};

template<typename T>
struct graph{
    std::vector<std::vector<edge<T> > > data;
    graph(int v):data(v){};
    void add_edge(edge<T> &e){
        data[e.f].push_back(e);
    }
    void add_edge(int f,int t,T c){
        data[f].emplace_back(f,t,c);
    }
    size_t size(){
        return data.size();
    }
    std::vector<edge<T>> make_edges(){
        std::vector<edge<T>> r;
        for(auto &i:data)std::copy(i.begin(),i.end(),std::back_inserter(r));
        return r;
    }
};

// template<typename T>
// std::vector<T> spfa(graph<T> &g,int s){
//     //queue
//     std::queue<int> q;
//     q.emplace(s);
//     //data init
//     std::vector<T> data(g.size(),std::numeric_limits<T>::max()/4);
//     std::vector<bool> isq(g.size(),false);
//     std::vector<int> count(g.size(),0);
//     data[s] = (T)0;isq[s] = true;++count[s];
//     //solve
//     while(!q.empty()){
//         int cur = q.front();q.pop();
//         isq[cur] = false;
//         for(auto &v:g.data)for(auto &e:v){
//             if(data[e.f] + e.c < data[e.t]){
//                 data[e.t] = data[e.f] + e.c;
//                 if(++count[e.t]>=g.size()){
//                     fill(data.begin(),data.end(),-1);
//                     return data;
//                 }
//                 if(!isq[e.t]){
//                     q.push(e.t);
//                     isq[e.t] = true;
//                 }
//             }
//         }
//     }
//     return data;
// }

template<typename T>
std::vector<T> bellmanford(graph<T> &g, int s){
    T INF = std::numeric_limits<T>::max()/4;
    std::vector<T> data(g.size(),INF);
    data[s] = 0;
    for(int i=0;i<g.size()-1;i++){
        for(auto &v:g.data)for(auto &e:v){
            if(data[e.f]==INF)continue;
            data[e.t] = std::min(data[e.f] + e.c,data[e.t]);
        }
    }
    for(auto &v:g.data)for(auto &e:v){
        if(data[e.f]==INF)continue;        
        if(data[e.f] + e.c < data[e.t]){
            fill(data.begin(),data.end(),std::numeric_limits<T>::min());
            break;
        }
    }
    return data;
}

int main(){
    using namespace std;
    using i64 = long long int;
    int v,e,r;
    cin >> v >> e >> r;
    graph<i64> g(v);
    int f,t;i64 d;
    for(int i=0;i<e;++i){
        cin >> f >> t >> d;
        g.add_edge(f,t,d);
    }
    vector<i64> res = bellmanford(g,r);
    i64 INF = numeric_limits<i64>::max()/4;
    i64 NEG = numeric_limits<i64>::min();
    for(auto &x:res){
        if(x==NEG){
            cout << "NEGATIVE CYCLE" << endl;
            break;
        }
        if(x>=INF)cout << "INF" << endl;
        else cout << x << endl;
    }
}


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

#define MOD 1000000007

int C[3];

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

	long long sum=1;

	for(int i=0;i<n;i++){
		long long cnt=0, id=-1;
		if(a[i]==C[0]){ cnt++;	id=0;}
		if(a[i]==C[1]){	cnt++;	id=1;}
		if(a[i]==C[2]){	cnt++;	id=2;}

		if(id==-1){	cout<<"0"<<endl;	return 0;	}

		sum*=cnt;	sum%=MOD;
		C[id]++;

	}

	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x,y,z;
    int f[n+1]={0};
    int k;
    for(x=1;x<100;x++){
        for(y=1;y<100;y++){
            for(z=1;z<100;z++){
                k=x*x+y*y+z*z+x*y+y*z+z*x;
                if(k<=n)f[k]++;
            }
        }
    }
    for(k=1;k<=n;k++){
        cout << f[k] << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t N,M;
  cin>>N>>M;
  vector<vector<int> > A(N+1,vector<int>(0));
  vector<int> B(N+1,-1),next(0),empty(0);
  int visited=0;
  for(int i=0; i<M; i++){
    int a,b;
    cin>>a>>b;
    A[a].push_back(b);
    A[b].push_back(a);
    // 1に繋がってるやつをnextに入れる
    if(a==1 ||b==1){

      if(a!=1 && B[a]==-1){B[a]=1; next.push_back(a);visited++;}
      else if(B[b]==-1){B[b]=1; next.push_back(b);visited++;}
      
    }
  }

  while(visited<N){
    vector<int>next2=next;
    next=empty;
    // nextに入ってた洞窟に繋がってる洞窟にその数字をつけてnextにいれる
   for(int i=0; i<next2.size(); i++){
       for(int j=0; j<A[next2[i]].size(); j++){
         if(B[A[next2[i]][j]]==-1){
         B[A[next2[i]][j]]=next2[i];
         //nextに入れる
         next.push_back(A[next2[i]][j]);
         visited++;
         }
       }
       if(visited==N)goto end;
   }
  }
  end :
  cout << "Yes" << endl;
  for(int i=2; i<=N; i++){
    cout<<B[i]<<endl;
  }
}
 

Measured memory_bytes: 10220
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
  int n,m,i,j,k;
  for(;;){
    cin >> n >> m;
    if(n==0&&m==0)break;
    vector<int> v(m);
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	cin >> k;
	if(k==1) v[j]++;
      }
    }
    multimap< int,int,greater<int> > mp;
    for(j=0;j<m;j++){
      mp.insert(multimap<int,int>::value_type(v[j],j+1));
    }
    multimap<int,int>::iterator it = mp.begin();
    cout << (*it).second;
    while(++it != mp.end()){
      cout << " " << (*it).second;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 908
#include <stdio.h>

int main(){
	int H1, M1, H2, M2, K;
	scanf("%d %d %d %d %d",&H1, &M1, &H2, &M2, &K);
	
	int hours = H2 - H1;
	int minutes = M2 - M1;
	
	int sum = (hours * 60) + minutes;
	int total = sum - K;
	
	printf("%d\n", total);
	
	
	return 0;
}


Measured memory_bytes: 1708
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String str = in.next();
            int n = Integer.parseInt(str);

            int s = 0;

            for (char cc : str.toCharArray()) {
                s += cc - '0';
            }

            out.println(n % s == 0 ? "Yes" : "No");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 22740
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n,k = MI()
a = RI()

for i in range(n):
    ddict[a[i]] += 1

d = sorted(ddict.items(),key=lambda x:x[1],reverse=True)
# print(d)

e = d[k:]
ans = 0
for i in range(len(e)):
    ans += e[i][1]
print(ans)



Measured memory_bytes: 133324
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    vector<vector<ll> >dp(n,vector<ll>(n));
    REP(i,1,n){
        if(s[0]==s[i])dp[0][i]=1;
    }
    ll ma=0;
    REP(i,1,n){
        REP(j,1,n){
            dp[i][j]=(s[i]==s[j]?min((ll)j-i,dp[i-1][j-1]+1):0);
            ma=max(ma,dp[i][j]);
        }
    }
    cout<<ma<<endl;
}

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

using namespace std;

int main() {
	int a[3];
	for(int i=0;i<3;i++){
	    cin>>a[i];
	}
	sort(a,a+3);
	int sum=0;
	for(int i=1;i<3;i++){
	    sum+=(a[i]-a[i-1]);
	}
	cout<<sum;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    K = Scanner.int()
    ans = 0
    for i in range(1, K + 1):
        for j in range(1, K+1):
            for k in range(1, K + 1):
                g = Math.gcd(i, j)
                g = Math.gcd(g, k)
                ans += g

    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 80492
#include <iostream>

using namespace std;
using ll = long long;


int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b > 2 && 4 * a * b < (c - a - b) * (c - a - b))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
using namespace std;
 
signed main() {
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for( int i = 0; i < N; i++ ) cin >> P.at(i);
  
  vector<double> kitai(N);
  for( int i = 0; i < N; i++ ){
    kitai.at(i) = (P.at(i)+1)/2.0000000000;
  }
  
 // for( int i = 0; i < N; i++ ) cout << kitai.at(i) <<  " ";
  
  double ans = 0;
  int r = 0;
  double now = 0;
  for( int l = 0; l < N; l++ ){
    while( r < min(l+K,N) ){
      now += kitai.at(r);
      r++;
    }
    if( l > 0 ) now -= kitai.at(l-1); 
    if( now > ans ) ans = now;
  }
  cout << ans << endl;
}

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

int main () {
	int a,b;
	char i;
	while ( cin >> a >> i >> b ){
		if ( i == '+' ){
			cout << a + b << endl;
		}
		else if ( i == '-' ){
			cout << a - b << endl;
		}
		else if ( i == '*' ){
			cout << a * b << endl;
		}
		else if ( i == '/' ){
			cout << a / b << endl;
		}
		else if ( i == '?' ){
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3112
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    ll N, M, ans=0;
    int i;

    cin >> N >> M;

    vector<int> H(N+1), A(M+1), B(M+1);
    vector<int> C(N+1, 1);

    for(i=1; i<=N; i++) {
        cin >> H[i];
    }

    for(i=1; i<=M; i++) {
        cin >> A[i] >> B[i];
        if(H[A[i]]>H[B[i]]) {
            C[B[i]] = 0;
        } else if (H[A[i]]<H[B[i]]) {
            C[A[i]] = 0;
        } else {
            C[A[i]] = C[B[i]] = 0;
        }
    }

    for(i=1; i<=N; i++) {
        if(C[i] == 1) {
            ans++;
        }
    }

    cout << ans << endl;
    
}

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

int main(void){
 string str;
 cin >> str;
 int n=0,w=0,s=0,e=0;
 for(auto x:str){
  switch(x){
  case 'N': n=1; break;
  case 'W': w=1; break;
  case 'S': s=1; break;
  case 'E': e=1; break;
  }
 }
 cout << ((!(n^s) && !(w^e)) ? "Yes" : "No") << endl;
 return 0;
}


Measured memory_bytes: 384
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String[] strs = N.split("");
        int[] sp = new int[strs.length];
        
        for(int i=0; i<strs.length; i++) {
            sp[i] = Integer.parseInt(strs[i]);
        }
        
        int n = Integer.parseInt(N);
        int k = Integer.parseInt(sc.next());
        int[] d = new int[10];
        for(int i=0; i<k; i++) {
            int x = Integer.parseInt(sc.next());
            d[x] = 1;
        }
        
        int ans = 0;
        boolean isequal = true;
        for(int i=0; i<sp.length; i++) {
            if(isequal) {
                if(d[sp[i]] == 0) {
                    ans = ans*10+sp[i];
                }else {
                    isequal = false;
                    for(int j=sp[i]; j<=9; j++) {
                        if(d[j] == 0) {
                            ans = ans*10+j;
                            break;
                        }
                        if(i == 9) {
                            ans = ans*10;
                        }
                    }
                } 
            }else {
                for(int j=0; j<=9; j++) {
                    if(d[j] == 0) {
                        ans = ans*10+j;
                        break;
                    }
                }
            }
        }
        if(ans >= n) {
            System.out.println(ans);
        }else {
            ans = 0;
            for(int i=0; i<sp.length+1; i++) {
                for(int j=0; j<=9; j++) {
                    if(i==0 && j==0) continue;
                    
                    if(d[j] == 0) {
                        ans = ans*10+j;
                        break;
                    }
                }
            }
            System.out.println(ans);
        }
        
    }   
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::set;
using std::vector;
using std::pair;
using std::make_pair;
using std::priority_queue;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

#define INF 0x7fffffffffffffff

ull i, j, k, l, m, n;
ull H, W, Q;
ull a, b, c, x, y;
ull K, L, N, M;
string str;

ull Comb2(ull n)
{
	return n * (n - 1) / 2;
}

int main()
{
	cin >> str;
	ull length = str.length();
	if (length == 1)
	{
		cout << "1\n";
		return 0;
	}
	x = 1+Comb2(length);
	vector<int> num(26, 0);
	for (i = 0; i < length; ++i)
	{
		num[str[i]-'a']++;
	}
	for (i = 0; i < 26; ++i)
	{
		x -= Comb2(num[i]);
	}
	cout << x << '\n';
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;

void solve()
{
    ll a;
    scanf("%lld", &a);
    ll b = 0;
    int ch = getchar();
    while (ch != 10)
    {
        if (ch >= '0' && ch <= '9')
            b *= 10, b += ch - '0';
        ch = getchar();
    }
    cout << a * b / 100 << endl;
}
int main()
{
    solve();
    return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main() {
    int n; cin >> n;
    vector<int> value;
    vector<int> cost;
    rp(i, 0, n) {
        int v; cin >> v; value.emplace_back(v);
    }
    rp(i, 0, n) {
        int v; cin >> v; cost.emplace_back(v);
    }
    int ans = 0;
    rp(i, 0, n) {
        if(value[i] - cost[i] > 0) ans += (value[i] - cost[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n,m; cin>>n>>m;
  vector<int> h(n);
  rep(i, n) cin>>h[i];
  vector<vector<int> > G(n);
  rep(i, m) {
    int a,b; cin>>a>>b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int res=0;
  rep(i, n) {
    bool ok=true;
    rep(j, G[i].size()) {
      int v=G[i][j];
      if (h[i]<=h[v]) ok=false;
    }
    if (ok) res++;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 8800
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll n,x,a[2005];

ll seg[(1<<12)];
void update(int k,ll a){
	k+=(1<<11)-1; seg[k]=a;
	while(k>0){
		k=(k-1)/2;
		seg[k]=min(seg[k*2+1],seg[k*2+2]);
	}
}
ll query(int a,int b,int k,int l,int r)
{
	if(r<a || b<l) return 1e18;
	if(a<=l && r<=b) return seg[k];
	else{
		ll vl=query(a,b,k*2+1,l,(l+r)/2);
		ll vr=query(a,b,k*2+2,(l+r)/2+1,r);
		return min(vl,vr);
	}
}
int main(){
	cin >> n >> x;
	for(int i=0;i<n;i++){
		cin >> a[i];
		update(i,a[i]);
	}
	ll ret = 1e18;
	for(int i=0;i<n;i++){
		ll sum = x * 1LL * i;
		for(int j=0;j<n;j++){
			// (j-i+n)%n....j
			int a = (j-i+n)%n,b = j;
			if(a<=b){
				sum += query(a,b,0,0,(1<<11)-1);
			}
			else{
				sum += min(query(a,n-1,0,0,(1<<11)-1),query(0,b,0,0,(1<<11)-1));
			}
		}
		ret = min(ret,sum);
	}
	cout << ret << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define lld         long long int
#define llf         long double
#define pb          push_back
#define mp          make_pair
#define IN          insert
#define loopN(n)    for(lld i=0;i<n;i++)
#define loop(p,n)   for(lld i=p;i<=n;i++)
#define rloop(p,n)  for(lld i=n;i>=p;i--)
#define loop2(p,n)  for(lld j=p;j<=n;j++)
#define all(v)      v.begin(),v.end()
#define F1          first
#define F2          second
#define INF         2e18
#define FILE        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define PI          2*acos(0.0)
#define ISO         ios::sync_with_stdio(false);cin.tie(0)
#define mem(a,b)    memset(a,b,sizeof(a))
#define case(z)     cout<<"Case "<<z<<": ";
using namespace std;

lld n,mw;
int w[105],v[105];
int dp[105][100005];
int mid,hi,low;

lld fun(int p, int k)
{
    if(k<=0)
    {
        return 0;
    }

    if(p>n-1)
    {
        return INF;
    }
    if(dp[p][k]!=-1)
    {
        return dp[p][k];
    }

    lld ans=min( w[p]+fun(p+1,k-v[p]), fun(p+1,k) );
    return dp[p][k]=ans;

}


int main()
{
    ISO;
    cin>>n>>mw;
    loopN(n)
    {
        cin>>w[i]>>v[i];
    }
    lld ans=-1;
    hi=1e5;
    low=1;

    lld k;
    while(low<=hi)
    {
        mid=(hi+low)/2;
        mem(dp,-1);

        k=fun(0,mid);

        if(k<=mw)
        {
            ans=mid;
            low=mid+1;
        }
        else
        {
            hi=mid-1;
        }

    }
    cout<<ans<<endl;



    return 0;
}




Measured memory_bytes: 44672
n = int(input())
ans = str()
check = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

while n != 0:
    n -= 1
    ans += check[n%26]
    n //= 26

print(ans[::-1])

Measured memory_bytes: 9200
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i<n; i++){
            list.add(sc.nextInt());
        }
        int distance = list.get(0) + k -list.get(n-1);
        for(int i = 1; i<n; i++){
            distance = Math.max(distance,list.get(i)-list.get(i-1));
        }
        System.out.println(k-distance);
    }
}

Measured memory_bytes: 86928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0233
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                Stack<string> res = new Stack<string>();
                while (n != 0)
                {
                    int q = n / -10;
                    int r = n - (q * -10);

                    if (r < 0)
                    {
                        r += 10;
                        q += 1;
                    }

                    res.Push(r.ToString());
                    n = q;
                }
                Console.WriteLine(WAr(res, string.Empty));
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 14604
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
int main()
{
	lli x, y, a, b;
	cin >> x >> y >> a >> b;
	lli ans = x * a;
	ans = max(ans, x * b);
	ans = max(ans, y * a);
	ans = max(ans, y * b);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    int x = (n+1000-1)/1000;
    int ans = x*1000 - n;
	cout << ans << "\n";
	return 0;
}


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

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

    int D, N;
    cin >> D >> N;

    int result;
    
    switch (D){

        case 0:
            result = N;
            if (N == 100) {
                result += 1;
            }
            break;

        case 1:
            result = 100 * N;
            if (N == 100) {
                result += 100;
            }
            break;
    
        case 2:
            result = 10000 * N;
            if (N == 100) {
                result += 10000;
            }            
            break;
    }

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long c[n-1],s[n-1],f[n-1];
  for (long i = 0; i < n-1; i++) {
    scanf("%ld %ld %ld", &c[i], &s[i], &f[i]);
  }

  long time;
  for (long i = 0; i < n-1; i++) {
    time = 0;
    for (long j = i; j < n-1; j++) {
      if (time < s[j]) {
        time = s[j];
      }
      if (time%f[j] != 0) {
        time = f[j]*(time/f[j]+1);
      }
      time += c[j];
    }
    printf("%ld\n", time);
  }
  printf("0\n");

  return 0;
}

Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt(), d = scanner.nextInt();
			Map<Integer, Point> map = new HashMap<>();
			IntStream.range(0, h)
					.forEach(i -> IntStream.range(0, w).forEach(j -> map.put(scanner.nextInt(), new Point(i, j))));
			// すべての結果を計算
			int[] result = new int[h * w + 1];
			IntStream.rangeClosed(0, d).forEach(i -> result[i] = 0);
			IntStream.rangeClosed(d + 1, h * w).forEach(i -> {
				Point now = map.get(i);
				Point prev = map.get(i - d);
				result[i] = result[i - d] + Math.abs(now.x - prev.x) + Math.abs(now.y - prev.y);
			});
			int q = scanner.nextInt();
			IntStream.range(0, q).forEach(i -> {
				int l = scanner.nextInt(), r = scanner.nextInt();
				System.out.println(result[r] - result[l]);
			});
		}
	}

	/**
	 * 座標データを格納するクラス
	 */
	static class Point {
		/** X座標 */
		final int x;
		/** Y座標 */
		final int y;

		Point(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
}


Measured memory_bytes: 68248
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll se=0;
ll sume(vector<int> a,int n){

}
int main(){
    ll n,a,b;cin>>n>>a>>b;
    cout<<n/(a+b)*a+min(a,n%(a+b))<<endl;
    return 0;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
cnt_dist = [0] * (n - 1)
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        k = min(j - i, abs(x - i) + 1 + abs(j - y))
        cnt_dist[k - 1] += 1
print(*cnt_dist, sep='\n')

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
int n,m;
string s[505];
int sy,sx,ey,ex;
struct edge{
    int to,cap,rev;
};
vector<edge> adj[505];
int level[505],iter[505];
void bfs(int s){
    memset(level, -1,sizeof(level));
    queue<int> q; q.push(s); level[s]=0;
    while(!q.empty()){
        int here = q.front(); q.pop();
        for(int i=0;i<adj[here].size();i++){
            edge &e =adj[here][i];
            if(e.cap > 0){
                if(level[e.to] == -1){
                    level[e.to] = level[here]+1;
                    q.push(e.to);
                }
            }
        }
    }
}
int dfs(int t,int here,int f){
    if(t == here)return f;
    for(int &i=iter[here];i<adj[here].size();i++){
        edge & e=adj[here][i];
        if(e.cap > 0 && level[e.to] > level[here]){
            int d =dfs(t,e.to,min(f,e.cap));
            if(d>0){
                e.cap-=d; adj[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int maxFlow(int source,int sink){
    int f=0;
    while(true){
        bfs(source);
        if(level[sink]==-1)return f;
        int r=1;
        memset(iter,0,sizeof(iter));
        while(r){
            r = dfs(sink,source,1e9);
            f+=r;
        }
    }
}
void addEdge(int from,int to,int cap){
    adj[from].push_back({to,cap,(int)adj[to].size()});
    adj[to].push_back({from,0,(int)adj[from].size()-1});
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int source = n+m+5; int sink=source+1;
    for(int i=0;i<n;i++)for(int j=0;j<m;j++){
        if(s[i][j] == 'S'){
            addEdge(source,i,1e9);
            addEdge(source,j+n,1e9);
            addEdge(i,j+n,1e9);
            addEdge(j+n,i,1e9);
         //   addEdge(source,j+n,1e9);
        }
        else if(s[i][j]=='T'){
           // addEdge(i,sink,1e9);
            addEdge(j+n,sink,1e9);
            addEdge(i,sink,1e9);
            addEdge(i,j+n,1e9);
            addEdge(j+n,i,1e9);
        }
        else if(s[i][j]=='o'){
            addEdge(i,j+n,1);
            addEdge(j+n,i,1);
        }
    }
    int min_cut = maxFlow(source,sink);
    if(min_cut>=1e9)min_cut=-1;
    cout<<min_cut;
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010], B[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i] >> B[i];
	sort(A, A + N);
	sort(B, B + N);

	int ans = 0;
	if (N % 2 == 0) {
		int AX = A[N / 2] + A[N / 2 - 1];
		int BX = B[N / 2] + B[N / 2 - 1];
		ans = BX - AX + 1;
	}
	else {
		int AX = A[N / 2];
		int BX = B[N / 2];
		ans = BX - AX + 1;
	}
	cout << ans << endl;
}







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

using namespace std;

int main()
{
    int n, S;
    
    while (scanf("%d %d", &n, &S) && n){
        int r[128] = {0};
        
        for (int i = 0; i < n; i++){
            int x;
            scanf("%d", &x);
            r[x]++;
        }
        
        int ans = 0;
        for (int i = 1; i <= 100; i++){
            for (int j = i + 1; j <= 100; j++){
                if (i + j > S){
                    ans += r[i] * r[j];
                }
            }
            if (i + i > S) ans += r[i] * (r[i] - 1) / 2;
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int a[1000],ans;
int main()
{
	string s;
	cin>>s;
	int len=s.size();
	for (int i=0;i<len;i++)
		a[i]=s[i];
	for (int i=0;i<len;i++) {
		if (a[i]!=a[len-i-1])
			ans++;
	}
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	static Scanner scanner;
 
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    String az="abcdefghijklmnopqrstuvwxyz";
 
	    String s=gs();
	    
	    //System.out.print(String.valueOf(s.charAt(0))+ (s.length()-2)+s.charAt(s.length()-1));
 
	    String r="None";
	    for (int i=0; i<az.length();i++) {
	    	char c=az.charAt(i);
	    	boolean f= true;
	    	for (int j=0; j<s.length();j++) {
	    		if(s.charAt(j)==c) {
	    			f=false;
	    			break;
	    		}
	    	}
	    	if(f) {
	    		System.out.print(c);
              return;
 
	    	}
	    }
	    
	    System.out.print(r);
 
 
	}
 
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}
 
	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}
 
	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
 
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38888