akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int64_t Undedined = 1e+17;

typedef std::vector<std::map<int64_t, int64_t>> SparseEdge;

// ワーシャル・フロイド法
vector<vector<int64_t>> warshall_floyd(int64_t N, SparseEdge &edges)
{
  vector<vector<int64_t>> d(N, vector<int64_t>(N, Undedined));
  
  for (int64_t i = 0; i < N; ++i) {
    for (auto &p : edges[i]) {
      d[i][p.first] = p.second;
    }
    d[i][i] = 0;
  }
  
  for (int64_t i = 0; i < N; ++i) {
    for (int64_t j = 0; j < N; ++j) {
      for (int64_t k = 0; k < N; ++k) {
        if (d[j][k] > d[j][i] + d[i][k]) {
          d[j][k] = d[j][i] + d[i][k];
        }
      }
    }
  }
  
  return d;
}

int main()
{
  int64_t N, M, L;
  cin >> N >> M >> L;
  
  SparseEdge distance_edges(N);
  for (uint64_t m = 0; m < M; ++m) {
    int64_t A, B, C;
    cin >> A >> B >> C;
    
    distance_edges[A - 1].emplace(B - 1, C);
    distance_edges[B - 1].emplace(A - 1, C);
  }
  
  vector<vector<int64_t>> d1 = warshall_floyd(N, distance_edges);
  
  SparseEdge refueling_edges(N);
  for (int64_t i = 0; i < N; ++i) {
    for (int64_t j = 0; j < N; ++j) {
      if (i != j && d1[i][j] <= L) {
        refueling_edges[i].emplace(j, 1);
      }
    }
  }
  
  vector<vector<int64_t>> d2 = warshall_floyd(N, refueling_edges);
  
  uint64_t Q;
  cin >> Q;
  
  for (uint64_t q = 0; q < Q; ++q) {
    uint64_t s, t;
    cin >> s >> t;
    --s; --t;
    
    if (d2[s][t] < Undedined) {
      cout << (d2[s][t] - 1) << endl;
    } else {
      cout << -1 << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 13056
from collections import deque
n, q = map(int, input().split())
g = [[] for i in range(n)]
k = []
for i in range(n-1):
  a,b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for i in range(q):
  a,b = map(int, input().split())
  k.append([a-1,b])
m = [-1]*n
m[0] = 0
m1 = [-1]*n
m1[0] = 0
q = deque()
q.append(0)
while len(q):
  d = q.popleft()
  for i in g[d]:
    if m[i] == -1:
      m[i] = m[d]+1
    if m1[i] == -1:
      m1[i] = d
      q.append(i)
kyori = [[] for i in range(max(m)+1)]
for i,j in enumerate(m):
  kyori[j].append(i)
ans= [0]*n
for i,j in k:
  ans[i]+=j
for i in kyori[1:]:
  for j in i:
    ans[j] = ans[j] + ans[m1[j]]
print(' '.join(map(str,ans)))

Measured memory_bytes: 132916
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n=int(input())
    print(n**3)
if __name__ == '__main__':
    main()

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

int main(){
  string S;
  cin >> S;
  int a = 0;
  int b = 0;
  int c = 0;
  for(int i = 0; i < 3; i++){
    if(S.at(i) == 'a'){
      a++;
    }
    if(S.at(i) == 'b'){
      b++;
    }
    if(S.at(i) == 'c'){
      c++;
    }
  }
  if(a == 1 && b == 1 && c == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

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

int main() {

    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k;j++)
        {
            for (int f = 1; f <= k;f++)
            {
                int x;
                x = gcd(f, j);
                ans += gcd(x, i);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll appear[200010] = {}; //i以上の要素の個数
  rep(i, n) appear[a[i]]++;
  for (ll i = 200005; i > 0; --i)
  {
    appear[i - 1] += appear[i];
  }

  auto simulate = [&](ll x) { //和がx以上のペアの個数がm以上か
    ll cnt = 0;
    rep(i, n)
    {
      cnt += appear[max(0LL, x - a[i])];
    }
    return cnt >= m;
  };

  auto binary_search = [&]() {
    ll lo = 0, hi = 200010;
    while (hi - lo > 1)
    {
      ll mi = (lo + hi) / 2;
      if (simulate(mi))
        lo = mi;
      else
        hi = mi;
    }
    return lo;
  };

  ll border = binary_search();

  ll csum[100010]; //添字がi以上のa[i]の和
  csum[n] = 0;
  for (ll i = n; i > 0; --i)
  {
    csum[i - 1] = csum[i] + a[i - 1];
  }

  ll sum = 0, Min = INF, add_cnt = 0;
  rep(i, n)
  {
    auto itr = lower_bound(all(a), border - a[i]);
    ll index = distance(a.begin(), itr);
    sum += a[i] * (n - index) + csum[index];
    add_cnt += n - index;
    if (index != n)
      Min = min(Min, a[i] + a[index]);
  }
  if (add_cnt > m)
  {
    sum -= Min * (add_cnt - m);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> h(N);
    REP(i,N)cin >> h[i];
    long long dp[N];
    REP(i,N)dp[i] = LLONG_MAX;
    dp[0] = 0;
    for(int i = 1;i < N;i++){
        chmin(dp[i],dp[i-1] + abs(h[i]-h[i-1]));
        if(i != 1)chmin(dp[i],dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout <<dp[N-1]<< "\n";
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#include <string>
#include <algorithm>
#define ll long long
int main()
{
    ll n,a,b,f=0,x,last;
    ll cha;
    cin>>n>>a>>b;
    cin>>x;
    last=x;
    for(int i=0;i<n-1;i++)
    {
        cin>>x;
        cha=(x-last)*a;
        if(cha<b)
        {
            f=f+cha;
        }
        else
        {
            f=f+b;
        }
        last=x;
    }
    cout<<f;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include<algorithm>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;
 
int _;

//========================================================================
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",n+n*n+n*n*n);
    return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <vector>
#include<cmath>
#include<numeric>

using namespace std;

int main() {

	string S;
	cin >> S;

	int Slen = S.length();
	int zeroOddCounter = 0;
	int zeroEvenCounter = 0;
	int OddCounter = 0;
	int EvenCounter = 0;

	for (int i = 0; i < Slen; i++) {
		if (i % 2 == 0) {
			EvenCounter++;
			if (S[i] == '0') {
				zeroEvenCounter++;
			}
		}
		if (i % 2 == 1) {
			OddCounter++;
			if (S[i] == '0') {
				zeroOddCounter++;
			}
		}
	}

	int ans = min(EvenCounter - zeroEvenCounter + zeroOddCounter, OddCounter - zeroOddCounter + zeroEvenCounter);

	cout << ans;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define inn ll arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
#define fora(i,n); for(ll i=0;i<n;i++)
#define forb(i,a,n); for(int i=a;i<n;i++)
#define mod 1000000007

int main()
{

//THIS CODE IS CREATED BY ANSHJAIN18
ll a,b;
cin>>a>>b;
if(a>b)
    swap(a,b);
for(ll i=0;i<b;i++)
    cout<<a;



return 0; }

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

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<LL, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 1e5 + 100;

LL a[N];
LL d[N];
int main() {
	int n;
	cin >> n;
	LL sum = 0;
	for(int i = 0; i < n; i ++) scanf("%lld", &a[i]);
	for(int i = 0; i < n; i ++) {
		sum += a[i];
		d[i] = a[i] - a[(i - 1 + n) % n]; 
	}
	if(sum % ((1 + n) * 1LL * n / 2) ) return puts("NO") * 0;
	LL K = sum / ((1 + n) * 1LL * n / 2);
	LL c = 0;
	for(int i = 0; i < n; i ++) {
		int t = (K - d[i]) / n;
		if(K - d[i]  < 0 || (K - d[i]) % n) return puts("NO") * 0;
		c += (K - d[i]) / n;
	}
	puts("YES");
}


Measured memory_bytes: 1792
def main():
    s = str(input())
    n = len(s)
    for i in range(2**(n-1)):
        op = ["+"]*(n-1)
        for j in range(n-1):
            if ((i >> j) & 1):
                op[j] = "-"
        formula = ""
        for p_s , p_o in zip(s, op+[""]):
            formula += p_s + p_o
        if (eval(formula)==7):
            print(formula+"=7")
            return
main()


Measured memory_bytes: 3060
if __name__ == '__main__':
    a, b = [int(i) for i in input().split()]
    symbol = None
    if a > b:
        symbol = '>'
    elif a < b:
        symbol = '<'
    else:
        symbol = '=='
    print("{0} {1} {2}".format('a', symbol, 'b'))

Measured memory_bytes: 6720
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

h, w, k = map(int, readline().split())
g = [list(readline().decode().rstrip()) for _ in range(h)]

ans = 0
for i in itertools.product([0, 1], repeat=h):
    for j in itertools.product([0, 1], repeat=w):
        cnt = 0
        for n,a in enumerate(i):
            for m, b in enumerate(j):
                if a == 1 and b == 1 and g[n][m] == '#':
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

struct Corr{
    ll index;
    ll num;
};

bool Compare(Corr a1, Corr a2){
    ll num1 = a1.num, num2 = a2.num;
    return num1 < num2;
}

int main(){
    ll n; cin >> n;
    Corr a[n];
    rep(i,n){
        ll tmp;
        cin >> tmp;
        a[i].index = i+1;
        a[i].num = tmp;
    }

    sort(a, a+n, Compare);
    rep(i,n) cout << a[i].index << " ";

}

Measured memory_bytes: 2432
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

X = int(input())
r = 0.01
s = 100

index = 1
while s <= 10 ** 18:
    s = int(s * (1 + r))
    if s >= X:
        break
    index += 1

print(index)




# def main():

# if __name__ == '__main__':
#     main()


Measured memory_bytes: 9576
if __name__ == '__main__':

	x = y = 0

	while True:

		try:
			a,b,c = map(int,input().split(","))

			if a*a + b*b == c*c:
				x += 1
			elif a == b:
				y += 1

		except EOFError:
			break

	print(x)
	print(y)




Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
const int MD=1e9+7;
int pri[N],tot,phi[N];
bool p[N];
void init() {
    p[1]=true,phi[1]=1;
    for(int i=2;i<N;i++) {
        if(!p[i]) pri[++tot]=i,phi[i]=i-1;
        for(int j=1;j<=tot&&i*pri[j]<N;j++) {
            p[i*pri[j]]=true;
            if(i%pri[j]==0) {
                phi[i*pri[j]]=phi[i]*pri[j];
                break;
            }
            else phi[i*pri[j]]=phi[i]*(pri[j]-1);
        }
    }
}
int quick_pow(int x,int y) {
    int ans=1;
    while(y) {
        if(y&1) ans=1LL*ans*x%MD;
        y>>=1;
        x=1LL*x*x%MD;
    }
    return ans;
}
void add(int &x,int y) {
    x+=y;
    if(x>=MD) x-=MD;
}
int main() {
    init();
    int n,k,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++) {
        add(ans,1LL*quick_pow(k/i,n)*phi[i]%MD);
    }
    printf("%d\n",ans);
}

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

int main() {
	int i,j=0,k;
	string ar,br;
	cin>>ar;
	cin>>br;
	for(i=0;i<3;i++){
		if(ar[i]==br[i]){
			j++;
		}
	}
	cout<<j<<'\n';
	return 0;
}

Measured memory_bytes: 256
T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if T[0]* A[0] + T[1] * A[1] == T[0] * B[0] + T[1] * B[1]:
    print('infinity')
else:
    ans = 0
    A_pos = 0
    B_pos = 0
    before_state = -1 # 0:A>B, 1:A < B, -1:A=B
    flag = True
    diff = abs(T[0]* A[0] + T[1]* A[1] - (T[0]* B[0] + T[1]* B[1]))
    diff_max = max(abs(A[0] - B[0])*T[0],  abs(A[1] - B[1])*T[1])
    max_num = int(diff_max/diff)
    up_num_first = 0
    for i in range(2):
        A_pos += T[i]* A[i]
        B_pos += T[i]* B[i]
        if A_pos > B_pos:
            if before_state == 0:
                up_num_first += 1
            before_state = 1
        elif A_pos < B_pos:
            if before_state == 1:
                up_num_first += 1
            before_state = 0
        elif A_pos == B_pos:
            up_num_first += 1
            before_state = -1
    A_pos_first = A_pos
    B_pos_first = B_pos
            
    up_num_second = 0
    for i in range(2):
        A_pos += T[i]* A[i]
        B_pos += T[i]* B[i]
        if A_pos > B_pos:
            if before_state == 0:
                up_num_second += 1
            before_state = 1
        elif A_pos < B_pos:
            if before_state == 1:
                up_num_second += 1
            before_state = 0
        elif A_pos == B_pos:
            up_num_second += 1
            before_state = -1

    A_pos = A_pos_first * (max_num - 1)
    B_pos = B_pos_first * (max_num - 1)
    up_num_final = 0
    for i in range(2):
        A_pos += T[i]* A[i]
        B_pos += T[i]* B[i]
        if A_pos > B_pos:
            if before_state == 0:
                up_num_final += 1
            before_state = 1
        elif A_pos < B_pos:
            if before_state == 1:
                up_num_final += 1
            before_state = 0
        elif A_pos == B_pos:
            up_num_final += 1
            before_state = -1
    if max_num > 1:
        ans = up_num_first  + (max_num - 2) * up_num_second  + up_num_final
    else:
        ans = up_num_first  + (max_num - 1) * up_num_second
    print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
int main()
{
	int w, h, x,y,r;
	scanf("%d %d %d %d %d", &w, &h, &x,&y,&r);
	if ((x + r <= w) && (x - r>=0) && (y + r <= h) && (y - r>=0))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 2620
#include <iostream>

int main(){
    std::string s;
    std::cin >> s;

    std::string ans = "";
    for(int i = 0; i < (s.size() + 1) / 2; ++i){
        ans += s.at(i * 2);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    
    string s, t;
    cin >> s >> t;
    int m = s.size(), n = t.size();
    vector<vector<int>> dp(m+1, vector<int>(n+1,0));
    for(int i=0; i<=m; ++i) {
        for(int j=0; j<=n; ++j) {
            if(i==0 || j==0) {
                dp[i][j] = 0;
            }
            else if(s[i-1] == t[j-1]) {
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    string res = "";
    int i=m, j=n;
    while(i>0 && j>0) {
        if(s[i-1]==t[j-1]) {
            res += s[i-1];
            i--; j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]) {
            i--;
        }
        else {
            j--;
        }
    }
    reverse(res.begin(), res.end());
    cout << res << "\n";
	return 0;
}


Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, x, pmin=1001; cin >> n >> x;
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		x -= p;
		pmin = min(pmin, p);
	}
	cout << n + x / pmin << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,N,s,ans;
  cin>>N;
  s=0;
  vector<int> A(N);
  for(i=0;i<N;++i){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  ans=A[N/2]-A[N/2-1];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <time.h>
#include <assert.h>


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    ll tt;
    // cin>>tt;
    tt=1;
    while(tt--){
        ll x,n;
        cin>>x>>n;
        if(n==0){
            cout<<x;
            return 0;
        }
        ll v[n];
        set<ll> st;
        For(i,0,n){
            cin>>v[i];
            st.insert(v[i]);
        }
        ll mn = INF;
        ll ans = -1000;
        vector<ll> a;
        For(i,-105,105){
            if(st.count(i) == 0)
                a.pb(i);
        }
        For(i,0,a.size()){
            if(abs(x-a[i])<mn){
                mn = abs(x-a[i]);
                ans = a[i];
            }
            else if(abs(x-a[i])==mn)
                ans = min(a[i],ans);
        }
        cout<<ans;
    }    
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){

    ll N,K,res;


    cin >> N >> K;
    vector<ll> h(N);


    REP(i,N)
    {
        cin >> h[i];
    }

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

    res = 1000000001;

    for(ll j = 0; j <= N - K; j++)
    {

        res = min(res, h[j + K - 1] - h[j]); 
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
def f s, c
	cs = s.chars
	count = 0
	while cs.uniq.size!=1
		ncs = (cs.size - 1).times.map{|i|
			if cs[i]==c or cs[i+1]==c
				c
			else
				cs[i]
			end
		}
		cs = ncs
		count += 1
	end
	count
end

s = gets.chomp
puts ('a'..'z').map{|c| f s, c}.min

Measured memory_bytes: 2172
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll n,a=0,b=0,c=0,d=0;
	string s;
	cin >> n;
	while(n--){
		cin >> s;
		if(s=="AC"){
			a++;
		}
		else if(s=="TLE"){
			b++;
		}
		else if(s=="WA"){
			c++;
		}
		else if(s=="RE"){
			d++;
		}
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << c << endl;
	cout << "TLE x " << b << endl;
	cout << "RE x " << d << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
#include<algorithm>
int main()
{
    int n,sum,i,j=1;
    int a[100];
    memset(a,1,sizeof(a));
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    sum=0;
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            ///printf("%d**\n",a[i]*a[j]);
            sum+=a[i]*a[j];
            ///printf("%d***\n",sum);
        }
    }
    j++;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),m=sc.nextInt(),x=sc.nextInt(),min=Integer.MAX_VALUE;
    int[][] a=new int[n][m+1];
    for(int i=0;i<n;i++) {
    	for(int j=0;j<=m;j++)a[i][j]=sc.nextInt();
    }
	for(int i=0;i<Math.pow(2, n);i++) {
		int[] status = new int[n];
		for(int j=0;j<n;j++) {//iを2進数にした場合にどこの桁が1になっているか判定し、1の場合はstatusに代入
			if((1&i>>j)==1) {
				status[j]=1;
			}
		}
		int[] res=new int[m+1];
		for(int j=0;j<n;j++) {
			if(status[j]==1) {
				for(int k=0;k<=m;k++) {
					res[k]+=a[j][k];
				}
			}
		}
		boolean flag=true;
		for(int j=1;j<=m;j++) {
			if(res[j]<x) {
				flag=false;
				break;
			}
		}
		if(flag)min=Math.min(min, res[0]);
	}
	if(min==Integer.MAX_VALUE)System.out.println(-1);
	else System.out.println(min);
  }
}


Measured memory_bytes: 38344
#include <stdio.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define N 1000010
int main(){
	int n,t,a[N]={0},ans=0;
	scanf("%d",&n);
	rep(i,n){scanf("%d",&t);a[t]++;}
	rep(i,N){//ふるい
		if(!a[i])continue;
		if(a[i]==1)ans++;else a[i]=0;
		for(int j=i*2;j<N;j+=i)a[j]=0;
	}
	printf("%d",ans);
}

Measured memory_bytes: 5640
#include<stdio.h>

using namespace std;

int main(){
  int n;
  int *p;
  int sum=0, suma=0, sumb=0;
  int i;
  int *a,*b;

  scanf("%d", &n);
  p = new int[2*n];
  for(i=0;i<2*n;++i){
    scanf("%d", &p[i]);
  }
  a = new int[n];
  b = new int[n];
  for(i=0;i<n;++i){
    suma += p[i];
    sumb += p[2*n-1-i];
    a[i] = suma;
    b[n-1-i] = sumb;
  }
  for(i=0;i<n;++i){
    if(a[i]+b[i] > sum) sum = a[i]+b[i];
  }
  printf("%d\n", sum);

  delete [] p;
  delete [] a;
  delete [] b;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
     string a;
     cin>>a;
     int n=a.length();int res=0;
     for(int i=0;i<n/2;i++)
     {
         if(a[i]!=a[n-1-i])
         {
             res++;
         }
     }
     cout<<res;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;


int main() {
	int N; cin >> N;
	vector<int> u(N,99);
	vector <vector<int>> z(N);
	map <pair<int, int>,long long> x;
	queue<int> a;
	for (int i = 0; i < N - 1; i++) {
		int f, b, c;
		cin >> f >> b >> c;
		f--; b--;
		x[{f, b}] = c%2; x[{b, f}] = c%2;
		z[f].push_back(b); z[b].push_back(f);
	}
	u[0] = 0;
	a.push(0);
	while(a.size()!=0) {
		int y;
		y = a.front();
		a.pop();
		for (int i = 0; i < z[y].size(); i++) {
			if(u[z[y][i]]==99)a.push(z[y][i]);
			u[z[y][i]] = x[{y, z[y][i]}] ^ u[y];
		}
	}

	for (int i = 0; i < N; i++) cout << u[i] << endl; 
}




Measured memory_bytes: 18816
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){
  return a < b ? a : b;
}

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=1; tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}



Measured memory_bytes: 11852
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int P = sc.nextInt();
    int i = A*3;
    P += i;
    int ans = P/2;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

//modしながら塁乗
ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){
  string s;
  cin>>s;
  if(s == "zyxwvutsrqponmlkjihgfedcba"){
    cout<<-1<<endl;
    return 0;
  }
  bool count[26];
  REP(i,26){
    count[i] = false;
  }

  int temp = 0;
  while(temp<s.length()){
    if(s.length()==26)break;
    if(s.length()==26&&s[temp+1]=='z')break;
    cout<<s[temp];
    count[s[temp]-'a'] = true;
    temp++;
  }
  REP(i,26){
    if(s.length()==26)break;
    if(count[i]==false){
      char c = 'a' + i;
      cout<<c<<endl;
      break;
    }
  }
  if(s.length()==26){
    int p = 25;
    for(int i=24;i>=0;i--){
      if(s[i] - s[i+1]<0){
        p = i;
        break;
      }
    }
    REP(i,p){
      cout<<s[i];
      count[s[i]-'a'] = true;
    }
    for(int i=s[p]-'a'+1;i<26;i++){
      if(count[i]==false){

        cout<<(char)('a'+i)<<endl;
        break;
      }
    }

  }

 

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def solve(N, M, A, B, C):
    key = []  # type: "List[List[int, int]]"
    for i in range(M):
        s = 0
        for j in range(B[i]):
            s |= 1 << (C[i][j] - 1)
        key.append([s, A[i]])
    
    INF = 1001001001
    dp = [INF] * (1 << N)
    dp[0] = 0
    for s in range(1 << N):
        for i in range(M):
            t = s | key[i][0]
            cost = dp[s] + key[i][1]
            dp[t] = min(dp[t], cost)
    ans = dp[-1]
    print(-1 if ans == INF else ans)
    pass


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A, B, C = [], [], []
    for _  in range(M):
        A.append(int(next(tokens)))
        B.append(int(next(tokens)))
        C.append([int(next(tokens)) for _ in range(B[-1])])
    solve(N, M, A, B, C)

if __name__ == '__main__':
    main()


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

int main()
{


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

        for (int i = 0; i < 1250; ++i) {

                int ap = (i+1)/100. * 8;
                int bp = (i+1)/100. * 10;
                if (ap == A && bp == B) {
                        cout << i+1 << endl;
                        exit(0);
                }
        }
        cout << -1 << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n,k;
    cin>>n>>k;
    int a[n]={};
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int c;
            cin>>c;
            c--;
            a[c] = 1;
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(a[i] == 0)ans++;
    }
    cout << ans << endl;
}

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

static vector<long> wList;
static vector<long> vList;

int main() {
  // 入力受け取り
  int N,W;
  cin >> N >> W;
  wList.resize(N);
  vList.resize(N);
  for(int i=0; i<N; i++) cin >> wList.at(i) >> vList.at(i);
  long long retList[N+2][W+2];
  memset(retList, 0, sizeof(retList));
  
  // 2dimention plot by dp
  for (int n=0; n<=N; n++) {
    for (int w=0; w<=W; w++) {
      if (w-wList[n] >= 0) {
        retList[n+1][w] = max(retList[n+1][w],retList[n][w-wList[n]] + vList[n]);
      }
      retList[n+1][w] = max(retList[n+1][w],retList[n][w]);
      //cout << "n+1:" << n+1 << " w:" << w << " " << retList[n+1][w] << endl;
    }
  }

  cout << retList[N][W] << endl;
}


Measured memory_bytes: 80000
using System.Collections.Generic;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var length = ToInt32(ReadLine());
        var str = ReadLine();
        var max = 0;
        for(var i = 1;i< length - 1; i++)
        {
            var str1 = str.Substring(0, i);
            var str2 = str.Substring(i);
            var chara1 = new HashSet<string>();
            var same = 0;
            for(var j = 0; j < str1.Length; j++)
            {
                chara1.Add(str1.Substring(j, 1));
            }
            for(var j = 0; j < str2.Length; j++)
            {
                var chara = str2.Substring(j, 1);
                if (chara1.Contains(chara)) { same++;chara1.Remove(chara); }
            }
            if (max < same) max = same;
        }

        WriteLine(max);
    }
}



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

int main(){
	string s;
	cin >> s;
	int ans = s.length();
	for (int i = 0; i < s.length()-1; i++){
		if (s[i] != s[i+1]){
			int temp = max(i+1, (int)s.length()-i-1);
			ans = min(temp, ans);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int n,k;cin>>n>>k;
  if(n!=2&&k!=2) {
    ll C[n+10][k+10];
    for(int i=0;i<=max(n-k+1,k-1);++i) {
      for(int j=0;j<=k;++j) {
        if(j==0 || i==j) {
          C[i][j] = 1;
        } else if(j==1) {
          C[i][j] = i;
        } else {
          C[i][j] = (C[i-1][j] + C[i-1][j-1])%(1000000000+7);
        }
      }
    }

    // for(int i=0;i<=max(n-k+1,k-1);++i) {
    //   for(int j=0;j<=i;++j) {
    //     pr(i,j,C[i][j]);
    //   }
    // }

    // pr("===");

    for(int i=1;i<=k;++i) {
      pr((C[n-k+1][i]*C[k-1][i-1])%(1000000000+7));
    }
  } else {
    pr(1);
    pr(0);
  }

  return 0;
}


Measured memory_bytes: 31616
N = int(input())

def PF(n):
    res = {}
    m = int(n**0.5)
    for i in range(2,m+1):
        cnt = 0
        while n % i == 0:
            n = n//i
            cnt+=1
        if cnt > 0:
            res[i] = cnt
    if n > 1:
        res[n] = 1
    return res

def solve(N):
    ans = 0
# N|K
    pf = PF(N)
    ps,fs = zip(*pf.items())
    cand = []
    pss = []
    for p,f in pf.items():
        pss.extend([p]*f)
    pts = set([1])
    for p in pss:
        nps = [q*p for q in pts]
        pts = pts.union(nps)
    for p in pts:
        if p == 1:
            continue
        M = N
        while M % p == 0:
            M //= p
        if M % p == 1:
            cand.append(p)

    # N |/ K
    M = int(N**0.5+1)
    cand2 = [i for i in range(2,M) if N % i == 1]
    for m in cand2[:]:
        k = (N-1)//m
        cand2.append(k)
    if N >= 3:
        cand.append(N-1)

    cand2 = set(cand2)
    return len(cand)+len(cand2)

print(solve(N))


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

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	vector<string> vec(h);
	rep(i, h) cin >> vec.at(i);
	rep(i, h + 2) {
		if (i == 0 || i == h + 1)
			cout << string(w + 2, '#') << "\n";
		else
			cout << "#" << vec.at(i - 1) << "#" << "\n";
	}
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, l;
string s[100];

int main() {
	cin >> n >> l;
	inc(i, n) { cin >> s[i]; }
	
	sort(s, s + n);
	
	inc(i, n) { cout << s[i]; }
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
def getlist():
    return list(map(int, input().split()))

N = int(input())
A = getlist()
B = getlist()

ans = 0
for i in range(N):
    if B[i] >= A[i]:
        ans += A[i]
        B[i] -= A[i]
        if B[i] >= A[i + 1]:
            ans += A[i + 1]
            A[i + 1] = 0
        else:
            ans += B[i]
            A[i + 1] -= B[i]
    else:
        ans += B[i]

print(ans)

Measured memory_bytes: 82148
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        if(n == 0) {
            System.out.println(x);
            return;
        }
        int[]p = new int [101];
        for(int i=0; i<n; i++) {
            p[sc.nextInt()] = 1;
        }
        for(int i=0; i<101; i++) {
            if(x-i >= 0) {
                if(0 == p[x-i]) {
                    System.out.println(x-i);
                    return;
                }
            } else {
                System.out.println(-1);
                return;
            }
            if(x+i <101) {
                if(0 == p[x+i]) {
                    System.out.println(x+i);
                    return;
                }
            }else {
                System.out.println(101);
                return;
            }
        }
    }
}

Measured memory_bytes: 35820
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

	vector<int> a(n, 0);
	for (auto& ai : a)
		cin >> ai;

	sort(a.begin(), a.end(), greater<int>());

	int alice = 0, bob = 0;
	for (int i = 0; i < n; ++i)
		if (i % 2 == 0)
			alice += a[i];
		else
			bob += a[i];

	cout << alice - bob << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using i64=int64_t;
 
#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}
 
void solve(){
    string s;
    cin >> s;

    int N=s.size();

    vector<int> a(N+1);
    rep(i,1,N+1) a[i]=a[i-1]^(1<<(s[i-1]-'a'));

    vector<int> opt(N+1);
    static int dp[1<<26];
    fill_n((int*)dp,1<<26,inf);
    opt[0]=0;
    rep(i,1,N+1){
        if(a[i]==0) opt[i]=1;
        else opt[i]=dp[a[i]]+1;
        rep(j,0,26){
            opt[i]=min(opt[i],dp[a[i]^(1<<j)]+1);
            if(a[i]==(1<<j)) opt[i]=1;
        }
        dp[a[i]]=min(dp[a[i]],opt[i]);
    }

    cout << opt[N] << endl;
}
 
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 264340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,P;
    cin >> A >> P;
    cout << (A*3+P)/2 << endl;



}


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

int main()
{
	vector<int> vec[2];
	int n;
	cin >> n;
	vec[0].resize(n);
	vec[1].resize(n);
	int sum1 = 0, sum2=0,mx=0;
	for (int i = 0; i < 2; i++)
	{
		sum2 = 0;
		for (int j = 0; j < n; j++)
		{
			int t;
			cin >> t;
			vec[i][j] = t;
			sum2 += t;
		}
	}

	for (int i = 0; i < n; sum2-=vec[1][i],i++)
	{
		sum1 += vec[0][i];
		if ((sum1 + sum2) > mx)
			mx = sum1 + sum2;
	}
	cout << mx << endl;
	return 0;
	
}

Measured memory_bytes: 256
score = list(map(int,input().split()))
kenl = list(map(int,input().split()))

syoki = 0
syoki = kenl[0]+(score[0]-kenl[score[1]-1])
length = [0]*score[1]
length[0] = syoki
for i in range(score[1]-1):
    length[i+1] = kenl[i+1]-kenl[i]

length.sort()
answer = length[score[1]-1]
print(score[0]-answer)

Measured memory_bytes: 99852
N = int(input())
A = list(map(int, input().split()))
AM = []
AP = []
AMlist = [0] * N
APlist = [0] * N

for i in range(N):
  plus = i+1 + A[i]
  AP.append(plus)  
  if AP[i] <= N:
    APlist[AP[i]-1] += 1
  minus = i+1 - A[i]
  AM.append(minus)
  if AM[i] > 0 and AM[i] <= N:
    AMlist[AM[i]-1] += 1
    
ans = 0

for j in range(N):
  ans += APlist[j] * AMlist[j]

print(ans)

Measured memory_bytes: 38016
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using P = pair<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

ld dist(ld x1,ld y1,ld x2,ld y2){
    return (ld)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ld X;
    cin >> X;
    ld nowX=0.0;
    ld nowY=0.0;
    for(ll i=0;;++i){
        nowX+=cos(X*i*pi/180.0);
        nowY+=sin(X*i*pi/180.0);
        if(dist(0.0,0.0,nowX,nowY)<eps){prt(i+1);return 0;}
    }

    return 0;
}



Measured memory_bytes: 4108
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
    int n;
    cin >> n;
    if(n < 1000)
        cout << "ABC" << endl;
    else
        cout << "ABD" << endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)

l = 0; r = n-1

ans = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    else:
        if s[l] == 'x':
            l += 1
            ans += 1
        elif s[r] == 'x':
            r -= 1
            ans += 1
        else:
            ans = -1
            break
print(ans)

Measured memory_bytes: 3316
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n,m):
        a = [LI() for _ in range(n)]
        t = collections.defaultdict(int)
        for d,v in a:
            if t[d] < v:
                t[d] = v
        r = 0
        for i in range(1, m+1):
            r += t[i]
        return r

    while 1:
        n,m = LI()
        if n == 0:
            break
        rr.append(f(n,m))

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e18;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

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

  ll ans = 0;
  for (ll a = 1; a < n; a++){
    for (ll b = 1; b < n/a + 1; b++){
      if ((n - a * b) > 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    vector<int> array;
    int x;
    int count;
    
    while(1)
    {
        cin >> x;
        if(x == 0)
        {
            break;
        }
        else
        {
            array.push_back(x);
            count++;
        }
    }

    for(int i = 0; i < count; i++)
    {
        cout << "Case " << i+1 << ": " << array[i] << endl;
    }
    return 0;
} 

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

int main(void){
    int h,w;
    cin>>h>>w;
    char c[h][w];
    for(int i=0;i<h;i++){
        for(int k=0;k<w;k++){
            cin>>c[i][k];
        }
        for(int j=0;j<=1;j++){
            for(int k=0;k<w;k++){
            cout<<c[i][k];
            }
        cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

s = list(ns())
ans = []
for i in range(0, len(s), 2):
    ans.append(s[i])
print(''.join(ans))


Measured memory_bytes: 4392
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from collections import Counter
import sys
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7
A = Counter(A)

if N % 2 == 1:
    for num, cnt in A.items():
        # print(num, cnt)
        if num == 0:
            if cnt != 1:
                print(0)
                sys.exit()
        else:
            if not (num % 2 == 0 and cnt == 2):
                print(0)
                sys.exit()
    print((2 ** (N // 2)) % MOD)
else:
    for num, cnt in A.items():
        # print(num, cnt)
        if not (num % 2 == 1 and cnt == 2):
            print(0)
            sys.exit()
    print((2 ** (N // 2)) % MOD)


Measured memory_bytes: 14812