akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int main() {
    long long n;
    long long ans=0;
    cin >> n;
    for(int i=1;i<=n;++i) {
        if((GetDigit(i))%2!=0) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=200000;
int N,K,a,cunt;
 
int main(){
    cin>>N>>K;

    map<int,int> mp;

    for(int i=0;i<N;i++){
        cin>>a;
        mp[a]++;    
    }
    
    priority_queue<int> PQ;

    for(auto p:mp){
        PQ.push(p.second);
    }

    for(int k=0;k<K&&!PQ.empty();k++) PQ.pop();

    if(PQ.empty()) {
        cout<<0<<"\n";
        return 0;
    }

    while(!PQ.empty()){
        cunt+=PQ.top();
        PQ.pop();
    }    

    cout<<cunt<<"\n";


    return 0;
}


Measured memory_bytes: 10748
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


def main():
    S = input().strip()
    T = input().strip()
    print(len([False for s, t in zip(S, T) if s != t]))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 11016
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
template<typename T>void read(T &x){
	x=0;int f(1);char c(getchar());
	for(;!isdigit(c);c=getchar())if(c=='-')f=-f;
	for(; isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c-'0');
	x*=f;
}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)write(x/10),x%=10;
	putchar(x+'0');
}
const int maxn=200005;
struct Edge{
	int v,nt;
	Edge(int v=0,int nt=0):v(v),nt(nt){}
}e[maxn*2];
int num,hd[maxn];
void add_edge(int u,int v){
	e[++num]=Edge(v,hd[u]);hd[u]=num;
}
int val[maxn],dp[maxn],cnt,ans[maxn];
void dfs(int u,int fa){
	int pos,tmp;
	if(val[u]>dp[cnt]){
		dp[++cnt]=val[u];
		pos=-1;
	}
	else{
		pos=lower_bound(dp,dp+cnt+1,val[u])-dp;
		tmp=dp[pos];dp[pos]=val[u];
	}
	ans[u]=cnt;
	for(int i=hd[u];i;i=e[i].nt){
		int v=e[i].v;
		if(v==fa)continue;
		dfs(v,u);
	}
	if(pos==-1)dp[cnt--]=0;
	else dp[pos]=tmp;
}
int main(){
	int n;read(n);
	for(int i=1;i<=n;++i)
		read(val[i]);
	for(int i=2;i<=n;++i){
		int u,v;
		read(u),read(v);
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1,0);
	for(int i=1;i<=n;++i)
		write(ans[i]),putchar('\n');
	return 0;
}


Measured memory_bytes: 23272
N, K = map(int, input().split())
h_list = [None] * N
for n in range(N):
    h_list[n] = int(input())

h_list = list(sorted(h_list))

min_diff = 10 ** 10
for i in range(N):
    if K - 1 + i >= N:
        break
    diff = h_list[K - 1 + i] - h_list[i]
    if diff < min_diff:
        min_diff = diff
print(min_diff)

