akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define sz(x) (x).size()
#define lowbit(x) (x)&(-x)
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))

namespace FastIO {
#define BUF_SIZE 100000
#define OUT_SIZE 100000
	bool IOerror=0;
	inline char nc() {
		static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
		if(p1==pend) {
			p1=buf;
			pend=buf+fread(buf,1,BUF_SIZE,stdin);
			if(pend==p1) {
				IOerror=1;
				return -1;
			}
		}
		return *p1++;
	}
	inline bool blank(char ch) {
		return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';
	}
	template<class T> inline bool read(T &x) {
		bool sign=0;
		char ch=nc();
		x=0;
		for(; blank(ch); ch=nc());
		if(IOerror)return false;
		if(ch=='-')sign=1,ch=nc();
		for(; ch>='0'&&ch<='9'; ch=nc())x=x*10+ch-'0';
		if(sign)x=-x;
		return true;
	}
	template<class T,class... U>bool read(T& h,U&... t) {
		return read(h)&&read(t...);
	}
#undef OUT_SIZE
#undef BUF_SIZE
};
using namespace std;
using namespace FastIO;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 0x3f3f3f3f;

ll a,b,n;

ll get(ll x){
	ll ans=(a*x)/b-a*(x/b);
	return ans;
}

int main() {

#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	
	read(a,b,n);
	ll l=1,r=n;
	while(r>l) {
		ll m1=l+(r-l)/3;
		ll m2=r-(r-l)/3;
		if(get(m1)>get(m2))
			r=m2-1;
		else
			l=m1+1;
	}
	cout<<get(l)<<endl;




	return 0;
}



Measured memory_bytes: 3592
#include<stdio.h>
int main (void)
{
	int N;
	scanf("%d",&N);
	int A[N];
	for(int i=0;i<N;i++) scanf("%d",&A[i]);
	int j=0;
	int k=0;
	while (k >= 0){
		for(int i = 0;i < N;i++){
			if (A[i] % 2 ==1) {
				k--;
				break;
			}
		}
		if(k<0)break;
		for(int i=0;i<N;i++)A[i]=A[i] / 2;
		j++;
	}
	printf("%d",j);
	return 0;
}


Measured memory_bytes: 128
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>  
#define endl "\n"
using namespace std;
	typedef long long ll;
	const int maxn=105000;
	const int inf=0x3f3f3f3f;
	ll w[105];
	ll v[105];
	ll dp[maxn];
	ll n,m;
	int main(){
		IOS
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>w[i]>>v[i];
		for(int i=2;i<=n+1;i++)
			for(int j=0;j<=m;j++)
				if(j+w[i-1]<=m)
					dp[j]=max(dp[j],dp[j+w[i-1]]+v[i-1]);
			
		ll ans=-1;
		for(int j=0;j<=m;j++)
			ans=max(ans,dp[j]);
		cout<<ans<<endl;
	}

Measured memory_bytes: 4420
/*💚💚💚 ITS A SLOW PROCESS BUT QUITING WONT SPEED IT UP 💚💚💚*/

#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <complex>
#include <cctype>

using namespace std;

/*-------------define----------------------------*/
#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ceilval(a,b)    (a+b-1)/ b
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define cf(x)            ll x; cin>>x; while(x--)

/*---------------bak****i end-----------------------*/


void zaroorat()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}


