akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n;
  cin>>n;
  vector<pair<ll,ll>> a(n);
  rep(i,n){
    ll x;
    cin>>x;
    a[i]=make_pair(x,i);
  }
  sort(begin(a),end(a));
  rep(i,n) cout << a[i].second+1 << " ";
  cout << endl;


  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

int main(void){
	string taro, hanako;
	int point_t=0, point_h=0, n;
	cin >>n;
	for(int i=0; i<n; i++){
		cin >>taro >>hanako;
		if(taro>hanako){
			point_t+=3;
		}else if(taro<hanako){
			point_h+=3;
		}else{
			point_t++;
			point_h++;
		}
	}
	cout <<point_t <<" " <<point_h <<endl;
    return 0;
}

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

using namespace std;

#define ll long long
#define mod (ll)1000000007

const ll INF = 1e11;

void solve(){

    string s; cin >> s;
    if(s == "RRR") cout << 3;
    else if(s == "SSS") cout << 0;
    else if(s == "RRS" || s == "SRR") cout << 2;
    else cout << 1;    

    return;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		System.out.println(z + " " + x + " " + y);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
	int s,w;
	cin>>s>>w;
	if(s<=w)cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
}


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

int main(){
  int h, n;  cin >> h >> n;
  int d=0;
  rep(i,n){
    int a;
    cin >> a;
    d+=a;
  }
  h<=d ? puts("Yes") : puts("No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int abs(int a, int b)
{
    if(a > b){
        return a - b;
    }
    else {
        return b - a;
    }
}


int main()
{
    int n;
    int a[100010];
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    a[0] = 0;
    a[n + 1] = 0;
    long long total = 0;
    for(int i = 0; i <= n; i++){
        total += abs(a[i], a[i + 1]);
    }
    //cout << total << endl;
    for(int i = 1; i <= n; i++){
        long long cost = total;
        cost = cost - abs(a[i - 1], a[i]) - abs(a[i + 1], a[i]) + abs(a[i - 1], a[i + 1]);
        cout << cost << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
use std::cmp;

fn main(){
  let nm: Vec<usize> = read_vec();
  let n = nm[0];
  let m = nm[1];

  let vp: Vec<usize> = read_vec();

  let mut vr: Vec<i64> = vec![0;n];
  
  for i in 0 .. m-1 {
    if vp[i] < vp[i+1] {
      vr[vp[i]-1] += 1;
      vr[vp[i+1]-1] -= 1;
    } else {
      vr[vp[i+1]-1] += 1;
      vr[vp[i]-1] -= 1;
    }
  }
  
  // println!("{:?}", vr);

  let mut ct: i64 = 0;
  let mut ans: i64 = 0;
  
  for i in 0 .. n-1 {
    let abc: Vec<i64> = read_vec();
    let a = abc[0];
    let b = abc[1];
    let c = abc[2];

    ct += vr[i];

    ans += cmp::min(ct * a, ct * b + c);
  }
  
  println!("{}", ans);
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 7076
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
inline lint _max(lint a, lint b){ return a>b ? a : b; }
inline lint _min(lint a, lint b){ return a<b ? a : b; }

const int MOD = 1e9+7;
const int MAX = 200010;
const int INF = 2e9+10;

struct node {
    int cnt=0, ch[26]={};
} T[1234567];
int bck = 1; // root is 1

string S[MAX];
bool has[1000010][26];
// does str has 'a'+j in str[i:] ?

void insert(int v, int si, int pos){
    node &nd = T[v];
    if(pos == int(S[si].size())){ nd.cnt++; return; }
    
    int &x = nd.ch[int(S[si][pos]-'a')];
    if(x == 0){ x = ++bck; /*cout<<"Make "<<v<<" -> "<<x<<": "<<S[si][pos]<<'\n';*/ }
    insert(x, si, pos+1);
}

int solve(int v, int si, int pos){
    if(pos == int(S[si].size())) return 0;
    node &nd = T[v];
    int res = 0;

    for(int j=0; j<='z'-'a'; j++){
        node &ch = T[nd.ch[j]];
        res += (has[pos][j] ? ch.cnt : 0);
    }

    int x = nd.ch[int(S[si][pos]-'a')];
    if(x>0) res += solve(x, si, pos+1);

    return res;
}

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

    int n; cin>>n;
    for(int i=1; i<=n; i++) cin>>S[i];

    sort(S+1, S+n+1, [&](string &a, string &b){
            return a.size() < b.size();
            });

    lint ans = 0;
    for(int si=1; si<=n; si++){
        reverse(S[si].begin(), S[si].end());
        int len = S[si].size();
    
//        cout<<si<<"th string: "<<S[si]<<" ("<<len<<")\n";

        for(int j=0; j<='z'-'a'; j++) has[len][j] = false;
        for(int i=len-1; i>=0; i--) for(int j=0; j<='z'-'a'; j++)
            has[i][j] = has[i+1][j] || (S[si][i] == 'a'+j);
/*
        for(int i=0; i<len; i++){
            cout<<has[i][0]<<has[i][1]<<has[i][2]<<has[i][23]<<has[i][24]<<'\n';
        }
        cout<<'\n';*/

        ans += solve(1, si, 0);
        insert(1, si, 0);
    }
    cout<<ans<<'\n';


    return 0;
}


Measured memory_bytes: 139424
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stdexcept>


typedef long long int llint;

llint hituyou_cost(const std::vector<llint>& A,
		   const std::vector<llint>& F,
		   llint target){
  llint ret = 0;
  for(int i=0; i<A.size(); i++){
    llint now = A[i]*F[i];
    llint diff = now - target;
    if(diff < 0) continue;
    llint cost = (diff + F[i] - 1) / F[i]; //ceil
    //std::cout << diff << " " << F[i] << " " << cost << std::endl;
    if((A[i]-cost)  * F[i] > target)  throw std::runtime_error("error1");
    if((A[i]-cost+1) *F[i] <= target) throw std::runtime_error("error2");
    ret += cost;
  }
  return ret;
}

int main(void){
  llint n, k;
  std::cin >> n >> k;

  std::vector<llint> A(n);
  std::vector<llint> F(n);
  for(int i=0; i<n; i++){
    std::cin >> A[i];
  }
  for(int i=0; i<n; i++){
    std::cin >> F[i];
  }
  std::sort(A.begin(), A.end());
  std::sort(F.begin(), F.end(), std::greater<llint>());

  llint total_A = std::accumulate(A.begin(), A.end(), 0L);
  if(total_A < k){
    std::cout << 0 << std::endl;
    return 0;
  }

  /**
  for(int i=0; i<n; i++){
    std::cout << A[i] << " ";
  }
  std::cout << std::endl;
  for(int i=0; i<n; i++){
    std::cout << F[i] << " ";
  }
  std::cout << std::endl;
  **/
  llint largest = A[0]*F[0];
  for(int i=1; i<n; i++){
    if(largest < A[i]*F[i]) largest = A[i]*F[i];
  }

  llint left = 0;
  llint right = largest;

  while(right-left > 1){
    llint mid = (left + right) / 2;
    llint temp = hituyou_cost(A, F, mid);
    //std::cout << left << " " << mid << " " << right << " " << temp << std::endl;
    if(temp > k){
      left = mid;
    }else{
      right = mid;
    }
  }
  //std::cout << left << " " << right << std::endl;

  if(hituyou_cost(A, F, left) <= k) std::cout << left  << std::endl;
  else                              std::cout << right << std::endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ostream>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  string s, t; cin >> s >> t;
  vector<set<ll>> c(26);

  rep(i, si(s)) c[s[i]-'a'].em(i);

  ll idx = 0, ans = 0;
  rep(i, si(t)) {
    auto itr = c[t[i]-'a'].lower_bound(idx);

    if (itr == c[t[i]-'a'].end()) {

      if (idx == 0) {
        cout << -1 << endl;
        return (0);
      }

      ans += si(s) - idx;
      
      idx = 0;
      --i;

    } else {
      ans += *itr - idx + 1;
      idx = *itr + 1;
    }
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 8488
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
using namespace std;


int main() {
	vector<int> v;
	int tmp;
	for (int i = 0; i < 3; i++) {
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end(), [](int a, int b) {return a < b; });
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i == v.size() - 1)
			cout << endl;
		else
			cout << " ";
	}
}

Measured memory_bytes: 1212
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  string s;
  cin>>s;
  int N;
  N=s.length();
  int x[N];
  for (int i=0;i<N;i++){
    if (s[i]=='B'){
      x[i]=0;
    }
    else if (s[i]=='W'){
      x[i]=1;
    }
  }
  long a=0;
  long counter=0;
  for (int i=0;i<N;i++){
    if (x[i]==0){
      a+=1;
    }
    else if (x[i]==1){
      counter+=a;
    }
  }
  cout<<counter;
  return 0;
}


Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;

int ans[N],k,a[110],n;
bool cov[N],print;

bool isdiff(int l,int r) {
	static bool vis[110];
	memset(vis,0,sizeof(vis));
	for(int i=l;i<=r;i++) {
		if(vis[ans[i]]) return 0;
		vis[ans[i]]=1;
	}
	return 1;
}

bool check(int len) {
	static int aa[110];
	int st=0;
	if(len-k+1>0&&isdiff(len-k+1,len)) {
		st=len+1;
		if(len==n) return 1;
	}
	else {
		st=len;while(st>1&&!cov[st-1]) --st;
		//for(int i=st;i<=len;i++) ++aa[ans[i]];
	}
	while(isdiff(st,len)) {
		int l=1,r=1e9;memcpy(aa,a,sizeof(a));
		for(int i=st;i<=len;i++) ++aa[ans[i]];
		for(int i=1;i<=k;i++) {
			l=max(l,aa[i]);
			r=min(r,2*aa[i]);
		}
		if(l>r) { --st; continue; }
		if(r-l>1||(l&1)||len==0) return 1;
		static bool vis[110];
		memset(vis,0,sizeof(vis));
		for(int i=st;i<=len;i++) vis[ans[i]]=1;
		bool fl=1;
		for(int i=st;i<=len;i++)
			if(l-aa[ans[i]]==l/2) {
				for(int j=i+1;j<=len;j++)
					if(l-aa[ans[j]]==0) { fl=0;break; }
				for(int j=1;j<=k;j++)
					if(!vis[j]&&l-aa[j]==0) { fl=0;break; }
				if(!fl) break;
				return 1;
			}
		if(fl) return 1;
		--st;
	}
	return 0;
}

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>k;
	for(int i=1;i<=k;i++) cin>>a[i],n+=a[i];
	if(!check(0)) return cout<<-1,0;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=k;j++) {
			ans[i]=j;--a[j];
			/*if(i==3&&j==3) {
			for(int j=1;j<=k;j++) cerr<<a[j]<<' ';
			return 0;
			}*/
			//print=(i==3&&j==3);
			if(check(i)) break;
			++a[j];
		}
		if(i>=k&&isdiff(i-k+1,i))
			for(int j=i-k+1;j<=i;j++) cov[j]=1;
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<' ';
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    // ここにプログラムを追記
    int R,G,P;
    cin >> R >> G;
    
    //パフォーマンス Pの計算
    //(R+P)/2=G
    P=(G*2)-R;
    cout << P << endl;
}


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

int main(){
	int a[10];
	int max,max_n;
	for(int i=0;i<10;i++){
	cin>>a[i];
	}
	for(int i=0;i<3;i++){
		max=a[0];
		max_n=0;
	for(int j=0;j<9;j++){
		if(max<a[j+1]){
			max=a[j+1];
			max_n=j+1;
		}
	}
		cout << max <<endl;
		a[max_n]=-1;
	
	}
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n);
    vector<int> a(9);
    Rep(n){
        Cin(int, r);
        if(r < 400) a[0] ++;
        else if(r < 800) a[1] ++;
        else if(r < 1200) a[2] ++;
        else if(r < 1600) a[3] ++;
        else if(r < 2000) a[4] ++;
        else if(r < 2400) a[5] ++;
        else if(r < 2800) a[6] ++;
        else if(r < 3200) a[7] ++;
        else a[8] ++;
    }
    int mi = 0, ma = 0;
    if(a[0]) mi ++, ma ++;
    if(a[1]) mi ++, ma ++;
    if(a[2]) mi ++, ma ++;
    if(a[3]) mi ++, ma ++;
    if(a[4]) mi ++, ma ++;
    if(a[5]) mi ++, ma ++;
    if(a[6]) mi ++, ma ++;
    if(a[7]) mi ++, ma ++;
    if(a[8]){
        if(mi == 0) mi ++;
        ma += a[8];
    }
    Cout(mi, " ", ma);
}

