akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/**
*   author: j o s e m a g o
*   user: m a m i s a k i
**/
using namespace std;

/***PLANTILLA***/

using namespace __gnu_pbds; //*st.find_by_order(1);  st.order_of_key(p);
#pragma GCC optimize ("Ofast")
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef double dbl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;

string tostring(auto a){
    stringstream ss;ss<<a;string s = ss.str();
    return s;
}

/**Mi Debug**/
#define var(x) cout<<#x<<" = ";
#define db(x) cout<<#x<<" = "<<x<<"\n";
void dbvector(vector<auto>&v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}
void dbmapa(map<auto,auto>mp){
   for(auto x : mp) cout<<"{"<<x.first<<":"<<x.second<<"} ";cout<<"\n";
}
void dbstring(string v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}

/***********Code***************/

const int JJJ = 100100;










int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);


    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    if(k <= a){
        sum = k;
        cout<<sum;
    }
    else if(k <= a+b){
        sum += a;
        cout<<sum;
    }
    else{
        sum += a;
        k -= a+b;
        cout<<sum+(k*(-1));
    }



    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+10;
int n,m,f[N],g[N],la[26];
char s[N],ch[N];
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	for (int i=0;i<26;++i) la[i]=n+1;
	f[n+1]=1;g[n+1]=n+2;ch[n+1]='a';
	for (int i=n;i;--i){
		f[i]=1e9;
		la[s[i]-'a']=i;
		for (int j=0;j<26;++j) if (f[i]>f[la[j]+1]+1) f[i]=f[la[j]+1]+1,g[i]=la[j]+1,ch[i]='a'+j;
	}
	int pos=1;
	while (f[pos]) putchar(ch[pos]),pos=g[pos];
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;

    int n = s.length();

    vector<vector<int>> a(26);
    rep(i, n) {
        int idx = s[i] - 'a';
        a[idx].push_back(i);
    }

    ll res = 0;
    int j = -1;
    rep(i, t.length()) {
        int idx = t[i] - 'a';
        if (a[idx].size() == 0) {
            cout << -1 << endl;
            return 0;
        }

        int u = upper_bound(a[idx].begin(), a[idx].end(), j) - a[idx].begin();
        if (u == a[idx].size()) {
            j = a[idx][0];
            res += n;
        } 
        else {
            j = a[idx][u];
        }
    }

    cout << res + j + 1 << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<int>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };

int main()
{
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	auto getPositions = [&] {
		vector<int> res;
		for (int i = 0; i < n && res.size() < k;)
		{
			if (s[i] == 'o') {
				res.push_back(i);
				i += c + 1;
			}
			else
			{
				++i;
			}
		}
		return res;
	};
	vector<int> l, r;
	l = getPositions();
	reverse(s.begin(), s.end());
	r = getPositions();
	rep(i, k) {
		r[i] = n-1-r[i];
	}
	reverse(s.begin(), s.end());
	vector<int> lastL(n + 1, -1);
	rep(i, k) { lastL[l[i] + 1] = i; }
	rep(i,n)
	{
		if (lastL[i + 1] == -1) { lastL[i + 1] = lastL[i]; }
	}
	vector<int> lastR(n + 1, -1);
	rep(i, k) { lastR[r[i]] = i; }
	for(int i = n-1 ; i >= 0 ;i-- )
	{
		if (lastR[i] == -1) { lastR[i] = lastR[i +1]; }
	}
	rep(i, n)
	{
		if (s[i] == 'x') { continue; }
		int li = lastL[i];
		int ri = lastR[i + 1];
		int cnt = 0;
		if (li != -1) { cnt += li + 1; }
		if (ri != -1) { cnt += ri  + 1; }
		if (li != -1 && ri != -1 && r[ri] -l[li] <= c) { --cnt; }
		if (cnt >= k) { continue; }
		printf("%d\n", i + 1);
	}
	return 0;
}

Measured memory_bytes: 4984
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n) cin>>s[i];
  vector<string> x={"AC","WA","TLE","RE"};
  vi y(4);
  rep(i,n){
    rep(j,4)if(s[i]==x[j]) y[j]++;
  }
  rep(i,4){
    cout<<x[i]<<" x "<<y[i]<<endl;
  }
}


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