int main()

  {
      zaroorat();

      char inp;
      cin>>inp;

      if(inp>='A' && inp<='Z'){
        cout<<"A"<<endl;

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


    return 0;
  }


Measured memory_bytes: 3648
s=raw_input()
for i in range(ord('a'), ord('a')+26):
	if s.find(chr(i))==-1:
		print s+chr(i)
		exit(0)
for i in range(25, 0, -1):
	if s[i]>s[i-1]:
		print s[0:i-1]+min([ch for ch in s[i:] if ch>s[i-1]])
		quit()
assert s=='zyxwvutsrqponmlkjihgfedcba'
print -1

Measured memory_bytes: 2568
n,k=map(int, input().split()) 
p=0
for i in range(n):
    dice=i+1
    k_=k/dice
    p_=1
    if dice<k:
        while(k_>1):
            k_/=2
            p_*=0.5
    p+=p_/n
print(p)

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

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

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

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

	ll n,i,j;

	cin >> n;

	vector <ll> b(n);
	ll a[n];

	memset(a,0,sizeof(a));

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

	a[0] = 0;
	a[1] = abs(b[1] - b[0]);

	for(i=2;i<n;i++)
	{
		a[i] = min(abs(b[i] - b[i-1]) + a[i-1] , abs(b[i] - b[i-2]) + a[i-2]);
	}

	cout << a[n-1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

ll maxProductSubarrayOfSizeK(ll A[], ll n, ll k) 
{ 
     sort(A, A + n); 
     ll product = 1; 
    
     if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
     
     if (A[n - 1] <= 0 && (k & 1)) { 
        
        for (ll i = n - 1; i >= n - k; i--) 
            {   
                product = (((product%mod)*( (A[i])%mod))%mod +mod)%mod; 
            }
        return product; 
    } 
  
    ll i = 0; 
    ll j = n - 1; 

    if (k & 1) { 
            product = (((product%mod)*( (A[j])%mod))%mod +mod)%mod; 
            if(product<0)product+=mod;
            j--; 
            k--; 
    } 
    k >>= 1; 
   
    for (ll itr = 0; itr < k; itr++) { 
   
        ll left_product = A[i] * A[i + 1]; 
        ll right_product = A[j] * A[j - 1]; 
        if (left_product > right_product) { 
            product = (((product%mod) *(left_product%mod))%mod+mod)%mod; 
            i += 2; 
        } 
        else { 
            
            product = (((product%mod)*(right_product%mod))%mod +mod)%mod; 
            j -= 2; 
        } 

    } 
 
    return product; 
} 

int main()
{   ll n,k;cin>>n>>k; ll ar[n]; for(ll i=0;i<n;i++){cin>>ar[i] ;} 
    ll c= maxProductSubarrayOfSizeK(ar,n,k) ; 
     // if(c<0)
       //c+=mod;
    cout<<c<<endl;   
}


Measured memory_bytes: 5152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ProblemB_IronBarCutting {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }
            long[] s = new long[n + 1];
            for (int i = 0; i < n; i++) {
                s[i + 1] = s[i] + a[i];
            }
            long ans = Long.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                long l = s[i];
                long r = s[n] - s[i];
                ans = Math.min(ans, Math.abs(l - r));
            }
            out.println(ans);
        }

    }

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

        public FastScanner(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());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 53596
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; i++) cin >> s[i] >> t[i];
  string x;
  cin >> x;
  
  int ans = accumulate(t.begin(), t.end(), 0);
  for (int i = 0; i < n; i++) {
    if (ans >= 0) ans -= t[i];
    if (s[i] == x) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue> 
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
int a[100100];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int tmp=INF,t=0;
    for (int i=1; i<=n; i++) 
        {scanf("%d",&a[i]); tmp=min(tmp,a[i]);}
    for (int i=1; i<=n; i++)
        if (tmp==a[i]) t++;
    printf("%d\n",(n-t+k-2)/(k-1));
    return 0;
}
    


Measured memory_bytes: 640
//セグ木区間和的な
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>;
using vvi = vector<vi>;

ll n,k,x,y;

//区間和とかのための
class SegTree_r
{
  public:
  ll n2,ln2;//2のべき乗になる数でn以上の数//n2のlog2値
  vector<ll> data;//●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  SegTree_r(ll logn)
  {
    ln2=logn;
    n2=1<<logn;
    data.resize(n2*2);
    for(ll i=0;i<n2*2;i++)
      data[i]=0;//●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  }
  //ある要素の値を取得、今まで加算した区間和 O(logn)
  ll GetVal(ll posi)
  {
    ll v=0;//●●●●●●●●●●●●●●●●●●●
    ll myi=posi+n2;
    v+=data[myi];//葉
    for(ll i=0;i<ln2;i++){//中間要素
      myi/=2;
      v+=data[myi];
    }
    return v;
  }
  //lを含むrを含まないところまでの区間にv値を加算
  void AddRange(ll l,ll r,ll v)
  {
    ll ret=data[l];
    ll l_=l;
    ll r_=r;
    for(ll i=0;(l_+r_)>0;i++){
      ll offset=1<<(ln2-i);
      if (r_%2==1){
          if (r_-1>=l_){
            data[offset+r_-1]+=v;
            r_--;
          }
      }
      if (l_%2==1){
          if (l_<r_){
            data[offset+l_]+=v;
            l_++;
          }
      }
      r_>>=1;
      l_>>=1;
    }
  }
};















int main(){
  ll ans=0;
  n=200000;
  ll logn=18;
  SegTree_r segtree_r(logn);//nが200000なら18をいれる

  
  cin >> n >> k;
  vi a(n),b(n);
  REP(i,n) cin>>a[i];

  for(ll i=0;i<min(k,42LL);i++){
    
    for(ll j=0;j<segtree_r.n2*2;j++)
      segtree_r.data[j]=0;//●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

    for(ll j=0;j<n;j++){
      segtree_r.AddRange(max(j-a[j],0LL),min(j+1LL+a[j],n),1LL);
    }

    for(ll j=0;j<n;j++){
      a[j]=segtree_r.GetVal(j);
    }

  }

/*
  segtree_r.AddRange(0,98,100);
  segtree_r.AddRange(1,28,10);
  segtree_r.AddRange(2,11,1);

  cout<<segtree_r.GetVal(0)<<endl;
  cout<<segtree_r.GetVal(1)<<endl;
  cout<<segtree_r.GetVal(2)<<endl;
  cout<<segtree_r.GetVal(5)<<endl;
  cout<<segtree_r.GetVal(10)<<endl;
  cout<<segtree_r.GetVal(11)<<endl;
  cout<<segtree_r.GetVal(12)<<endl;
  cout<<segtree_r.GetVal(99)<<endl;
*/

  for(ll i=0;i<n;i++){
    cout<<segtree_r.GetVal(i)<<" ";
  }
  cout<<endl;
  return 0;
}



/*
200000 42
0 0 0 0 0 0 0 0 0 0
*/

/*



int main(){

  
    
      
      
    }
    
  }


  cout<<ans<<endl;
  return 0;
}
*/

Measured memory_bytes: 10388
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int X = sc.nextInt();
			