Measured memory_bytes: 256
l = list(map(str,input().split()))

d = {'A':0,'B':1,'C':2,'D':3,'E':4,'F':5}

if d[l[0]] < d[l[1]]:
    print('<')
elif d[l[0]] > d[l[1]]:
    print('>')
else:
    print('=')

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

using namespace std;

int main() {
	string str1, str2, str3;
	cin >> str1 >> str2 >> str3;
	char c1 = 'A' + (str1[0] - 'a');
	char c2 = 'A' + (str2[0] - 'a');
	char c3 = 'A' + (str3[0] - 'a');
	cout << c1 << c2 << c3 << endl;
	return 0;
}

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

int
main (void)
{
  int n = 0;
  int aux = 0;

  cin >> n;

  aux = n % 1000;
  if (aux == 0)
    cout << "0\n";
  else
    cout << 1000 - (n % 1000) << "\n";

  return 0;
}


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

using namespace std;

typedef pair<char, int> par;
set<par> s;
char arr[] = {'S', 'H', 'C', 'D'};

bool cmp(par a, par b)
{
    if(a.first == b.first)
        return a.second < b.second;
    for(int i = 0;i < 4;i++)
    {
        if( a.first == arr[i] )
            return true;
        if( b.first == arr[i] )
            return false;
    }
    return false;
}

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

    for(int i = 1;i <= 13;i++)
    {
        s.insert( make_pair( 'S', i ) );
        s.insert( make_pair( 'H', i ) );
        s.insert( make_pair( 'D', i ) );
        s.insert( make_pair( 'C', i ) );
    }

    for(int i = 0;i < n;i++)
    {
        char x;
        int y;
        cin >> x >> y;
        s.erase( make_pair(x, y) );
    }
    vector<par> v;
    for(set<par>::iterator it = s.begin();it != s.end();it++)
    {
        v.push_back( make_pair(it -> first, it -> second) );
    }
    sort(v.begin(), v.end(), cmp);
    for(int i = 0;i < (int)v.size();i++)
        cout << v[i].first << ' ' << v[i].second << '\n';
    return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAXs
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  string a,b,c; cin >> a >> b >> c;
  int la = a.size(),lb = b.size(),lc = c.size();
  int aa = 0,bb = 0,cc = 0;

  char now = 'a';

  while(true){

    if(now=='a'){
      if(la==0){
        puts("A");
        return 0;
      }
      now = a.at(aa);
      la--;
      aa++;

    }else if(now=='b'){
      if(lb==0){
        puts("B");
        return 0;
      }
      now = b.at(bb);
      lb--;
      bb++;
    }else if(now=='c'){
      if(lc==0){
        puts("C");
        return 0;
      }
      now = c.at(cc);
      lc--;
      cc++;
    }
  }
}


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

