akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 1e5+5;
const ll INF = 1e13+7;

ll N,M,S,T;
vector<vector<ll> > node;

ll dijkstra(ll s, ll e){
  queue<tuple<ll,ll,ll> > Q;
  vector< vector<ll> > d(N, vector<ll>(3,INF));

  // start, mod, cost
  d[s][0] = 0;
  // start, mod, cost
  Q.push(make_tuple( s, 0, 0));

  while(!Q.empty()){
    tuple<ll ,ll, ll> f = Q.front(); Q.pop();
    ll now = get<0>(f);
	ll mod = get<1>(f);
	ll cost = get<2>(f);
    for(int j=0;j<node[now].size();j++){
      ll next = node[now][j];
	  ll nmod = (mod+1) % 3;
	  ll ncost = cost + 1;
      if(d[next][nmod] > d[now][mod] + 1){
        d[next][nmod] = d[now][mod] + 1;
        Q.push(make_tuple(next, nmod, ncost) );
      }
    }
  }
  return (d[e][0] == INF) ? -1 : (d[e][0]/3);
}

signed
main(){
	cin >> N >> M;
	node = vector<vector<ll> >(N+4);
	for(int i=0;i<M;i++) {
		ll u,v;
		cin >> u >> v;
		u--, v--;
		node[u].push_back(v);
	}
	cin >> S >> T;
	S--, T--;

	cout << dijkstra(S,T) << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
    int n,m;
    cin>>n>>m;
    char ch[n][m];
    char c;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        cin>>ch[i][j];
        //cin>>c;
    }
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(i==1 && j==1)
            dp[i][j]=1;
            else if(ch[i-1][j-1]=='#')
            dp[i][j]=0;
            else
            dp[i][j]=(0LL+dp[i-1][j]+dp[i][j-1]+mod)%mod;
        }
    }
    cout<<dp[n][m]<<"\n";
    return 0;
}

Measured memory_bytes: 5120
# coding: utf-8
# Your code here!
N = (123456*2)+1
p = [1] * N

def seive():
    for i in range(2, int(N ** 0.5)+1):
        if p[i] == 1:
            for j in range(i*2, N+1, i):
                p[j] = 0
seive()

def main():
    while True:
        n = int(input())
        if n == 0: break
        print(sum(p[n+1: n*2+1]))

main()



Measured memory_bytes: 8952
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),ans(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  rep(i,n) b.at(i) = i+1;
   rep(i,n){
    ans.at(a.at(i)-1) = b.at(i);
  }

  rep(i,n){
    if(i > 0) cout << " ";
    cout << ans.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 2048
N = int(input())
B = list(map(int, input().split()))

a_list = [10**18]*N
for i, b in enumerate(B):
    a_list[i] = min(a_list[i], b)
    a_list[i+1] = min(a_list[i+1], b)

print(sum(a_list))

Measured memory_bytes: 3060
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define INF = 1e9;
#define MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    set<int> inter, uni;
    set<int> set_b;
    rep(i, m) set_b.insert(b[i]);
    rep(i, n) {
        if (set_b.count(a[i]) == 1) inter.insert(a[i]);
    }
    rep(i, n) uni.insert(a[i]);
    rep(i, m) uni.insert(b[i]);
    cout << inter.size() << " " << uni.size() << endl;
    for (int x : inter) cout << x << endl;
    for (int x : uni) cout << x << endl;
    return 0;
}



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

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

    int n;
    cin >> n;

    int maxx = 0;
    long long ans = 0;

    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;

        if (i == 1)
            maxx = x;

        ans += max(0, maxx - x);
        maxx = max(maxx, x);
    }

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


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  VS Z(H);
  rep(i,H) cin>>Z[i];
  int S,T;
  rep(i,H) rep(j,W) if(Z[i][j]=='S'){
    S=i;
    T=j;
  }
  VVI X(H,VI(W,-1));
  X[S][T]=0;
  queue<PII> Q;
  Q.push(mp(S,T));
  vector<PII> Y;
  Y.pb(mp(S,T));
  while(!Q.empty()){
    PII tmp=Q.front();
    Q.pop();
    int A=tmp.first;
    int B=tmp.second;
    if(X[A][B]==K) break;
    auto solve=[&](int A,int B,int C,int D){
      if(A+C<0 or A+C>H-1 or B+D<0 or B+D>W-1) return;
      if(X[A+C][B+D]==-1 and Z[A+C][B+D]=='.'){
        X[A+C][B+D]=X[A][B]+1;
        Q.push(mp(A+C,B+D));
        Y.pb(mp(A+C,B+D));
      }
    };
    solve(A,B,-1,0);
    solve(A,B,1,0);
    solve(A,B,0,-1);
    solve(A,B,0,1);
  }
  int ans=1001001001;
  rep(i,Y.size()){
    ans=min(ans,1+(min({Y[i].first,H-1-Y[i].first,Y[i].second,W-1-Y[i].second})+K-1)/K);
  }
  cout<<ans<<endl;
}


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