			boolean[] cans = new boolean[X + 1];
			cans[0] = true;
			for(int price = 100; price <= 105; price++) {
				for(int i = 0; i <= X - price; i++) {
					cans[i + price] |= cans[i];
				}
			}
			
			System.out.println(cans[X] ? 1 : 0);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21460
n = int(input())
A = list(map(int, input().split()))
for i in range(1, n):
    A[i] = A[i] + A[i-1]
ans = 0
A.sort()
p = A[0]
count = 1
for i in range(1, n):
    x = A[i]
    if x == p:
        count += 1
    else:
        if p == 0:
            ans += count
        ans += count * (count-1)//2
        count = 1
        p = x
if p == 0:
    ans += count
ans += count * (count-1)//2
print(ans)


Measured memory_bytes: 25976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		String s = scanner.next();
		int length = s.length();
		for (int i = 0; i < length; i++) {
			System.out.print((char) ('A' + (s.charAt(i) - 'A' + n) % 26));
		}
	}

}


Measured memory_bytes: 26580
val1 = gets.chomp.to_i
array1 = gets.chomp.split(" ").map(&:to_i)
val2 = gets.chomp.to_i
array2 = gets.chomp.split(" ").map(&:to_i)

def solution(temp1, temp2)
  ans = 0

  temp1.each do |val|
    if temp2.include?(val)
      ans += 1
    end
  end

  if ans.to_i.zero?
    0
  else
    ans
  end
end

if array1.length < array2.length
  puts solution(array1, array2)
else
  puts solution(array2, array1)
end

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int S, W; cin >> S >> W;
	if (W >= S) cout << "unsafe\n";
	else cout << "safe\n";
	return 0;
}

Measured memory_bytes: 3552
def reads():
    return list(map(int, input().split()))

MOD = 10**9 + 7

N, M = reads()
proh = set()
for _ in range(M):
    a, = reads()
    proh.add(a)

res = [0] * (N + 2)
res[0] = 1
for i in range(1, N+1):
    if i not in proh:
        res[i] = (res[i-1] + res[i-2]) % MOD
print(res[N])

Measured memory_bytes: 52696
#include <bits/stdc++.h>
#define mp make_pair
#define pb emplace_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,begin,end) for(__typeof(end) i = (begin)-((begin)>(end)); i != (end)-((begin)>(end)); i += 1-2*((begin)>(end)))
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 1e-8
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 303030
#define LOGN 20
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;


int tree[MAXN][2], n, root = 1, ptr = 2;
ll l, ans;
char s[MAXN];

ll get(ll v){
	rep(i,0,63) if(!(v&(1LL<<i))) return (1LL<<i);
	assert(0);
	return 0;
}

void dfs(int v, ll d){
	int cnt=0;
	rep(i,0,2) if(tree[v][i]) cnt++, dfs(tree[v][i],d-1);
	if(cnt==1)
		ans ^= get(d);
}

void insert(int node, char * s){
	if(!*s){ assert(!tree[node][0] && !tree[node][1]); return; }
	int b = *s - '0';
	if(!tree[node][b]) tree[node][b] = ptr++;
	insert(tree[node][b],s+1);
}

