akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	double a;
	while(scanf("%lf", &a) != EOF){
		double sum = 0.0;
		rep(i, 10){
			sum += a;
			a *= (i%2 ? 1.0/3.0 : 2.0);
		}
		printf("%.8f\n", sum);
	}

	return 0;
}

Measured memory_bytes: 0
# include <iostream>
# include <string>
# include <vector>
using namespace std;
struct node
{
	int val;
	node* next,*pre;
};
node *head;
void Insert(int x)
{
	node *p;
	p = new node; p->val = x;
	head->next->pre = p; p->next = head->next;
	head->next = p;  p->pre = head;
}
void Delete(int x)
{
	node *p = head->next;
	while(p->val != x && p != head) p = p->next;
	if(p == head) return ;
	p->pre->next = p->next;
	p->next->pre = p->pre;
	delete p;
}
void deleteFirst()
{
	head->next = head->next->next;
	head->next->pre = head;
}
void deleteLast()
{
	head->pre = head->pre->pre;
	head->pre->next = head;
} 

int main(void)
{
	int n,k;
	string s;
	scanf("%d",&n);
	head = new node;
	head->next = head->pre = head;
	while(n--)
	{
		cin>>s;
		if(s == "insert")
		{
			scanf("%d",&k);
			Insert(k);
		}
		else if(s == "delete")
		{
			scanf("%d",&k);
			Delete(k);
		}
		else if(s == "deleteFirst") deleteFirst();
		else deleteLast();
	}
	node *p = head->next;
	vector<int> ans;
	while(p != head)
	{
		ans.push_back(p->val);
		p = p->next;
	}
	for(int i = 0;i < ans.size();i++) printf("%d%c",ans[i],(i == ans.size()-1?'\n':' '));
	return 0;
}


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

using namespace std;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d\n",n)
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
typedef long long int 	LL;
typedef long double 	LD;
typedef pair<int,int>   II;
typedef vector<int>     VI;
const int MOD = 1e9 + 7;
const int N = 100011;
LL dp[N];

int main() {
    int n;
    char a[2][N];
    SI(n);
    scanf("%s\n%s", a[0], a[1]);
    
    bool prev = 0;
    for(int i = 0; i < n; ++i) {
        if(i == 0) {
            if(a[0][i] == a[0][i+1]) dp[i+1] = 6, prev = 0, i++;
            else dp[i] = 3, prev = 1;
            continue;
        }
        bool cur = 0;
        if(a[0][i] == a[0][i+1]) cur = 0;
        else cur = 1;
        if(!prev) {
            if(cur) dp[i] = dp[i-1];
            else dp[i+1] = (dp[i-1]*3) % MOD, i++;
        }
        else if(prev) {
            if(cur) dp[i] = (2LL*dp[i-1]) % MOD;
            else dp[i+1] = (2LL*dp[i-1]) % MOD, i++;
        }
        prev = cur;
    }
    PL(max(dp[n-1], dp[n]));
    return 0;
}

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

using namespace std;

const long long llmax = numeric_limits<long long>::max();