Measured memory_bytes: 8616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.OptionalInt;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            TreeSet<String> ans = new TreeSet<>();
            gen("a", N, ans);
            ans.forEach(out::println);
        }

        private void gen(String s, int n, TreeSet<String> ans) {
            if (s.length() == n) {
                ans.add(s);
                return;
            }
            StringBuilder sb = new StringBuilder(s);
            char max = (char) (s.chars().max().getAsInt() + 1);
            for (char c = 'a'; c <= max; c++) {
                sb.append(c);
                gen(sb.toString(), n, ans);
                sb.setLength(sb.length() - 1);
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 53196
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
struct SCC {
  int V;
  vector<vector<int>> G, rG;
  vector<int> vs, cmp; // post order, topological order
  vector<bool> used;
  SCC() {}
  SCC(int V) : V(V), G(V), rG(V), used(V), cmp(V) {}
  void add_arc(int s, int t) {
    G[s].push_back(t);
    rG[t].push_back(s);
  }
  void dfs(int v) {
    used[v] = true;
    for (int i : G[v]) {
      if (not used[i])
        dfs(i);
    }
    vs.push_back(v);
  }
  void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for (int i : rG[v]) {
      if (not used[i])
        rdfs(i, k);
    }
  }
  int scc() {
    fill(all(used), false);
    vs.clear();
    rep(v, 0, V) {
      if (not used[v])
        dfs(v);
    }
    fill(all(used), false);
    int k = 0;
    rrep(i, 0, vs.size()) {
      if (not used[vs[i]])
        rdfs(vs[i], k++);
    }
    return k;
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int V, E;
  cin >> V >> E;
  SCC g(V);
  loop(E) {
    int u, v;
    cin >> u >> v;
    g.add_arc(u, v);
  }
  g.scc();
  int Q;
  cin >> Q;
  loop(Q) {
    int u, v;
    cin >> u >> v;
    cout << (g.cmp[u] == g.cmp[v]) << endl;
  }

  return 0;
}



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

using namespace std;

class Data
{
  public:
    Data(){
    }
    Data(long _v, long _w, string _t, long _d, string _s){
        v = _v;
        w = _w;
        t = _t;
        d = _d;
        s = _s;
    }
    
    long v, w, d;
    string t, s;
    
    bool operator < (const Data &arg) const {
        
        return  v != arg.v ? v < arg.v : 
                w != arg.w ? w < arg.w : 
                t != arg.t ? t < arg.t : 
                d != arg.d ? d < arg.d : 
                s != arg.s ? s < arg.s : false;
        
    }
    
};

int main()
{
    int N; 
    cin >> N;
    vector<Data> Datas;
    
    for(int i = 0; i < N; ++i)
    {
        long v, w, d;
        string t, s;
        cin >> v >> w >> t >> d >> s;
        
        Datas.push_back(Data(v, w, t, d, s));
    }
    
    sort(Datas.begin(), Datas.end());
    
    for(int i = 0; i < N; ++i)
      cout << Datas[i].v << " " << Datas[i].w << " " << Datas[i].t << " " << 
      Datas[i].d << " " << Datas[i].s << endl;
    
    return 0;
}


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

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N + 1);
    for (int i = 0; i < N; i++) cin >> A[i];
    A[N] = K + A[0];

    int maxd = -1, sum = 0;;
    for (int i = 1; i < N + 1; i++) {
        int tmp = A[i] - A[i - 1];
        sum += tmp;
        maxd = max(maxd, tmp);
    }

    cout << sum - maxd << endl;
}

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

#define INF (1 << 29)

int N, M, R;
int d[201][201];
int r[9];
int A, B, C;
int res;
bool used[9];

void dfs(int c, int las, int dist){
    if(c == R+1){
        res = min(res, dist);
        return;
    }
    for(int i = 1; i <= R; i++){
        if(used[i]) continue;
        used[i] = true;
        if(las == -1) dfs(c+1, i, 0);
        else dfs(c+1, i, dist+d[r[las]][r[i]]);
        used[i] = false;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> R;
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            if(i != j) d[i][j] = INF;
        }
    }
    for(int i = 1; i <= R; i++){
        cin >> r[i];
    }
    for(int i = 1; i <= M; i++){
        cin >> A >> B >> C;
        if(d[A][B] > C) d[A][B] = d[B][A] = C;
    }
    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                if(d[i][j] > d[i][k]+d[k][j])
                    d[i][j] = d[i][k]+d[k][j];
            }
        }
    }
    res = INF;
    dfs(1, -1, 0);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
x,k,d=map(int,input().split())
x=abs(x-0)
if (x-(k*d))>0:
    print((x-(k*d)))
else:
    k1=0
    k1=x//d
    k-=k1
    a=(x-(k1*d))
    if k%2==0:
        print(a)
    else:
        print(abs(a-d))
    