int main(){

    string S;
    cin >> S;

    int blue = 0, red = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == '0') red++;
        else blue++;
    }

    cout << 2 * (int)min(blue, red) << endl;

    return 0;
}

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

int main(){
	int n, input;
	ll fanc(int n);
	cin >> n;
	map<int, int> m;
	rep(i, n){
		cin >> input;
		if(n % 2 == 1){
			if(m.count(input) == 0) m[input]++;
			else if(input == 0 || m[input] == 2 || input > n-1){
				cout << 0 << endl;
				return 0;
			}else m[input]++;
		}else{
			if(input == 0 || m.count(input) == 1 && m[input] == 2 || input > n-1){
				cout << 0 << endl;
				return 0;
			}else m[input]++;
		}
	}
	
	cout << fanc(n/2) << endl;
	
}

ll fanc(int n){
	ll ans = 1;
	rep(i, n){
		ans *= 2;
		ans = ans % 1000000007;
	}
	return ans;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        int c = 0;
        while (v[i] % 2 == 0) {
            v[i] /= 2;
            c++;
        }
        res += c;
    }
    cout << res << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
//
#define forn(i, n)for(ll i=0;i<n;i++)
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(ll j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll pre[25],a[25];
int main(){FAST;
cin>>n;
for(ll i=0;i<n;i++){
	cin>>a[i];
	if(i){
		pre[i]=max(pre[i-1],a[i]);	
	}
	else{
		pre[i]=a[i];
	}
}
ll ans=0;
for(ll i=0;i<n;i++){
	if(pre[i] == a[i]){
		ans++;
	}
}
cout<<ans;
return 0;
}




Measured memory_bytes: 256
// Copyright 2017 wu_qing
#include <cstdio>
#include <algorithm>
const int N = 1e5 + 10;
int n, a[N], rank[N], ans;
bool cmp(int x, int y) {
    return a[x] < a[y];
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        rank[i] = i;
    }
    std::sort(rank, rank + n, cmp);
    for (int i = 0; i < n; i += 2)
        if (rank[i] & 1)
            ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)




int32_t main()
{
       



     map<string,int> mp;


    int n;
    cin >> n;


    rep(i,1,n)
    {
      string s;
      cin >> s;
      sort(all(s));
      mp[s]++;
    }

    int ans = 0;

    for(auto i:mp)
    {
      ans += ((i.s - 1)*(i.s))/2;
    }

    cout << ans;
   return 0;
}

Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int start = -1;
		int end = -1;
		char ch = 'a';
		for (int i = 0; i < 26; i++) {
			String s = String.valueOf(ch);
			Pattern p = Pattern.compile(s + s + "|" + s + "." + s);
			Matcher m = p.matcher(line);
			if (m.find()) {
				start = m.start() + 1;
				end = m.end();
				break;
			}
			ch++;
		}
		System.out.println(start + " " + end);
	}
}


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

#define INF ll(1e18)

using namespace std;

typedef long long ll;

int h, w, n;
int oy, ox;
ll oa;

vector<pair<int,ll> > yx[100005];
vector<pair<int,ll> > xy[100005];
ll mnx = -INF;
ll mny = -INF;



ll vly[100005];
ll vlx[100005];

void avx(int x, ll a);

void avy(int y, ll a) {
    if (a < 0 || (vly[y] != -1 && vly[y] != a)) {
        printf("No\n");
        exit(0);
    }
    if (vly[y] != -1) return;
    vly[y] = a;
    mnx = max(mnx, oa-a);
    for (auto e : yx[y]) {
        int x; ll d; tie(x,d) = e;
        avx(x, d+oa-a);
    }
}

void avx(int x, ll a) {
    if (a < 0 || (vlx[x] != -1 && vlx[x] != a)) {
        printf("No\n");
        exit(0);
    }
    if (vlx[x] != -1) return;
    vlx[x] = a;
    mny = max(mny, oa-a);
    for (auto e : xy[x]) {
        int y; ll d; tie(y,d) = e;
        avy(y, d+oa-a);
    }
}

ll sndy[100005];
ll sndx[100005];
ll mn1, mn2;

void gox(int x, ll a);