int main()
{
   ll n,a,b,c,d,e;
   cin >> n >> a >> b >> c >> d >> e;
   ll m = min(a,min(b,min(c,min(d,e))));
   cout<<(n+m-1)/m+4<<endl;
   return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private static final boolean N_CASE = false;

    private void solve() {
        int N = sc.nextInt();
        int[] A = sc.nextArray(N);

        int[] cnt = new int[N + 1];
        for (int i = 0; i < N; i++) {
            ++cnt[A[i]];
        }

        long total = 0;
        for (int i = 1; i <= N; i++) {
            if (cnt[i] >= 0) {
                total += (long) cnt[i] * (cnt[i] - 1) / 2;
            }
        }

        for (int i = 0; i < N; i++) {
            out.println(total - (cnt[A[i]] - 1));
        }
    }

    private void run() {
        int T = N_CASE ? sc.nextInt() : 1;
        for (int t = 0; t < T; ++t) {
            solve();
        }
    }

    private static MyWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        int[] nextArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        List<Integer> nextList(int n) {
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }
    }

    private static class MyWriter extends PrintWriter {
        private MyWriter(OutputStream outputStream) {
            super(outputStream);
        }

        void printArray(int[] a) {
            for (int i = 0; i < a.length; ++i) {
                print(a[i]);
                print(i == a.length - 1 ? '\n' : ' ');
            }
        }

        void printlnArray(int[] a) {
            for (int v : a) {
                println(v);
            }
        }

        void printList(List<Integer> list) {
            for (int i = 0; i < list.size(); ++i) {
                print(list.get(i));
                print(i == list.size() - 1 ? '\n' : ' ');
            }
        }

        void printlnList(List<Integer> list) {
            list.forEach(this::println);
        }
    }

    public static void main(String[] args) {
        out = new MyWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().run();
        out.close();
    }
}

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

