akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
        //#define endl '\n'
        #define modulo 1000000007
        #define int long long
        #pragma GCC optimize("-Ofast")
        #define float double
        #define PI 3.141592653589793238462643383279502884
        #define sinDegrees(x) sin((x) * PI / 180.0)
        #define tanDegrees(x) tan((x) * PI / 180.0)
        #define atanDegrees(x) atan(x)* 180.0 / PI
        #define f first
       // #define s second
        using namespace std;
        int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
        int inv(int x)
        {
        return (power(x,modulo-2,modulo))%modulo;
        }
        bool comp(int a,int b)
        {
            return a>b;
        }
        ///Solution created by:Ahmadsm2005
        int32_t main()
        {
            //freopen("output.txt","w", stdout);
            //freopen("input0.txt","r", stdin);
            iostream::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            int n;
            cin>>n;
            cout<<n*(n+1)/2;
            return 0;
        }


Measured memory_bytes: 256
s = input()
K = int(input())
ans = []
for i in s:
    if not (i in ans):
        ans.append(i)
ans.sort()
ans = ans[:5]
j = len(s)
if j >= 2:
    for i in range(j-1):
        if (s[i] in ans) and not (s[i:i+2] in ans):
            ans.append(s[i:i+2])
ans.sort()
ans = ans[:5]
if j >= 3:
    for i in range(j-2):
        if (s[i:i+2] in ans) and not (s[i:i+3] in ans):
            ans.append(s[i:i+3])
ans.sort()
ans = ans[:5]
if j >= 4:
    for i in range(j-3):
        if (s[i:i+3] in ans) and not (s[i:i+4] in ans):
            ans.append(s[i:i+4])
ans.sort()
ans = ans[:5]
if j >= 5:
    for i in range(j-4):
        if (s[i:i+4] in ans) and not (s[i:i+5] in ans):
            ans.append(s[i:i+5])
ans.sort()
ans = ans[:5]
print(ans[K-1])


Measured memory_bytes: 3188
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>


#define DEBUG if(false)

using namespace std;

int main(){
  int N;
  cin >> N;
  if(N%10 == 3){
    cout << "bon" << endl;
  }else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
  int N;
  vector<int> threeFlag(3, 0);
  vector<int> fourFlag(4, 0);

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    string str;
    cin >> str;
    if (str == "P")
    {
      threeFlag[0] = 1;
      fourFlag[0] = 1;
    }
    else if (str == "W")
    {
      threeFlag[1] = 1;
      fourFlag[1] = 1;
    }
    else if (str == "G")
    {
      threeFlag[2] = 1;
      fourFlag[2] = 1;
    }
    else if (str == "Y")
    {
      fourFlag[3] = 1;
    }
  }

  int fourSum = accumulate(fourFlag.begin(), fourFlag.end(), 0);
  int threeSum = accumulate(threeFlag.begin(), threeFlag.end(), 0);

  if (fourSum == 4) cout << "Four\n";
  else if (threeSum == 3) cout << "Three\n";

  return 0;
}


Measured memory_bytes: 256
N,M=map(int,raw_input().split())

dp=[ [ float("inf") for i in range(N+1) ]  for j in range(N+1)]
for i in range(N+1): dp[i][i]=0
l={}

for i in range(M):
	A,B,C=map(int, raw_input().split())
	dp[A][B]=C
	dp[B][A]=C
	l[(A,B)]=C


for k in range(1,N+1):
	for x in range(1,N+1):
		for y in range(1,N+1):
			dp[x][y]=min(dp[x][y], dp[x][k]+dp[k][y])


ans=0
for i  in l.items():
	x=i[0][0]
	y=i[0][1]
	c=i[1]
	if dp[x][y]==c:
		pass
	else:
		ans+=1
print ans

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

struct cake{
    int x, y, h, w;
    cake(int x=0, int y=0, int h=0, int w=0): x(x), y(y), h(h), w(w){}

    pair<cake, cake> cut(int L){
        L %= (h+w);
        cake a, b;
        if(L < w){
            a = {x, y, h, L};
            b = {x, y+L, h, w-L};
        }
        else if(L < h+w){
            a = {x, y, L-w, w};
            b = {x+L-w, y, h+w-L, w};
        }
        else if(L < h+w*2){
            a = {x, y, h, h+2*w-L};
            b = {x, y+h+2*w-L, h, L-h-w};
        }
        else{
            a = {x, y, 2*(h+w)-L, w};
            b = {x+2*(h+w)-L, y, L-h-2*w, w};
        }
        if(a.h*a.w > b.h*b.w) swap(a, b);
        return {a, b};
    }
};