int main(){
	rep(i,0,MAXN) tree[i][0] = tree[i][1] = 0;
	scanf("%d%lld", &n, &l);
	rep(i,0,n){
		scanf("%s", s);
		insert(root,s);
	}
	dfs(root,l-1);
	if(ans) puts("Alice");
	else puts("Bob");
}



Measured memory_bytes: 5888
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define MOD 998244353



long long N, A, B, K;


//逆元で二項係数を計算(MODは素数)　前処理O(n),本計算O(1)
#define MAXN 300001
long long inv[MAXN + 1];//MODを法とする乗法の逆元
long long fact[MAXN + 1];//階乗
long long ifact[MAXN + 1];//階乗の逆元
void init() {
	inv[1] = 1;
	for (int i = 2; i <= MAXN; i++) inv[i] = inv[MOD%i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= MAXN; i++) {
		fact[i] = i*fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD*ifact[r] % MOD;
}



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

	
	cin >> N >> A >> B >> K;

	if (K==0) {
		cout << 1 << endl;
		return 0;
	}
	long long ans = 0;

	rep(a, N+1) {
		long long rem = K - A*a;
		if (rem < 0)break;

		if (rem % B == 0) {
			long long b = rem / B;
			if (b <= N) {
				ans += C(N, a) * C(N, b);
			}
		}

		ans %= MOD;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define ll long long int
#define N 200005
using namespace std;

int main()
{
    int n,a=0;

    cin >> n;

    for(int i=1;i<=50000;i++)
    {
        int b = i*1.08;

        if(b==n) {cout << i ; exit(0);}
    }

     cout <<":(";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int[] num = new int[4];
		for (int i = 0; i < 4; i++) {
			num[i] = Integer.parseInt(S.substring(i, i + 1));
		}
		for (int i=-1; i<=1; i+=2) {
			for (int j = -1; j <= 1; j+=2) {
				for (int k = -1; k <= 1; k+=2) {
					if (num[0] + i*num[1] + j*num[2] + k*num[3] == 7) {
						System.out.println(String.format("%d%+d%+d%+d=7", num[0], i*num[1], j*num[2], k*num[3]));
						return;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define int long long

bool is_prime[10000001];

signed main() {
    for (int i=0; i<=10000000; i++) {
        is_prime[i] = true;
    }
    
    is_prime[0] = false;
    is_prime[1] = false;
    
    for (int i=2; i*i<=10000000; i++) {
        if (!(is_prime[i])) {
            continue;
        }
        
        for (int j=2*i; j<=10000000; j+=i) {
            is_prime[j] = false;
        }
    }
    
    vector<int> l;
    
    for (int i=13; i<=10000000; i++) {
        if (is_prime[i] && is_prime[i-2] && is_prime[i-6] && is_prime[i-8]) {
            l.push_back(i);
        }
    }
    
    while (true) {
        int n;
        cin >> n;
        
        if (n==0) {
            break;
        }
        
        int idx = distance(l.begin(), upper_bound(l.begin(), l.end(), n))-1;
        cout << l[idx] << endl;
    }
}


Measured memory_bytes: 12920
#include<stdio.h>
#include<math.h>
int main(){
  int a,b,x;
  scanf("%d%d%d",&a,&b,&x);
  int c=a*a*b;
  int m=a*a*a;
  double d,e,f;
  d=c/2;
  if(d>=x){
    e=a*b*b/2;
    e=e/x;
    printf("%f\n",180*atan(e)/(atan(1.0)*4));
  }
  else {
    f=2*(c-x);
    f=f/m;
    printf("%f\n",180*atan(f)/(atan(1.0)*4));
  }
  return 0;}


Measured memory_bytes: 128
from collections import defaultdict
N=int(input())
SP=defaultdict(list)
S=set()
for i in range(N):
    s,p=input().split()
    p=int(p)
    SP[s].append([p,i+1])
    S.add(s)
S=list(S)
S.sort()
for i in S:
    l=SP[i]
    l.sort(reverse=True)
    for k in l:
        print(k[1])


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

int main()
{
  int n;
  cin >> n;
  string s[n+1];
  rep(i,n) cin >> s[i];
  s[n] = "00";
 
  int m;
  cin >> m;
  string t[m];
  rep(i,m) cin >> t[i];
  
  sort(s,s+n);
  sort(t,t+m);
  
  int ans = 1, maxans = 0;;
  for(int i = 0; i < n; i++){
    if(s[i] == s[i+1]){
      ans++;
      continue;
    }
    for(int j = 0; j < m; j++){
      if(s[i] == t[j]){
        ans--;
      }
    }//for
    
    if(ans > maxans){
      maxans = ans;
    }
    ans = 1;
  }//for
  
  cout << maxans << endl;
}


Measured memory_bytes: 3636
while true
  n, m = gets.chomp.split(" ").map{|s| s.to_i}
  break if n == 0 && m == 0

  ps = (1..n).map{|p| p}
  k = n - 1
  ds = []

  while ps.length > 1
    k = (k + m) % ps.length
    ds.push ps.delete_at(k)
    k -= 1
  end
  #p ds

  puts ps[0]
end

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

using namespace std;

typedef long long ll;
#define int long long
#define F first
#define S second
#define pii pair<int,int>
#define mpr make_pair

const int maxn = 2e5+10;
const int mod = 998244353;
//const ll inf = 1e9+10;

/*int pw(int a, int b)
{
    if(b == 0) return 1;
    int x = pw(a,b/2); x = (x * 1ll * x) % mod;
    if(b & 1) x = (x * 1ll * a) % mod;
    return x;
}*/

int n, A[maxn], B[maxn];
set<pii> se;

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

signed main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>> n;
    for(int i = 1; i <= n; i++) cin>> A[i];
    for(int i = 1; i <= n; i++)
    {
        cin>> B[i];
        se.insert({B[i],i});
    }

    int ans = 0;
    while(se.size())
    {
        auto it = se.end(); it--;
        int i = (*it).S, M = (*it).F;

        int left = i-1; if(left == 0) left = n;
        int right = i+1; if(right == n+1) right = 1;
        int x = B[left];
        int y = B[right];

        se.erase({B[i],i});
        if((A[i] % (x+y)) == (B[i] % (x+y)))
        {
            ans += (B[i] - A[i]) / (x+y);
            B[i] = A[i];
            continue;
        }

        if(B[i] <= (x+y)) kill();
        ans += B[i] / (x+y);
        B[i] %= (x+y);
        if(B[i] == 0) return cout<< -1, 0;
        se.insert({B[i],i});
    }
    cout<< ans;
}




Measured memory_bytes: 19264
# include<iostream>
# include<cmath>
# include<algorithm>
using namespace std;
int main ()
{
	 int N;
	 cin>>N;
	 int L[N];
	 for(int i=0;i<N;i++)
	 {
	 	 cin>>L[i];
	 }
	 int sum =0;
	 sort(L,L+N);
	 for(int i=0;i<N;i++)
	 {
	 	 for(int j=i+1;j<N;j++)
	 	 {
	 	 	for(int k=j+1;k<N;k++)
	 	 	{
	 	 		 if(L[i]+L[j]>L[k])
	 	 		 {
	 	 		 	if(L[j]-L[i]<L[k])
	 	 		 	{
	 	 		 	//	cout<<L[i]<<" "<<L[j]<<" "<<L[k]<<endl;
	 	 		 		sum++;
					   }
	 	 		 	
				   }
				   else
				   {
				   	break;
				   }
			  }
		  }
	 }
	 cout<<sum<<endl;
	 
}

Measured memory_bytes: 256
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
x=[1]*31
y=[[] for _ in range(a)]
for i in range(a):
  for j in range(31):
    if l[i]>>j & 1:
      x[j]=x[j]*(-1)
      y[i].append(-1)
    else:
      y[i].append(1)
c=0
for k in range(a):
  co=0
  for j in range(31):
    if x[j]!=y[k][j]:
      co+=2**j
  print(co,end=' ')

Measured memory_bytes: 158876
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,i,sum;
    while(scanf("%d %d",&a,&b) != EOF){
        
        sum=a+b;
        i=0;
        while(sum)
        {
            sum/=10;
            i++;
        }
        printf("%d\n",i);
    }
    return 0;
}



Measured memory_bytes: 2048
#
# abc179 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
1 2
6 6
4 4
3 3
3 2"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
1 1
2 2
3 4
5 5
6 6"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6
1 1
2 2
3 3
4 4
5 5
6 6"""
        output = """Yes"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    D = [list(map(int, input().split())) for _ in range(N)]

    n = 0
    for d in D:
        d1, d2 = d
        if d1 == d2:
            n += 1
            if n == 3:
                print("Yes")
                break
        else:
            n = 0
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16332
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = IL()

a = max(l)
b = sum(l)-a
if a < b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 22020
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) (n) % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std;
 
int main() { 
    IOS;
    ll n, k;
    cin >> n >> k;
    vll a(n);
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    }
    ll dp[n][k + 1];
    ll cum[n][k + 1];
    memset(dp, 0, sizeof dp);
    memset(cum, 0, sizeof cum);
    for (int i = 0; i < n; i++) {
    	for (int j = 0; j < k + 1; j++) {
    		if (i == 0) {
    			dp[i][j] = (a[i] >= j)? 1: 0;
    		}
    		else {
    			if (j - (a[i] + 1) < 0) dp[i][j] = mod(cum[i - 1][j]);
    			else dp[i][j] = mod(1000000007 + mod(cum[i - 1][j]) - mod(cum[i - 1][j - (a[i] + 1)]));
    		}
    		
    		if (j > 0) cum[i][j] = mod(mod(dp[i][j]) + mod(cum[i][j - 1]));
    		else cum[i][j] = mod(dp[i][j]);
    	}
    }
    cout << dp[n - 1][k] << endl;
}

Measured memory_bytes: 159868
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a[4];
    cin>>a[0]>>a[1]>>a[2];
    if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0){
        cout<<0<<endl;
    }
    else{
        sort(a,a+3);
        cout<<a[0]*a[1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
using ll = long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)



int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	if (A > B) {
		out("0");
		return 0;
	}
	if (N == 1 && A != B) {
		out("0");
		return 0;
 	}
	ll under, top;
	under = (N - 1)*A + B;
	top = (N - 1)*B + A;
	out(top-under + 1);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else return 0;
}

long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);++i){
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;++i){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}