int main() {
	int n,l;
	cin>>n>>l;
	int sum=0,sum1=0,sum2=0;
	int a[n];
	for(int i=1;i<=n;i++)
	{
		a[i]=l+i-1;
		sum+=a[i];
	}
	if(l>0)
	{
		sum1=sum-a[1];
		cout<<sum1;
	}
	else
	{
		if(n+l>0)
		{
			cout<<sum<<endl;
		}
		else
		{   
			sum2=sum-a[n];
			cout<<sum2<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
// "header" {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod1 = 1000000007;
const long long mod2 = 998244353;


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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}

inline int square(int a){ return a * a; }

inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	
    return xRes * x;
}

// }}}

int n,m;
vector<vector<int> > g;
vector<int> dp;

int dfs(int now){
    int maxv = 0;
    if(dp[now] != -1) return dp[now] + 1;
    rep(i,g[now].size()){
        int next = g[now][i];
        chmax(maxv,dfs(next));
    }
    chmax(dp[now],maxv);
    return maxv + 1;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> m;

    g.resize(n+1);
    dp.resize(n+1,-1);

    rep(i,m){
        int x,y;
        cin >> x >> y;
        g[x].emplace_back(y);
    }

    int res = 0;

    reps(i,n){
        if(dp[i] == -1) chmax(res,dfs(i)-1);
    }


    cout << res << '\n';
    
    return 0;
}


Measured memory_bytes: 8576
package main

import (
	"fmt"
)

func main() {
	z := make([]int, 100001)

	var n int
	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		var a int
		fmt.Scanf("%d", &a)

		z[a] = z[a] + 1
	}

	sum := 0
	for i := 0; i < len(z); i++ {
		if z[i] != 0 {
			sum = sum + (i * z[i])
		}
	}

	var q int
	fmt.Scanf("%d", &q)

	ans := make([]int, q)
	var b1, b2 int
	for i := 0; i < q; i++ {
		fmt.Scanf("%d", &b1)
		fmt.Scanf("%d", &b2)

		if z[b1] > 0 {
			sum = sum - (b1 * z[b1] - b2 * z[b1])
			z[b2] = z[b2] + z[b1]
			z[b1] = 0
		}
		ans[i] = sum
	}

	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}


Measured memory_bytes: 7316
N = int(input())
B = list(map(int, input().split()))
A = [0] + B + [0]
s = 0
t = 0

for i in range(1,N+2):
    t += abs(s-A[i])
    s = A[i]