int main(){
    int n, w, h;
    while(scanf("%d%d%d", &n, &w, &h) && h){
        vector<cake> v = {{0, 0, h, w}};
        rep(_, n){
            int p, s;
            scanf("%d%d", &p, &s);
            --p;
            auto nc = v[p].cut(s);
            v.erase(v.begin()+p, v.begin()+p+1);
            v.push_back(nc.fi);
            v.push_back(nc.se);
        }
        sort(v.begin(), v.end(), [](const cake &a, const cake &b){
            return a.h*a.w < b.h*b.w;
        });
        rep(i, v.size()) printf("%d%c", v[i].h*v[i].w, (i==v.size()-1 ? '\n' : ' '));
    }
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

typedef long long ll;

vector<ll> pot(50);
int n, m;

ll Licz(vector< vector<bool> >& T, vector< vector<int> >& zb, int mask)
{
    int kr = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            if ((mask & zb[i][j]) != 0)
                ++kr;
    kr /= 2;
    return pot[n - 1 - kr];
}

bool dfs(vector< vector<bool> >& T, int a, int b)
{
    stack<int> S;
    vector<bool> odw(n, false);
    S.push(a);
    odw[a] = true;
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < n; ++i)
        {
            if (T[akt][i] && !odw[i])
            {
                S.push(i);
                odw[i] = true;
            }
        }
    }
    return odw[b];
}

int main()
{
    ios_base::sync_with_stdio(0);
    pot[0] = 1;
    for (ll i = 1; i < 50; ++i)
        pot[i] = pot[i - 1] * 2;
    cin >> n;
    vector< vector<bool> > T(n, vector<bool>(n, false));
    for (int i = 0; i < n - 1; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        T[a][b] = true;
        T[b][a] = true;
    }
    cin >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; ++i)
    {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }
    vector< vector<int> > zb(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            for (int k = 0; k < m; ++k)
            {
                if (!T[i][j])
                    continue;
                T[i][j] = false;
                T[j][i] = false;
                bool ok = dfs(T, a[k], b[k]);
                if (!ok)
                    zb[i][j] |= (1 << k);
                T[i][j] = true;
                T[j][i] = true;
            }
        }
    }
    ll odp = pot[n - 1];
    for (int mask = 1; mask < (1 << m); ++mask)
    {
        ll il = Licz(T, zb, mask);
        if (__builtin_popcount(mask) % 2 == 1)
            odp -= il;
        else
            odp += il;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a, b, c;

        a = scanner.nextInt();

        if(a < 1200) {
            System.out.println("ABC");
        }else{
            System.out.println("ARC");
        }
    }








}




Measured memory_bytes: 10192
/*#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n, p[100];
  while(cin >> n){
    for(int i = 0 ; i < n ; i++ ) cin >> p[i];
    sort( p, p + n);
    int ret = p[0];
    for(int i = 1 ; i < n ; i++ ) ret += p[i] += p[i - 1];
    cout << ret << endl;
  }
}*/
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,b,t[100];
int main()
{
  while(cin>>n)
    {
    for(int i=0;i<n;i++)cin>>t[i];
    sort(t,t+n);
    a=b=0;
    for(int i=0;i<n;i++)
    {
      b+=t[i];
      a+=b;
    }
    cout<<a<<endl;
  }

  return 0;
}

Measured memory_bytes: 1176
use std::io::Read;
use std::collections::HashMap;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut map: HashMap<&str, usize> = HashMap::with_capacity(n);
    for i in 0..n {
        *map.entry(iterator.next().unwrap()).or_insert(0) += 1;
    }

    let mut max_count: usize = 0;
    for (_, &v) in &map {
        max_count = max(max_count, v);
    }

    let filtered = map.into_iter()
        .filter(|&(_, v)| v == max_count)
        .collect::<HashMap<&str, usize>>();

    let mut keys = Vec::with_capacity(filtered.len());
    for &key in filtered.keys() {
        keys.push(key)
    }

    keys.sort();

    return keys.join("\n");
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"7
beat
vet
beet
bed
vet
bet
beet"
        ),
        "beet
vet"
    );
//    assert_eq!(
//        solve(
//            r""
//        ),
//        ""
//    );
//    assert_eq!(
//        solve(
//            r""
//        ),
//        ""
//    );
}


