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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  --a;
  --b;
  --c;
  --d;

  bool ans = true;
  rep(i, a, c - 2) {
    if (s[i] == '#' && s[i + 1] == '#') ans = false;
  }
  rep(i, b, d - 2) {
    if (s[i] == '#' && s[i + 1] == '#') ans = false;
  }
  if (c > d) {
    ans = false;
    rep(i, b, d) {
      if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') {
        ans = true;
        break;
      }
    }
  }
  if (ans) { cout << "Yes\n"; }
  else { cout << "No\n"; }

  return 0;
}


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

using namespace std;

int abs(int a, int b){
  if(a >= b){return a - b;}
  else{return b - a;}}

int main(){ 
 vector<int> vec(6); for(int i = 0; i < 5; i++){cin >> vec[i];}
  int k ; cin >> k;
  
  int max_diff = 0;
  
  for(int i = 0; i < 4; i++){
    for(int j = i+1; j < 5; j++){
      max_diff = max(max_diff,abs(vec[j],vec[i]));}}
  
 if( max_diff > k){cout << ":(" <<endl;}
  else{cout << "Yay!"<< endl;}
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    if(n%2==0){
      ans = n/2-1;
    }
    else{
      ans = n/2;
    }
    System.out.println(ans);
  }
}
     

Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

map<string, llong> mp;

int main() {
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    string s;
    cin >> s;
    cout << mp[s] << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<long long> Lucas(N+1);
  Lucas.at(0)=2LL; 
  Lucas.at(1)=1LL;
  for (int i=0;i<N-1;i++){
    Lucas.at(i+2)=Lucas.at(i+1)+Lucas.at(i);
  }
  cout << Lucas.at(N) << endl;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char s[5],t[5];
int main(){
	scanf("%s%s",s+1,t+1);
	printf("%d\n",(s[1]==t[1])+(s[2]==t[2])+(s[3]==t[3]));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
int main(){
  int s,x,y,z,k,t;
  cin >> k >> s;
  t=0;
  for(x=0;x<=k;x++){
    for(y=0;y<=k;y++){
        z=s-x-y;
        if(z<=k&&z>=0)
          t=t+1;
   }}
   cout << t;
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include <iterator>

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    std::map<int, int, std::greater<int>> bucket;
    for(int i = 0; i < n; i++){
        int value;
        scanf("%d", &value);
        bucket[value]++;
    }

    for(int i = 0; i < m; i++){
        int b, c;
        scanf("%d %d", &b, &c);
        bucket[c] += b;
    }

    long sum = 0;
    int count = 0;
    for(auto const& entry: bucket){
        if(count + entry.second >= n){
            sum += (long)entry.first * (long)(n - count);
            break;
        }else{
            sum += (long)entry.first * (long)entry.second;
            count += entry.second;
        }
    }

    printf("%ld\n", sum);
}

Measured memory_bytes: 9600
N = gets.to_i

ns = []
list_x = []
list_y = []
N.times{|i|
	pos = gets.strip.split(/ /).collect(&:to_i)
	ns << pos
	x, y = pos
	if l = list_x[x]
		l << i
	else
		list_x[x] = [i]
	end
	if l = list_y[y]
		l << i
	else
		list_y[y] = [i]
	end
}

groups = N.times.to_a

def get_root(groups, g)
	parent = groups[g]
	if parent == g
		return parent
	else
		return groups[g] = get_root(groups, parent)
	end
end

def set_root(groups, g, root)
	parent = groups[g]
	groups[g] = root
	if parent == g
		return
	else
		set_root(groups, parent, root)
	end
end

def combine(groups, g1, g2)
	root = get_root(groups, g1)
	set_root(groups, g2, root)
end

def combine_groups(groups, l)
	if l
		if l.length > 1
			i1 = l[0]
			(1...l.length).each{|i|
				i2 = l[i]
				combine(groups, i1, i2)
				i1 = i2
			}
		end
	end
end

list_x.each{|l|
	combine_groups(groups, l)
}

list_y.each{|l|
	combine_groups(groups, l)
}

table = {}
groups.each_with_index{|g, i|
	g = get_root(groups, g)
	if l = table[g]
		l << i
	else
		table[g] = [i]
	end
}

count = 0
table.values.each{|list|
	x_table = {}
	y_table = {}
	list.each{|i|
		x, y = ns[i]
		x_table[x] = true
		y_table[y] = true
	}
	x_count = x_table.length
	y_count = y_table.length
	if x_count >= 2 && y_count >= 2
		count += (x_count * y_count - list.length)
	end
}
puts count


Measured memory_bytes: 27896
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		long X = Long.parseLong(sc.next());
		long Y = Long.parseLong(sc.next());
		int ans = 0;
		while(X<=Y){
			X = X*2;
			ans++;
		}
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


string S;
int K;

int main() {
  cin >> S >> K;
  vector<string> vec;
  for (int i = 0; i < S.size(); ++i) {
    for (int j = 1; j <= K; ++j) {
      string tmp = S.substr(i, j);
      vec.push_back(tmp);
    }
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  cout << vec[K-1] << endl;
}

Measured memory_bytes: 1660
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll a, b, c, d; cin >> a >> b >> c >> d;
  ld h = c * 30. + 30. * d / 60.;
  ld m = d * 6.;
  h = abs(h - m);
  h = min(360. - h, h);
  fin(sqrt(a * a + b * b - 2 * a * b * cos(h *PI / 180.)));
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 4168
import java.util.*;

class Main{
  static public void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt(),
    b=sc.nextInt(),c=sc.nextInt();
    if(a<=c&&c<=b)System.out.println("Yes");
    else System.out.println("No");
    sc.close();
  }
}


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

static const int IINF = 1 << 30;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

int main() {
  // Input
  std::string S;
  int K;
  int N;
  std::cin >> S;
  std::cin >> K;
  N = S.length();

  // Initialization
  auto dp = vectors<int>(1 + N + 1, 1 + N + 1, 1 + K + 1, -IINF);

  // Initial condition
  for (int k = 0; k <= K; ++k)
    dp[0][0][k] = 0;

  // DP main
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      for (int k = 0; k <= K; ++k) {
        chmax(dp[i + 1][j][k], dp[i][j][k]);
        chmax(dp[i][j + 1][k], dp[i][j][k]);
        chmax(dp[i + 1][j + 1][k + 1], dp[i][j][k] + 1);
        if (i < N and j < N and S[i] == S[N - j - 1])
          chmax(dp[i + 1][j + 1][k], dp[i][j][k] + 1);
      }
    }
  }

  // Output
  int res = -1;
  for (int i = 0; i <= N; ++i)
    chmax(res, 2 * dp[i][N - i][K]);
  for (int i = 0; i < N; ++i)
    chmax(res, 2 * dp[i][N - i - 1][K] + 1);

  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 111104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll ans=b-b/c-b/d+b/lcm(c,d);
    ans-=(a-1)-(a-1)/c-(a-1)/d+(a-1)/lcm(c,d);

    cout<<ans<<endl;
}



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