for i in range(1,N+1):
    print(t + abs(A[i-1]-A[i+1]) - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]))


Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    bool ok = 1;
    while (n--) {
        int x;
        cin >> x;
        if (x % 2 == 0) {
            if (x % 3 && x % 5)
                ok = 0;
        }
    }
    cout << (ok ? "APPROVED\n" : "DENIED\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,t;
    cin >> n >> t;
    VP r(n);
    int a,b;
    REP(i,0,n) {
        cin >> a >> b;
        r[i] = MP(a,b);
    }
    sort(all(r), [](auto &l, auto &r) {
        if (l.second != r.second) return l.second > r.second;
        return l.first > r.first;
    });
    int ans = 0;
    {
        VVI dp(n,VI(t+1));
        dp[0][r[0].first] = r[0].second;
        REP(i,1,n) {
            REP(j,0,t+1) {
                dp[i][j] = dp[i-1][j];
                if (j - r[i].first >= 0) {
                    dp[i][j] = max(dp[i][j], dp[i-1][j-r[i].first]+r[i].second);
                }
            }
        }
        ans = max(ans, *max_element(all(dp[n-1])));
        REP(i,0,t) {
            vector<bool> used(n);
            int v = i;
            RREP(j,1,n) {
                if (dp[j][v] == dp[j-1][v]) continue;
                used[j] = true;
                v -= r[j].first;
            }
            if (v > 0) used[0] = true;
            int maxv = 0;
            REP(j,0,n) if (!used[j]) maxv = max(maxv, r[j].second);
            ans = max(ans, dp[n-1][i] + maxv);
            //cerr << i << ", " << ans << endl;
            //REP(j,0,n) if (used[j]) cerr << j << endl;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,m;
  cin>>n>>m;
  Graph G(n);
  int h[n];
  rep(i,n){
    cin>>h[i];
  }
  rep(i,m){
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  int ans=0;
  rep(i,n){
    int x=1;
    for(auto itr=G[i].begin();itr!=G[i].end();++itr){
      if(h[i]<=h[*itr]){
        x=0;
      }
    }
    ans+=x;
  }
  cout<<ans;
}

Measured memory_bytes: 8748
def BFS(K,path,N):
  """リストのリスト道順path,頂点の個数Nが与えられたとき, 頂点Kから各頂点までの距離をlistで返す"""
  from collections import deque
  dist=[-1]*N
  dist[K]=0
  que=deque()
  que.append(K)
  while que:
    label=que.popleft()
    for i,c in path[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        que+=[i]
  return dist
 
N=int(input())
path=[ [] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  path[a-1]+=[[b-1,c]]
  path[b-1]+=[[a-1,c]]
Q,K=map(int,input().split())
distance=BFS(K-1,path,N)
for i in range(Q):
  x,y=map(int,input().split())
  print(distance[x-1]+distance[y-1])

Measured memory_bytes: 49928
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	long long a, b, x, ans;
	cin >> a >> b >> x;
	ans = (b + x) / x - (a + x - 1) / x;
	cout << ans << endl;
	return 0;
}


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


int main() {
    string s;
    cin >> s;

    if  (s == "ABC")
        cout << "ARC" << endl;
    else
    {
        cout << "ABC" << endl;
    }
    

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  while (n--) {
    int a, b = 0, c = 0;
    bool f = true;
    for (int i = 0; i < 10; i++) {
      cin >> a;
      if (b < a) b = a;
      else if (c < a) c = a;
      else f = false;
    }
    cout << (f ? "YES\n" : "NO\n");
  }
}


Measured memory_bytes: 3012
import sys

readline = sys.stdin.readline
N = int(readline())
CSF = [list(map(int, readline().split())) for _ in range(N-1)]
for i in range(N):
    time = 0
    for c, s, f in CSF[i:N-1]:
        if time < s:
            time = s
        else:
            time = (time+f-1)//f*f
        time += c
    print(time)


Measured memory_bytes: 3188
#include <stdio.h>
 
int main(void){
 
  int n;
  int An[100];
  int i,f = 0;
  
  do{
    scanf("%d", &n);
  }while(n<1 || n>100);
  
  for(i = 0; i < n; i++){
    do{
      scanf("%d", &An[i]);
    }while((An[i] < 1)&&(An[i] > 1000));
  }
  
  for(i = 0; i < n; i++){
    if((An[i] % 2) == 0){
      if(((An[i] % 3) != 0)&&((An[i] % 5) != 0)){
        f = 1;
      }
    }
  }
  if(f == 0){
    printf("APPROVED");
  }else{
    printf("DENIED");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  string s;
  cin>>s>>m;
  string a,b;
  for (ll i = 0; i < m; ++i)
  {
    cin>>k;
    if(k==1){
    	x = x^1;
    }
    else{
    	char ch;
    	cin>>n>>ch;
    	if(x==0){
    		if(n==1){
    		 a+=ch;
    		}
    		else b+=ch;
    	}
    	else{
    	 if(n==1){
    		 b+=ch;
    		}
    		else a+=ch;
    	}
    }
  }
  if(x==1){
  	reverse(b.begin(), b.end());
  	reverse(s.begin(), s.end());

  	c(b+s+a);
  }
  else{
  	reverse(a.begin(), a.end());
  	c(a+s+b);
  }
  
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  ll T=1;
  //cin>>T;
  while(T--){
  solve();
  }
  return 0;
}


Measured memory_bytes: 1300
N = int(input())
d = dict()
for i in range(1, 10):
    for j in range(1, 10):
        d[str(i) + str(j)] = 0

for i in range(1, N + 1):
    if str(i)[-1] != '0':
        d[str(i)[0] + str(i)[-1]] += 1

result = 0
for i in range(1, 10):
    for j in range(1, 10):
        result += d[str(i) + str(j)] * d[str(j) + str(i)]

print(result)

Measured memory_bytes: 3064
n,m=map(int,input().split())
p=list(map(int,input().split()))
xs=[tuple(map(int,input().split())) for _ in range(m)]
def root(n):
  if union[n]==n:
    return n
  union[n]=root(union[n])
  return union[n]
union={x:x for x in range(1,n+1)}
for x,y in xs:
  union[root(x)]=root(y) 
print(sum(root(i+1)==root(p[i]) for i in range(n)))

Measured memory_bytes: 33980
#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
#define mod 1000000007
using namespace std;
int main()
{
	lli t,n,s,j,i;
	cin>>s;
	vector<lli>ds(2001,1);
	ds[0]=ds[1]=ds[2]=0;
	for(i=3;i<=s;i++){
		j=i-3;
		while(j>=3){
			ds[i]+=ds[j];
			ds[i]%=mod;
			j--;
		}
	}
	cout<<ds[s];	
	return 0;
}

Measured memory_bytes: 3584
/*ex3_2
    takafumi_ueki*/
#include <stdio.h>
int main(void){
    //N(:ある整数)がK進法で表したときM桁になる
    int N,K;
    int M = 0;
    //Nが0になるまで引き続け、その引いた回数が桁数になる
    scanf("%d %d",&N,&K);
    while(N != 0){
        N = N/K;
        M++;
    }
printf("%d\n",M);
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int A;
  A = K;
  for (int i = 0; i < N - 1; i++) {
      A *= (K - 1);    
  }  
  cout << A << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	m, _ := strconv.Atoi(Scanner())
	a := make([]int, n+1)
	mod := make(map[int]int)
	mod[0] = 1
	for i := 1; i < n+1; i++ {
		a[i], _ = strconv.Atoi(Scanner())
		a[i] = (a[i-1] + a[i]) % m
		mod[a[i]]++
	}
	ans := 0
	for _, v := range mod {
		ans += (v - 1) * v / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7296
/* ex 9_1
   hangan2020 */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 11

//Stack structure
typedef struct stack{
   int size;
   int count;
   char data[SIZE];
   char *top;
} stack;

//Initialize stack array
void initialize_stack(stack *stk){
   stk->count = 0;
   stk->size = SIZE;
   stk->top = &(stk->data[SIZE]);
}

//Push function
void push(stack *stk, char elem){
   if(stk->count >= stk->size){
      fprintf(stderr, "Error: Stack overflow\n");
      exit(1);
   }
   else{
      stk->top--;
      *(stk->top) = elem;
      stk->count++;
   }
}

//Pop function
void pop(stack *stk){
   if(stk->count <= 0){
      fprintf(stderr, "Error: Stack underflow\n");
      exit(1);
   }
   else{
      stk->top++;
      stk->count--;
   }
}

// Function to print stack
void print_stk(stack *stk){
   char *p;
   p = stk->top;
   for(int i = stk->count; i > 0; i--){
      printf("%c", p[i-1]);
   }
   printf("\n");
}

int main(void){
   stack stk;
   char string[SIZE];
   int i = 0;

   initialize_stack(&stk);
   scanf("%s", &string);
   
   // Traverse from the right
   while(string[i] != '\0'){
      //If meet B and the string is not empty, delete the prev element
      if(string[i] == 'B'){
         if(stk.count != 0){
            pop(&stk);
         }
      }else{ //Otherwise push
         push(&stk, string[i]);
      }
      i++;
   }

   print_stk(&stk);

   return 0;

}

Measured memory_bytes: 1640
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const ll MOD = 998244353;
const int N = 2e5 + 5;

ll f[N], inv[N];
ll n, m, k;

ll get(ll x, ll y) {
  if(y == -1) y = MOD - 2;
  ll res = 1LL;
  while(y) {
    if(y & 1) res = (res * x) % MOD;
    x = (x * x) % MOD;
    y >>= 1;
  }
  return res;
}

ll ncr(ll n, ll r) {
  if(n < r or n < 0 or r < 0) return 0;
  ll cur = f[n];
  ll p = inv[r];
  p = (p * inv[n - r]) % MOD;
  return cur * p % MOD;
}

void solve() {
  cin >> n >> m >> k;
  f[0] = inv[0] = 1;
  for(int i = 1; i < N; i++) {
    f[i] = (f[i - 1] * i) % MOD;
    inv[i] = get(f[i], -1);
  }
  ll ans = 0;
  for(ll i = 1; i <= k + 1; i++) {
    ll q = m * get(m - 1, n - i) % MOD;
    ans += (q * ncr(n - 1, i - 1)) % MOD;
    ans %= MOD;
  }
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}


Measured memory_bytes: 6808
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int x= in .nextInt();
        int[] l= new int[n];
        for(int i=0;i<n;i++)
            l[i]=in.nextInt();
        int d=0,i=0;
        for(;i<n;i++){
            d=d+l[i];
            if(d>x)
                break;
        }
        System.out.println(i+1);


    }
}


Measured memory_bytes: 21972
#![allow(non_snake_case)]
use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let R: usize = read();
    if N >= 10 {
        println!("{}", R);
    } else {
        println!("{}", R + (100 * (10 - N)));
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
long long mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int> > ab(m);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    ab[i]=make_pair(b,a);
  }
  sort(ab.begin(),ab.end());
  int ans=0;
  int last=-1;
  for(int i=0;i<m;i++){
    if(ab[i].second>last){
      last=ab[i].first-1;
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    int w = n;
    int sum = 0;
    while(w > 0){
        sum += w%10; w /= 10;
    }
    if(n%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,W;
ll w[110],v[110];
ll dp[110][100100];
ll ans;

void input(){
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	return;
}

void solve(){
	for(int i=0;i<n;i++){
		for(int j=0;j<W;j++){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			if(j+w[i]>W)continue;
			dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
			ans=max(ans,dp[i+1][j+w[i]]);
		}
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}


Measured memory_bytes: 79360
#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    switch(N % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        std::cout << "hon" << std::endl;
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        std::cout << "pon" << std::endl;
        break;
        case 3:
        std::cout << "bon" << std::endl;
        break;
    }
    return 0;
}

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



ll N, K;
vector<ll> A, F;

int main(){
	cin >> N >> K;
	
	A.resize(N);
	F.resize(N);
	for ( int i = 0; i < N; i++ ){
		cin >> A[i];
	}
	for ( int i = 0; i < N; i++ ){
		cin >> F[i];
	}
	
	sort(A.begin(),A.end());
	sort(F.begin(),F.end(),[](const ll& l, const ll& r){return l > r;});
	
	ll tmax = 0;
	for ( int i = 0; i < N; i++ )
		tmax = max( tmax, A[i]*F[i] );
	ll tmin = -1;
	
	// 二分探索
	// tmin: K回の修行で達成できない成績 の最大値
	// tmax: K回の修行で達成できる成績 の最小値
	while ( tmax-tmin > 1 ){
		ll t = tmin + (tmax-tmin)/2;
		ll k = 0; // 成績tを達成するために必要な修行回数
		for ( int i = 0; i < N; i++ ){
			ll a = t / F[i];
			if ( A[i] > a )
				k += A[i]-a;
		}
		
		if ( k <= K )
			tmax = t;
		else
			tmin = t;
	}
	
	cout << tmax << endl;
	
	return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
 
void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}
 
const int N=2e6+3,M=5e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;
 
int n,m,k,tc,ans,a[N];
 
char s[N];

int main(){
    int d;
    scanf("%d%d",&n,&d);
    for(int i = 0 ; i < n ; i++){
        ll x,y;
        scanf("%lld%lld",&x,&y);
        if (sqrt(x*x + y*y) <= d)
            ans++;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 3808
#include<iostream>

using namespace std;

int main(){

    int n;

    cin >> n;

    int b[99];

    for (int i=0 ; i<n-1;i++) cin >> b[i];

    int a[100];

    a[0]=b[0];

    for (int i=1 ; i<n;i++) a[i] = min(b[i-1],b[i]);

    a[n-1]=b[n-2];

    int s=0;

    for (int i=0 ; i<n ; i++) s+=a[i];

    cout << s << endl;

}

Measured memory_bytes: 256
n=int(input())
S=[input() for i in range(n)]
s=set(S[0])
for i in range(1,n):
    s&=set(S[i])
ans=""
for i in sorted(s):
    tmp=99
    for j in S:
        tmp=min(tmp,j.count(i))
    ans+=i*tmp
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int n;
    cin >> n;
    cout << 24 + (24 - n) << endl;

    return 0;
}

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

using namespace std;

int main() {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
        int n;
        scanf("%d", &n);
        vector<int> h(n);
        for (int i = 0; i < n; i++) {
                scanf("%d", &h[i]);
        }
        const int INF = (int) 1e9 + 100;
        vector<int> dp(n + 10, INF);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
                for (int j = 1; j <= 2; j++) {
                        if (i + j < n) {
                                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
                        }
                }
        }
        printf("%d\n", dp[n - 1]);
        return 0;
}


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

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

  for(int i = 0; i < 4; i++){
    for(int j = i + 1; j < 4; j++){
    
      if(S[i] == S[j]){
          repeated++;
          }
        }
     }
  if (repeated == 2){
      cout << "Yes" << endl;
    }
  else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

# 勝つ手を求める
def f(ch):
    if ch == 'r':
        return 'p'
    elif ch == 's':
        return 'r'
    else:
        return 's'

te = []
for i in range(N):
    r = f(T[i])
    if i < K:
        te.append(r)
    else:
        if te[i-K] == r:
            te.append('*')
        else:
            te.append(r)

ans = 0
for ti in te:
    if ti == 'r':
        ans += R
    elif ti == 's':
        ans += S
    elif ti == 'p':
        ans += P
print(ans)
# print(te)


Measured memory_bytes: 4212
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias t = Tuple!(string, "name", long, "y");

void main()
{
    auto x = lread();
    auto rest = x % 100;
    foreach (a; iota(100 / 1))
    {
        foreach (b; iota(100 / 2))
        {
            foreach (c; iota(100 / 3))
            {
                foreach (d; iota(100 / 4))
                {
                    foreach (e; iota(100 / 5))
                    {
                        if((a + 2 * b + 3 * c + 4 * d + 5 * e) == rest)
                        {
                            auto s = a + b + c +  d + e;
                            if(s * 100 <= x - rest)
                            {
                                writeln(1);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
    writeln(0);
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
map$q[$_]+=$q[$N]/@$N,@{/ /,push@
$`,$' for<>;++$N}for++$q[1]..<>;while(--$N){$b=1;$e[$N]=$b+=$_/@@for@@=@e[@$N];$a<($~=$q[$N]*($b-1-$_)/($#@||1))or$a=$~for@@}print$a+$b

Measured memory_bytes: 108308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
using ping = pair<ll, ll>;

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

    ll cnt_0 = 0, cnt_1 = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == '0') cnt_0++;
      else
        cnt_1++;
    }
    cout << 2*min(cnt_0, cnt_1) << endl;
    return 0;
}

Measured memory_bytes: 3728
l, r  = map(int, input().split())
ans = 10000
for i in range(l, min(r, l + 2030)):
    for j in range(i + 1, min(r + 1, l + 2030)):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            print(ans)
            exit()
print(ans)


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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

int main() {
	string s;
	cin >> s;
	int A = 0, B =0 ;
	for (int i = 1; i <= 3; i++) {
		if (s[i - 1] == 'A') A++;
		else B++;
	}
	if (A > 0 && B > 0) {
		cout << "Yes"; return 0;
	}
	else {
		puts("No"); return 0;
	}
	return 0;
}


Measured memory_bytes: 3596
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int left = 0;
        int right = 0;

        for(int i=0; i<num; i++){
            String line1 = sc.next();
            String line2 = sc.next();

            if (line1.compareTo(line2) < 0){
                right+=3;
            } else if (line1.compareTo(line2) > 0){
                left+=3;
            } else {
                left++;
                right++;
            }
        }

        System.out.println(left + " " + right);
    }
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N, K;
    cin >> N >> K;
    vec H(N);
    REP(i,0,N) cin >> H[i];
    sort(ALL(H), greater<ll>());

    ll c = 0;
    if(N > K) {
        REP(i,K,N) c += H[i];
    }
    PR(c);

    return 0;
}

/*



*/

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJ0049().doIt();
	}
	
	class AOJ0049{
		void doIt(){
			HashMap<String, Integer> map = new HashMap<String, Integer>();
			map.put("A", 0);
			map.put("B", 0);
			map.put("AB",0);
			map.put("O", 0);
			while(in.hasNext()){
				String[] input = in.next().split(",");
				map.put(input[1],map.get(input[1])+1);
			}
			System.out.println(map.get("A"));
			System.out.println(map.get("B"));
			System.out.println(map.get("AB"));
			System.out.println(map.get("O"));
		}
	}
	
	
	
}

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

int main() {
string s,ans="Yes";cin>>s;
  
 for(int i=0;i<s.size();i++){
   if(s.at(i)=='U' || s.at(i)=='D') ans=ans;
   else if(s.at(i)=='L' && i%2==0)ans="No";
   else if(s.at(i)=='R' && i%2==1)ans="No";
 }
 cout<<ans<<endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int i,a,b,month[14][5],x,y;
char d;
scanf("%d\n",&a);
for(y=1;y<=4;y++){
for(x=1;x<=13;x++){
month[x][y]=0;
}
}
for(i=1;i<=a;i++){
scanf("%c %d\n",&d,&b);
if(d=='S'){
month[b][1]=1;
}
if(d=='H'){
month[b][2]=1;
}
if(d=='C'){
month[b][3]=1;
}
if(d=='D'){
month[b][4]=1;

}
}
for(i=1;i<=13;i++){
if(month[i][1]==0){
printf("S %d",i);
printf("\n");
}
}
for(i=1;i<=13;i++){
if(month[i][2]==0){
printf("H %d",i);
printf("\n");
}
}
for(i=1;i<=13;i++){
if(month[i][3]==0){
printf("C %d",i);
printf("\n");
}
}
for(i=1;i<=13;i++){
if(month[i][4]==0){
printf("D %d",i);
printf("\n");
}
}
return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
char s[100005];
int n,f[100005],nx[100005][2],sum=0;
bool flag=1;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	f[n+1]=1;nx[n+1][0]=nx[n+1][1]=nx[n+2][0]=nx[n+2][1]=n+2;
	for(int i=1;i<n;i++) if(s[i]==s[i+1]) flag=0;
	if(flag)
	{
		puts("1");
		return 0;
	}
	for(int i=n;i>=1;i--)
	{
		sum=(sum+(s[i]-'a'+1))%3;
		nx[i][0]=(s[i]=='a')?i+1:((s[i+1]=='b')?i+2:nx[i+2][0]);
		nx[i][1]=(s[i]=='b')?i+1:((s[i+1]=='a')?i+2:nx[i+2][1]);
		f[i]=(f[nx[i][0]]+f[nx[i][1]]+(sum==0))%mod;
	}
	printf("%d\n",(f[1]-(sum==0)+mod)%mod);
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

int main(){
	string s;
	cin>>s;

	bool ok=true;
	string s1=s;
	reverse(all(s1));
	string s2=s.substr(0,(s.size()-1)/2);
	reverse(all(s2));
	string s3=s.substr((s.size()+3)/2-1);
	reverse(all(s3));
	if(s!=s1)ok=false;
	if(s.substr(0,(s.size()-1)/2)!=s2)ok=false;
	if(s.substr((s.size()+3)/2-1)!=s3)ok=false;

	cout<< (ok?"Yes":"No") <<endl;


	return 0;
}



Measured memory_bytes: 256
typedef struct{double x,y,k;}w;w p[100],b;m,v[100],n,j,r;z(w*c,w*d){r=c->k>d->k?-1:1;}double o(w q,w r,w s){return q.x*(r.y-s.y)+r.x*(s.y-q.y)+s.x*(q.y-r.y);}main(i){for(;j=scanf("%d",&n)+~n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;b=p[m];p[m]=*p;for(i=1;i<n;i++)p[i].k=(p[i].x-b.x)/hypot(p[i].x-b.x,p[i].y-b.y);qsort(p+1,n-1,24,z);*v=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;o(p[v[j-1]],p[v[j]],p[i])<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}}

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

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++)

typedef long long int ll;


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

	int a,b,c,k;
	cin >> a >> b >> c >> k;

    cout << a+b+c+max({a,b,c})*((1<<k) - 1);
	return 0;
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
ans = 10**9+7
for i in range(10**5+1):
  if ans > (2*C*i + max(0,Y-i)*B + max(0,X-i)*A):
    ans = 2*C*i + max(0,Y-i)*B + max(0,X-i)*A
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n; cin >> n;
	while(n>0){
		n-=1000;
	}
	cout <<  -n;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3632
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll N,ans;
ll A[100000], B[100000], C[100000];
ll ans1[100000], ans2[100001];

int main() {
	cin >> N;
	FOR(i, 0, N)cin >> A[i];
	FOR(i, 0, N)cin >> B[i];
	FOR(i, 0, N)cin >> C[i];
	sort(A, A + N); sort(B, B + N); sort(C, C + N);

	int cur = 0;
	FOR(i, 0, N) {
		while (B[i] >= C[cur]&&cur<N) {
			cur++;
		}
		if (cur == N)break;
		ans1[i] = N - cur;
	}

	

	REP(i, N-1, -1) {
		ans2[i] = ans2[i+1] + ans1[i];
	}
	cur = 0;
	FOR(i, 0, N) {
		while (A[i] >= B[cur] && cur < N) {
			cur++;
		}
		if (cur == N)break;
		ans+= ans2[cur];
	}

	ct(ans);
	return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(Math.max(0, c - a + b));
    }

}


Measured memory_bytes: 21844
a,b,c,d,e,f,g=map(int,input().split())
check=[a%2,d%2,e%2]
if check.count(1)==3 or check.count(1)==0:
    print(a+b+d+e)
elif check.count(1)==1:
    print(a+b+d+e-1)
else:
    if a*d*e>0:
        print(a+b+d+e-1)
    else:
        print(a+b+d+e-2)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC target("avx2")
#pragma GCC optimize("-O3")
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define INF 1e18
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1743;
const ll gd = 2000001;
const ll gd_o = 1000001;
//const ll p = 31;
const ll MD=1e6 + 3;
int rnd(int x) { return mrand() % x;}
ll fastpow(ll a, ll n) {ll res=1;while(n){if(n&1)res*=a;a*=a;n>>=1;}return res;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll nok(ll a,ll b){ return (a * b / gcd(a, b));}


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//    freopen("msched.in", "r", stdin);
//    freopen("msched.out", "w", stdout);
    string n;
    cin >> n;
    for (int i = 0; i < n.size(); i++)
        if (n[i] == '7') {cout << "Yes"; return 0;}
    cout << "No";
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<string>
#include<string.h>
#include<list>
#include<queue>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<deque>
#include<stack>
using namespace std;
#define debug(x) cout<<"###"<<x<<"###"<<endl;
const int INF=0x3f3f3f3f,MAXN=3e3+5;
typedef long long ll;
int w[MAXN],v[MAXN];
int dp[MAXN][MAXN*2];
struct Node{
	int w,v;
}node[MAXN];
bool cmp(Node a,Node b){
	return a.w<b.w;
}
int main(){
	int n,t;
	cin>>n>>t;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		scanf("%d%d",&node[i].w,&node[i].v);
	}
	sort(node+1,node+1+n,cmp);
	for(int i = 1; i <= n; i++){              
        for(int j=1;j<=t+node[i].w-1; j++){
        	if(j<node[i].w){
        		dp[i][j]=dp[i-1][j];
			}
			else{
				 dp[i][j] =max(dp[i-1][j], dp[i-1][j-node[i].w] + node[i].v);
			} 
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
    	ans=max(dp[i][t+node[i].w-1],ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70784
H,W = map(int,input().split())
S = [input() for _ in range(H)] 

nS = [['' for i in range(W)] for j in range(H)]

cpC = [1, 0, -1, 0, 1, -1, -1, 1]
cpR = [0, 1, 0, -1, 1, 1, -1, -1]


for i in range(H):
    for j in range(W):
        counter = 0
        if S[i][j] == '#':
            nS[i][j] = '#'
            continue

        for r,c in zip(cpR,cpC):
            x = i + r
            y = j + c
            if x >= 0 and x < H and y >= 0 and y < W and S[x][y] == "#":
                counter += 1
        
        nS[i][j] = counter

for i in range(H):
    for j in range(W):
        print(nS[i][j], end="")
    print('')


Measured memory_bytes: 3444
// A.

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans >= 10) {
		cout << "error" << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    int n, k;
    scan(n, k);
    auto a = readln.split.to!(int[]);

    auto presum = new long[](n + 1);
    auto possum = new long[](n + 1);
    foreach (i ; 1 .. n + 1) {
        presum[i] = a[i-1] + presum[i-1];
        possum[i] = max(a[i-1], 0) + possum[i-1];
    }

    long ans;
    foreach (i ; 0 .. n - k + 1) {
        long t = possum[n] - (possum[i + k] - possum[i]) + max(0, presum[i + k] - presum[i]);
        ans = max(ans, t);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 7112