Measured memory_bytes: 9180
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int n; cin >> n&&n;) {
		vector<int> a(n);
		rep(i, 0, n)cin >> a[i];
		int s; cin >> s;
		int l = 0, r = n - 1;
		int cnt = 0;
		while (true) {
			if (r - l < 0)break;
			cnt++;
			if (r - l == 0)break;
			int m = (l + r) / 2;
			//dump(m); dump(l); dump(r);
			if (a[m] > s)r = m - 1;
			else if (a[m] < s)l = m + 1;
			else break;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testcases \
    int tcc;      \
    cin >> tcc;   \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    fast_io;
    int n;
    cin >> n;
    unordered_map<int, int> mp;
    lp(i, 0, n) {
        int t;
        cin >> t;
        mp[t]++;
    }
    int cnt = 0;
    for (auto i : mp) {
        if (i.second > 1) continue;
        if (i.first != 1 && mp.find(1)!=mp.end() && mp[1]>0) continue;
        int sq = sqrt(i.first);
        bool is = true;
        for (int j = 2; j <= sq; j++) {
            if (i.first % j == 0) {
                if (mp.find(j)!=mp.end() || mp.find(i.first/j)!=mp.end()) {
                    is = false;
                    break;
                }
            }
    	}
        cnt += is;
    }
    cout << cnt;
}

Measured memory_bytes: 11364
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    set<int>S;
    int x;
    for(int i = 0; i < n; i++){
        cin >> x;
        S.insert(x);
    }
    int q;
    cin >> q;
    int cnt = 0;
    for(int i = 0; i < q; i++){
        cin >> x;
        if(S.find(x) != S.end()){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 7764
n = int(input())
s = [int(input()) for s in range(n)]
s1 = []
sum0 = 0
for i in s:
    if i%10 == 0:
        sum0 += i
    else:
        s1.append(i)

if len(s1) == 0:
    print(0)
else:
    sum1 = sum(s1)
    if sum1%10 != 0:
        print(sum0 + sum1)
    else:
        print(sum0 + sum1 - min(s1))

Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define mx(a,b) (a>b?a:b)
char s[110];
int n,pos,ans;
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;++i)
		pos+=s[i]=='I'?1:-1,
		ans=mx(ans,pos);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  main()
{
	int n,i;
	cin >> n;
	string s;
	cin >> s;
	for(i=0;i<s.size();i++)
	{
		if (s[i] + n <= 90)
		{
			char c = s[i] + n;
			cout << c;
		}
		else
		{
			char c = (s[i]+n) - 26;
			cout << c;
		}
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<int> A(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
  }

  deque<int> Q;
  if ( !(N%2) ) {
    for ( int i = 0; i < N; i++ ) {
      if ( i%2 ) Q.push_front(i);
      else Q.push_back(i);
    }
  } else {
    for ( int i = 0; i < N; i++ ) {
      if ( !(i%2) ) Q.push_front(i);
      else Q.push_back(i);
    }
  }

  while ( Q.size() ) {
    cout << A[Q.front()] << " ";
    Q.pop_front();    
  }

  cout << endl;
  
  return 0;
}


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

vector<int> vec;
vector<int> dp(100001,-1);

int back(int i,int k){
    for(int j=1;j<=k;j++){
        if(i+j==vec.size()-1) return abs(vec[i+j]-vec[i]);
    }
    // if(i+2==vec.size()-1) return abs(vec[i+2]-vec[i]);
    if(dp[i]!=-1) return dp[i];
    
    int ans=INT_MAX;
    for(int j=1;j<=k;j++){
        if(i+j<vec.size()){
            ans= min(ans, abs(vec[i+j]-vec[i]) + back(i+j,k));
        }
    }

    dp[i]=ans;
    return dp[i];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        vec.push_back(a);
    }
    cout<<back(0,k);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  long a[n], cnt[200000] = {};
  for (int i=0; i<n; i++) {
    cin >> a[i];
    cnt[a[i]-1]++;
  }
  long sum = 0;
  for (int i=0; i<n; i++)
    sum += cnt[i]*(cnt[i]-1)/2;
  for (int i=0; i<n; i++) {
    long ans;
    int tmp = a[i]-1;
    ans = sum - cnt[tmp] + 1;
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 5760
N, Y = map(int, input().split())
ans = [-1,-1,-1]
for x in range(0,N+1):
    for y in range(0,N-x+1):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y:
            ans[0] = x
            ans[1] = y
            ans[2] = z
print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var T1 = BigInteger.Parse(ReadLine());

        for (int i = 1; i < N; i++) {
            var T = BigInteger.Parse(ReadLine());
            T1 = Lcm(T1, T);
        }

        WriteLine(T1);
    }

    public static BigInteger Lcm(BigInteger a, BigInteger b) {
        return a * b / Gcd(a, b);
    }

    public static BigInteger Gcd(BigInteger a, BigInteger b) {
        if (a < b)
            return Gcd(b, a);
        while (b != 0) {
            var tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }
}

Measured memory_bytes: 13524
#include<algorithm>
#include<iostream>
#include<string>

int main()
{
	const char* s = "01235789";
	int n;
	std::string ans;

	while( std::cin >> n, n )
	{
		ans.clear();

		while( n )
		{
			ans += s[n & 7];
			n >>= 3;
		}

		std::reverse( ans.begin(), ans.end() );
		std::cout << ans << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include <iostream>

#define MAX 1000

void output(int A[MAX], int n) {
  for(int i = 0; i < n; i++) {
    std::cout << A[i];
    if(i != n - 1) {
      std::cout << " ";
    }
  }
  std::cout << std::endl;
}

void insertion_sort(int A[MAX], int n) {
  for(int i = 1; i < n; i++) {
    int v = A[i];
    int j = i - 1;

    while(j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;

    output(A, n);
  }
}

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

  int A[MAX] = { 0 };
  for(int i = 0; i < n; i++) {
    std::cin >> A[i];
  }

  output(A, n);

  insertion_sort(A, n);

  return 0;
}


Measured memory_bytes: 3108
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int citiesN = scanner.nextInt();
        int startX = scanner.nextInt();
        int[] cityCoordinatex = new int[citiesN+1];
        int[] distance = new int[citiesN];

        for(int i=0;i<citiesN;i++){
            cityCoordinatex[i]= scanner.nextInt();
        }
        cityCoordinatex[citiesN] = startX;
        Arrays.sort(cityCoordinatex); //配列を読み込んでソートする

        for(int i=1;i<citiesN+1;i++) {
            distance[i-1] = cityCoordinatex[i]-cityCoordinatex[i-1];
        } //距離の算出

//        //debug
//        for(int i=0;i<citiesN+1;i++) {
//            System.out.print(cityCoordinatex[i]+" ");
//        }
//        System.out.println();
//        for(int i=0;i<citiesN;i++) {
//            System.out.print(distance[i]+" ");
//        }
//        System.out.println();

        int g;
        if(citiesN!=1) {
            g = gcds(distance);
        }else{
            g = distance[0];
        }
        System.out.println(g);
    }

    public static int gcds(final int... param) {
        final int len = param.length;
        int g = gcd(param[0], param[1]);
        if(len!=2) {
            for (int i = 1; i < len - 1; i++) {
                g = gcd(g, param[i + 1]);
            }
        }
        return g;
    }

    public static int gcd(int a, int b) {
        //a > b にする（スワップ）
        if (a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        //ユークリッドの互除法
        int r = -1;
        while (r != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        return a;    //b には r=0 の値が入るため、a を返す
    }

}


Measured memory_bytes: 50252
N = K = 0
N, K = map(int, input().split())
Xi = list(map(int, input().split()))

def calc(startIndex):
    if startIndex + K > N:
        return -1
    endIndex = startIndex + K - 1
    x1 = Xi[startIndex]
    x2 = Xi[endIndex]
    len1 = abs(x1) + abs(x2 - x1)
    len2 = abs(x2) + abs(x2 - x1)
    return min(len1, len2)

INF = 100000000000000
min_value = INF
for i in range(N):
    d = calc(i)
    if d >= 0 and d < min_value:
        min_value = d
if min_value == INF:
    print(0)
else:
    print(min_value)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;

int N,K;
P dt[SIZE];
map<int,int> S;

ll T=0LL;

int main(){
  cin >> N >> K;
  rep(i,0,N){
    int t;ll d;
    cin >> t >> d;
    dt[i] = make_pair(d,t);
  }
  sort(dt,dt+N,greater<>());
  priority_queue<P,vector<P>,greater<P>> A;
  ll sumd = 0LL;

  ll types = 0LL;
  rep(i,0,K){
    A.push(dt[i]);
    if(S[dt[i].second]==0) types++;
    S[dt[i].second]++;
    sumd += dt[i].first;
  }

  T = max(T,sumd + types*types);

  rep(i,K,N){
    //dt[i]は使えない
    if(S[dt[i].second] > 0)continue;
    
    //取り出すものをえらぶ !!
    P a = make_pair(0,0);
    bool f = false;
    while(!A.empty()){
      a = A.top();A.pop();
      if(S[a.second] == 1)continue;
      else{
        S[a.second]--;
        sumd -= a.first;
        f = true; //取り出し
        break;
      }
    }

    //これ以上種類を増やせない
    if(!f)break;

    //交換
    A.push(dt[i]);
    S[dt[i].second]++;
    types++;
    sumd += dt[i].first;
    T = max(T,sumd + types*types);
  }

  cout << T << endl;

  return 0;
}


Measured memory_bytes: 6256
#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)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/







int dp[3030][3030];
int A, B, C, D, E, F;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B >> C >> D >> E >> F;

    double ma = 0;
    int ans1 = 100 * A, ans2 = 0;
    dp[0][0] = 1;
    rep(i, 1, F + 1) rep(j, 0, i + 1) {
        int water = i - j;
        int suger = j;

        if (100 * A <= i) if (dp[i - 100 * A][j]) dp[i][j] = 1;
        if (100 * B <= i) if (dp[i - 100 * B][j]) dp[i][j] = 1;
        if (C <= i && C <= j) if (dp[i - C][j - C]) dp[i][j] = 1;
        if (D <= i && D <= j) if (dp[i - D][j - D]) dp[i][j] = 1;

        if (suger * 100 <= water * E && dp[i][j] && 0 < j) {
            double e = 1.0 * 100 * j / i;
            if (ma < e) {
                ma = e;
                ans1 = i;
                ans2 = j;
            }
        }
    }

    printf("%d %d\n", ans1, ans2);
}


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

int main(){

	int r, c, i, j;
	int ans[101][101] = {0};

	cin >> r >> c;

	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
			cin >> ans[i][j];
			ans[i][c] += ans[i][j];
			ans[r][j] += ans[i][j];
			ans[r][c] += ans[i][j];
		}

	}

	for(i=0; i<=r; i++){
		for(j=0; j<c; j++){
			cout << ans[i][j] << " ";
		}
		cout << ans[i][c]<<endl;
	}

	return 0;

}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int dp[100001];

int solve(int n, vector<int> h) {
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}
	return dp[n-1];
}

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	cout << solve(n, h) << endl;
}

Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	float ans=0;
	int temp;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>temp;
		ans+=(1.00000/temp);
	}
	cout<<(1.00000/ans)<<endl;
}