void Main() {
    int N;
    long long W;
    cin >> N >> W;
    vector<long long> w(N, 0LL);
    vector<int> v(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    const int MAXVALUE = accumulate(v.begin(), v.end(), 0);
    vector<vector<long long> > minWeight(N, vector<long long>(MAXVALUE + 1, llmax));
    minWeight[0][v[0]] = w[0];
    minWeight[0][0] = 0;
    for (int i = 1; i < N; ++i) {
        for (int j = 0; j <= MAXVALUE; ++j) {
            if (j < v[i]) {
                minWeight[i][j] = minWeight[i - 1][j];
            }
            else if (minWeight[i - 1][j - v[i]] == llmax) {
                minWeight[i][j] = minWeight[i - 1][j];
            }
            else {
                minWeight[i][j] = min(minWeight[i - 1][j], minWeight[i - 1][j - v[i]] + w[i]);
            }
        }
    }
    const vector<long long>& goal = minWeight.back();
    int ans = 0;
    for (int i = 0; i < goal.size(); ++i) {
        if (goal[i] <= W) {
            ans = i;
        }
    }

    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 79488
# import numpy as np
import math
import sys
input = sys.stdin.readline

X = int(input())

if X == 2:
    print(X)
    sys.exit()

def segment_sieve(a,b):
    ass = []
    is_prime_small = [True] * (int(b**0.5)+1)
    is_prime = [True] * (b-a)
    for i in range(2,int(b**0.5)):
        if is_prime_small[i]:
            j = 2*i
            while j**2 < b:
                is_prime_small[j] = False
                j += i
            j = max(2*i,((a+i-1)//i)*i)
            while j < b:
                is_prime[j-a] = False
                j += i
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(a+i)
    if ass[0] == 1:
        del ass[0]
    return ass

list = segment_sieve(X,100004)
res = list[0]

print(res)


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> x(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	
	sort(x.begin(), x.end());
	
	int ans = 0;
	auto itr = x.begin();
	while(itr != x.end())
	{
		int cnt = 1;
		while(*itr == *(itr + cnt))
		{
			cnt++;
		}
		
		itr += cnt;
		
		if((cnt % 2) == 1)
		{
			ans++;
		}
		
		if(itr == x.end())
		{
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string o, e; cin >> o >> e;
    int saveO = 0, saveE = 0;
    REP(i, o.size() + e.size()){
        if(i % 2 != 0){
            cout << e[saveE];
            saveE++;
        }
        else {
            cout << o[saveO];
            saveO++;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;

struct nodo
{
	int v, anti, antj;
	char a;
};

nodo SET(int v, int i, int j, char a)
{
	nodo aux;
	aux.v = v; aux.anti=i; aux.antj=j; aux.a=a;
	return aux;
}

string LCS(string s1, string s2)
{
	vector < vector <nodo> > dp(3005,vector <nodo>(3005));
	int n=s1.size(), m=s2.size();
	
	forn(i,n+1)
	{
		forn(j,m+1)
		{
			if(i==0 || j==0) continue;
			if(s1[i-1]==s2[j-1])
			{
				dp[i][j]=SET(dp[i-1][j-1].v+1,i-1,j-1,s1[i-1]);
				continue;
			}
			if(dp[i-1][j].v > dp[i][j-1].v)
			{
				dp[i][j]=SET(dp[i-1][j].v,i-1,j,'a');
			}
			else dp[i][j]=SET(dp[i][j-1].v,i,j-1,'a');
		}
	}
	
	string ans;
	while(n!=0 && m!=0)
	{
		if(dp[n][m].anti == n-1 && dp[n][m].antj == m-1) ans.pb(dp[n][m].a);
		int aux = n;
		n=dp[n][m].anti; m=dp[aux][m].antj;
	}
	reverse(all(ans));
	return ans;
}
 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif

	string s1, s2;
	cin >> s1 >> s2;
	cout << LCS(s1,s2) << endl;
    return 0;
}


Measured memory_bytes: 144436
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n + 2];
        a[0] = 0;
        a[n + 1] = 0;
        for (int i = 1; i < n + 1; i++) {
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 1; i < n + 2; i++) {
            sum += Math.abs(a[i] - a[i - 1]);
        }
        for (int i = 1; i < n + 1; i++) {
            if (a[i - 1] <= a[i] && a[i] <= a[i + 1]) {
                System.out.println(sum);
            } else if (a[i - 1] >= a[i] && a[i] >= a[i + 1]) {
                System.out.println(sum);
            } else if (a[i - 1] <= a[i]) {
                if (a[i - 1] < a[i + 1]) {
                    int rest = a[i] - a[i + 1];
                    System.out.println(sum - (2 * rest));
                } else {
                    int rest = a[i] - a[i - 1];
                    System.out.println(sum - (2 * rest));
                }
            } else if (a[i - 1] > a[i]) {
                if (a[i - 1] <= a[i + 1]) {
                    int rest = a[i - 1] - a[i];
                    System.out.println(sum - (2 * rest));
                } else {
                    int rest = a[i + 1] - a[i];
                    System.out.println(sum - (2 * rest));
                }
            }
        }

    }
}


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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;rep(tcs,1,tt+1)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble
    string s;
    cin>>s;
    int mx=0;
    for(int i=0;i<_sz(s);i++){
        int cnt=0;
        if(s[i]=='R'){
            int j=i;
            while(j<_sz(s)&&s[j]=='R')
                cnt++,j++;
            i=j;
        }
        mx=max(mx,cnt);
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 3648
import math
a,b,c=map(int,input().split())

s=a*b/2*math.sin(math.radians(c))
l=a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c)))
h=b*math.sin(math.radians(c))

print(s)
print(l)
print(h)




Measured memory_bytes: 5708
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];   // 重み付き有向グラフの隣接リスト表現

void dijkstra() {
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int d[MAX];
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while (! PQ.empty()) {
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;

        color[u] = BLACK;

        // 最小値を取り出し, それが最短でなければ無視
        if (d[u] < f.first * (-1)) continue;

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;
                // priority_queueはデフォルトで大きい値を優先するため-1をかける
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    int k, u, v, c;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}


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

min_=100000

for i in range(1, N//2+1):
    j=N-i
    sum_i=0
    sum_j=0
    tmp_i=i
    tmp_j=j
    while tmp_i  > 0:
        sum_i += tmp_i % 10
        tmp_i = tmp_i // 10
    while tmp_j > 0:
        sum_j += tmp_j % 10
        tmp_j = tmp_j // 10
    min_=min(min_, sum_i+sum_j)

print(min_)

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

using ll=long long;

int main() {
  int X; cin >>X;
  int t=0;
  rep_eq(i,1,X) {
    t+=i;
    if (t>=X) {
      cout <<i <<endl;
      return 0;
    }
  }
}


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N;
vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  string s, t, u;
  ll a,b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (u == s) {
    cout << a-1 << " " << b << endl;
  } else {
    cout << a << " " << b-1 << endl;
  }
  return 0;
}


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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa {
	aaa() {
		cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

signed main()
{
	int n; cin >> n;
	map<string, int,less<>> ms;

    REP(i, n){
      string s;cin >> s;
      ++ms[s];
    }
  
    int m;cin >> m;
    REP(i, m) {
      string s;cin >> s;
      --ms[s];
    }

    int ans = 0;
    for(const auto &p : ms){
      ans = max(ans, p.second);
    }
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main()
{
  ll a,b;cin>>a>>b;
  if((a+b)%2 ==1)cout<<"IMPOSSIBLE"<<endl;
  else cout<<(a+b)/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int mx = 0;
  REP(i,n){ 
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  
  int g = a[0];
  FOR(i, 1, n) g = GCD(g, a[i]);
  
  string ans = "POSSIBLE";
  if(k>mx || k%g>0) ans = "IMPOSSIBLE";
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string S;cin >> S;
  int N = S.size(),m=N;
  for(int i = 1; i<N;++i) if(S[i-1]!=S[i]) m = min(m, max(i,N-i));
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0_0002
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null)
                {
                    break;
                }
                int[] Nums = s.Split(' ').Select(int.Parse).ToArray();
                string Sum = (Nums[0] + Nums[1]).ToString();
                Console.WriteLine(Sum.Length);
            }
        }
    }
}



Measured memory_bytes: 18356
#include <iostream>
#include <vector>
using namespace std;
long long mod = 1000000007;

long long modpow(long long a, long long p)
{
    if (p == 0)
    {
        return 1;
    }
    if (p % 2 == 0)
    {
        long long half = modpow(a, p / 2);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}
long long calcComb(long long a, long long b)
{
    if (b > a-b)
    {
        return calcComb(a, a-b);
    }
    long long ansMul = 1, ansDiv = 1;
    for(int i = 0; i < b; i++)
    {
        ansMul *= a-i;
        ansDiv *= i+1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    long long ans = ansMul * modpow(ansDiv, mod-2) % mod;
    return ans;
}

int main()
{
    long long n, m;
    cin >> n >> m;
    long long ans = 1;
    for(long long i = 2; i <= m; i++)
    {
        if (m%i == 0) {
            long long cnt = 0;
            while(m%i == 0){
                cnt++;
                m /= i;
            }
            ans *= calcComb(cnt+n-1, n-1);
            ans %= mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
l = int(len(s))

t = l/2

t = int(t)
f = s[:t]
r = s[t:]
r = r[::-1]
f = list(f)
r = list(r)

c = 0
for i in range(t):
    if f[i] != r[i]:
        c +=1
    else:
        pass
print(c)


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

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n+(x-1))/x*t << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

int YesOrNo(){
    puts("Yes");
    return 0;
}

int main(){
    int i;
    char s[5], a,b,c,d;

    scanf("%s", s);
    a = s[0];
    b = s[1];
    c = s[2];
    d = s[3];

    if (a==b && b==c) return YesOrNo();
    if (b==c && c==d) return YesOrNo();
    puts("No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll A, B;
  cin >> A >> B;
  cout << A * B << endl;
}

Measured memory_bytes: 3636
import numpy as np
import itertools

h,w,k = (int(x) for x in input().split())
c = np.array([list(input()) for x in range(h)])
answer = 0


for x,y in itertools.product(range(2**h), range(2**w)):
    count = 0
    for i,j in itertools.product(range(h), range(w)):
        if x>>i &1 or y>>j&1:continue
        if c[i,j]=="#":
            count+=1
    if count == k:
        answer += 1
        
print(answer)

Measured memory_bytes: 26936
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_V = 110;

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

    vvl dist(MAX_V, vl(MAX_V));  // dist[u][v] : 頂点uと頂点vの最短距離
    rep(i, n) {
        rep(j, n) {
            if(i != j) {
                dist[i][j] = INF;
            }
        }
    }
    
    vvl A(n, vl(n));  // A[u][v] : 頂点uと頂点vを結ぶ辺の距離
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        A[a][b] = A[b][a] = c;
        if(dist[a][b] > c) {
            dist[a][b] = dist[b][a] = c;
        }
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans = 0;
    rep(u, n-1) {
        exrep(v, u+1, n-1) {
            rep(w, n) {
                if(w != u && w != v && dist[u][w] + dist[w][v] < A[u][v]) {
                    ans++;
                    break;
                }
            }
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if((a+b) == 15) {
        cout << "+" << endl;
    } else if((a*b) == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int T;
        public void Run()
        {
            T = Input.ReadInt();
            for (int i = 0; i < T; i++)
            {
                var ary = Input.ReadLongArray();
                var success = Query(ary[0], ary[1], ary[2], ary[3]);
                Console.WriteLine(success ? "Yes" : "No");
            }
        }

        bool Query(long A, long B, long C, long D)
        {
            // 9 7 6 9 -> Yes
            if (!(A >= B)) return false;
            if (!(B <= D)) return false;
            if (B <= C) return true;

            // C < B <= Dを前提
            long AM = A % B;
            if (C < AM) return false;
            long DM = GCD(B, D);
            long CC = C - (C - AM) % DM;
            return (CC + DM) >= B;
        }

        public static long GCD(long a, long b)
        {
            return b == 0 ? a : GCD(b, a % b);
        }

    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			int C = scan.nextInt();
			int X = scan.nextInt();
			int Y = scan.nextInt();
			
			int m = Math.min(A, B);
			int l = Math.max(A, B);
			
			int minx = 0;
			int miny = 0;
			int minz = 0;
			
			int saisyou = 2*C*Math.max(X, Y);
			
			for(int i =0;i<=Math.min(X, Y);i++) {
				
				int ne = A*(X-i)+B*(Y-i)+2*C*i;
				//System.out.println(ne);
				if(saisyou>ne) {
					saisyou=ne;
					minx  = (X-i);
					miny  = (Y-i);
					minz = 2*i;
					
				}
				
			}
			
			
			
			System.out.println(saisyou);
			//System.out.println(minx);
			//System.out.println(miny);
			//System.out.println(minz);
			
			
		}	
	}
}


Measured memory_bytes: 21716
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ld x;cin>>x;
	x*=3.14159265359*2.0;
	printf("%.9Lf\n",x);
}


Measured memory_bytes: 3764
#include <stdio.h>

int main(){
    int a,n,x,z = 0,an = 0;
    scanf("%d",&n);
    for(x=0;x<n;x++){
        scanf("%d",&a);
        an += a;
        z++;
    }
    printf("%d\n",an-z);

    return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N,K;
    string S;
    cin >> N >> K;
    map<ll,ll> mp;
    vector<ll> d(K);
    ll tmp;
    rep(i,K){
        cin >> d[i];
        rep(j,d[i]){
            cin >> tmp;
            mp[--tmp]++;
        }
    }
    cout << N - mp.size() <<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

template<typename T>
class WUnionFind
{
	public:
	vector<T> parent;
	vector<T> dweight;
	
	WUnionFind(T n):parent(n),dweight(n)
	{
		for(int i=0;i<n;i++)
		{
			parent[i]=i;
			dweight[i]=0;
		}
	}
	
	bool unite(T a,T b,T w)
	{
		w=w+weight(a)-weight(b);

		a=root(a);
		b=root(b);
		if(a==b)return false;
		if(a>b)
		{
			swap(a,b);
			w=-w;
		}

		dweight[b]=w;
		parent[b]=a;
		return true;
	}
	
	T root(T n)
	{
		if(parent[n]==n)
			return n;
	
		T ret=root(parent[n]);
		dweight[n]+=dweight[parent[n]];
		parent[n]=ret;
		return ret;		
	}

	T weight(T n)
	{
		root(n);
		return dweight[n];
	}

	T diff(T a,T b)
	{
		return weight(b)-weight(a);
	}
};

int main()
{
	int N,M;

	cin >> N >> M;

	WUnionFind<int> uf(N);
	string ans="Yes";
	for(int i=0;i<M;i++)
	{
		int L,R,D;
		cin >> L >> R >> D;
		L--;
		R--;
		
		if(uf.root(L)!=uf.root(R))
			uf.unite(L,R,D);
		else
		{
			if(uf.diff(L,R)!=D)
			{
				ans="No";
				break;
			}
		}
	}

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


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static Scanner in = new Scanner(System.in);
    void solve() {
        int n = in.nextInt();
        for(int i = 40000; i > 1; i--){
            if(i * i <= n){
                System.out.println(i * i);
                return;
            }
        }
        System.out.println(1);
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

// https://drken1215.hatenablog.com/entry/2018/06/24/010600
int S(ll x) {
  int ret = 0;
  while (x) {
    ret += x % 10;
    x /= 10;
  }
  return ret;
}
double g(ll x) {
  return 1.0 * x / S(x);
}

void solve() {
  vector<ll> v;
  rep3(i, 1, 10) v.eb(i);

  rep3(i, 10, 1001) {
    rep3(j, i + 1, 5001) {
      if (g(i) > g(j)) break;
      if (j == 5000) v.eb(i);
    }
  }
  // rep(i, sz(v)) cout << v[i] << endl;

  // 4 桁以上
  rep3(i, 2, 10) {
    // j, k, (i 個の 9)
    rep3(j, 1, 10) rep(k, 10) {
      string s;
      s += j + '0';
      s += k + '0';
      rep(l, i) s += '9';

      ll x = stoll(s);
      v.eb(x);
    }
  }
  rep3(i, 8, 14) {
    rep3(j, 1, 10) rep(k, 10) rep(l, 10) {
      string s;
      s += j + '0';
      s += k + '0';
      s += l + '0';
      rep(m, i) s += '9';

      ll x = stoll(s);
      v.eb(x);
    }
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());
  // rep(i, sz(v)) cout << v[i] << endl;
  int n;
  cin >> n;

  int cnt = 0;
  rep(i, sz(v)) {
    rep3(j, i + 1, sz(v)) {
      if (g(v[i]) > g(v[j])) break;
      if (j == sz(v) - 1) {
        cnt++;
        cout << v[i] << endl;
        if (cnt == n) return;
      }
    }
  }
}


Measured memory_bytes: 384
def solve():
    A, B, C, D, E, F = map(int, input().split())
    memo = {}

    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    w = (100 * A) * a + (100 * B) * b
                    s = C * c + D * d
                    if w == 0:
                        break
                    if w + s > F:
                        break
                    else:
                        if w / 100 * E >= s:
                            density = 100 * s / (w + s)
                            memo[a, b, c, d] = density

    max_v = max(memo.values())

    for k, v in memo.items():
        if v == max_v:
            print((100 * A) * k[0] + (100 * B) * k[1] + C * k[2] + D * k[3], C * k[2] + D * k[3])
            break


if __name__ == '__main__':
    solve()

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


ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


ll divide(ll a, ll b, ll m) {
    a %= m;
    return a * modinv(b, m) % m;
}


ll comb(ll n, ll r, ll m) {
    if (n < 0 or r < 0 or n < r) return 0;
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        n %= m;
        ans *= i;
        ans %= m;
    }
    for (ll j = 1; j <= r; ++j) {
        ans = divide(ans, j, m);
    }
    return ans;
}


int main() {
    ll mod = 1000000007;
    ll n, b;
    cin >> n >> b;
    ll r = n - b;
    for (ll i = 1; i <= b; ++i) {
        if (n == b and i == 1) {
            cout << 1 << endl;
            continue;
        }
        ll cur = 0;
        cur += comb(b - 1, i - 1, mod) % mod * comb(r - 1, i - 2, mod) % mod;
        cur %= mod;
        cur += 2 * comb(b - 1, i - 1, mod) % mod * comb(r - 1, i - 1, mod) % mod;
        cur %= mod;
        cur += comb(b - 1, i - 1, mod) % mod * comb(r - 1, i, mod) % mod;
        cout << cur % mod << endl;
    }
}


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

const int N = 100005, A = 100005;

int n, m, a[N], b[N];

vector<int> rwd[A]; // rwd[i]: i日後に得られる報酬
multiset<int> job;

int main() {
  cin >> n >> m;
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, n) rwd[a[i]].push_back(b[i]);
  int ans = 0;
  rep(i, m+1) {
    rep(j, rwd[i].size()) job.insert(-rwd[i][j]);
    auto itr = job.begin();
    if (itr == job.end()) continue;
    ans -= *itr;
    job.erase(itr);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11744
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
      int t = scn.nextInt();
      int[] a = new int[n];
      for(int i=0; i<a.length; ++i){
        a[i] = scn.nextInt();
      }
      int[] b = new int[n];
      for(int i=0; i<b.length; ++i){
        if(i>0){
        b[i] = a[i] - a[(i-1)] ;
        }
      }
      int count = 0;
      for(int i=0; i<b.length; ++i){
        if(b[i] <= t){
          count = count + b[i];
        }else{
          count = count + t;
        }
      }
      int ans = count + t;
      System.out.println(ans);
	}
}


Measured memory_bytes: 58748
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

int main(){
	string S, T;
	cin >> S >> T;
	ll w = 0, m = -1;
	vector<ll> ch[300];
	for (int i = 0;i < S.size();i++) {
		ch[S[i]].push_back(i);
	}
	for (int i = 0;i < T.size();i++) {
		auto it = upper_bound(all(ch[T[i]]), m);
		if (it != ch[T[i]].end()) {
			m = *it;
		}
		else {
			w++;
			it = upper_bound(all(ch[T[i]]), -1);
			if (it == ch[T[i]].end()) {
				cout << -1 << endl;
				return 0;
			}
			m = *it;
		}
	}
	ll ans = w * S.size() + m + 1;
	cout << ans << endl;
}

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

int main() {
  int H, N; cin >> H >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    sum += a;
  }
  if (sum >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int

	fmt.Scanf("%d %d %d", &a, &b, &c)

	diff := a - b
	retDiff := c - diff
	if retDiff > 0 {
		fmt.Print(retDiff)
	} else {
		fmt.Print(0)
	}
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll INF = (1LL<<60);

int main(){

    string s; cin >> s;

    ll c = 0;
    rep(i, s.size()/2){
        if(s[i]!=s[s.size()-i-1]) c++;
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, k;
	int min = 1;
	cin >> n >> k;

	for (int i = 0; i < n; i++)
	{
		if (2 * min < k + min)
		{
			min = 2 * min;
		}
		else
		{
			min += k;
		}
	}
	cout << min << endl;
}

Measured memory_bytes: 256
<?php
  list($h, $w) = explode(" ", trim(fgets(STDIN)));

  $s = [];
  for($i=0; $i<$h; $i++){
    list($s[]) = explode(" ", trim(fgets(STDIN)));
  }

  for($i=0; $i<$h; $i++){
    for($j=0; $j<$w; $j++){
      if($s[$i][$j] == '#'){
        echo "#";
      }else{
        $a = [[$i-1,$j-1],[$i-1,$j],[$i-1,$j+1],[$i,$j-1],[$i,$j+1], [$i+1,$j-1],[$i+1,$j],[$i+1,$j+1]];
        $count = 0;
        for($k=0; $k<8; $k++){
          if($a[$k][0] < 0 || $a[$k][1] < 0 || $a[$k][0] >= $h || $a[$k][1] >= $w){
          }else{
            if($s[$a[$k][0]][$a[$k][1]] == '#'){
              $count++;
            }
          }
        }
        echo $count;
      }      
      if($j == $w-1){
        echo PHP_EOL;
      }
    }
  }

Measured memory_bytes: 16248
grid = []
for _ in range(3):
    grid.append((list)(map(int, input().split())))

for i in range(3):
    j = (i+1) % 3
    diff1 = grid[i][0] - grid[j][0]
    diff2 = grid[i][1] - grid[j][1]
    diff3 = grid[i][2] - grid[j][2]

    if diff1 != diff2 or diff2 != diff3:
        print("No")
        exit()

print("Yes")


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,A,B; cin >> N >> A >> B;
    int ans = 0;
    FOR(i,1,N+1){
        int n = i;
        int s = 0;
        while(n>0){
            s += n%10;
            n /= 10;
        }
        if(A<=s && s<=B) ans += i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
n = int(input())
if n == 3:
    ans = [2, 5, 63]
elif n == 4:
    ans = [2, 5, 20, 63]
elif n == 6:
    ans = [2, 4, 8, 10, 3, 9]
else:
    even = odd = None
    for i in range(1, 5001):
        a = n-3*i
        if a % 2 == 0 and 0 < a <= 5000:
            even = 3*i
            odd = a
            break
    if n == 19999:
        even = 14999
        odd = 5000
    assert(even+odd == n)
    assert(0 < even <= 15000)
    assert(0 < odd <= 5000)
    evens = [i for i in range(1, 30001) if i%2 == 0]
    odds = [i for i in range(1, 30001) if i%3 == 0 and i%2 == 1]
    ans = evens[:even] + odds[:odd]
print(*ans)

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;string s;cin>>n>>s;

  int res=0;
  for(int i=1;i<n;i++){
    int tst=0;
    string x = s.substr(0, i);
    string y = s.substr(i, n-i);
    set<char> s;
    for(int j=0;j<x.size();j++){
      s.insert(x[j]);
    }
    for(auto c : s) {
      int t = count(y.begin(), y.end(), c);
      if(t)tst++;
    }
    res=max(tst, res);
  }

  cout<<res<<endl;


  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        int countB = 0;
        int countW = 0;
        char prev = ' ';
        for (int i = 0; i < d.length; i++) {
            if (prev == d[i]) {
                continue;
            }
            prev = d[i];
            if (prev == 'W') {
                countW += 1;
            }
            if (prev == 'B') {
                countB += 1;
            }
        }
        System.out.println(countB + countW - 1);
    }
}


Measured memory_bytes: 25812
import java.util.Arrays; 
import java.util.HashMap;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		boolean first = true;
		while(true){
			String input[] = sc.nextLine().split(" ");
			
			final int n = Integer.parseInt(input[0]);
			final int m = Integer.parseInt(input[1]);
			
			if(n == 0 && m == 0){
				break;
			}
			
			HashMap<String, Integer> dict = new HashMap<String, Integer>();
			int[] parent = new int[n];
			boolean[][] child = new boolean[n][n];
			
			int[] stack = new int[n];
			Arrays.fill(parent, -1);
			
			int number_count = 0;
			for(int i = 0; i < n; i++){
				String line = sc.nextLine();
				String name = line.replaceAll(" ", "");
				
				if(!dict.containsKey(name)){
					dict.put(name, number_count);
					number_count++;
				}
				
				final int cur_number = dict.get(name);
				
				int high = 0;
				while(line.charAt(high) == ' '){
					high++;
				}
				
				if(high != 0){
					parent[cur_number] = stack[high - 1];
					child[stack[high-1]][cur_number] = true;
				}
				stack[high] = cur_number;
				
				
				//System.out.println(dict);
				//System.out.println(Arrays.toString(stack));
			}
			
			for(int i = 0; i < m; i++){
				String[] inputs = sc.nextLine().split(" ");
				
				final int arg1 = dict.get(inputs[0]);
				String ops = inputs[3];
				final int arg2 = dict.get(inputs[5].substring(0, inputs[5].length() - 1));
				
				//System.out.println(arg1 + " " + ops + " " + arg2);
				
				if("child".equals(ops)){
					System.out.println(child[arg2][arg1] ? "True" : "False");
				}else if("parent".equals(ops)){
					System.out.println(parent[arg2] == arg1 ? "True" : "False");
				}else if("sibling".equals(ops)){
					final int p_num= parent[arg2];
					
					if(p_num >= 0){
						System.out.println(child[p_num][arg1] ? "True" : "False");
					}else{
						System.out.println("False");
					}
				}else if("ancestor".equals(ops)){
					int p_num = parent[arg2];
					
					while(p_num >= 0 && p_num != arg1){
						p_num = parent[p_num];
					}
					
					System.out.println(p_num >= 0 ? "True" : "False");
				}else if("descendant".equals(ops)){
					int p_num = parent[arg1];
					
					while(p_num >= 0 && p_num != arg2){
						p_num = parent[p_num];
						//System.out.println(p_num + " " + parent[p_num]);
						//sc.next();
					}
					
					System.out.println(p_num >= 0 ? "True" : "False");
				}
			}
			
			System.out.println();
		}
		
		sc.close();
	}
}

Measured memory_bytes: 43480
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int a, b;
  cin >> a >> b;
  int whiteNum = 1;
  int blackNum = 1;
  vector<char> white(100, '#');
  vector<char> black(100, '.');

  cout << 100 << ' ' << 100 << endl;

  for (int i = 1; i < 50; i += 2){
    for (int i = 0; i < 100; i++) cout << '#';
    cout << endl;
    vector<char> white(100, '#');
    for (int j = 1; j < 100; j += 2){
      if (whiteNum < a) {
        white[j] = '.';
        whiteNum++;
      }
    }
    for(char c : white) cout << c;
    cout << endl;
  }

  for (int i = 1; i < 50; i += 2){
    for (int i = 0; i < 100; i++) cout << '.';
    cout << endl;
    vector<char> black(100, '.');
    for (int j = 1; j < 100; j += 2){
      if (blackNum < b) {
        black[j] = '#';
        blackNum++;
      }
    }
    for(char c : black) cout << c;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int h, m, s, a, S;
	scanf("%d", &S);

	h = S / 3600;
	a = S % 3600;
	m = a / 60;
	s = a % 60;

	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

using namespace std;


int us[200005],n,m=0,c[200005],a1=0,a2=0;
vector<int>e[100005];
void dfs(int v,int l)
{
    int i;
    if(v==n)
    {
        m=l;
        return ;
    }
    for(i=0;i<e[v].size();i++)
    {
        if(us[e[v][i]]==0)
        {
            us[e[v][i]]=1;
            dfs(e[v][i],l+1);
        }
        if(m>0)
        {
            if(l<=m/2)
            {
                c[v]=1;
            }
            else
            {
                c[v]=-1;
            }
            return ;
        }
    }
}
void dfs1(int v)
{
    if(c[v]==-1)
    {
        return ;
    }
    a1++;
    for(int i=0;i<e[v].size();i++)
    {
        if(us[e[v][i]]==0)
        {
            us[e[v][i]]=1;
            dfs1(e[v][i]);
        }
    }
}
void dfs2(int v)
{
    if(c[v]==1)
    {
        return ;
    }
    a2++;
    for(int i=0;i<e[v].size();i++)
    {
        if(us[e[v][i]]==0)
        {
            us[e[v][i]]=1;
            dfs2(e[v][i]);
        }
    }
}
int main()
{
    int i,a,b;
    scanf("%d",&n);
    for(i=0;i<n-1;i++)
    {
        scanf("%d %d",&a,&b);
        e[a].push_back(b);
        e[b].push_back(a);
    }
    c[1]=1;
    c[n]=-1;
    dfs(1,0);
    us[1]=1;
    memset(us,0,sizeof(us));
    dfs1(1);
    us[1]=1;
    memset(us,0,sizeof(us));
    dfs2(n);
    us[1]=1;
    if(a1>a2)
    {
        printf("Fennec\n");
    }
    else
    {
        printf("Snuke\n");
    }
    return 0;
}


Measured memory_bytes: 11520