Measured memory_bytes: 28456
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int count = 0;
		for (int i = 0; i < arr.length; i++) {
		    if (i % 2 == 0 ^ arr[i] == '0') {
		        count++;
		    }
		}
		System.out.println(Math.min(count, arr.length - count));
   }
}


Measured memory_bytes: 26324
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vi(v)        vector<int>v;
#define   vl(v)        vector<ll>v;
#define   vs           vector<string>v
#define   rslt(x)      cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          rslt("YES");
#define   no           cout<<"NO"<<endl;
#define   srt(v)       sort(v.begin(),v.end())
#define   rvs(v)       reverse(v.begin(),v.end());
#define   AR           ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   max          1000007
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
int main()
{
    AR
    ll a,b,c,d,a1,b1,c1,d1,maxi = -1000000000000000000;
    cin>>a>>b>>c>>d;
    a1 = a*c;
    if(a1>maxi)
        maxi = a1;

    b1 = a*d;
    if(b1>maxi)
        maxi = b1;

    c1 = b*c;
    if(c1>maxi)
        maxi = c1;

    d1 = b*d;
    if(d1>maxi)
        maxi = d1;
    cout<<maxi<<endl;

    return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	int x = 0;
	int cnt = 1;
	rep(i, m) cnt *= 2;
	
	x += ((n-m) * 100 + m * 1900) * cnt;
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

int N,T;
char field[10001];
double dp[2][2001];

double calc(){
    for(int i=T;i>=0;i--){
        for(int j=0;j<N;j++){
            int cur=i%2;
            int prv=(i+1)%2;
            double res=0;
            if(i==T){
                if(field[j]=='R')res=1;
            }
            else{
                for(int k=1;k<=6;k++){
                    int npos=(j+k)%N;
                    res+=dp[prv][npos]/6.0;
                }
            }
            dp[cur][j]=res;
        }
    }
    double res=dp[0][0];
    for(int i=1;i<N;i++)res=max(res,dp[0][i]);
    return res;
}

int main(){
    while(cin>>N>>T&&(N|T)){
        for(int i=0;i<N;i++)cin>>field[i];
        double res=calc();
        printf("%.10f\n",res);
    }
    return 0;
}

Measured memory_bytes: 944
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	auto ans = R;
	if (N < 10)
	{
		ans += 100 * (10 - N);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll dp[3000];
ll N, M;
ll A[5005], B[5005], C[5005];
ll P;
bool negative[5005];
bool start[5005], goal[5005];

void f() {
    for(int timer = 0; timer <= N; timer++) {
        for(int i = 1; i <= M; i++) {
            chmax(dp[B[i]], dp[A[i]] + C[i] - P);
        }
    }
}
void g() {
    for(int timer = 0; timer <= N; timer++) {
        for(int i = 1; i <= M; i++) {
            if(chmax(dp[B[i]], dp[A[i]] + C[i] - P)) {
                negative[B[i]] = true;
            }
        }
    }
}


void h() {
    for(int timer = 0; timer <= N; timer++) {
        for(int i = 1; i <= M; i++) {
            start[B[i]] |= start[A[i]];
            goal[A[i]] |= goal[B[i]];
        }
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> P;
    for(int i = 1; i <= M; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }
    for(int i = 1; i <= N; i++) {
        dp[i] = -1e17;
    }
    dp[1] = 0;
    f();
    ll ans = dp[N];
    //for(int i = 1; i <= N; i++) cerr << i << " " << dp[i] << endl;
    cerr << dp[N] << endl;
    g();
    cerr << dp[N] << endl;
    start[1] = true;
    goal[N] = true;
    h();
    chmax(ans, 0LL);
    for(int i = 1; i <= N; i++) {
        if(start[i] && goal[i] && negative[i]) ans = -1;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int n, ans = 0;
	int p[20];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	for (int i = 1; i < n-1; i++) {
		if (p[i] > p[i - 1] && p[i] < p[i + 1]) {
			ans++;
		}
		else if (p[i] > p[i + 1] && p[i] < p[i - 1]) {
			ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> P;
#define INF (1<<24)
#define MAX_V 100

int V,E,a,b,c,d,R;

vector< vector<P> > t;
vector< vector<P> > u;

void init();
int dijkstra(int,int,vector< vector<P> >&);

int main(){
  while(cin>>E>>V){
    if(V==0&&E==0)break;
    init();
    for(int i=0;i<E;i++){
      cin>>a>>b>>c>>d;
      b--;a--; 
      t[a].push_back(P(b,c));
      t[b].push_back(P(a,c));
      u[a].push_back(P(b,d));
      u[b].push_back(P(a,d));
    }
    cin>>R;
    for(int i=0;i<R;i++){
      cin>>a>>b>>c;
      a--;b--;
      cout<<dijkstra(a,b,(c?u:t))<<endl;
    }
  }
  return 0;
}


int dijkstra(int si,int ti,vector< vector<P> > &G){
  int d[MAX_V];
  for(int i=0;i<MAX_V;i++)d[i]=INF;
  d[si]=0;
  priority_queue< P , vector<P> , greater<P> > Q;
  Q.push(P(0,si));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int pos=p.second,cost=p.first;
    for(int i=0;i<(int)G[pos].size();i++){
      int v=G[pos][i].first;
      int w=G[pos][i].second;
      if(cost+w>=d[v])continue;
      d[v]=cost+w;
      Q.push(P(d[v],v));
    }
  }
  return d[ti];
}

void init(){
  t.clear();
  u.clear();
  t.resize(V);
  u.resize(V);
}

Measured memory_bytes: 1336
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

bool drop(vector<string>& b, int h, int w) {
  bool ch = false;
  REP(i,w) {
    int k = h-1;
    for(int j=h-1;j>=0;--j) {
      if (b[j][i] == '.') continue;
      if (j!=k) {
        b[k][i] = b[j][i];
        b[j][i] = '.';
        ch = true;
      }
      --k;
    }
  }
  return ch;
}

bool erase(vector<string>& b, int h, int w, int n) {
  vector<vector<bool>> ise(h,vector<bool>(w, false));
  bool ch = false;
  REP(i,h) {
    int cont = 0;
    char old = '.';
    REP(j,w) {
      if (b[i][j] != old) {
        if (cont >= n && old != '.') {
          REP(k,cont) {
            ise[i][j-k-1] = true;
          }
          ch = true;
        }
        cont = 1;
        old = b[i][j];
      } else {
        ++cont;
      }
    }
    if (cont >= n && old != '.') {
      REP(k,cont) {
        ise[i][w-k-1] = true;
      }
      ch = true;
    }
  }
  REP(i,w) {
    int cont = 0;
    char old = '.';
    REP(j,h) {
      if (b[j][i] != old) {
        if (cont >= n && old != '.') {
          REP(k,cont) {
            ise[j-k-1][i] = true;
          }
          ch = true;
        }
        cont = 1;
        old = b[j][i];
      } else {
        ++cont;
      }
    }
    if (cont >= n && old != '.') {
      REP(k,cont) {
        ise[h-k-1][i] = true;
      }
      ch = true;
    }
  }
  if (ch) {
    REP(i,h)REP(j,w) {
      if (ise[i][j])
        b[i][j] = '.';
    }
  }
  return ch;
}

bool is_emp(vector<string>& b){
  for(auto& s:b)
    for(auto& c:s)
      if(c != '.')
        return false;
  return true;
}

bool ok(vector<string>& b, int h, int w, int n) {
  drop(b,h,w);
  while(erase(b,h,w,n)) {
    drop(b,h,w);
  }
  return is_emp(b);
}

int main() {
  int h,w,n;
  cin>>h>>w>>n;
  vector<string> b(h);
  REP(i,h)cin>>b[i];
  bool yes=false;
  REP(i,h)REP(j,w-1) {
    auto cp = b;
    swap(cp[i][j], cp[i][j+1]);
    if (ok(cp,h,w,n)) {
      yes = true;
      break;
    }
  }
  if(yes) 
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cstring>
#include <vector>
#define rep(i,n) for(ll i=1;i<=n;i++)
#define repn(i,n) for(ll i=n;i>=1;i--)
#define ll long long
#define mt(a,x) memset(a,x,sizeof(a))
const ll mod = 1e9+7;
const ll maxn = 1000050;
using namespace std;
vector<int> road[maxn],rail[maxn];
int road_father[maxn],rail_father[maxn];
int n,k,l;
int road_g[maxn],rail_g[maxn];
int ans1[maxn],ans2[maxn];
map<pair<int,int>,int> mp;
void solve1(int pos,int father)
{
    road_father[pos]=father;
    road_g[pos]=1;
    for(int i=0;i<road[pos].size();i++)
    {
        if(!road_g[road[pos][i]]) solve1(road[pos][i],father);
    }
    return ;
}
void solve2(int pos,int father)
{
    rail_father[pos]=father;
    rail_g[pos]=1;
    for(int i=0;i<rail[pos].size();i++)
    {
        if(!rail_g[rail[pos][i]]) solve2(rail[pos][i],father);
    }
    return ;
}
void connect()
{
    mt(road_g,0);
    mt(rail_g,0);
    rep(i,n)
    {
        if(road_g[i]) continue;
        solve1(i,i);
    }
    rep(i,n)
    {
        if(rail_g[i]) continue;
        solve2(i,i);
    }
}
int main()
{
    //freopen("data","r",stdin);
    ios::sync_with_stdio(0);
    cin>>n>>k>>l;
    rep(i,k)
    {
        int p,q;
        cin>>p>>q;
        road[p].push_back(q);
        road[q].push_back(p);
    }
    rep(i,l)
    {
        int r,s;
        cin>>r>>s;
        rail[r].push_back(s);
        rail[s].push_back(r);
    }
    connect();
    rep(i,n) mp[make_pair(road_father[i],rail_father[i])]++;
    rep(i,n) cout<<mp[make_pair(road_father[i],rail_father[i])]<<" ";
}


Measured memory_bytes: 79104
#include <iostream>
#include <queue>
#include <set>
#include <list>
#include <deque>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <iterator>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define powr(x,n,p) for(int axy=0 ; axy<p ; axy++){x=x*n;}
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nl printf("\n")
#define fr0(n,q) for(q=0 ; q<n ; q++)
#define fr1(n,q) for(q=1 ; q<=n ; q++)
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define lst(x) x[x.size()-1]
#define llst(x) x[x.size()-2]
#define md 1000000007
#define check(x,y) (x&(1<<y))
#define set(x,y) x=x|(1<<y)
using namespace std;
ll arr[105],v[105];
ll dp[105][100005];
ll w,n;
ll solve(ll i, ll j){
	if(i>n) return 0;
	if(dp[i][j]!=-1) return dp[i][j];
	ll ret=solve(i+1,j);
	if(j-arr[i]>=0) ret=max(ret,v[i]+solve(i+1,j-arr[i]));
	return dp[i][j]=ret;
}
int main()
{
	cin>>n>>w;
	for(int i=0 ; i<105 ; i++){
		for(int j=0 ; j<100005 ; j++) dp[i][j]=-1;
	}
	for(int i=1 ; i<=n ; i++){
		cin>>arr[i]>>v[i];
	}
	cout<<solve(1,w);
	nl;
	return 0;
}


Measured memory_bytes: 85676
<?php

fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%s', $s);

$s_array = str_split($s);
$w_total[] = 0;
$total = 0;
// 累積和
foreach ($s_array as $value) {
    if($value == 'W'){
    $total += 1;
    }
    $w_total[] = $total;
    // 012345
    // 011123
}

$min = 3000000;
for ($i = 1; $i <= $n; $i++) { // n=5

    $right = ($n-$i) - ($w_total[$n]-$w_total[$i]); // リーダーの右全員 - Wの数 = 右側のEの数（Wにしたい数） 4-2=2
    $left = $w_total[$i-1]; // リーダーの左側 wの数 = Eにしたい数
    if($min>($right+$left)){
        $min = ($right+$left);
    }

}
echo $min;

Measured memory_bytes: 101192
import std.stdio : write, writeln;
import std.array;
import std.range;

void main(){
	string[] str = readln.chomp.split(" ");
	string ans;
	foreach(s; str){
		auto wd = s.split(".");
		foreach(w; wd){
			auto res = w.split(",");
			foreach(r; res){
				auto l = r.length;
				if(3<=l && l<=6){
					if(ans == ans.init){
						ans = r;
					}else{
						ans ~= " " ~ r;
					}
				}
			}
		}
	}
	
	writeln = ans;
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

Measured memory_bytes: 1016
/*宣言*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int main()
{
	int n, u, k, w[101][101], v, c;
	int d[101], kas[101] = { 0 }, K;
	cin >> n;
	memset(d, 0x7f, sizeof(d));
	memset(w, 0x7f, sizeof(w));
	rep(i, n)
	{
		cin >> u >> k;
		rep(j, k)
		{
			cin >> v >> c;
			w[u][v] = c;
		}
	}
	d[0]=0;
	int p[101];
	int Min,Min1;
	Min = 0;
	Min1 = 100000000;
	kas[0] = 1;
	rep(j, n)
	{
		rep(i, n)
		{
			if (d[i] > d[Min] + w[Min][i])
			{
				d[i] = d[Min] + w[Min][i];
				p[i] = Min;
			}
			if (Min1 > d[i] && kas[i] == 0)
			{
				Min1 = d[i];
				K = i;
			}
		}
		kas[K] = 1;
		Min = K;
		Min1 = 100000000;
	}
	rep(i, n)
	{
		cout << i <<' '<< d[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3124
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
int dp[3001][3001][2];
int a[3001];
int n;
int ans(int l,int r,int p)
{
    int &res=dp[l][r][p];
    if(res!=-1)
        return dp[l][r][p];
    if(l==r)
    {
        if(p==0)
        {
            return res=a[l];
        }
        else
            return res=-a[l];
    }
    if(p==0)
    {
        res=max(ans(l+1,r,!p)+a[l],ans(l,r-1,!p)+a[r]);
    }
    else
        res=min(ans(l+1,r,!p)-a[l],ans(l,r-1,!p)-a[r]);
    return res;

}
int32_t main()
{
    IOS
    
  
  
  cin>>n;

  for(int i=0;i<n;++i)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<-ans(0,n-1,1);


}



Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    string s;
    cin >> s;
    vector<int> ans(s.size());
    int sPoint = 0, even = 1, odd = 0;
    for(int i = 1; i < s.size(); i++){
        if( (s[i-1] == 'L' && s[i] == 'R')){
            if (sPoint % 2 == 0){
                ans[sPoint] = even;
                ans[sPoint-1] = odd;
            } else{
                ans[sPoint] = odd;
                ans[sPoint-1] = even;
            }
            even = odd = 0;
        }
        if ( s[i-1] == 'R' && s[i] == 'L' ){
            sPoint = i;
        }
        if(i % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }
    if (sPoint % 2 == 0){
        ans[sPoint] = even;
        ans[sPoint-1] = odd;
    }else{
        ans[sPoint] = odd;
        ans[sPoint-1] = even;
    }

    rep(i, s.size()){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

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

int main(void){

    int N;cin>>N;
    int a=0;
    for (int i = 0; i < N; ++i) {
        int tmp; cin>>tmp;
        a = __gcd(a,tmp);
    }
    cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int ele[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	cin>>k;
	k--;
	cout<<ele[k];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;
ll wy = 0;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
void algo( string & s, int pocz, long long sum ) {
    if( pocz>=s.size() )
        return;
    long long n=0, x=0;
    for( int i=pocz; i<s.size(); i++ ) {
        n=n*10+s[i]-'0';
        algo( s, i+1, sum+n );
    }
    wy+=sum+n;
}
 
int main()
{
    string s;
    cin >> s;
    algo( s, 0, 0 );
    cout << wy;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[105][105];
int h,w,ok,sh[105],sw[105],hx,wx;
int main() {
    cin>>h>>w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin>>s[i][j];
        }
    }
    hx=0;
    for (int i = 0; i < h; ++i) {
        ok=1;sh[hx]=i;
        for (int j = 0; j < w; ++j) {
            if(s[i][j]=='#') {
                ok=0;break;
            }
        }
        if(ok==0) hx++;
    }
    wx=0;
    for (int j = 0; j < w; ++j) {
        ok=1;sw[wx]=j;
        for (int i = 0; i < h; ++i) {
            if(s[i][j]=='#') {
                ok=0;break;
            }
        }
        if(ok==0) wx++;
    }
    for (int i = 0; i < hx; ++i) {
        for (int j = 0; j < wx; ++j) {
            cout<<s[sh[i]][sw[j]];
        }cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
#import copy


def xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


def sp_xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example
        input   1
        retrun  [1]

        input   123
        return  [1,2,3]

        input   123
                4
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        return [int(k) for k in xsxs()]
    else:
        return [[int(k) for k in xsxs()] for _ in range(n)]


def xsxs(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   AA
        retrun  AA

        input   A BBB CC
        return  ["A","BBB","CC"]

        input   A BB CCC
                D
        return  [["A","BBB","CC"],
                ["D"]]
    """
    if n == 0:
        temp = list(input().split())
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        return [list(input().split()) for _ in range(n)]


def sp_xsxs(n=0):
    """
    args:
        int n: a number of lows to read
        example:
            input   A
            retrun  ["A"]

            input   ABC
            return  ["A","B","C"]

            input   ABC
                    D
            return  [["A","B","C"],
                    ["D"]]
    """
    if n == 0:
        return [s for s in xsxs()]
    else:
        return [[s for s in xsxs()] for _ in range(n)]


def p_num(a):

    if a == 1:
        return [[a, 1]]
    else:
        tmp = 2
        ans = []
        while tmp < np.sqrt(a) + 1:
            n = 0
            p = [tmp]

            while a % tmp == 0:
                a = int(a / tmp)
                # p.append(tmp)
                n += 1
                c = 1
            if n != 0:
                p.append(n)
                ans.append(p)
            tmp += 1
            c = 0
        if c == 0 and a != 1:
            ans.append([a, 1])
        return ans


def p_num_edit(n):
    tmp = n
    ans = []
    for i in range(2, int(np.sqrt(n)) + 1):
        cnt = 0
        while tmp % i == 0:
            cnt += 1
            tmp = int(tmp / i)
        if cnt > 0:
            ans.append([i, cnt])
    if tmp != 1:
        ans.append([tmp, 1])
    if ans == []:
        ans.append([n, 1])
    return ans


n = xnxn()

if n == 1:
    print(0)
    sys.exit()
else:
    a = p_num_edit(n)
    c = 0
    for num in a:
        i = 1
        while num[1] - i > -1:
            num[1] -= i
            i += 1
            c += 1
    print(c)


Measured memory_bytes: 27168
#include<stdio.h>

int max(int,int);

int main(void){
  int n,m,h[201],r[201],i,j,t,dp[201],res;

  while(scanf("%d",&n),n){
    for(i=0;i<n;i++)scanf("%d %d",&h[i],&r[i]);
    scanf("%d",&m);
    for(i=n;i<n+m;i++)scanf("%d %d",&h[i],&r[i]);

      for(i=0;i<n+m;i++){
	  for(j=i;j<n+m;j++){
	      if(h[i]>h[j]){
		  t=h[i];
		  h[i]=h[j];
		  h[j]=t;
		  t=r[i];
		  r [i]=r[j];
		  r[j]=t;
		}
	      else if(h[i]==h[j] && r[i]>r[j]){
		  t=h[i];
		  h[i]=h[j];
		  h[j]=t;
		  t=r[i];
		  r [i]=r[j];
		  r[j]=t;
	      }
	  }
	}
      for(i=0;i<n+m;i++)dp[i]=0;
      dp[0]=1;
      
      for(i=0;i<n+m;i++){
	for(j=i+1;j<n+m;j++){
	  if(h[i]<h[j] && r[i]<r[j] && dp[i]>=dp[j])dp[j]=dp[i]+1;
	}
      }
      res=0;
      for(i=0;i<n+m;i++)res=max(res,dp[i]);

      printf("%d\n",res);
  }
  
  return 0;
}

int max(int x,int y){
  return x>y?x:y;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 2010, maxa = 2010;

int n;
bitset<maxn * maxa + 5> f;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	f[0] = 1;
	int sum = 0;
	REP(i, 0, n)
	{
		int x;
		scanf("%d", &x);
		sum += x;
		f |= f << x;
	}
	int ans = (sum + 1) >> 1;
	while (!f[ans]) ++ans;
	printf("%d\n", ans);
	return 0;
}


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

int main(){
    int n;
    string S, T;
    int i, ans;
    int daytime[86402];
    cin >> n;
    while(n>0){
        fill(daytime,daytime+86402,0);
        for(i=0; i<n; i++){
            cin >> S >> T;
            daytime[((S[0]-'0')*10+(S[1]-'0'))*3600+((S[3]-'0')*10+(S[4]-'0'))*60+((S[6]-'0')*10+(S[7]-'0'))]++;
            daytime[((T[0]-'0')*10+(T[1]-'0'))*3600+((T[3]-'0')*10+(T[4]-'0'))*60+((T[6]-'0')*10+(T[7]-'0'))]--;
        }
        for(i=1; i<=86400; i++){
            daytime[i] += daytime[i-1];
        }
        ans=0;
        for(i=0; i<=86400; i++){
            ans = max(ans,daytime[i]);
        }
        cout << ans << endl;
        cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


long gcd(long x, long y){
    
    long z;
    
    while((z = x %y) != 0){
        x = y;
        y = z;
        //printf("%ld %ld\n",x,y);
    }
    
    return y;
}

long lcm(long a,long b){
//    if(gcd(a, b)){
//        exit(0);
//    }
    return (a * b) / gcd(a, b);
}

int main(int argc, const char * argv[]){
    
    long a,b;
    
    while(scanf("%ld %ld",&a,&b) != EOF){
        printf("%ld %ld\n",gcd(a,b),lcm(a,b));
    }
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

#define max(a, b) (((a) > (b)) ? (a) : (b))

int main(void) {
	int i, j, k;
	int n;
	int sum[101] = {0}, dp[101][101] = {0}, max;

	scanf("%d", &n);

	max = -10000;
	for (i = 0; i < n; i++) {
		for (j = 1; j <= n; j++) {
			int a;
			scanf("%d", &a);
			sum[j] = sum[j - 1] + a;
		}

		for (j = 1; j <= n; j++)
			for (k = j; k <= n; k++) {
				dp[j][k] = max(dp[j][k] + sum[k] - sum[j - 1], sum[k] - sum[j - 1]);
				max = max(max, dp[j][k]);
			}
	}

	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 648
A,B= map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A_B_and = set(prime_factorize(A)) & set(prime_factorize(B))
print(len(A_B_and)+1)

Measured memory_bytes: 38512
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
use std::cmp;

fn calc_h(h: usize, w: usize, a: usize) -> usize {
    let mut v1 = vec![a * w];
    let mut v2 = vec![a * w];
    if (h - a) / 2 == 0 {
        v1.push(usize::max_value());
    }
    v1.push((h - a) / 2 * w);
    if (h - a) % 2 != 0 {
        v1.push(((h - a) / 2 + 1) * w);
    }
    if (h - a) == 0 {
        v2.push(usize::max_value());
    }
    v2.push((w / 2) * (h - a));
    if w % 2 != 0 {
        v2.push(((w / 2) + 1) * (h - a));
    }
    let x = v1.iter().max().unwrap() - v1.iter().min().unwrap();
    let y = v2.iter().max().unwrap() - v2.iter().min().unwrap();
    cmp::min(x, y)
}

fn calc_w(h: usize, w: usize, a: usize) -> usize {
    let mut v1 = vec![a * h];
    let mut v2 = vec![a * h];
    if (w - a) / 2 == 0 {
        v1.push(usize::max_value());
    }
    v1.push((w - a) / 2 * h);
    if (w - a) % 2 != 0 {
        v1.push(((w - a) / 2 + 1) * h);
    }
    if (w - a) == 0 {
        v2.push(usize::max_value());
    }
    v2.push((h / 2) * (w - a));
    if h % 2 != 0 {
        v2.push(((h / 2) + 1) * (w - a));
    }
    let x = v1.iter().max().unwrap() - v1.iter().min().unwrap();
    let y = v2.iter().max().unwrap() - v2.iter().min().unwrap();
    cmp::min(x, y)
}

fn main() {
    let (h, w): (usize, usize);
    input!(h, w);
    let mut min = usize::max_value();
    for z in 1..h + 1 {
        min = cmp::min(calc_h(h, w, z), min);
    }
    for z in 1..w + 1 {
        min = cmp::min(calc_w(h, w, z), min);
    }
    p(min);
}

Measured memory_bytes: 4352
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}



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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

#define dbg(x) cerr << (#x) << " --> " << (x) << nl;
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

#define Toktama ""

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//typedef tree < pair <int, int>, null_type, less < pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e6 + 7, inf = 1e9 + 7, mod = 1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int get_int() {
  char x = getchar();
  bool mns = 0;
  while (!isdigit(x)) mns |= x == '-', x = getchar();
  int res = 0;
  while (isdigit(x)) res = res * 10 + x - '0', x = getchar();
  if (mns) res = -res;
  return res;
}
void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
int mult(int x, int y) {
  return x * 1ll * y % mod;
}
int sum(int x, int y) {
  add(x, y);
  return x;
}

string s;
void solve() {
  cin >> s;
  set <char> st;
  for (char i : s)
    st.insert(i);
  int ans = inf;
  for (auto i : st) {
    string x = s;
    int cnt = 0;
    while (1) {
      bool ok = 0;
      rep(j, 0, sz(x) - 1)
        if (x[j] != i) ok = 1;
      if (!ok) break;
      ++cnt;
      rep(j, 0, sz(x) - 2) {
        if (x[j] == i) continue;
        x[j] = x[j + 1];
      }
      x.pp();
    }
    ans = min(ans, cnt);
  }
  cout << ans;
}
int main() {
  #ifndef Toktama
    freopen (Toktama".in", "r", stdin);
    freopen (Toktama".out", "w", stdout);
  #endif
  Kazakhstan
  int t = 1;
  while (t--)
    solve();
  ioi
}


Measured memory_bytes: 256