// y of i + a
void goy(int y, ll a) {
    //printf("y=%d, a=%lld\n", y, a);
    if (sndy[y] != INF && sndy[y] != a) {
        printf("No\n");
        exit(0);
    }
    if (sndy[y] != INF) return;
    mn1 = min(mn1, a);
    sndy[y] = a;
    for (auto e : yx[y]) {
        int x; ll d; tie(x,d) = e;
        gox(x, d+oa-a);
    }
}

// a - y of i
void gox(int x, ll a) {
    //printf("x=%d, a=%lld\n", x, a);
    if (sndx[x] != INF && sndx[x] != a) {
        printf("No\n");
        exit(0);
    }
    if (sndx[x] != INF) return;
    mn2 = min(mn2, a);
    sndx[x] = a;
    for (auto e : xy[x]) {
        int y; ll d; tie(y,d) = e;
        goy(y, d+oa-a);
    }
}

int main() {
    scanf("%d %d %d", &h, &w, &n);
    if (n == 0) {
        printf("Yes\n");
        return 0;
    }

    FO(z,0,n) {
        int y, x, a; scanf("%d %d %d", &y, &x, &a);
        x--; y--;
        if (z == 0) {
            oy = y;
            ox = x;
            oa = a;
        }
        yx[y].emplace_back(x,a);
        xy[x].emplace_back(y,a);
    }

    memset(vly, -1, sizeof vly);
    memset(vlx, -1, sizeof vlx);
    avy(oy, oa);

    FO(i,0,h) sndy[i] = INF;
    FO(i,0,w) sndx[i] = INF;

    vector<ll> v;
    FO(i,0,h) if (sndy[i] == INF) {
        mn1 = INF;
        mn2 = INF;
        goy(i,0);
        //printf("%lld\n", lo+hi);
        //printf("%lld\n", mn1 + mn2);
        v.push_back(mn1+mn2);
    }
    //printf("%lld %lld\n", mny, mnx);

    sort(v.begin(), v.end());
    if (sz(v) && (v[0] < oa || oa < mny+mnx)) {
        printf("No\n");
        exit(0);
    }

    printf("Yes\n");
    exit(0);
}



Measured memory_bytes: 17148
var num = +(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
var ends = (n) => { return n >> 1; };
var odds = (n) => { return 3 * n + 1; };
var r = [num];
while (true) {
  num = (num % 2 == 0 ? ends(num) : odds(num));
  if (r.lastIndexOf(num) > -1) {
    break;
  }
  r.push(num);
}
console.log(r.length + 1);

Measured memory_bytes: 7372
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

n, k, c = map(int, input().split())
s = input()
left = [-1]*k
right = [-1]*k

d = w = 0
while w < k:
    if s[d] == "o":
        left[w] = d
        w += 1
        d += c+1
    else:
        d += 1

d, w = n-1, k-1
while w >= 0:
    if s[d] == "o":
        right[w] = d
        w -= 1
        d -= c+1
    else:
        d -= 1

# print(left, right)
for i in range(k):
    if left[i] == right[i]:
        print(left[i]+1)


Measured memory_bytes: 74464
package main

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

func nextLine(r *bufio.Reader) string {
	var buf []byte
	for {
		line, isPrefix, err := r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func nextStr(s *bufio.Scanner) string {
	s.Scan()
	ref := s.Bytes()
	cp := make([]byte, len(ref))
	copy(cp, ref)
	return string(cp)
}

func nextInt(s *bufio.Scanner) int {
	n, err := strconv.Atoi(nextStr(s))
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	// s := bufio.NewScanner(os.Stdin)
	// s.Split(bufio.ScanWords)
	r := bufio.NewReader(os.Stdin)

	S := nextLine(r)
	T := nextLine(r)

	ans := 0
	for i := 0; i < len(S); i++ {
		if S[i] != T[i] {
			ans++
		}
	}

	fmt.Println(ans)
}


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

int main(){
  int N,D; cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> X[i][j];
    }
  }
  int ans = 0;
  int sum;
  int sa;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      sum = 0;
      for(int k = 0; k<D; k++){
        sa =X[i][k]-X[j][k];
        sum+=sa*sa;
      }
      int r =sqrt(sum);
      if(r*r==sum) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
vector<char>a;
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='C'||s[i]=='F')
            a.push_back(s[i]);
    }
    if(a.empty()){
        cout<<"No"<<endl;
    return 0;
    }
    for(int i=0;i<a.size()-1;i++)
    {
        if(a[i]=='C'&&a[i+1]=='F')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	char O[51], E[51];
	cin >> O >> E;
	Rep(i, strlen(O)){
		cout << O[i];
		if(i != strlen(E)){
			cout << E[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
int dir_x[4] = {-1,0,1,0};
int dir_y[4] = {0,-1,0,1};

int main(){
    int H,W;
    cin>>H>>W;
    bool S[H+2][W+2];
    int res=0;
    
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
            if(i==0||i==H+1||j==0||j==W+1){
                S[i][j] = false;
                continue;
            }
            char a;cin>>a;
            if(a=='.')S[i][j] = true;
            else S[i][j] = false;
        }
    }
    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
            if(S[i][j]==true){
                vector<vector<int>> dist(H+2,vector<int>(W+2,-1));
                dist[i][j] = 0;
                queue<pair<int,int>> que;
                que.push(make_pair(i,j));
                while(!que.empty()){
                    pair<int,int> p = que.front();
                    que.pop();
                    int x = p.first;
                    int y = p.second;
                    for(int way=0;way<4;way++){
                        int new_x = x+dir_x[way];
                        int new_y = y+dir_y[way];
                        if(dist[new_x][new_y]==-1&&S[new_x][new_y]==true){
                            dist[new_x][new_y] = dist[x][y] + 1;
                            res = max(res,dist[new_x][new_y]);
                            que.push(make_pair(new_x,new_y));
                        }
                    } 
                }
            }
        }
    }


    cout<<res<<endl;
}