int insert(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;++i){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}


int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<M;++i)H[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;++i){
        scanf("%s %s",com,str);
        if(com[0]=='i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                if(find(str)){
                    printf("yes\n");
                }else{
                    printf("no\n");
                }
            }
        }
    }
    return 0;
}


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

long N, K, i;
double p[200005] = {}, box = 0, check = 0;
string s;

int main() {

	cin >> N >> K;
	for (i = 0;i < N;i++) {
		cin >> p[i];
		p[i] = p[i] / 2 + 0.5;
	}

	for (i = 0;i < K;i++) {
		box += p[i];
	}

	check = box;

	for (i = 1;i < N - K + 1;i++) {
		box = box - p[i - 1] + p[i + K - 1];

		if (box > check) {
			check = box;
		}

	}
	s = to_string(check);

	cout << s;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 整数
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		long result = 0;

		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0)
				result += i;
		}

		System.out.println(result);

	}

}

Measured memory_bytes: 35784
n=int(input())
if n==3:
    ans=[2,5,63]
elif n==4:
    ans=[2,5,20,63]
elif n==5:
    ans=[2,4,6,3,9]
elif n==6:
    ans=[2,4,6,3,9,24]
else:
    for i in range(15000,0,-3):
        if n-i>0 and (n-i)%2==0:
            m2=i
            m3=n-i
            break
    m5=0
    if m3*6-3>30000:
        while m2%5>0:
            m2-=6
            m5+=6
        while m3%5>0:
            m3-=6
            m5+=6
    ans=[]
    for i in range(2,m2*2+1,2):
        ans.append(i)
    for i in range(3,m3*6,6):
        ans.append(i)
    for i in range(5,m5*30,30):
        ans.append(i)