int main() {
  string S; cin >> S;
  int w; cin >> w;

  string ans="";
  for(int i=0; i<S.size(); i++){
    if(i%w == 0) ans = ans + S[i];
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    while(N--) {
        int s, d;
        cin >> s >> d;
        int now = s;
        int res = 0;
        while(now != d) {
            int mv;
            for(int i=1; now+i<=d; i <<= 1) {
                if(now % i == 0) {
                    mv = i;
                }
            }
            res++;
            now += mv;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N;
	cin >> N;
	vector<vector<ll>> edge(N, vector<ll>());
	//vector<vector<ll>> color(N, vector<ll>(N, 0));
	map<pair<ll, ll>, ll> color;
	vector<pair<ll, ll>> store;
	ll color_sum = 0;

	rep(i, N - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		store.emplace_back(make_pair(a, b));
		edge[a].emplace_back(b);
		edge[b].emplace_back(a);
	}

	ll pos = 0;
	queue<pair<ll, ll>> Q;
	Q.push(make_pair(0, 0));

	while (Q.size() != 0) {

		/*now,pre*/
		pair<ll, ll> P = Q.front();
		Q.pop();

		ll clr = 1;
		ll ald = color[P];

		rep(i, edge[P.first].size()) {
			if (edge[P.first][i] == P.second) continue;

			if (clr == ald) clr++;

			color_sum = max(clr, color_sum);
			color[make_pair(P.first, edge[P.first][i])] = clr;
			color[make_pair(edge[P.first][i], P.first)] = clr;

			Q.push(make_pair(edge[P.first][i], P.first));

			clr++;

		}
	}

	//debug(color);
	//debug(store);

	cout << color_sum << endl;

	rep(i, N - 1) {
		cout << color[make_pair(store[i].first, store[i].second)] << endl;
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 20592
#include <stdio.h>

int main(void) {
	int n,x,ans=0;
	int dou[1005];
	scanf("%d%d",&n,&x);
	int min=100000;
	for(int i=0; i<n; i++){
		scanf("%d",&dou[i]);
		if(dou[i] < min)min=dou[i];
		x-=dou[i];
	}
	ans=n+(x/min);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> adj[100005];
map<ll,bool> visited;
void dfs(ll i,ll parent){
    if(!visited[i]){
        visited[i]=true;
        for(auto it: adj[i]){
            if(it!=parent)
                dfs(it,i);
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m,i,x,y,ans=0;
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        x-=1;y-=1;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(i=0;i<n;i++){
        if(!visited[i]){
            dfs(i,i);
            ans+=1;
        }
    }
    cout<<ans-1<<endl;
    return 0;
}



Measured memory_bytes: 18164
/*input
24

*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define fore( i ,st) for ( int i= 0 ; i < (int)(st) ; i ++)
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bug(x) cout <<__LINE__ << ":"<<__FILE__ << " : " <<   #x  << " = " << x << "\n";

#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

const int maxn =1e5 + 5;

int n , m ;
string ans;

int getmax( int x){
	if ( x == 0 )return  0;
	int t =2 ,p =3;
	int w =0;
	while( t <= x){
		w++;
		t+=p;
		p++;
	}
	
	return w;

}


void solve(int test ) 
{	
	int n;
	cin >> n ;
	int t = n;
	int cnt =0;
	for ( int i =2; i *i <= n ; i++){
		if ( n % i ==0 ){
			cnt++;
			n= n / i;
			int tmp=0;
			if ( n% i ==0 ){
			while( n % i == 0 ){
			n/=i;
			tmp++;
		}
			}
			// cout << tmp << "\n";
			cnt += getmax( tmp);
		}
	}
	if (n > 1) cnt++;
	cout <<cnt;

}
signed main(){
	// bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	for ( int i = 0 ; i < t; i++)
	solve(i+1);
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,a[N],ans=1e9;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=-100;i<=100;i++){
		int num=0;
		for (int j=1;j<=n;j++)num+=(i-a[j])*(i-a[j]);
		ans=min(ans,num);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

ans = 0
attack = []

for a, b in ab:
    attack += [[a, 0]]
    attack += [[b, 1]]

attack = sorted(attack, key=lambda x:(-x[0], x[1]))

for a, i in attack:
    if i == 1:
        H -= a
        ans += 1
        if H <= 0:
            break
    else:
        cnt = (H-1)//a + 1
        ans += cnt
        break

print(ans)

Measured memory_bytes: 122860
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define debug(elem) foreach(e, elem){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+8
#define PI acos(-1)
using ll = long long;
using ull = unsigned long long;
ll MOD = 1000000007;

map<char, int> mp;

int main(){
    string s;
    cin >> s;
    foreach(e, s){
        mp[e]++;
    }

    foreach(e, mp){
        if(e.second >= 2){
            println("no");
            stop;
        }
    }

    println("yes");
}

Measured memory_bytes: 256
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>
#define MOD (ll)(1e9 + 7)

vvi mult(vvi a, vvi b, ll n) {
    vvi temp(n);
    for (auto &it : temp) {
        it.resize(n, 0);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                temp[i][j] += (a[i][k] * b[k][j]) % MOD;
                temp[i][j] %= MOD;
            }
        }
    }

    return temp;
}

vvi binpow(vvi a, ll p, ll n) {
    vvi b(n);
    for (auto &it : b) {
        it.resize(n, 0);
    }

    for (int i = 0; i < n; i++) {
        b[i][i] = 1;
    }

    while (p > 0) {
        if (p & 1) {
            b = mult(b, a, n);
        }

        p >>= 1;
        a = mult(a, a, n);
    }

    return b;
}

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

    ll n, k;
    cin >> n >> k;

    vvi adj(n);
    for (auto &it : adj) {
        it.resize(n);
    }

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

    adj = binpow(adj, k, n);
    ll ans = 0;

    for (auto it : adj) {
        for (auto itr : it) {
            ans += itr;
            ans %= MOD;
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 384
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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


int main(){
    string S;
    cin >> S;
    int ans = 100000;
    for(int i = 0; i <= S.length()-3; i++){
        int X = stoi(S.substr(i, 3));
        ans = min(ans, abs(X - 753));
    }
    
    cout << ans << endl;
    return 0;
}


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



int main(){
  
  string s;
  cin >>s;
  string t;
  cin >>t;
  string s2=s+s;
  string ans="No";
  for(int i=0;i<s.length();i++){
    if(s2.substr(i,s.length())==t){
      ans="Yes";
      break;
    }
  }
  
  cout <<ans<<endl;
  return 0;
}

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

const int N = 2005;
int n, ans = N * N, x;

vector <int> adj[N];
vector <int> vec[N];
bool mark[N];
int sum[N];
int maxs[N];
int cnt[N];
string s;

void dfs(int v, int d = 0) {
	mark[v] = true;
	if (s[v] == '1') {
		x += d;
		cnt[v]++;
	}
	int maxi = 0, maxfor = n;
	for (auto u : adj[v]) {
		if (!mark[u]) {
			dfs(u, d + 1);
			cnt[v] += cnt[u];
			sum[v] += sum[u] + cnt[u];
			maxs[v] += maxs[u] + cnt[u];
			if (sum[u] + cnt[u] >= maxi) {
				maxfor = u;
				maxi = sum[u] + cnt[u];
			}
			maxi = max(maxi, sum[u] + cnt[u]);
		}
	}
	int q = sum[v] % 2;
	sum[v] = max(0, maxi + maxs[maxfor] + cnt[maxfor] - maxs[v]);
	sum[v] = max(sum[v], q);
//	cout << "72 " << v << " " << maxi << " " << maxfor << " " << sum[v] << endl;
//	if (q) {
//		sum[v] = max(sum[v], 1ll);
//	}
}

int main() {
	cin >> n >> s;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 0; i < n; i++) {
		x = 0;
		fill(mark, mark + n, false);
		fill(sum, sum + n, 0);
		fill(cnt, cnt + n, 0);
		fill(maxs, maxs + n, 0);
		mark[i] = true;
		dfs(i);
//		for (int j = 0; j < n; j++) {
//			cout << "73 " << j << " " << cnt[j] << " " << sum[j] << " " << maxs[j] << " " << x << endl;
//		}
		if (sum[i] == 0) {
			ans = min(ans, x / 2);
		}
	}
	if (ans == N * N) {
		cout << -1;
	}
	else {
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 3912
S = input()
N = int(len(S))

S1 = S[:int(N/2)]
S2 = S[int(N/2)+1:N]
#print(S1)
#print(S2)

for i in range(int(N/2)):
    if(S[i] != S[N-1-i]):
        print("No")
        exit()

    if(S1[i] != S1[int(N/2)-1-i]):
        print("No")
        exit()

    if(S2[i] != S2[int(N/2)-1-i]):
        print("No")
        exit()

print("Yes")        

Measured memory_bytes: 9140
// AOJ 2208: The Melancholy of Thomas Right
// 2017.11.7 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

int r[10001], c[10001];

char buf[60001], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int input(int *a, int n)
{
	int i, r;

	i = n, r = 1;
	fgets(p=buf, 60000, stdin);
	while (i--) {
		*a = getint(), p++;
		if (*a++ > n) r = 0;
	}
	return r;
}

int des(int *a, int *b) { return *b - *a; }
int inc(int *a, int *b) { return *a - *b; }
int main()
{
	int n, i, j, k, ans;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		ans = 1;
		ans &= input(r+1, n);
		ans &= input(c+1, n);
		if (!ans) goto done;
		if (n == 1) { ans = r[1] == c[1]; goto done; }
		r[0] = n, c[0] = -1;

		qsort(r+1, n, sizeof(int), des);
		qsort(c+1, n, sizeof(int), inc);
		
		for (j = 0, i = 1; i <= n; i++) {
			if (r[i] != r[i-1] && c[j+1] != c[j]) {
				k = c[j+1];	while (j <= n && c[j+1] == k) j++;
			}
			if (r[i] + j != n) { ans = 0; break; }
		}
done:	puts(ans ? "Yes" : "No");
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string str;
    string f,b;
    set<string> set;
    cin>>str;
    set.insert(str);
    for(int j=1;j<str.size();j++){
    f=str.substr(0,j);
    b=str.substr(j);
    set.insert(b+f);
    reverse(f.begin(),f.end());
    set.insert(f+b);
    set.insert(b+f);
    reverse(b.begin(),b.end());
    set.insert(b+f);
    set.insert(f+b);
    reverse(f.begin(),f.end());
    set.insert(b+f);
    set.insert(f+b);
    }
    cout<<set.size()<<endl;
  }
  return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<int> a(n);
	vector<vector<pair<int, int> > > xy(20);
	REP(i, n) {
		cin >> a[i];
		REP(j, a[i]) {
			int x, y; cin >> x >> y;
			xy[i].push_back(make_pair(--x, y));
		}
	}

	int maxi = 0;
	REP(mask, 1 << n) {
		bool ok = true;
		for (int i = 0; i < n && ok; i++) {
			if (!(mask & (1 << i)))
					continue ;
			for (auto p : xy[i])
				if (bool(mask & (1 << p.first)) != p.second)
					ok = false;
		}
		if (ok)
			maxi = max(maxi, __builtin_popcount(mask));
	}
	cout << maxi << '\n';
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B)
        cout << C << endl;
    else if (B == C)
        cout << A << endl;
    else
        cout << B << endl;

    return 0;
}

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

#define MAX_N 8

int main() {
  int n;
  int ans = 3000;
  int abc[3], l[MAX_N];

  std::cin >> n >> abc[0] >> abc[1] >> abc[2];
  for(int i = 0; i < n; ++i) {
    std::cin >> l[i];
  }

  for(int i = 0; i < (1 << 2 * n); ++i) {
    int v[MAX_N];
    for(int j = 0; j < n; ++j) {
      v[j] = (i >> 2 * j) & 3;
    }

    int length[3] = {0};
    int cost = -30;

    for(int j = 0; j < n; ++j) {
      if(v[j] < 3) {
        length[v[j]] += l[j];
        cost += 10;
      }
    }

    bool f = false;
    for(int j = 0; j < 3; ++j) {
      if(length[j] == 0) {
        f = true;
        break;
      }
    }
    if(f) continue;

    for(int j = 0; j < 3; ++j) {
      int d = abc[j] - length[j];
      cost += (d >= 0) ? d : -d;
    }

    ans = std::min(ans, cost);
  }

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


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

typedef long long int ll;



int main(){
  ll n,k;
  cin>>n>>k;
  ll i;
  vector <ll> freq(n+1);
  while(k--){
    ll d;
    cin>>d;

    for(i=0;i<d;i++){
      ll x;
      cin>>x;
      freq[x]++;
    }
  }
  ll cnt=0;
  for(i=1;i<=n;i++){
    if(!freq[i]){
      cnt++;
    }
  }
  cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 3628
import sys
from collections import defaultdict, deque
sys.stdin.readline().split()
A = defaultdict(deque)
ans = []
for query in sys.stdin:
    if query[0] == '0':
        t, x = query[2:].split()
        A[t].append(x)
    elif query[0] == '1':
        ans.append(' '.join(A[query[2:-1]]) + '\n')
    else:
        s, t = query[2:].split()
        if A[t]:
            if len(A[s]) == 1:
                A[t].append(A[s][0])
            elif len(A[t]) == 1:
                A[s].appendleft(A[t][0])
                A[t] = A[s]
            else:
                A[t].extend(A[s])
        else:
            A[t] = A[s]
        A[s] = deque()
sys.stdout.writelines(ans)


Measured memory_bytes: 45768
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N,A,B;
  in(N,A,B);
  out(min(N*A,B));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    int N,X;
    int L[100];
    cin >> N >> X;
    for (int i=0; i<N; i++) cin >> L[i];

    int step = 1;
    int d = 0;
    for (int i=0; i<N; i++) {
        d += L[i];
        if (d <= X) step++;
    }
    cout << step << endl;
    return 0;
}



Measured memory_bytes: 256
def judge(s):
  s=sorted(s)
  ls=len(s)
  t=list(set(s))
  lt=len(t)
  if ls==lt:
    return "YES"
  else:
    return "NO"

n=int(input())
a=list(map(int,input().split()))
result=judge(a)
print(result)

Measured memory_bytes: 105428
#include<stdio.h>
#include<iostream>
using namespace std;
struct Y
{
char s;
int b;
int t=0;
};
int main(){
int i,j,n,ad;
Y d,f[52];
for(i=0;i<4;i++){
	for(j=0;j<13;j++){
		ad=i*13+j;
		if(i==0)
			f[ad].s='S';
		else if(i==1)
			f[ad].s='H';
		else if(i==2)
			f[ad].s='C';
		else
			f[ad].s='D';
		f[ad].b=j+1;
	}
}
scanf("%d",&n);
for(i=0;i<n;i++){

	scanf( "%c" ,&d.s ) ;

	scanf("%c %d",&d.s,&d.b);

	for(j=0;j<52;j++){
		if(d.b==f[j].b&&d.s==f[j].s){
			f[j].t=1;
		}
	}
}
for(i=0;i<52;i++){	
	if(f[i].t==0){
		printf("%c %d\n",f[i].s,f[i].b);
	}
}
return 0;
}

Measured memory_bytes: 3228
# -*- coding: utf-8 -*-

def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

s = int(input())
a = [s]

for m in range(1, 1000001):
    a_m = f(a[m-1])

    if a_m in a:
        print(m+1)
        break
    else:
        a.append(a_m)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
map<ll,bool> pot;
vector<pair<ll,ll>> G[200005];
ll Gc[200005];
map<ll,ll> mp;
map<ll,ll> nmp;
 
ll answer;
 
ll getPair(ll x, map<ll,ll>& cnt){
  if(pot.count(x) > 0) return -1;
  ll p = 1;
  while(p < x) p*=2;
  if(cnt.count(p-x) > 0) return p-x;
  return -1;
}
 
void calc(ll id){
  //cout << nmp[id] << endl;
  rep(i,G[id].size()){
    pair<ll,ll> tmp = G[id][i];
    if(tmp.second == -1) continue;
    //cout << " " << tmp.first << " " << tmp.second << endl;
    calc(tmp.first);
    if(Gc[id] > 0 && Gc[tmp.first] > 0){
      ll mn = min(Gc[id], Gc[tmp.first]);
      answer += mn;
      Gc[id] -= mn;
      Gc[tmp.first] -= mn;
    }
  }
}
 
ll solve(const vector<ll>& v){
  map<ll,ll> cnt;
  rep(i,v.size()){
    cnt[v[i]]++;
  }
 
  vector<ll> out(cnt.size(), 0);
  ll no = 0;
  FOR(it,cnt){
    ll id1 = no;
    mp[it->first] = id1;
    //nmp[id1] = it->first;
    Gc[id1] = it->second;
 
    //cout << "check: " << it->first << endl;
    ll tmp = getPair(it->first, cnt);
    if(tmp != -1){
      ll id2 = mp[tmp];
      //cout << " pair: " << nmp[id1] << " " << nmp[id2] << endl;
      G[id1].push_back(make_pair(id2,-1));
      G[id2].push_back(make_pair(id1,1));
      out[id1]++;
    }
    no++;
  }
 
  answer = 0;
  rep(i,out.size()){
    if(out[i] != 0) continue;
    calc(i);
  }
  return answer;
}
 
 
int main(){
 
  ll p = 1;
  while(p<1e12){
    pot[p] = true;
    p *= 2;
  }
 
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));
  ll ret = solve(v);

  FOR(it,pot){
    if(mp.count(it->first) > 0){
      ret += (Gc[mp[it->first]])/2;
    }
  }
 
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 40564
N,K = map(int, input().split())
dp = [0]*(K+1)
MOD = 10**9+7
ans = 0
for X in range(K,0,-1):
  m = pow(K//X,N,MOD)
  x = 2*X
  while x<=K:
    m -= dp[x]
    m %= MOD
    x += X
  ans += X*m
  ans %= MOD
  dp[X] = m
print(ans)
  

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

template<class graph_type,class T> std::vector<T> spfa(const graph_type &graph,const int start){
    std::vector<T> dist(graph.size(),std::numeric_limits<T>::max());
    std::deque<int> dq;
    std::vector<bool> in_dq(graph.size(),false);
    dist[start]=0;
    dq.push_back(start);
    in_dq[start]=true;

    int64_t denom=1,numer=0;
    auto small_label_first=[&](){
        const int u=dq.front(),v=dq.back();
        if(dist[u]>dist[v]){
            dq.pop_back();
            dq.push_front(v);
        }
    };
    auto large_label_last=[&](){
        while(dist[dq.front()]*denom>numer){
            dq.push_back(dq.front());
            dq.pop_front();
        }
    };
    while(!dq.empty()){
        const int u=dq.front();
        dq.pop_front();
        in_dq[u]=false;
        --denom;
        numer-=dist[u];
        for(const auto &edge:graph[u]){
            const int v=edge.first;
            if(dist[v]>dist[u]+edge.second){
                dist[v]=dist[u]+edge.second;
                if(!in_dq[v]){
                    dq.push_back(v);
                    in_dq[v]=true;
                    ++denom;
                    numer+=dist[v];
                    small_label_first();
                    large_label_last();
                }
            }
        }
    }
    return dist;
}

void solve(){
    int v,e,r;
    cin >> v >> e >> r;
    vector<vector<pair<int,int>>> graph(v);
    rep(i,0,e){
        int s,t,d;
        cin >> s >> t >> d;
        graph[s].push_back(make_pair(t,d));
    }
    vector<int> dist=spfa<vector<vector<pair<int,int>>>,int>(graph,r);
    rep(i,0,v){
        if(dist[i]==std::numeric_limits<int>::max()) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 12316
#import<iostream>
#define F for(i=0;i<N;++i)
using namespace std;int N,b[111][12],c,A,i,j;main(){cin>>N;F for(j=0;j<10;*b[i]|=c<<j,++j)cin>>c;F for(j=0;j<11;)cin>>b[i][++j];A=-1<<30;for(j=1;j<1024;++j,A=max(A,c)){c=0;F c+=b[i][__builtin_popcountll(*b[i]&j)+1];}cout<<A<<"\n";}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S; cin >> S;
    while(S.length() >= 2) {
        S.erase(S.length() - 2, 2);
        bool is_same = true;
        REP(i, S.length() / 2) {
            if(S[i] != S[i + S.length() / 2]) {
                is_same = false;
                break;
            }
        }
        if(is_same) {
            break;
        }
    }
    cout << S.length() << "\n";
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <queue>
using namespace std;

int main () {
	vector<int> v(5, 0);
	for (int i = 0; i < 3; i++) {
		int a, b;
		cin >> a >> b;
		v[a]++;
		v[b]++;
	}	
	int res = 0;
	for (int i = 1; i <= 4; i++) {
		if (v[i] == 0) {
			cout << "NO";
			return 0;
		}
		if (v[i] % 2 == 1)
			res++;
	}
	if (res > 2)
		cout << "NO";
	else
		cout << "YES";
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define neko 200010
#define feko 800010
#define meko 200010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
int cnt,a[neko],b[neko],c[neko],tag[neko],n,m;
typedef int ars[feko];
ars Sum,Cov;
int cmax(int a,int b){return a>b?a:b;}
namespace Seg_Tree
{
	#define ori tagl,tagr
	#define lson root<<1,l,mid
	#define rson root<<1|1,mid+1,r
	void pushup(int root)
	{Sum[root]=Sum[root<<1]+Sum[root<<1|1];}
	void pushdown(int root,int l,int r,int mid)
	{
		if(Cov[root])
		{
			Sum[root<<1]=mid-l+1,Sum[root<<1|1]=r-mid;
			Cov[root<<1]=Cov[root<<1|1]=1;
			Cov[root]=0;
		}
	}
	void update(int root,int l,int r,int tagl,int tagr)
	{
		if(l>=tagl&&r<=tagr){Sum[root]=r-l+1,Cov[root]=1;return;}
		int mid=(l+r)>>1;
		pushdown(root,l,r,mid);
		if(tagl<=mid)update(lson,ori);
		if(tagr>mid)update(rson,ori);
		pushup(root);
	}
	void repair(int root,int l,int r,int tag,int x)
	{
		if(l==r){Sum[root]=x;return;}
		int mid=(l+r)>>1;
		pushdown(root,l,r,mid);
		if(tag<=mid)repair(lson,tag,x);
		else repair(rson,tag,x);
		pushup(root);
	}
	int query(int root,int l,int r,int tagl,int tagr)
	{
		if(l>=tagl&&r<=tagr)return Sum[root];
		int mid=(l+r)>>1;
		pushdown(root,l,r,mid);
		int tmp=0;
		if(tagl<=mid)tmp=query(lson,ori);
		if(tagr>mid)tmp+=query(rson,ori);
		return tmp;
	}
}
int main()
{
	using namespace Seg_Tree;
	int x,y;
	scanf("%d%d",&n,&m);
	f(i,1,n)scanf("%d",&a[i]),c[i]=a[i];
	std::sort(a+1,a+n+1);
	f(i,1,n)
	{
		if(a[i]^a[i-1]&&i>1)
		{
			if(a[i-1]-cnt+1<1)
			{
				f(j,a[i-1]-cnt+1,1)++tag[1];
				f(j,2,a[i-1])++tag[j];
			}
			else f(j,a[i-1]-cnt+1,a[i-1])++tag[j];
			update(1,1,n,cmax(a[i-1]-cnt+1,1),a[i-1]);
			b[a[i-1]]=cnt,cnt=1;
		}
		else ++cnt;
	}
	if(a[n]-cnt+1<1)
	{
		f(j,a[n]-cnt+1,1)++tag[1];
		f(j,2,a[n])++tag[j];
	}
	else f(j,a[n]-cnt+1,a[n])++tag[j];
	update(1,1,n,cmax(a[n]-cnt+1,1),a[n]),b[a[n]]=cnt;
	f(i,1,m)
	{
		scanf("%d%d",&x,&y);
		if(tag[cmax(c[x]-b[c[x]]+1,1)]==1)repair(1,1,n,c[x]-b[c[x]]+1,0);
		--tag[cmax(c[x]-b[c[x]]+1,1)],--b[c[x]];
		if(!tag[cmax(y-b[y],1)])repair(1,1,n,cmax(y-b[y],1),1);
		++tag[cmax(y-b[y],1)],++b[y];
		printf("%d\n",n-query(1,1,n,1,n));
		c[x]=y;
	}return 0;
}

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

#define MAX_V 100000
#define INF 111111111
struct edge{int to,cost;};
typedef pair<int ,int> P; //firstは距離、secondは頂点の番号

int V; //頂点数
vector<edge> G[MAX_V]; //添字がfrom
int d[MAX_V]; //最短コスト

int prim(){
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d,d+V,INF);
  int res=0;
  que.push(P(0,0));
  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;
    if(d[v]!=INF)continue;
    res+=p.first;
    d[v]=p.first;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]==INF)que.push(P(e.cost,e.to));
    }
  }
  return res;
}

int main(){
  int E;
  cin>>V>>E;
  for(int i=0;i<E;i++){
    int s,t,c;
    edge e;
    cin>>s>>t>>c;
    e.to=t,e.cost=c;
    G[s].push_back(e);
    e.to=s;
    G[t].push_back(e);
  }
  cout<<prim()<<endl;
  return 0;
}



Measured memory_bytes: 8920
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextLong();
        }
        
        //       3
        //       3
        //  3 4 3 2
        // 6 4 3 2 2
        // 117 5 3 2
        long min = 2;
        long max = 2;
        String ans = "";
        for (int i = n-1; i >= 0; i--) {
            long num = array[i];
            long nmin = (min + num-1) / num * num;
            long nmax = max / num * num;
            
            if (min <= nmin && nmin <= nmax && nmax <= max) {
                min = nmin;
                max = nmax;
                max += (array[i]-1);
            } else {
                ans = "-1";
                break;
            }
            
            // System.out.println(num + " " + min + " " + max);
        }
        
        if (!ans.equals("-1")) {
            ans = min + " " + max;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 62164
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class MBR{
 public:
	char A;
	int count;
	
};

bool solution(const string& S ){
	bool result;
	int n = S.size();
	vector<MBR> MEMBER;
	
	MBR element;
	char b;
	
	for(int i = 0; i < n; i++){
		b = S[i];
		bool match = false;
		for(int j = 0; j < MEMBER.size(); j++){
			if(MEMBER[j].A == b) {
				MEMBER[j].count++;
				match = true;
			}
		}
		
		element = {b, 1};
		if(match == false){
			MEMBER.push_back(element);
			
		}
	}
	

	for(int j = 0; j < MEMBER.size(); j++){
		if(MEMBER[j].count != 2) {
				return false;
		}
	}	
	
	
	
	return true;
	
}


int main(){
  string S;
  
  cin >> S;
  
  bool result = solution(S);
  
  if (result == true) cout << "Yes" << endl;
  if (result == false) cout << "No" << endl;
  
  
  
  return 0; 
}


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

struct line{
	long long m;
	long long b;
	line(){};
	line(long long _m, long long _b){
		m = _m;
		b = _b;
	}
};

const int N = 200000+5;

int n;
int len;
int h[N];
long long C;
vector<line> CHT;
long long memo[N];

bool L3isUseless(line l1, line l2, line l3){
	return 0 < (l2.b - l1.b) * (l1.m - l3.m) - (l3.b - l1.b) * (l1.m - l2.m);
}

void add_line(line x){
	int len = CHT.size();
	while(len >= 2 and L3isUseless(CHT[len-2],CHT[len-1],x)){
		len -= 1;
	}
	CHT.resize(len);
	CHT.emplace_back(x);
	len++;
}

long long f(int pos, long long x){
	return CHT[pos].m * x + CHT[pos].b;
}

long long getMinimum(long long x){
	int lo = 0, hi = CHT.size() - 1;
	while(lo < hi){
		int mi = lo + (hi-lo)/2;
		if(f(mi,x) <= f(mi+1,x)) hi = mi;
		else lo = mi + 1;
	}
	return f(lo,x);
}

int main() {
	cin >> n >> C;
	for(int i=1; i<=n; i++){
		cin >> h[i];
	}
	memo[1] = 0;
	add_line(line(-2LL * h[1],1LL * h[1] * h[1]));
	for(int i=2; i<=n; i++){
		memo[i] = getMinimum(h[i]) + 1LL * h[i] * h[i] + C;
		add_line(line(-2LL * h[i], 1LL * h[i] * h[i] + memo[i]));
	}
	cout << memo[n] << endl;
	return 0;
}

Measured memory_bytes: 8560
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>


using namespace std;

int main()
{
    string s;
    cin>>s;
    string tmp=s;
    reverse(s.begin(),s.end());
    
    string subs=tmp.substr(0,((s.size()-1)/2));
    string Rsubs=subs;
    reverse(Rsubs.begin(),Rsubs.end());
    
    string subs2=tmp.substr(((s.size()+3)/2)-1,s.size());
    string Rsubs2=subs2;
    reverse(Rsubs2.begin(),Rsubs2.end());

    //cout<<subs2<<" "<<Rsubs2<<endl;
    if(s==tmp&&subs==Rsubs&&subs2==Rsubs2){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}






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

#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PrintLn(X) cout << X << endl
int main(void)
{
	int N, M;
	cin >> N >> M;
	int ans[50] = {0};
	Rep(i, M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		ans[a]++;
		ans[b]++;
	}
	Rep(i, N){
		PrintLn(ans[i]);
	}
	return 0;
}


Measured memory_bytes: 256