Measured memory_bytes: 256
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
//#include<unordered_map>
#include <set>
//#include<unordered_set>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
//#define PC cout << "Case "//NOTES:cout
//#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("input.txt", "r", stdin)
#define WRITE() freopen("output.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define PRIME 999998727899999 			// (largest prime below 10^16)
#define PB push_back
#define pii pair<int, int>
#define pic pair<int, char>
#define pci pair<char, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define pss pair<string, string>
#define PI 2 * acos(0.0)
#define EPS 1e-11
///************************************************************///
// Numeric Functions
template < class T > inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline LL POW(LL base, LL power){
	LL res = base; if (power == 0) return 1;
	for (int I = 0; I < power - 1; I++) res *= base; return res;
}
// Translator Functions
int ToInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToInt(
double ToDouble(string s) { double r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToDouble(
string ToString(int n) { string s; stringstream convert; convert << n; s = convert.str(); return s; }//NOTES:ToString(
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 100 + 10;
LL ar[SIZE];



int main()
{
	BOOST
	///READ();
	///WRITE();
	LL T, I, J, K, N, n, m, cnt = 0, len, a, b, LCM;

	cin >> N;

	for(I = 0; I < N; I++)
		cin >> ar[I];

	if(N == 1)
	{
		cout << ar[0] << NL;
		return 0;
	}

	a = ar[0];
	b = ar[1];

	LCM = (a / __gcd(a, b)) * b;

	for(I = 2; I < N; I++)
	{
		a = LCM;
		b = ar[I];
		LCM = (a / __gcd(a, b)) * b;
	}

	cout << LCM << NL;

	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  INT(N);
  VEC(string,A,N);
  vector<ll> B;
  REP(i,N){
    int flag = 0;
    int cnt=0;
    string num;
    string point;
    REP(j,sz(A[i])){
      if(flag==0&&A[i][j]!='.'){
        num.push_back(A[i][j]);
      }
      if(A[i][j]=='.'){
        flag=1;
        continue;
      }else if(flag==1){
        point.push_back(A[i][j]);
      }
    }
    while(point.size()<=8){
      point.push_back('0');
    }
    if(point.size()>0){
      B.push_back(stol(num)*1000000000+stol(point));
    }else{
      B.push_back(stol(num)*1000000000);
    }
  }
  // REP(i,sz(B)){
  //   cout <<B[i] << endl;
  // }

  vector<P> C(sz(B));
  REP(i,sz(B)){
    C[i]=make_pair(0,0);
  }

  int dp[50][50]={0};
  REP(i,sz(B)){
    ll x = B[i];
    while(x%2==0){
      x/=2;
      C[i].fi++;
    }
    ll y = B[i];
    while(y%5==0){
      y/=5;
      C[i].se++;
    }
    // cout << C[i].fi <<" " << C[i].se<< endl;
    dp[C[i].fi+1][C[i].se+1]++;
    dp[C[i].fi+1][0]--;
    dp[0][C[i].se+1]--;
    dp[0][0]++;
  }
  REPR(i,48,0){
    REPR(j,48,0){
      dp[i][j]+=dp[i][j+1];
    }
  }
  REPR(i,48,0){
    REPR(j,48,0){
      dp[i][j]+=dp[i+1][j];
    }
  }
  // REP(i,30){
  //   REP(j,30){
  //     cout <<dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  ll ans = 0;
  REP(i,sz(B)){
    if(18-C[i].fi<=C[i].fi&&18-C[i].se<=C[i].se){
      ans+=dp[max((ll)0,18-C[i].fi)+1][max((ll)0,18-C[i].se)+1]-1;
    }else{
      ans+=dp[max((ll)0,18-C[i].fi)+1][max((ll)0,18-C[i].se)+1];
    }
  }

  cout << ans/2 << endl;
}

Measured memory_bytes: 13976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

string N;int K,n;

int nCr(int n,int r){
    if(r==1)return n;
    if(r==2)return n*(n-1)/2;
    if(r==3)return n*(n-1)*(n-2)/6;
    return 0;
}

int dp(int i,int k,bool smaller){
    if(k==0)return 1;
    else if(i==n)return 0;

    if(smaller)return nCr(n-i,k)*pow(9,k);
    else {
        if(N[i]=='0')return dp(i+1,k,0);
        int oxx= dp(i+1,k,1);
        int xxx= dp(i+1,k-1,1)*(N[i]-'1');
        int nxx= dp(i+1,k-1,0);
        return oxx+xxx+nxx;
    }
}

void solve() 
{
    cin>>N>>K;
    n=N.size();
    cout<<dp(0,K,0)<<endl;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
#define M (1<<20)-1
#define MAX 100000000
#define MIN -100000000
#define mod 998244353 
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main(){
	ll n;
	cin>>n;
	ll a[n],fr[n+1] = {0},ans = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		fr[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		ans += (fr[i]*(fr[i]-1))/2;
	}
	
	for(int i=0;i<n;i++){
		ll temp = (fr[a[i]]-1);
		cout<<(ans-temp)<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 5760
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] cakes = new int[n];
        for (int i = 0; i < n; i++) {
            cakes[i] = Integer.parseInt(sc.next());
        }
        // 最大値
        int max = 0;
        // 最大値のインデックス
        int index = 0;
        for (int i = 0; i < n; i++) {
            if (cakes[i] > max) {
                max = cakes[i];
                index = i;
            }
            if (i == n -1) cakes[index] /= 2;
        }
        int result = 0;
        for (int i = 0; i < n; i++) {
            result += cakes[i];
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23124
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,l,ans=0;
	string s;
	cin >> n >> k >> l;

	
 	ans = l-(n-k);

	if(ans<0){
		ans = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 int L, R, A, B, C, D;
 
 int main(){ 

  cin >> A >> B >> C >> D;

  L = A+B;
  R = C+D; 
 
  if (L>R) cout << "Left" << endl;
   else if (L<R) cout << "Right" << endl;
   else if (L = R) cout << "Balanced" << endl;

 return 0;
}


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n, m; cin >> n >> m;
	vi h(n); cin >> h;
	vpii ab(m); cin >> ab;
	vvi g(n);
	for (auto [u, v] : ab) {
		u--, v--;
		g[u].push_back(v); g[v].push_back(u);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		bool isgud = true;
		for (int v : g[i]) if (h[v] >= h[i]) isgud = false;
		if (isgud) ans++;
	}
	cout << ans << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 9536
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >

#define all(a) (a).begin(),(a).end()
using namespace std;

ll f(ll a){
	if (a % 2 == 0) return a / 2;
	else return 3 * a + 1;
}

int main(){
	ll n; cin >> n;
	ll maxi = 0;
	ll ans = 0;
	for (int i = 0; i < n; ++i){
		ll t; cin >> t;
		ans += t;
		maxi = max(t, maxi);
	}cout << ans - maxi/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
 
int main() {
    int N,A,B;
    cin >> N >> A >> B;
 
    int ans = 0;
    repr(i, 1, N+1) {
        int n = i;
        int keta = 0;
        while (n > 0) {
            keta += n % 10;
            n = n / 10;
        }
        if (A <= keta && keta <=  B) {
            ans += i;
        }
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=10)
		a=10-a;
	else
		a=0;
	printf("%d\n",b+100*a);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		if(a > b){
			System.out.println("a > b");
		} else if(a < b){
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
	}
}

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

#define INF 0x3f3f3f3f
#define eps 1e-8

typedef long long ll;
const int MAXN = 2010;

int cost1[MAXN], cost2[MAXN];
int dp[MAXN];

int main() {
	int num;
	cin >> num;
	cout << num+num*num+num*num*num << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
	while (1) {
		int a, b, sol;
		char op;
		scanf("%d %c %d", &a, &op, &b);
		switch (op) {
		case '?' :
			return 0;
		case '*' :
			sol = a * b;
			break;
		case '/' :
			sol = a / b;
			break;
		case '+' :
			sol = a + b;
			break;
		case '-' :
			sol = a - b;
			break;
		}
		printf("%d\n", sol);
	}
}

Measured memory_bytes: 600
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func main() {
	N := loadint()
	T := loadint()
	mincost := 9999
	for i := 0; i < N; i++ {
		c := loadint()
		t := loadint()
		if t <= T {
			if c < mincost {
				mincost = c
			}
		}
	}
	if mincost <= 1000 {
		fmt.Println(mincost)
	} else {
		fmt.Println("TLE")
	}
}


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

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

int main(){
    int n; cin >> n;
    vector<vector<pair<int,int>>> v(n);
    rep(i,n) {
        int a; cin >> a;
        rep(j,a) {
            int x,y;cin >> x >> y;
            x--;
            v[i].emplace_back(x,y);
        }
    }

    int mx = 0;
    for (int i=1; i < 1 << n+1; i++) {
        int count = 0;
        bool isOk = true;
        for (int j=0; j<n; j++) {
            if (! (i >> j & 1)) {
                continue;
            }
            rep(k,v[j].size()) {
                if ((i >> v[j][k].first & 1) ^ v[j][k].second) {
                    isOk = false;
                }
            }
            count++;
        }
        if (isOk) {
            mx = max(mx, count);
        }
    }
    cout << mx << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def f(x):
    s = 0
    while x != 0:
        s += x % 10
        x = x//10
    return s

n = int(input())
res = 10**9
for i in range(1,n):
    res = min(res,f(i)+f(n-i))
print(res)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n; vector<int>v(100010, 0); map<int, int>mp;
	rep(i, 0, n) {
		int a; cin >> a;
		mp[a]++;
	}
	int even = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (it->second % 2 == 0)even++;
	}
	cout << mp.size() - (even % 2) << endl;
	return 0;
}

Measured memory_bytes: 5376
mod = 10**9 + 7

def comb(n, k):
    x, y = 1, 1
    k = min(k, n-k)
    for i in range(k):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x*pow(y, mod-2, mod) % mod

N, M, K = map(int, input().split())
print((sum(i*(N-i)*M**2 for i in range(N))+sum(i*(M-i)*N**2 for i in range(M)))*comb(N*M-2, K-2) % mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep( i, a, b ) for( int i = (a); i <= (b); ++i )
#define dep( i, a, b ) for( int i = (a); i >= (b); --i )
using namespace std;
typedef long long ll;
const int N = 5e5+9, INF = 0x3f3f3f3f;
int n, dt[N], ans = 0;

void marge( int dt[], int left, int mid, int right ) {
    int n1 = mid - left;
    int n2 = right - mid;
    int a[n1 + 1], b[n2 + 1];
    for( int i = 0; i < n1; ++i ) a[i] = dt[i + left];
    for( int i = 0; i < n2; ++i ) b[i] = dt[mid + i];
    a[n1] = b[n2] = INF;
    int t1 = 0, t2 = 0;
    for( int i = left; i < right; ++i ) {
        if( a[t1] < b[t2] ) {
            dt[i] = a[t1];
            t1++;
        }
        else {
            dt[i] = b[t2];
            t2++;
        }
        ++ans;
    }
}

void marge_sort( int dt[], int left, int right ) {
    if( right - left > 1 ) {
        int mid = right + left >> 1;
        marge_sort( dt, left, mid );
        marge_sort( dt, mid, right );
        marge( dt, left, mid, right );
    }
}

int main( void ) {
    ios::sync_with_stdio( false );
    int n;
    cin >> n;
    for( int i = 0; i < n; ++i ) cin >> dt[i];
    marge_sort( dt, 0, n );
    for( int i = 0; i < n; ++i ) cout << dt[i] << ( i == n - 1 ? '\n' : ' ' );
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7012
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();

		// 文字列の入力
		String s = sc.next();
        int ans = 0;
        for(int i = 1; i < n; i++) {
          Set<String> front = new HashSet<>(Arrays.asList(s.substring(0, i).split("")));
          Set<String> back = new HashSet<>(Arrays.asList(s.substring(i, n).split("")));
          int count = 0;
          for(String value : front) {
            if (back.contains(value)) {
              count++;
            }
          }
          if (count > ans) {
            ans = count;
          }
        }
        
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 24148
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 10000)
	scanner.Buffer(buf, 1000000)
	scanner.Scan()
	in := scanner.Text()
	length := len(in)
	match := 0 // 101010...のパターンに一致する数
	for i, char := range strings.Split(in, "") {
		// 奇数
		if i%2 != 0 {
			if char == "1" {
				match++
			}
			// 偶数
		} else {
			if char == "0" {
				match++
			}
		}
	}
	fmt.Print(math.Min(float64(match), float64(length-match)))
}


Measured memory_bytes: 2560
import math
 
n=int(input())
 

a=math.sin(math.radians(60))
b=math.cos(math.radians(60))

 
def f(n,x1,x2,y1,y2):
    if n==0:
        return
 
    sx=(2*x1 + 1*x2) / 3
    sy=(2*y1 + 1*y2) / 3
    tx=(1*x1 + 2*x2) / 3
    ty=(1*y1 + 2*y2) / 3
    ux=(tx-sx)*b - (ty-sy)*a + sx
    uy=(tx-sx)*a + (ty-sy)*b + sy
 
    f(n-1,x1,sx,y1,sy)
    print(sx, sy)
    f(n-1,sx,ux,sy,uy)
    print(ux, uy)
    f(n-1,ux,tx,uy,ty)
    print(tx, ty)
    f(n-1,tx,x2,ty,y2)
 
 
print(0.00000000, 0.00000000)
f(n,0,100,0,0)
print(100.00000000, 0.00000000)


Measured memory_bytes: 5784
use std::collections::{BTreeMap, BinaryHeap, VecDeque};

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();

    let mut graph = vec![vec![]; (1 << (n + 1)) - 1];
    let mut inverse = vec![vec![]; (1 << (n + 1)) - 1];
    for i in 0..((1 << n) - 1) {
        graph[i].push(i * 2 + 1);
        graph[i].push(i * 2 + 2);
        inverse[i * 2 + 1].push(i);
        inverse[i * 2 + 2].push(i);
    }
    //    eprintln!("{:?}", graph);

    let v: Vec<u64> = sc.vec(1 << n);
    let count = v.into_iter().fold(BTreeMap::new(), |mut map, v| {
        *map.entry(v).or_insert(0) += 1;
        map
    });

    let mut values = vec![0; graph.len()];
    let mut heap = BinaryHeap::new();
    heap.push((1 << n, 0));

    for (value, count) in count.into_iter().rev() {
        if heap.len() < count {
            println!("No");
            return;
        }
        let vs = (0..count).map(|_| heap.pop().unwrap()).collect::<Vec<_>>();
        for (mut size, mut cur) in vs.into_iter() {
            loop {
                values[cur] = value;
                if graph[cur].is_empty() {
                    break;
                }
                heap.push((size / 2, graph[cur][1]));
                cur = graph[cur][0];
                size /= 2;
            }
        }
    }

    println!("Yes");
}

fn get_min_leaf(root: usize, graph: &Vec<Vec<usize>>) -> usize {
    if graph[root].is_empty() {
        root
    } else {
        get_min_leaf(graph[root][0], graph)
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define bug(x) cout << #x << " = " << x << endl;
#define fr(a) freopen(a,"r",stdin);
#define fw(a) freopen(a,"w",stdout);
#define tc() int tc;cin >> tc; for (int _tc=1;_tc<=tc;_tc++)
#define up(i,l,r) for (int i=l;i<=r;i++)
#define down(i,r,l) for (int i=r;i>=l;i--)
#define pb push_back
#define mp make_pair
#define ins insert;
typedef long long int ll;
typedef unsigned long long int llu;
using namespace std;

void printArr(int a[], int l, int r)
{
    up(i,l,r) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void printMtx(int a[][1010],int n, int m)
{
    up(i,1,n) {
        up(j,1,m) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

string s;
vector<int> v[30];
int res = INT_MAX, cnt, t;

int main()
{
    ios_base::sync_with_stdio(0);


    cin >> s;
    up(i,0,s.length()-1) {
        t = int(s[i]) - int('a');
        v[t].pb(i);
    }

    up(i,0,25) {
        if (v[i].size() != 0) {
            cnt = v[i][0];
            up(j,1,v[i].size()-1) {
                cnt = max(cnt,v[i][j] - v[i][j-1] - 1);
            }
            t = s.length() - v[i][v[i].size()-1] - 1;
            cnt = max(cnt, t);
            res = min(res,cnt);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)(1e18)

signed main(){
	int N, i;
	scanf("%lld", &N);
	vector<int> A(N + 1);
	for(i = 0; i <= N; i++){
		scanf("%lld", &A[i]);
	}
	if(N == 0){
		if(A[0] == 1){
			printf("1\n");
		}
		else{
			printf("-1\n");
		}
		return 0;
	}
	if(A[0] != 0){
		printf("-1\n");
		return 0;
	}
	vector<int> limit(N + 1, 1);
	for(i = 1; i <= N; i++){
		limit[i] = min(2 * limit[i - 1] - A[i], inf);
		if(limit[i] < 0){
			printf("-1\n");
			return 0;
		}
	}
	int ans = 1;
	for(i = N; i > 0; i--){
		if(A[i] <= limit[i - 1]){
			ans += A[i];
			A[i - 1] += A[i];
		}
		else{
			ans += A[i];
			A[i - 1] += limit[i - 1];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=2010;
int n,x,y,cnt[maxn],tmp;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(x); read(y);
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j++) {
		tmp=min(j-i,abs(i-x)+abs(j-y)+1);
		tmp=min(tmp,abs(i-y)+abs(j-x)+1);
		cnt[tmp]++;
	}
	for (int i=1;i<n;i++) printf("%d\n",cnt[i]);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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

string S;
string pat = "keyence";
bool check(int from, int to)
{
  string tmp = "";
  for (int i = 0; i < from; i++)
    tmp += S[i];
  for (int j = to + 1; j < S.size(); j++)
    tmp += S[j];
  return tmp == pat;
}

int main()
{
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    for (int j = i; j < S.size(); j++) {
      if (check(i, j)) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  if (S != pat) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<stdio.h>

using namespace std;
int main(){
	int n=19;
	char a[n];
	for(int i=0;i<n;i++)
	scanf("%c",&a[i]);
	for(int i=0;i<n;i++)
	{
		if(a[i]==',')
		printf(" ");
		else
		printf("%c",a[i]);
	}
	
	}

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


int main(){
  int n;
  cin >> n;
  int dp[n+1];
  rep(i,n+1)dp[i] = INF;
  dp[0] = 0;
  rep(i,n){
    dp[i+1] = min(dp[i+1],dp[i] + 1);
    for(int j=1;i+1 - pow(6,j) >= 0; j++){
      int tmp = pow(6,j);
      dp[i+1] = min(dp[i+1],dp[i+1-tmp] + 1);
    }
    for(int j=1;i+1 - pow(9,j) >= 0;j++){
      int tmp = pow(9,j);
      dp[i+1] = min(dp[i+1],dp[i+1-tmp] + 1);
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 4360