Measured memory_bytes: 256
def main():
    import math
    a,b,x=map(int,input().split())
    v=a*a*b
    if x==v:
        print(0)
    elif x<v/2:
        h=2*x/(a*b)
        t=math.degrees(math.atan(h/b))
        print(90-t)
    else:
        h=2*(v-x)/(a*a)
        t=math.degrees(math.atan(h/a))
        print(t)
        
main()

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

int main(){
  int N,M;
  cin  >> N >> M;
  P S[100010]; //Sは(i問目,結果(WA or AC))という形にする
  for(int i =1; i<=M; i++){
    cin >>S[i].first;
    cin >>S[i].second;
  }
  int WA[100010];
  int ACnum = 0;
  int WAnum = 0;
  int a;
  string b;
  bool judge[100010]; //Nこ trueならすでにACした問題
  for(int i =1; i <=M ; i++){
    a = S[i].first;
    b = S[i].second;
    
    if( judge[a] == false && b == "AC"){
      judge[a] = true;
      ACnum ++;
      WAnum += WA[a];

    }
    else if(judge[a] == false && b == "WA"){
      WA[a]++;
    }
    
  }
  
  cout << ACnum << " " << WAnum << endl;
  
  
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



int main(){
	cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    string s;
    cin >> n;
    cin >> s;
    ll ans = 0;
    REP(i,n-2){
        if("ABC" == s.substr(i,3)) ans++;
    }
    cout << ans << endl;
    return 0;
    
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define black_tree tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pair_black_tree tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update>
#define gp __gnu_pbds
#define INF 1000000000
#define MOD 1000000007
#define MAX 1000001
#define endl '\n'
#define ll long long
#define ld long double
#define lli long long int
#define ull unsigned long long
#define ulli unsigned long long int
#define pb push_back
#define pf push_front
#define ook order_of_key
#define fbo find_by_order
#define np next_permutation
#define mp make_pair
#define eb emplace_back
#define mae max_element
#define mie min_element
#define lb lower_bound 
#define ub upper_bound
#define bs binary_search
#define ff first
#define ss second
using namespace std;
using namespace gp;
ll n;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	if(n==1){
		cout<<0;
	}
	else{
		cout<<1;
	}
}

Measured memory_bytes: 3632
from math import sqrt
import sys

# print('input >>')
X = int(input())

if X == 1:
    print(0, -1)

for x in range(1, int(sqrt(X))):
    if X % x == 0:
        flg = False
        for a in range(1000000):
            if (a-1) ** 5 - (a-1-x) ** 5 < a ** 5 - (a-x) ** 5:
                flg = True
            if flg and a ** 5 - (a-x) ** 5 > X:
                break
            if a ** 5 - (a-x) ** 5 == X:
                print(a, a-x)
                sys.exit()

# print('-----output-----')


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin>>n>>m;
    map<int,int> mp;
    rep(i, m){
        int a,b; cin>>a>>b;
        mp[a]++;
        mp[b]++;
    }
    for(auto a : mp){
        if(a.second % 2 == 1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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

int main() {
	int numLetter;
	string letterA, letterB;
	cin >> numLetter;
	cin >> letterA >> letterB;
	for ( int i = 0; i < numLetter; i++ ) {
		cout << letterA[i] << letterB[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int h,w;
    cin >> h >> w;
    
    vector<string> c(h);
    for(int i = 0;i < h;i++){
          cin >> c[i];
    }
    
    for(int i = 0;i < h;i++){
          for(int j = 0;j < 2;j++){
                cout << c[i] << endl;
          }
    }
}


Measured memory_bytes: 256
"""
参考 Xenous
if sortを少なくし、maxで処理
""" 
# 初期入力
N = int(input())
a=[]
b=[]
c=[]
for i in range(N):
    a1,b1,c1 = (int(x) for x in input().split())
    
    a.append(a1)
    b.append(b1)
    c.append(c1)

dp_A = [0]*(N) ;dp_A[0] =a[0] 
dp_B = [0]*(N) ;dp_B[0] =b[0] 
dp_C = [0]*(N) ;dp_C[0] =c[0] 


#
for i in range(0,N-1):
    dp_A[i+1] = max(dp_B[i] + a[i+1] , dp_C[i] + a[i+1])
    dp_B[i+1] = max(dp_A[i] + b[i+1] , dp_C[i] + b[i+1])
    dp_C[i+1] = max(dp_A[i] + c[i+1] , dp_B[i] + c[i+1])
print(max (dp_A[N-1],dp_B[N-1],dp_C[N-1]) )

Measured memory_bytes: 71256
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    s = input()
    t = input()
    ans = 100000
    for i in range(len(s) - len(t) + 1):
        anstmp = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                anstmp += 1
        ans = min(ans, anstmp)

    print(ans)


main()


Measured memory_bytes: 9912
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int n;
  cin >> n;
  cout << (1000 - n % 1000 == 1000 ? 0 : 1000 - n % 1000);
}


Measured memory_bytes: 3644
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  string S;
  cin >> N >> S;

  vll V('z' - 'a' + 1, 0);
  REP(i, 0, S.size()) {
    V[S[i] - 'a']++;
  }

  ll ans = 1;
  REP(i, 0, V.size()) {
    if (V[i] > 0) {
      ans = (ans * (V[i] + 1)) % kMod;
    }
  }
  ans--;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    REP(i,q){
        string X,Y; cin >> X >> Y;
        int dp[1005][1005] = {};
        for(int i = 0; i < X.length(); i++){
            for(int j = 0; j < Y.length(); j++){
                if(X[i] == Y[j]){
                    dp[i+1][j+1] = dp[i][j] + 1;
                }
                else{
                    dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
                }
            }
        }
        cout << dp[X.length()][Y.length()] << endl;
    }

}


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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int K = int.Parse(input[2]);
        var result = new List<int>();
        
        for (var i = 1; i <= 100; i++)
        {
            if (A % i == 0)
            {
                if (B % i == 0)
                {
                    result.Add(i);
                }
            }
            
            if (A <= i || B <= i)
            {
                break;
            }
        }

        var c = result.Count();
        var d = c - K;
        Console.WriteLine(result[d]);
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
    ll n,k,ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        ll a;
        cin>>a;
        if(a>=k) ans++;
    }
    cout<<ans<<endl;
}

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

#define INF 999999999
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pub push_back
#define pob pop_back
#ifdef LOCAL
  #define de(e) cout << "L" << __LINE__ << ": " << e << "\n" // debug echo
  #define dr(e) cout << "L" << __LINE__ << ": " << #e << " -> " << e << "\n" // debug repr
#else
  #define de(e)
  #define dr(e)
#endif
#define out(fmt, ...) printf(fmt, __VA_ARGS__); printf("\n")
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

//
// Implementation
//

int main() {
  int M; cin >> M;
  cout << 48 - M << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
typedef long long ll;
const int mod=998244353;
int a[305],f[900050],p[2][1800050];
inline int fp(int p){
	int a=3,s=1;
	while(p){
		if(p&1)s=(ll)s*a%mod;
		a=(ll)a*a%mod;
		p>>=1;
	}
	return s;
}
int main(){
	int n,i,j,sum=0,ans,t=0;
	scanf("%d",&n);ans=fp(n);
	f[0]=1;
	for(i=1;i<=n;++i){
		scanf("%d",a+i);sum+=a[i];
		for(j=sum;j>=0;--j){
			f[j]=(f[j]<<1)%mod;
			if(j>=a[i])f[j]=(f[j]+f[j-a[i]])%mod;
		}
	}
	for(i=(sum+1)>>1;i<=sum;++i)ans=(ans-(ll)f[i]*3%mod+mod)%mod;
	if(!(sum&1)){
		p[0][sum]=1;
		for(i=1;i<=n;++i){
			t+=a[i];
			memset(p[i&1],0,sizeof(p[i&1]));
			for(j=sum-t;j<=sum+t;++j){
				if(j-sum-a[i]>=-t+a[i])p[i&1][j]=(p[i&1][j]+p[i&1^1][j-a[i]])%mod;
				if(j-sum+a[i]<=t-a[i])p[i&1][j]=(p[i&1][j]+p[i&1^1][j+a[i]])%mod;
			}
		}
	}
	printf("%d\n",(ans+(ll)p[n&1][sum]*3)%mod);
	return 0;
} 

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

class Magatro
{
    static void Main()
    {
        new Magatro().Solve();
    }
    
    public void Solve()
    {
        var line = Console.ReadLine().Split(' ');
        var x=int.Parse(line[0]);
        var t=int.Parse(line[1]);
        var anser=Math.Max(0,x-t);
        Console.WriteLine(anser);
    }
}

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

void outputV(vector<int>);
void outputV(vector<vector<int>>);

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n,q;
  string s;
  cin>>n>>q>>s;
  vector<int> ruiseki(n+1,0);
  for(int i=0;i<n;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      ruiseki[i+1]++;
    }
    ruiseki[i+1]+=ruiseki[i];
  }
  //outputV(ruiseki);
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    l--;
    r--;
    cout<<ruiseki[r]-ruiseki[l]<<endl;
  }
  return 0;
}