print(" ".join(map(str,ans)))

Measured memory_bytes: 5108
#! python3
# binarySearch.py - 二分探査を行う

def binarySearch(num_list, value):
    lo = 0
    hi = len(num_list)
    while lo < hi:
        mid = int((lo + hi) / 2)
        if num_list[mid] == value:
            return True
        elif value < num_list[mid]:
            hi = mid
        elif value > num_list[mid]:
            lo = mid + 1
    return False

num_of_S = int(input())
S = [int(i) for i in input().split()]
num_of_T = int(input())
T = [int(i) for i in input().split()]

cnt = 0
for i in range(num_of_T):
    if binarySearch(S, T[i]):
        cnt += 1
print(cnt)


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


int main(){
  ll k,n;
  cin>>k>>n;
  vector<ll>A;
  for(int i=0;i<n;i++){
    ll in;
    cin>>in;
    A.push_back(in);
  }
  int min = 10000000;
  for(int i=1;i<n;i++){
    ll cur = (A[i-1]-A[i]);
    if(cur<0) cur+=k;
    cur%=k;
    if(cur<min) min = cur;
  }
  ll cur = (A[n-1]-A[0]);
  if(cur<0) cur+=k;
  cur%=k;
  if(cur<min) min = cur;
  cout<<min<<endl;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int X;
	bool ans = false;

	cin >> X;

	repc(i, 1, X / 100) {
		int rem = X - 100 * i;
		if (rem <= 5 * i)ans = true;
	}

	cout << (ans ? 1 : 0) << endl;

	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
for k in range(K):
    B = [0] * N
    for n in range(N):
        l = max(0, n- A[n])
        r = min(N-1, n+A[n])
        B[l] += 1
        if r +1 < N:
            B[r+1] -= 1
    #print(B)
    for i in range(N-1):
        B[i+1] += B[i]
    #print(B)
    if sum(A) == N**2:
        break
    else:
        A = B[:]
print(*A)

Measured memory_bytes: 222028
#include<iostream>

int main(){
    int n;
    double gu = 1 / 2, s;

    std::cin >> n;

    if(n % 2 == 0){
        s = n / 2;
    }else{
        s = n / 2 + 1;
    }
    double ans = s / n;

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

    return 0;
}


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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    } else {
    	return a.first < b.first;
    }
}