int main()
{

  int k, a, b;

  cin >> k;
  cin >> a >> b;

  if (a % k == 0)
  {
    cout << "OK" << endl;
    return 0;
  }

  int temp = a / k;
  int max = temp * k + k;

  if (max <= b)
  {
    cout << "OK" << endl;
  }
  else
  {
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int check(int n){
	int x=n,p=0;
	string s[5];
	for(int i=0;i<5;i++){
		s[i]=x%10+'0';
		x/=10;
	}
	if(s[0]==s[4]&&s[1]==s[3]) p=1;
  	return p;
}
int main(){
	int a,b,ans=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		ans+=check(i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> PII;
const ll h[3]={3,5,7};
int n;
ll a,b,c,x,y,z;
ll ans=5;
ll beg=0;
ll res=0;
set<int> mpp;
void dfs(ll f,ll a,ll b,ll c)
{
	if(f>1e9) return;
	if(a>=1 && b>=1 && c>=1) mpp.insert(f);
	dfs(f*10+3,a+1,b,c);
	dfs(f*10+5,a,b+1,c);
	dfs(f*10+7,a,b,c+1);
}
int main()
{		
	cin>>n;
	if(n<357)
	{
		cout<<0<<endl;
		return 0;
	}
	mpp.clear();
	dfs(3,1,0,0);
	dfs(5,0,1,0);
	dfs(7,0,0,1);
	set<int>::iterator iter;
	for(iter=mpp.begin();iter!=mpp.end();iter++)
	{
//		cout<<*iter<<endl;
		if(*iter>n || *iter<0) break;
		else res++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
 
int main(void) {
  double a,b,c,d;
  double sum;
  scanf("%lf",&a);
  scanf("%lf",&b);
  scanf("%lf",&c);
  scanf("%lf",&d);
  if(a<=b) sum=a*c;
  else sum=sum=b*c+(a-b)*d;
  printf("%.0f\n",sum);
  return 0;
}

Measured memory_bytes: 128
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
	int a,b,n,x,y;
	while(cin>>a>>b,a){
		int p[17][17]={0},k[17][17]={0};
		cin>>n; while(n--)cin>>x>>y,k[y][x]=1;
		rep1(i,b)rep1(j,a)p[i][j]=i==1&&j==1?1:(p[i-1][j]+p[i][j-1])*(1-k[i][j]);
		cout<<p[b][a]<<endl;
	}
	return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int a,b;
  cin>>a>>b;
  int sa=0,sb=0;
  rep(i,b) sa =sa*10+a;
  rep(i,a) sb =sb*10+b;
  cout << min(to_string(sa),to_string(sb))<<endl;
}




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

int main() {
    int N;
    cin >> N;
    int64_t D;
    cin >> D;
    int count = 0;
    rep(i, N) {
        int64_t x, y;
        cin >> x >> y;

        if (x*x + y*y <= D*D) count++ ;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using static System.Console;

namespace abc179
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(ReadLine());
            var count = 0;
            var maxCount = 0;
            for (var i = 0; i < n; ++i)
            {
                var d = ReadLine();
                if (d[0] == d[2])
                {
                    ++count;
                    maxCount = Math.Max(maxCount, count);
                }
                else
                {
                    count = 0;
                }
            }
            WriteLine(maxCount > 2 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27524
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    for(int i = 1; i <= n; i++) {
      int p = 0;
      for(int j = 1; j <= i; j++) {
        if((i % j) == 0) p++;
      }
      if((p == 8) && ((i % 2) == 1)) ans++;
    }
    System.out.println(ans);
  }
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            a -= 1;
            b -= 1;
            int result = 0;

            while (b > 0)
            {
                b -= a;
                ++result;
            }

            b = b == 0 ? 1 : b;
            Console.WriteLine($"{result}");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}
int k1(string s){
  int n = int(s.size());
  return (n-1)*9 + (s[0]-'0');
}
int k2(string s){
  int n = int(s.size());
  int cnt(1),ret(0);
  ret = (n-1)*(n-2)/2*9*9 + (n-1)*9*(s[0]-'0'-1);
  n--;
  while(cnt < int(s.size()) && s[cnt] == '0'){
    cnt++;
    n--;
  }
  if (n>=1){
    return ret + k1(s.substr(cnt,int(s.size())-cnt));
  }else{
    return ret;
  }
}
int k3(string s){
  int n = int(s.size());
  int cnt(1),ret(0);
  ret = (n-1)*(n-2)*(n-3)/6*9*9*9 + (n-1)*(n-2)/2*9*9*(s[0]-'0'-1);
  n--;
  while(cnt < int(s.size()) && s[cnt] == '0'){
    cnt++;
    n--;
  }
  if (n>=2){
    return ret + k2(s.substr(cnt,int(s.size())-cnt));
  }else{
    return ret;
  }
}

int main(){
  string s;
  int K;
  cin>>s>>K;
  int n = int(s.size());
  if (n < K){
    cout << 0 << endl;
    return 0;
  }else{
    if (K == 1) {
      cout << k1(s) << endl;
    }else if (K==2){
      //cout << (n-1)*9*(s[0]-'0'-1) +s[1]-'0' + (n-2)*9 + (n-1)*(n-2)/2*9*9 << endl;
      cout << k2(s) << endl;
    }else{
      //cout << (n-1)*(n-2)*(n-3)/6*9*9*9 + (s[0]-'0'-1)*(n-1)*(n-2)/2*9*9 + (n-2)*9*(s[1]-'0'-1) +s[2]-'0' + (n-3)*9 + (n-2)*(n-3)/2*9*9 << endl;
      //int tmp = (n-1)*(n-2)*(n-3)/6*9*9*9 + (s[0]-'0'-1)*(n-1)*(n-2)/2*9*9;
      //int cnt(1);
      //n--;
      //while(s[cnt] == '0'){
      //  cnt++;
      //  n--;
      //}
      ////cout<< tmp << " " <<cnt<< " " << n <<endl;
      //if (n>=2){
      //  cout << tmp + (n-1)*9*(s[cnt]-'0'-1) +s[cnt]-'0' + (n-2)*9 + (n-1)*(n-2)/2*9*9 <<endl;
      //}else{
      //  cout << tmp << endl;
      //}
      cout << k3(s) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

#ifndef MAX
#define MAX 2400000
#endif

//Range Update Query+Range Minimum Query
template<class T>
class RUQ_RMQ {
public:
	int n;
	T dat[MAX], lazy[MAX], DEFAULT;
	bool(*cmp)(T, T);
	void init(int n_,
		bool(*c)(T, T) = [](int a, int b) {return a < b; }, T d = INT_MAX) {
		cmp = c;
		DEFAULT = d;
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = lazy[i] = DEFAULT;
		}
	}
	inline void push(int k) {
		if (lazy[k] == DEFAULT)return;
		dat[k] = lazy[k];
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k];
			lazy[k * 2 + 2] = lazy[k];
		}
		lazy[k] = DEFAULT;
	}
	inline void update_node(int k) {
		if (cmp(dat[k * 2 + 1], dat[k * 2 + 2]))dat[k] = dat[k * 2 + 1];
		else dat[k] = dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = x; push(k); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return DEFAULT;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		if (cmp(lb, rb))return lb;
		return rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};


struct st{
	int a,b,c;
}s[300000];

RUQ_RMQ<int>seg;
int d[300000];

int main(){
	int n,m;cin>>n>>m;
	vector<int>xs;
	rep(i,n){
		scanf("%d%d%d",&s[i].a,&s[i].b,&s[i].c);
		s[i].a-=s[i].c;
		s[i].b-=s[i].c;
		xs.push_back(s[i].a);
		xs.push_back(s[i].b);
	}
	rep(i,m){
		scanf("%d",&d[i]);
		xs.push_back(d[i]);
	}
	sort(s,s+n,[](st a,st b){return a.c>b.c;});
	sort(xs.begin(),xs.end());
	seg.init(xs.size());
	rep(i,n){
		s[i].a=lower_bound(xs.begin(),xs.end(),s[i].a)-xs.begin();
		s[i].b=lower_bound(xs.begin(),xs.end(),s[i].b)-xs.begin();
		seg.update(s[i].a,s[i].b,s[i].c);
	}
	rep(i,m){
		d[i]=lower_bound(xs.begin(),xs.end(),d[i])-xs.begin();
		int res=seg.query(d[i]);
		if(res==INT_MAX){
			puts("-1");
		}
		else printf("%d\n",res);
	}
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

double dist(int x1, int y1, int x2, int y2){
	return sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
}
const int mod = 1e9+7;
int main()
{
	cout << setprecision(10);
	int n ;
	cin >> n ;
	vector<int> x(n),y(n);
	rep(i,n) cin >> x[i] >> y[i];
	ll perm = 1; 
	ll perm_2 = 1;
	for(int i = 1 ; i <= n ; i++){
		perm *= i ;
	}
	for(int i = 1 ; i <= n -2 ; i ++){
		perm_2 *= i ;
	}
	debug(perm);//n！
	double sum_dist = 0 ;
	rep(i,n){
		rep(j,n){
			//i番目とj番目の距離を求める。i==jのときは勝手に0になる
			double now_dist = dist(x[i],y[i],x[j],y[j]);
			debug(sum_dist);
			sum_dist += now_dist;
		}
	}
	debug(sum_dist);
	sum_dist = (1.*sum_dist  *(n-1)*perm_2) / (1.*perm);
	cout << sum_dist << endl;
}


Measured memory_bytes: 256
import bisect

p=10**9+7
N,M=map(int,input().split())
a=[]
for i in range(M):
    a.append(int(input()))
x=[0 for i in range(N+1)]
x[0]=1
if 1 in a:
    x[1]=0
else:
    x[1]=x[0]
for i in range(2,N+1):
    if bisect.bisect_right(a,i-1)-bisect.bisect_left(a,i-1)==0: # i-1 not in a
        x[i]+=x[i-1]
    if bisect.bisect_right(a,i-2)-bisect.bisect_left(a,i-2)==0: # i-2 not in a
        x[i]+=x[i-2]
    x[i]%=p

print(x[N])

Measured memory_bytes: 8788
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	string s;
	cin >> s;
	for (int n = sz(s), i = 0; i < n; i++) {
		if (i % 2 == 0 && s[i] == 'L') {
			cout << "No\n";
			return 0;
		} else if (i % 2 == 1 && s[i] == 'R') {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}



Measured memory_bytes: 256
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

ceil = lambda number: math.ceil(number / 10) * 10

minutes = [A, B, C, D, E]
ceiled_minutes = list(map(ceil, minutes))

minimum = 10
for minute in minutes:
    digit_1st = minute % 10
    if digit_1st == 0: continue

    if minimum is None or digit_1st < minimum:
        minimum = digit_1st
diff = 10 - minimum

answer = sum(ceiled_minutes) - diff

print(answer)


Measured memory_bytes: 3064
//==================================================================================================
// Name        : a.cpp
// Author      : lotus.eater086
// Copyright   : If you're reading this then this warning is for you. Every word you read of this 
//               useless fine print is another second of your life. Don't you've other things to do?
//               Is your life so empty that you honestly can't think of a better way to spend these
//               moments ? Or are you so impressed with authority that you give respect and 
//               credence to all who claim it ? Do you read everything you're supposed to read ? Do
//               you think everything you're supposed to think ? Buy what you're told you should 
//               want ? Get out of your apartment . Meet a member of the opposite sex. Stop the 
//               excessive shopping and self-improvement . Quit your boring job.
//               Start a fight. Prove you're alive. If you don't claim your humanity you'll become a
//               statistic. You've been warned !

// Description : 
// Date        : 2019-10-02
// Time        : 18:50:48
// Directory   : C:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode
// FilePath    : C:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode\a.cpp
//==================================================================================================
    

#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;
    
//
template < typename T >

inline T read( T &x )
{

    x = 0 ;

    int f = 0 ;

    char ch = getchar() ;

    while( ch < '0' || ch > '9' )  {

        f |= ( ch == '-' ) , ch = getchar() ;

    }

    while( ch >= '0' && ch <= '9' )  {

        x = ( x << 1 ) + ( x << 3 ) + ch - '0' , ch = getchar() ;

    }

    return x = f ? -x:x ;

}
//

LL g( LL a , LL b )
{

    while( b )
    {

        LL temp = b ; 

        b = a % b ;

        a = temp ;  

    }

    return a ;  

}

void solve( void )
{

    LL a , b ;

    read( a ) , read( b ) ;

    cout << g( a , b ) << endl ;

}

int main( void )

{

    //ios_base::sync_with_stdio( false ) ;  cin.tie( NULL ) ;  cout.tie( NULL ) ;

   

    if( 0 )  {

        int t = 100 ;

        for( int i = 1 ; i <= t ; i++ )  solve() ;

    }

    else  {

        solve() ;

    }

    

    return 0 ;

}



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

using namespace std;

typedef long long ll;

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans;
    ans=max(a*c,max(a*d,max(b*c,b*d)));
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    string s;
    cin>>s;
    string x = s;
    reverse(x.begin(), x.end());
    bool ok = 1;
    if(x != s) {
        ok = 0;
    }
    lli n = s.size();
    string a = "", b = "";
    for(int i = 0; i < ((n - 1) / 2); i ++)
        a += s[i];
    for(int i = ((n + 3) / 2) - 1; i < n; i ++) {
        b += s[i];
    }
    x = a;
    reverse(x.begin(), x.end());
    if(a != x)
        ok = 0;
    x = b;
    reverse(x.begin(), x.end());
    if(x != b)
        ok = 0;
    if(ok)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<'\n';
    return ;
}



/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
	bool p[10001] = {0};
	rep(i, 10001)if(i>1&&!p[i])for(int j = i+i; j < 10001; j+=i)p[j]=1;
	int n, c, s;
	while(cin>>n, n){
		c = 0;
		rep(i, 9999){
			s = 0;
			if(p[i+2])continue;
			for(int l=i+2; l<=n && s<n; l++){
				
				if(!p[l])s+=l;
			}
			if(s==n)c++;
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
n, a, b, c = map(int, input().split())
s = []

for i in range(n):
  s.append(input())

ans = []
flag = True
for i in range(n):
  if s[i] == "AB":
    if a < b:
      ans.append("A")
      a += 1
      b -= 1
    elif a == b == 1 and i < n - 1 and "A" in s[i + 1]:
      ans.append("A")
      a += 1
      b -= 1
    elif a == b == 0:
      flag = False
      break
    else:
      ans.append("B")
      a -= 1
      b += 1
  if s[i] == "AC":
    if a < c:
      ans.append("A")
      a += 1
      c -= 1
    elif a == c == 1 and i < n - 1 and "A" in s[i + 1]:
      ans.append("A")
      a += 1
      c -= 1
    elif a == c == 0:
      flag = False
      break
    else:
      ans.append("C")
      a -= 1
      c += 1
  if s[i] == "BC":
    if b < c:
      ans.append("B")
      b += 1
      c -= 1
    elif b == c == 1 and i < n - 1 and "B" in s[i + 1]:
      ans.append("B")
      b += 1
      c -= 1
    elif b == c == 0:
      flag = False
      break
    else:
      ans.append("C")
      b -= 1
      c += 1

print("Yes" if flag else "No")
if flag:
  for _ans in ans:
    print(_ans)

Measured memory_bytes: 17116
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    long long n, m, i = 1;
    vector<long long> v;
    cin >> n >> m;

    while (i <= sqrt(m)) {
        if (m % i == 0) {
            v.push_back(i);
            v.push_back(m / i);
        }
        i++;
    }

    sort(v.begin(), v.end());

    for (auto j: v) {
        if (j >= n) {
            cout << m / j << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import os, sys, re, math

N,K = map(int,input().split(' '))

ret = 0

memo = [0 for _ in range(K)]

for i in range(1,N+1):
    memo[i % K] += 1

# only mod(0)     ex. mod(0) + mod(0) = mod(0)
ret += memo[0] ** 3

# only mod(K/2) when K is even  ex. mod(K/2) + mod(K/2) = mod(0)
if K % 2 == 0:
    ret += memo[K // 2] ** 3

print(ret)


Measured memory_bytes: 4844
S=input()+"X"
N=len(S)
A,B=-1,-1

for i in range(N-2):
    if S[i] == S[i+1]:
        A,B=i+1,i+2
    if S[i] == S[i+2]:
        A,B=i+1,i+3

print(A,B)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	bool flag=false;
	cin>>n;
	for(i=1;i<=n;i*=2){
		if(i==n)flag=true;
	}
	if(flag){
		cout<<"No"<<endl;
		return 0;
	}
	for(a=1;a<=n+1;a*=2);
	a/=2;
	cout<<"Yes"<<endl;
	for(i=1;i<a-1;i++){
		cout<<i<<" "<<i+1<<endl;
		cout<<n+i<<" "<<n+i+1<<endl;
	}
	cout<<a-1<<" "<<n+1<<endl;
	if(a==n+1)return 0;
	cout<<1<<" "<<a<<endl;
	cout<<a<<" "<<n+a+1<<endl;
	cout<<1<<" "<<a+1<<endl;
	cout<<a+1<<" "<<n+a<<endl;
	for(i=a+2;i<=n;i++){
		j=i-a;
		cout<<j<<" "<<i<<endl;
		cout<<i-1<<" "<<i+n<<endl;
	}
}


Measured memory_bytes: 2688
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
using namespace std;
// ¯\_(ツ)_/¯
#define f first
#define s second
#define p push
#define mp make_pair
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define endl " \n"
#define newl cout<<"\n"
#define MAXN 100005
#define MOD 1000000007LL
#define EPS 1e-13
#define INFI 1000000000             // 10^9
#define INFLL 1000000000000000000ll //10^18
// ¯\_(ツ)_/¯
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long>
#define vvll vector<vll>
//vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.
#define pll pair<long long, long long>

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);

ll tc, n, m, k;
// ll ans = 0, c = 0;
// ll i, j;
// ll a, b;
// ll x, y;


void dfs(ll u, vll& done, vvll& adjgraph, vll& dp) {

    for(auto v:adjgraph[u]) {
        if(!done[v]) dfs(v, done, adjgraph,  dp);
        dp[u] = max(dp[u], dp[v]+1);
        done[v] = true;
    }
}


int main()
{
    fast_io();
#ifndef ONLINE_JUDGE
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif

    cin>>n>>m;
    vvll adjgraph(n+1);
    rep(i, 0, m) {
        ll u, v;
        cin>>u>>v;
        adjgraph[u].pb(v);
    }

    ll ans = 0;
    vll done(n+1, 0);
    vll dp(n+1, 0);
    dp[0] = 0;
    rep(i, 1, n+1)
    {
        dfs(i, done, adjgraph, dp);
        done[i] = 1;
    }
    for(auto x:dp) ans = max(ans, x);
    cout<<ans;


    return 0;
}

/*
2
4
0 1 0 1
5
0 0 1 0 0
*/

Measured memory_bytes: 10752
#include <iostream>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    vector<bool> dp(n); dp[0] = true;
    vector<int> cnt(n, 1);
    repeat (i,m) {
        int x, y; cin >> x >> y;
        -- x; -- y;
        -- cnt[x]; ++ cnt[y];
        if (dp[x]) dp[y] = true;
        if (cnt[x] == 0) dp[x] = false;
    }
    cout << whole(count, dp, true) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N,M;
    string S[100];
    string T[100];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    cin >> M;
    for(int i=0;i<M;i++){
        cin >> T[i];
    }
    
    int count=0;
    string ob;
    int res=0;
    
    for(int i=0;i<N;i++){
        count=0;
        ob=S[i];
        for(int j=0;j<N;j++){
            if(ob==S[j]){
                count++;
            }
        }
        for(int j=0;j<M;j++){
            if(ob==T[j]){
                count--;
            }
        }
        res=max(res,count);
    }
    cout << res << endl;
}


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

int main() {
    string str, tmp;
    int m, h;

    while (true) {
        cin >> str >> m;
        if (str == "-") break;

        for (int i = 0; i < m; i++) {
            tmp = str;
            cin >> h;
            for (int j = 0; j < h; j++) {
                str[str.length() - h + j] = tmp[j];
            }
            for (int j = h; j < str.length(); j++) {
                str[j - h] = tmp[j];
            }
        }

        cout << str << endl;
    }
    return 0;
}


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

S = list(input())

change = 0
for i in range(len(S)):
  if i > 0:
    if S[i-1] == S[i]:
      if S[i-1] == '0':
      	S[i] = '1'
      else:
        S[i] = '0'
      change += 1
      
print(change)
  

Measured memory_bytes: 3956