void outputV(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    if (i) {
      //cout << ' ';
    }
    cout << v[i];
  }
  cout << endl;
}

void outputV(vector<vector<int>> v) {
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (j) {
        cout << ' ';
      }
      cout << v[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
using ll = long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 200006;

int N, K;
string s;

void solve()
{
	int ans = 0;
	for(int i=0;i+1<N;++i){
		if(s[i] == s[i+1]) ans++;
	}
	cout << min(ans + 2*K, N-1) << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> K;
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 512
# Kadane
module Kadane
  def self.max_subarray(a)
    max_so_far = max_ending_here = -1.0 / 0
    a.each do |i|
      max_ending_here = [i, max_ending_here + i].max
      max_so_far = [max_so_far, max_ending_here].max
    end
    max_so_far
  end
end

while n = gets.chomp.to_i
  break if n == 0
  a = []
  n.times { a << gets.chomp.to_i }
  puts Kadane.max_subarray(a)
end

Measured memory_bytes: 8776
from operator import itemgetter
n = int(input())
data = [list(map(lambda x: x == '#', input().strip())) for i in range(n)]
row_cnt = list(map(sum, data))
col_cnt = [sum(map(itemgetter(i), data)) for i in range(n)]

mr = max(row_cnt)
if not mr:
  print(-1)
else:
  temp = sum([col_cnt[i] for i in range(n) if row_cnt[i] == mr])
  k0 = 0 if temp else 1
  k1 = n - mr
  k2 = sum(map(lambda x: x < n, col_cnt))
  print(k0+k1+k2)
    

Measured memory_bytes: 5364
# https://atcoder.jp/contests/abc131/tasks/abc131_c



A, B, C, D = gets.split.map(&:to_i)

multiple_count = lambda do |x|
  B / x - (A - 1) / x
end

puts B - A + 1 - multiple_count.call(C) - multiple_count.call(D) + multiple_count.call(C.lcm(D))


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

using namespace std;
using ll = long long int;
#define long ll

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

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

    ll r = 0;
    ll m1 = 0, m2 = 0;
    for(auto &t: m) {
        ll x, c;
        tie(x, c) = t;
        if(c >= 4) 
            r = max(r, x*x);
        if(c >= 2)
            if(m1 < x) m2 = m1, m1 = x;
            else m2 = max(m2, x);
    }
    r = max(r, m1*m2);
    cout << r << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;

#define fi first
#define se second

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ll inf = ll(1e18);
const int MOD = (1e9 + 7);

ld dis(pll x,pll y){
	return sqrt((x.fi-y.fi)*(x.first-y.first)+(x.se-y.se)*(x.se-y.se));
}

int main() 
{

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	#ifdef DEBUG_
		freopen("input.txt","r",stdin);
	#endif
	cout.setf(ios::fixed), cout.precision(20);
	ll n;
	cin >> n;
	vpll vc(n);
	for(int i=0;i<n;i++){
		cin >> vc[i].fi >> vc[i].se;
	}
	vll v(n);
	for(int i=0;i<n;i++)
		v[i]=i;
	
	ld su=0.0;
	ld cnt = 0.0;
	do{
		cnt+=1.0;
		for(int i=1;i<n;i++){
			su+=dis(vc[v[i]],vc[v[i-1]]);
		}
	}
	while(next_permutation(v.begin(),v.end()));
	cout<<su/cnt<<"\n";
	return 0;
}



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

int main() {
    int n;cin>>n;
    string s;cin>>s;
    int ans = 0;
    
    rep(i,n){
        int a[26],b[26];
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        rep(j,i){
            int m = s[j]-'a';
            a[m]=1;
        }
        for(int k = i;k<n;++k){
            int m = s[k]-'a';
            b[m]=1;
        }
        int tmp = 0;
        rep(i,26)tmp+=a[i]*b[i];
        ans = max(ans,tmp);
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,m; cin >> n >> m;
    int ans=n*(n-1)/2+m*(m-1)/2;
    cout << ans << endl;
}


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

char buf[1009];

bool solve(){
	vector<int> st;
	for(int i=0; buf[i]; i++){
		st.push_back(buf[i]&15);
	}

	bool ret = false;
	while((int)st.size() > 1){
		int x = st.back(); st.pop_back();
		int y = st.back(); st.pop_back();
		int z = x + y;
		if(z <= 9){
			st.push_back(z);
		}
		else{
			st.push_back(1);
			st.push_back(z%10);
		}
		ret = !ret;
	}
	return ret;
}

int main(){
	int T;
	scanf("%d\n", &T);
	while(T--){
		scanf("%[^\n]%*c", buf);
		printf("%s wins.\n",solve()?"Fabre":"Audrey");
	}
	return 0;
}

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

using namespace std;

const int N = 100005;

int main() {
	int n;
	scanf("%d", &n);
	long long ans = 0;
	for(int i = 1; i <= n; i++) {
		if(i % 3 == 0 and i % 5 == 0);
		else if(i % 3 == 0);
		else if(i % 5 == 0);
		else ans += i;
	}
	printf("%lld\n", ans);
}


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

public class Program{
  public static void Main(){
    var n = Int32.Parse(Console.ReadLine());
    var s = Console.ReadLine().ToCharArray();
    var we = new UInt32[n,2];
    we[0,0] = 0;
    for(var i=1; i<n; i++) if(s[i]=='E') we[0,1]++;
    var m = we[0,0]+we[0,1];
    for(var i=1; i<n; i++){
      we[i,0]=we[i-1,0]; we[i,1]=we[i-1,1];
      if(s[i-1]=='W') we[i,0]++;
      if(s[i]=='E') we[i,1]--;
      if(m > we[i,0]+we[i,1]) m = we[i,0]+we[i,1];
    }
    Console.WriteLine(m.ToString());
  }
}


Measured memory_bytes: 16992