int main() {
	int		a,b,c,i,j,k,n,m,x,l,y,ans = 0;
	
	cin >> n;	
	
	vector<pair<int , int>> p(n);
	vector<int> q(n);

	for(i=0; i<n; i++) {
		cin >> x >> l;
		p[i] = make_pair(x-l, x+l);
	}
	
	sort(p.begin(), p.end(), compare_by_b);
	
	//for(i=0;i<n;i++) {
	//	printf("%d %d\n",p[i].first, p[i].second);
	//}
	j = p[0].second;
	ans = n;
	for(i=1;i<n;i++) {
		//printf("%d\n",p[i].first);
		if (j > p[i].first) {
			ans--;
		} else {
			j = p[i].second;
		}
	}
	
	cout << ans << endl;


}


Measured memory_bytes: 1408
#include <stdio.h>          // printf(), scanf()

#define MAX_V 100

const int INF = 1000000000;

int V;
int d[MAX_V][MAX_V];

void
warshall_floyd()
{
	for (int k = 0; k < V; ++k)
	{
		for (int i = 0; i < V; ++i)
		{
			for (int j = 0; j < V; ++j)
			{
				int t = d[i][k] + d[k][j];
				if (t < d[i][j])
					d[i][j] = t;
			}
		}
	}
}

int
main(int argc, char **argv)
{
	scanf("%d", &V);
	for (int i = 0; i < V; ++i)
	{
		for (int j = 0; j < V; ++j)
			d[i][j] = (i == j) ? 0 : INF;
	}

	for (int i = 0; i < V; ++i)
	{
		int r, k;
		scanf("%d%d", &r, &k);
		for (int j = 0; j < k; ++j)
		{
			int t;
			scanf("%d", &t);
			d[r - 1][t - 1] = 1;
		}
	}

	warshall_floyd();

	int p;
	scanf("%d", &p);
	for (int i = 0; i < p; ++i)
	{
		int f, t, v;
		scanf("%d%d%d", &f, &t, &v);
		int c = d[f - 1][t - 1] + 1;
		if (c <= v)
			printf("%d\n", c);
		else
			printf("NA\n");
	}

	return 0;
}

Measured memory_bytes: 1856
w = gets.to_i
n = gets.to_i

horizon_bars = []
n.times do
  horizon_bars << gets.split(",").map(&:to_i)
end

1.upto(w) do |i|
  horizon_bars.reverse_each do |bar|
    source =  bar.index(i)
    i = bar[(source+1)%2] if source
  end
  puts i
end

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

int main()
{
  int n;
  cin >> n;
  vector<int> h(n + 1);
  vector<int> dp(n + 1, 2'000'000'000);
  
  for (auto i = 1; i <= n; i++) {
    cin >> h[i];
  }
  dp[1] = h[1];
  for (auto i = 1; i <= n; i++) {
    int i1 = i + 1;
    int i2 = i + 2;
    if (i1 <= n) {
      dp[i1] = min(dp[i1], dp[i] + (h[i] < h[i1] ? h[i1] - h[i] : h[i] - h[i1]));
    }
    if (i2 <= n) {
      dp[i2] = min(dp[i2], dp[i] + (h[i] < h[i2] ? h[i2] - h[i] : h[i] - h[i2]));
    }
  }
  cout << dp[n] - dp[1] << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] p = new int[n];
        for (int i=0; i<n; i++) p[i] = sc.nextInt();

        int ans = 1;

        Set<Integer> set = new TreeSet<>();
        for (int i=0; i<n; i++){
            set.add(p[i]);
            if (i>=k){
                if (((TreeSet<Integer>) set).first()!=p[i-k] || ((TreeSet<Integer>) set).last()!=p[i]){
                    ans++;
                }
                set.remove(p[i-k]);
            }
        }

        int notChange = 0;

        int cnt = 1;

        for (int i=0; i<n-1; i++){
            if (p[i]<p[i+1]){
                cnt++;
                if (cnt==k){
                    notChange++;
                }
            }else {
                cnt = 1;
            }
        }

        if (notChange>=2){
            notChange -= 1;
        }else {
            notChange = 0;
        }
        System.out.println(ans-notChange);

    }
}

Measured memory_bytes: 93672
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

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

  int len = S.length();

  int ans = 0;
  for (int i = 0; i < len / 2; i++) {
    if (S[i] != S[len - i - 1]) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	repn(i, 1, n - 1){
		vector<char> v(26, 0);
		rep(j, i) v[s[j] - 'a'] = 1;
		int cur = 0;
		repn(j, i, n) if(v[s[j] - 'a']) cur++, v[s[j] - 'a']--;
		ans = max(ans, cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, cnt, sum[210000], ans, dp[210000], a[210000], b[210000];
string str, ss;
bool f[210000];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<vector<Edge>>vec[110000];
vector<Pll>v;
map<string, LL>ma;
multiset<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	ans = 0;
	cin >> n >> m;
	for (int i = 1; i <= m;i++) {
		if ((i * 2) % m == 0) {
			if (n - i >= 0) {
				LL num = (n - i) / m + 1;
				ans += num * num*num;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6400
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
        "strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
        // TODO: メモリの使用量がやばいので Token ごとに読む
        // Reference: https://atcoder.jp/contests/abc148/submissions/9067537
        bufsize := 100 * 1024 * 1024
        sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
}
func readInt() int              { return readIntArray()[0] }
func readInt2() (int, int)      { a := readIntArray(); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(); return a[0], a[1], a[2] }
func readIntArray() []int {
        a := make([]int, 0, 1000)
        sc.Scan()
        for _, v := range strings.Split(sc.Text(), " ") {
                vv, _ := strconv.Atoi(v)
                a = append(a, vv)
        }
        return a
}
func readString() string            { return readStringArray()[0] }
func readString2() (string, string) { a := readStringArray(); return a[0], a[1] }
func readStringArray() []string     { sc.Scan(); return strings.Split(sc.Text(), " ") }

func isprime(x int) bool {
        if x == 1 {
                return false
        }
        for i := 2; i*i <= x; i++ {
                if x%i == 0 {
                        return false
                }
        }
        return true
}

func main() {
        x := readInt()
        for {
                if isprime(x) {
                        break
                }
                x++
        }
        fmt.Println(x)
}


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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0n(i, n) for (i = 0; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
//*/

//int row, column;
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        string s;
        ll cnt = 0;

        cin >> s;
        for(auto ch : s)
        {
            if (ch == '+')cnt++;
            else cnt--;
        }
        cout << cnt << endl;
    }
    return 0;
}
template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}


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

using namespace std;

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

    int ans = 0;

    for (int i = 1; i <= N; i++)
    {
        if (to_string(i).length() % 2 != 0)
        {
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
from bisect import bisect_left

n = int(input())
aa = sorted(list(map(int,input().split())))
a_max = max(aa)

half = a_max/2
p = bisect_left(aa, half)
if abs(half - aa[p]) >= abs(half - aa[p-1]):
  print(a_max,aa[p-1])  
else:
  print(a_max,aa[p])  

Measured memory_bytes: 14428
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#ifdef WIN32
	#define LL "%I64d"
#else
	#define LL "%lld"
#endif

#ifdef CT
	#define debug(...) printf(__VA_ARGS__)
	#define setfile() 
#else
	#define debug(...)
	#define filename ""
	#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif

#define R register
#define getc() (_S == _T && (_T = (_S = _B) + fread(_B, 1, 1 << 15, stdin), _S == _T) ? EOF : *_S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char _B[1 << 15], *_S = _B, *_T = _B;
inline int F()
{
	R char ch; R int cnt = 0; R bool minus = 0;
	while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
	ch == '-' ? minus = 1 : cnt = ch - '0';
	while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
	return minus ? -cnt : cnt;
}
#define maxn 100010
int a[maxn];
int main()
{
//	setfile();
	R int n = F(), x = F();
	for (R int i = 1; i <= n; ++i) a[i] = F();
	R long long ans = 0;
	for (R int i = 2; i <= n; ++i)
	{
		R int temp = dmin(a[i - 1] + a[i] - x, a[i]);
		cmax(temp, 0);
		a[i] -= temp;
		ans += temp;
		if (i == 2 && a[1] + a[i] > x)
		{
			ans += a[1] + a[2] - x;
		}
	}
	printf("%lld\n", ans );
	return 0;
}


Measured memory_bytes: 640