akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{

	int A, B;

	scanf("%d %d", &A, &B);

	if (A>9||B>9)
		printf("-1\n");
	else
		printf("%d\n", A*B);

	return 0;
}
	

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,ans;
int a[200005],b[200005];
int pre[200005],suf[200005],dat[200005];
void init(vector<pair<int,int> >&_B){
	memset(pre,0,sizeof pre);
	memset(suf,0,sizeof suf);
	for(int i=1;i<=n;i++)dat[i]=_B[i-1].first;
	for(int i=1;i<=n;i++){
		pre[i]=pre[i-1]+(1-_B[i-1].second);
	}
	for(int i=n;i>=1;i--){
		suf[i]=suf[i+1]+(_B[i-1].second);
	}
}
int calc(int x,int mask){
	int l=0,r=n+1;
	int less=mask-x%mask;
	while(r-l>1){
		int mid=l+r>>1;
		if(dat[mid]>=less)r=mid;
		else l=mid;
	}
//	cerr<<r<<" "<<x<<" "<<mask<<" "<<pre[r-1]<<" "<<suf[r]<<endl;
	return (x&mask)==0?n-pre[r-1]-suf[r]:pre[r-1]+suf[r];
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	for(int i=0;i<30;i++){
		int mask=1<<i;
		vector<pair<int,int> >B;
		for(int j=1;j<=n;j++)B.push_back(make_pair(b[j]&mask-1,b[j]&mask?1:0));
		sort(B.begin(),B.end());
		init(B);
		int one=0;
		for(int j=1;j<=n;j++){
			one+=calc(a[j],mask);one&=1;
		}
		if(one&1)ans|=mask;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9812
#include <stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a==5 && b==5 &&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		//Scanner sa = new Scanner(System.in);
		int building[] = new int[n]; 
		for(int i = 0;i < n ; i++){
			building[i] = sc.nextInt();
		}

		int ans =1;

		for(int j =1;j<n;j++){
			int counter=0;
			for(int k=0;k<j;k++){
				if(building[k] <= building[j]){
					counter++;
				}
			}
			if(counter == j){
				ans++;
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 23124
n=int(input())
s=input()
x=[0]*n
t=0
for i in range(n):
    if s[i]=="E":
        t+=1
    x[i]=t
M=x[n-1]
c=0
ans=10**9
for i in range(n):
    ans=min(ans,i-c+M-x[i])
    c=x[i]
print(ans)

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
template<typename T>
void pr(T a){
  cout<<a<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  auto v=vec(3,3,0LL);
  rep(i,0,3)rep(j,0,3)cin>>v[i][j];
  set<ll>st;
  ll n;cin>>n;
  rep(i,0,n){
    ll b;cin>>b;
    st.insert(b);
  }
  judge=false;
  rep(i,0,3){
    bool sw=true;
    rep(j,0,3)if(!st.count(v[i][j]))sw=false;
    if(sw)judge=true;
  }
  rep(j,0,3){
    bool sw=true;
    rep(i,0,3)if(!st.count(v[i][j]))sw=false;
    if(sw)judge=true;
  }
  bool sw=true;
  rep(i,0,3)if(!st.count(v[i][i]))sw=false;
  if(sw)judge=true;
  sw=true;
  rep(i,0,3)if(!st.count(v[i][2-i]))sw=false;
  if(sw)judge=true;
  ans1(judge);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <algorithm>
     
    int main()
    {
      int N;
      std::cin >> N;
      std::vector<int> L(N);
      for (int i=0; i<N; ++i)
        std::cin >> L[i];
      std::sort(L.begin(), L.end());

      int sum = 0;
      for (int i=0; i<N-2; ++i) 
    	for (int j=i+1; j<N-1; ++j)
          for (int k=j+1; k<N; ++k) {
            if (L[i]+L[j]<=L[k]) break;
            else sum +=1;
          }
      std::cout << sum << std::endl;
      return 0;
    }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int N; cin >> N;
  int a[N*3]; for (int i{0}; i < N*3; ++i) cin >> a[i];
  sort(a, a + N*3);
  long total{0};
  for (int i = N*3-2; i >= N; i -= 2) total += a[i];
  cout << total << "\n";
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define LL long long
#define N 1000010
#define M 1000000007
LL n,f[N],sum;
int main()
{
	scanf("%lld",&n);
	f[n]=n,f[n-1]=(LL)n*n%M;
	for(LL i=n-2;i>=1;--i)
	{
		sum=(sum+f[i+3])%M;
		f[i]=f[i+1];
		f[i]=(f[i]+(LL)(n-1)*(n-1)%M)%M;
		f[i]=(f[i]+sum)%M;
		f[i]=(f[i]+i+1)%M;
	}
	printf("%lld\n",f[1]);
	return 0;
}

Measured memory_bytes: 8064
fun main() {
    readLine()!!
    val list = readLine()!!.split(" ").map { it.toLong() }
    var temp = list[0]
    var count = 0L
    for (a in list.indices) {
        if (list[a] <= temp) {
            count += temp - list[a]
        } else {
            temp = list[a]
        }
    }
    println(count)
}

Measured memory_bytes: 65076
import math
n,d = map(int,input().split())
l = []
for i in range(n):
  r = list(map(int,input().split()))
  l.append(r)
f = []
for i in range(n-1):
  for j in range(i+1,n):
    e = []
    for k in range(d):
      e.append((l[i][k]-l[j][k])**2)
    f.append(sum(e))
count = 0
for i in f:
  if math.sqrt(i).is_integer():
    count += 1
print(count)

Measured memory_bytes: 38384
N = gets.to_i
ds = gets.split.map(&:to_i)
hash = Hash.new(0)
ds.each{|d| hash[d] += 1}
if hash[0] > 0 || hash.values.max >= 3
    puts 0
    exit
end

tz = [0, 24]
rev = false
hash.keys.sort.each do |i|
    if hash[i] == 1
        tz.push(rev ? 24-i : i)
        rev = !rev
    else
        tz.push(i, 24-i)
    end
end
tz.sort!
puts (tz.length-1).times.map{|i| tz[i+1] - tz[i]}.min

Measured memory_bytes: 1788
n = int(input())
ans = 0
aend = 0
bstart = 0
aendbstart = 0
for _ in range(n):
   sl = list(input())
   for i in range(len(sl)-1):
      if sl[i] == "A" and sl[i+1] == "B":
         ans += 1
   if sl[0] == "B" and sl[-1] == "A":
      aendbstart += 1
   elif sl[0] == "B":
      bstart += 1
   elif sl[-1] == "A":
      aend += 1

if aendbstart == 0:
   ans += min(aend, bstart)
elif bstart + aend > 0:
   ans += aendbstart + min(aend, bstart)
else:
   ans += aendbstart - 1
print(ans)


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

int main()
{
    int N, K = 0;
    cin >> N >> K;

    string s = "";
    if((double)N / 2 + 0.5 >= K)
    {
        s = "YES";
    }
    else
    {
        s = "NO";        
    }
    
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s,t,u;
    int64_t a,b;
    cin >> s >> t >> a >> b >> u;
    if(s==u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
}


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

int main() {
    vector<vector<int>> g(6, vector<int>(2, -1));
    g[0][0] = 1;
    g[0][1] = 2;
    g[1][1] = 3;
    g[2][0] = 1;
    g[3][0] = 4;
    g[3][1] = 5;
    g[4][0] = 5;
    g[4][1] = 2;
    g[5][0] = 2;
    g[5][1] = 1;
    string path;
    while(cin >> path, path != "#") {
        bool ok = true;
        int now = 0;
        for(int i=0; i<path.size(); ++i) {
            int next = g[now][path[i] - '0'];
            if(next == -1) {
                ok = false;
                break;
            } else {
                now = next;
            }
        }
        if(ok && now == 5) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3164
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int a[SIZE];
int N;
VI e[SIZE];
int an[SIZE];
int d[SIZE],dn;
void dfs(int x,int lt){
    int ll=0,rr=dn;
    while(ll<rr){
        int mm=(ll+rr)/2;
        if(d[mm]<a[x])ll=mm+1;
        else rr=mm;
    }
    int tmp=d[ll];
    int last_dn=dn;
    d[ll]=a[x];
    if(dn==ll)dn++;
    an[x]=dn;
    for(int y:e[x]){
        if(y==lt)continue;
        dfs(y,x);
    }
    d[ll]=tmp;
    dn=last_dn;
}
int main(){
    R(N);
    FOR(i,1,N)R(a[i]);
    REPP(i,1,N){
        int x,y;
        R(x,y);
        e[x].PB(y);
        e[y].PB(x);
    }
    dfs(1,1);
    FOR(i,1,N)W(an[i]);
    return 0;
}


Measured memory_bytes: 49316
#include<bits/stdc++.h>
using namespace std;
const long long mod=pow(10,9)+7;
int n;
long long a[200010],pre[200010];
int main(){
	 cin>>n;
	 for(int i=1;i<=n;i++){
	 	cin>>a[i];
	 	pre[i]=pre[i-1]+a[i];
	 	pre[i]%=mod;
	 }
	 long long ans=0;
	 for(int i=n;i>=1;i--){
	 	ans+=a[i]*pre[i-1];
	 	ans%=mod;
	 }
	 cout<<ans<<endl;
} 

Measured memory_bytes: 6736
while 1:
  m, n_min, n_max =map(int, input().split())
  if m==0:
    break
  P =[]
  for p in range(m):
    p =int(input())
    P.append(p)
#    d=[int(input()) for i in range(a)]
#  P.sort()
#  print(P)
  
  gap= 0
  x = 0
  for num in range(n_min, n_max+1):
#    print(num-1)
    a = P[num-1]-P[num]
    if a>=gap:
      gap = a
      x = num
      
#  print(gap)
  print(x)



Measured memory_bytes: 5620
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 1000000000000
#define MAX 100001
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/


int main(){
    int N;
    ll A[310000],pre[310000],post[310000];
    cin>>N;
    priority_queue<ll> que,que2;
    for(int i=1;i<=3*N;i++) cin>>A[i];
    ll sum=0,sum2=0;
    for(int i=1;i<=N;i++){
        sum+=A[i];
        sum2+=A[3*N+1-i];
        que.push(-A[i]);
        que2.push(A[3*N+1-i]);
    }
    pre[N]=sum; post[2*N+1]=sum2;
    for(int i=N+1;i<=2*N;i++){
        sum+=A[i];
        sum2+=A[3*N+1-i];
        que.push(-A[i]);
        que2.push(A[3*N+1-i]);
        ll x=que.top(),y=que2.top();
        que.pop(); que2.pop();
        sum+=x; sum2-=y;
        pre[i]=sum; post[3*N+1-i]=sum2;
    }
    ll ans=-10000000000000000;
    for(int i=N;i<=2*N;i++){
        ll temp=pre[i]-post[i+1];
        ans=max(ans,temp);
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 9196
n = int(input())
tasks = [list(map(int, input().split())) for _ in range(n)]
tasks.sort(key=lambda x: x[1])

current_time = 0

for task in tasks:
    current_time += task[0]
    if current_time > task[1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 53600
/* ~ CoderMehraJ ~ */
#include <bits/stdc++.h>
using namespace std;

#define show(x) cout << #x << " = " << x << '\n';

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n;
    cin>>n;
    if(n%2) cout<<n*2<<endl;
    else cout<<n<<endl; 
	return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

void solve() {
    int N, w;
    cin >> N >> w;
    vector<ll> W(N), V(N);
    for (int i = 0; i < N; i++) {
        cin >> W[i] >> V[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(w + 1, 0));
    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) {
                dp[i + 1][j + W[i]] = max(dp[i + 1][j + W[i]], dp[i][j] + V[i]);
            }
        }
    }
    ll ans = 0;
    for (int j = 0; j <= w; j++) {
        ans = max(ans, dp[N][j]);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long ll;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{
	int s;
	cin>>s;
	int count=0;
	if(s==1|s==2|s==4)
		cout<<4<<endl;

	else{
	while(true){


		if(s%2==0)
			s=s/2;
		else
			s=s*3+1;
		count+=1;

		if(s==4)
			break;


	}

	cout<<count+4<<endl;}
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input.trim();
  input = input.split("\n").map(Number);
  var P = Math.max(input[0],input[1]);
  console.log(Math.ceil(input[2]/P))

}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split("");
    }
  return arr;
}

Measured memory_bytes: 22964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define rlp(i,a,b) for(int i=a;i>=b;i--)
#define ft first
#define sd second
#define pii pair<int,int>
#define all(vect) vect.begin(),vect.end()
#define rall(vect) vect.rbegin(),rend() 
const int num = 200001;
typedef long long ll;
ll dp[num],h[num];
int main()
{
	int n,k;
	cin >> n >> k;
	rep(i,1,n+1)
		cin >> h[i],dp[i]=INT_MAX;
	dp[1]=0;
	rep(i,2,n+1)
	{
		rlp(j,i-1,max(i-k,1))
			dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
	}
	cout << dp[n];




	return 0;
}

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

namespace AABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int gu = 0;
            int ki = 0;

            if(k%2==0)//偶数なら
            {
                gu = k / 2;
                ki = gu;
            }
            else//奇数
            {
                gu = (k - 1) / 2;
                ki = k - gu;
            }

            Console.WriteLine(gu*ki);

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    vector<int> data(N);
    for(int i = 0; i < N; i++){
        cin >> data[i];
    }

    string ans = "Yes";

    for(int i = N-1; 0 < i; i--){
        int shita = data[i-1];
        int ue = data[i];
        if(ue < shita){
            shita-=1;
            data[i-1] = shita;
        }
        if(ue < shita){
            ans = "No";
            break;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean [] number = new boolean[1000001];
		number[0] = false;
		number[1] = false;
		for(int i=2;i<=1000000;i++) {
			number[i] = true;
		}
		for(int i=2;i<=500000;i++) {
			for(int j=2;j<=1000000/i;j++) {
				number[i*j] = false;
			}
		}
		while(true) {
			int n = sc.nextInt();
			int p = sc.nextInt();
			if(n==-1 && p==-1) break;
//			long [] ans = new long[120];
//			for(int i=0;i<100;i++) {
//				ans[i] = 2000000;
//			}
			
			int [] prime = new int[1000001];
			for(int i=0,j=2;j<=1000000;j++) {
	    		if(number[j]) {
	    			prime[i] = j;
	    			i++;
	    		}
	    	}

			
			/*for(int i=0;i<a;i++) {
				System.err.printf(prime[i]+" ");
			}*/
				
		   
			List<Integer> ans=new ArrayList<Integer>();
			int a = 0;
			while(prime[a]<=n) a++;
			
			for(int i=a;i<a+p;i++) {
				for(int j=i;j<a+p;j++) {
					ans.add( prime[i] + prime[j]);
				}
			}
//			 for(int i=0;i<120;i++) {
//			    	System.err.print(ans[i]+" ");
//			    }
//			    System.err.println();
			Collections.sort(ans);
			//System.err.println(ans);
			
			System.out.println(ans.get(p-1));
		}
	}
}



Measured memory_bytes: 437536
function Main(input) {
  "use strict"
  const temp = input.split("\n")
  
	const n = parseInt(temp.shift());
  const hn = temp.shift().split(" ").map(e => parseInt(e));
  
  let flag = true;
  let maximum = 0;
  for(let i = 0; i < n; i++){
    if(hn[i] > maximum) maximum = hn[i]
    else if(maximum - hn[i] > 1){
      flag = false;
      break;
    }
  }
  const ans = (flag) ? "Yes" : "No";
  console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

#define ll long long
using namespace std;


int main(){
	ll n; cin >> n;
	vector<ll> c(n), v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	for (int i = 0; i < n; ++i) cin >> c[i];
	ll sum = 0;
	for (int i = 0; i < n; ++i) if (v[i] - c[i]>0) sum += (v[i] - c[i]);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[15];
    memset(a, 0, sizeof(a));
    int ji = 0;
    while(n)
    {
        a[ji++] = n%10;
        n /= 10;
    }
    bool ok = false;
    if(a[0] == a[1] && a[1] == a[2])ok = true;
    if(a[1] == a[2]&& a[3] == a[2])ok = true;
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
r,g,b,n = list(map(int,input().split()))

a = sorted([r,g,b])
count = 0
for i in range(0,n//a[2]+1):
    for j in range(0,(n-i*a[2])//a[1]+1):
        if (n-a[2]*i-a[1]*j)%a[0] == 0:
            count += 1
print(count)

Measured memory_bytes: 3060
import math
import collections
#X=int(input())
N,M=map(int,input().split())
S=[[]for i in range(N)]
# for i in range(Q):
H=list(map(int,input().split()))
#     S[i]=a
# ans=0
# print()
ans=0
for i in range(M):
    A, B = map(int, input().split())
    S[A-1].append(H[B-1])
    S[B - 1].append(H[A - 1])
#print(S)
for i in range(N):
    if len(S[i])==0:
        ans+=1
        continue
    elif H[i]>max(S[i]):
        ans += 1

print(ans)


Measured memory_bytes: 90324
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    ll A[3][3],B[3][3];
    vl P;
    rep(i,3){
        rep(j,3){
            cin>>A[i][j];
            B[i][j]=0;
        }
    }

    set<ll> S;
    cin>>n;
    rep(i,n){
        cin>>x;
        P.push_back(x);
    }

    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(P[i]==A[j][k])B[j][k]=1;
            }
        }
    }

    rep(i,3){
        a=0;
        rep(j,3){
            a+=B[i][j];
        }
        if(a==3)ans=1;
    }

    rep(j,3){
        a=0;
        rep(i,3){
            a+=B[i][j];
        }
        if(a==3)ans=1;
    }

    a=0;
    rep(i,3){
        a+=B[i][i];
        if(a==3)ans=1;
    }

    a=0;
    rep(i,3){
        a+=B[i][2-i];
        if(a==3)ans=1;
    }

    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
string a,b,c;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    cin>>a>>b>>c;
    rep(i,n){
        cnt=2;
        if(a[i]==b[i]&&b[i]==c[i])continue;
        if(a[i]==b[i])cnt--;
        if(b[i]==c[i])cnt--;
        if(a[i]==c[i])cnt--;
        ans+=cnt;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
        fast;
       string s;
       cin>>s;
       ll cnt=0;
       for(int i=0;i<s.length()/2;i++)
    		if(s[i]!=s[s.length()-1-i])
				cnt++;
		cout<<cnt;
        return 0;
}


Measured memory_bytes: 3628
N ,Q = map(int, input().split())
S = input()

cumul = [0]*len(S)
cnt = 0
for i in range(len(S)-1):
    cumul[i] = cnt
    if S[i]=='A':
        if S[i+1] == 'C':
            cnt+=1
cumul[-1]=cnt

ret = []
for i in range(Q):
    l, r = map(int, input().split())
    cnt = cumul[r-1] - cumul[l-1]
    ret.append(str(cnt))
print('\n'.join(ret))

Measured memory_bytes: 13708
s = input()
p=2019;n=len(s)
digit_rm = [0 for _ in range(n)]
for i in range(n):
	digit_rm[i] = (int(s[n-1-i]) * pow(10, i, p) ) % p

remain = [0 for _ in range(n)]
for i in range(n):
	if i == 0:
		remain[i] = digit_rm[i]
	else:
		remain[i] = (remain[i-1] + digit_rm[i]) % p
pcnt = [0 for _ in range(p)]
for i in remain:
	pcnt[i] += 1
ans = pcnt[0]
for num in pcnt:
	if num != 0:
		ans += num * (num - 1) // 2
print(ans)

Measured memory_bytes: 23816
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int n,k;  cin >> n >> k;
  rep(i,0,n){
    int x;  cin >> x;
  }
  cout << 1+max(0, (n-k+k-2)/(k-1)) << endl;
  return 0;
}


Measured memory_bytes: 256
/*input
2000 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll inv(ll z){
    if(z==1) return 1;
    return (MOD-MOD/z)*inv(MOD%z)%MOD;
}
ll c(ll n,ll k){
	if(k==0) return 1;
	if(k<0) return 0;
    ll z=1;
    for(ll i=n-k+1;i<=n;i++) z=(z*i)%MOD;
    ll b=1;
    for(ll i=1;i<=k;i++) b=(b*i)%MOD;
    return z*inv(b)%MOD;
}
int arr[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	REP(i,k){
		int z=i+1;
		cout<<((c(n-k-1,z)+2*c(n-k-1,z-1)+c(n-k-1,z-2))*(c(k-1,z-1)))%MOD<<'\n';
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 301
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define RER(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
ll n, a[MAX_N][MAX_N];

signed main(){
	cin >> n;
	ll ret = 0;
	bool ans = true;
	REP(i, n) REP(j, n){ cin >> a[i][j]; ret += a[i][j]; }
	ret /= 2;

	REP(i, n) FOR(j, i, n){
		bool once = true;
		REP(k, n){
			if(i == j || i == k || j == k) continue;
			ans &= (a[i][k] + a[k][j] >= a[i][j]);
			if(a[i][k] + a[k][j] == a[i][j] && once){
				ret -= a[i][j];
				once = false;
			}
		}
	}

	if(ans) cout << ret << endl;
	else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 896
s = list(input())
flag = True
if s[0] != "A":
    flag = False
c = False
if s[1].isupper() and s[1] != "A" and s[1] != "C":
    flag = False
for i in range(len(s) - 3):
    if s[i + 2] == "C":
        if c:
            flag = False
        c = True
    else:
        if s[i + 2].isupper() and s[i + 2] != "A" and s[i + 2] != "C":
            flag = False

if s[-1].isupper() and s[-1] != "A" and s[-1] != "C":
    flag = False


if flag and c:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>

const int N=105;
int A[N],B[N];

int n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",A+i);
	for(int i=1;i<=n;i++)
		scanf("%d",B+i);
	for(int i=1;i<=n;i++)A[i]+=A[i-1];
	for(int i=n;i;i--)B[i]+=B[i+1];
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=std::max(ans,A[i]+B[i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
list1=[abs(a[0])]*(n+1)
list2=[abs(a[n-1])]*(n+1)
for i in range(n-1):
  list1[i+1]=list1[i]+abs(a[i+1]-a[i])
  list2[i+1]=list2[i]+abs(a[n-i-1]-a[n-i-2])
list1[n]=abs(a[n-1])
list2[n]=abs(a[0])
print(list2[n-2]+abs(a[1]))
for i in range(1,n-1):
  print(list2[n-2-i]+list1[i-1]+abs(a[i+1]-a[i-1]))
print(list1[n-2]+abs(a[n-2]))
  

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);

    for(int i=0; i<n; i++) cin >> a.at(i);

    int ans = 0;
    for(int i=0; i<n; i++){
        if( i%2==0 && a.at(i) % 2 != 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
from heapq import heappush, heappop, heapify

X, Y, A, B, C = map(int, input().split())

PA = list(map(int, input().split()))
PB = list(map(int, input().split()))
PC = list(map(int, input().split()))

PA.sort(reverse=True)
PB.sort(reverse=True)

heap = []
heapify(heap)

for a in PA[:X]:
    heappush(heap, -a)

for a in PB[:Y]:
    heappush(heap, -a)

for a in PC:
    heappush(heap, -a)

cnt = 0
sum_ = 0
while cnt < X + Y:
    val = heappop(heap)
    sum_ += val * -1

    cnt += 1


print(sum_)


Measured memory_bytes: 29872
using System;
using System.Collections.Generic;
using System.Linq;

namespace B159
{
    class Program
    {
        static void Main(string[] args)
        {
            // C
            var L = int.Parse(Console.ReadLine());

            var w = (double)L / 3;
            var h = (double)L / 3;
            var t = (double)L / 3;

            Console.WriteLine(w * h * t);
        }
    }
}


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

using namespace std;

int main() {
    long long h, w;
    cin>>h>>w;
    
    if (h==1 || w==1){
        cout<<"1";
    }
    else if  (h%2==0){
        cout<<(h*w)/2;
    }
    else 
    {
        if (w%2!=0){
        cout<<(h*w)/2+1;}
        else {
            cout<<(h*w)/2;
        }
    }
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define endl "\n"
#define ll long long
#define pb emplace_back
#define fi first
#define se second
#define pll pair<ll, ll>
#define ull unsigned long long
#define ld long double

#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repa(i,a,b) for(ll i=(a);i<=(b);i++)
#define all(x) (x).begin(), (x).end()
#define ordered_set tree<int , null_type, less<int> , rb_tree_tag, tree_order_statistics_node_update>
/*
 Ordered set docs:
 order_of_key (k) : Number of items strictly smaller than k .
 find_by_order(k) : K-th element in a set (counting from zero).
*/
#define blc boost::lexical_cast<long long>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
const int MOD = 1e9+7;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}

ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}

ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}

ll powerLL(ll x, ll n, ll mod) 
{ 
    ll result = 1; 
    while (n) { if (n & 1) result = (result%mod * x%mod) % mod; n = n / 2; x = (x%mod * x%mod) % mod; } return result; 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)
    	cin>>a[i];
	ll p=1000, res = 1000, prev = 0, sto = 0, val = 0;
	rep(i,n)
	{
		if(i>0)
		{
			if(a[i]>a[i-1])
			{
				ll t = p;
				sto=(p/a[i-1]);
				p = p-sto*a[i-1];
				val=(a[i]-a[i-1])*sto;
				p = t+val;
				//cout<<p<<" ";
			}
		}
	}
	//cout<<endl;
	if(p>res)
		cout<<p<<endl;
	else
		cout<<res<<endl;
}
int32_t main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0; 
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w,n;cin >> h >> w >> n;
	map<pii,int> m;
	rep(i,n){
		int a,b;cin >> a >> b;
		for(int j = -2; j <= 0; j++){
			for(int k = -2; k <= 0; k++){
				if(a + j >= 1 && a + j <= h - 2 && b + k >= 1 && b + k <= w - 2){
					m[mp(a + j, b + k)]++;
				}
			}
		}
	}
	vector<int> ans(10);
	ll sum = 0;
	for(auto i : m){
		ans[i.second]++;
		sum++;
	}
	cout << (ll)(h - 2) * (w - 2) - sum << endl;
	rep(i,9){
		cout << ans.at(i + 1) << endl;
	}
}


Measured memory_bytes: 56576
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int H1 = Integer.parseInt(tokens[0]);
		int M1 = Integer.parseInt(tokens[1]);
		int H2 = Integer.parseInt(tokens[2]);
		int M2 = Integer.parseInt(tokens[3]);
		int K = Integer.parseInt(tokens[4]);

		int time = 0;
		time += 60 * (H2 - H1);
		if (M2 >= M1) {
			time += M2 - M1;
		} else {
			time -= 60;
			time += (60 - (M1 - M2));
		}
		System.out.println((time - K));
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 32492
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

    string t;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != 'x') {
            t += s[i];
        }
    }
    for (int i = 0; i < t.length(); i++) {
        if (t[i] != t[t.length() - i - 1]) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> x;
    int tmp = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'x') {
            tmp++;
        } else {
            x.push_back(tmp);
            tmp = 0;
        }
    }
    x.push_back(tmp);

    int output = 0;
    for (int i = 0; i < x.size(); i++) {
        if (x[i] != x[x.size() - i - 1]) {
            output += abs(x[i] - x[x.size() - i - 1]);
        }
    }

    cout << output / 2 << endl;

    return 0;
}


Measured memory_bytes: 4116
N = int(raw_input())
A,B = map(int,raw_input().split())
cnt = [0,0,0]
arr = map(int,raw_input().split())
for i in arr:
    if i<=A:
        cnt[0] += 1
    elif i>B:
        cnt[1] += 1
    else:
        cnt[2] += 1
print min(cnt)

Measured memory_bytes: 2568
#!/mnt/c/Users/moiki/bash/env/bin/python
N,K = map(int, input().split())
a = list(map(int, input().split()))

from collections import Counter
from functools import reduce
d = Counter(a)

# print(d.items())
# print(d.most_common()[::-1])
s =  reduce( lambda x,y:x+y, map(lambda x:x[1], d.most_common()[::-1][:len(d.most_common())-K]))\
  if len(d.most_common())-K >0 else 0
print(s)


Measured memory_bytes: 126408
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
#define bp __builtin_popcount
typedef long long ll;
const ll MAX_N = 1e5+100;
const ll MOD = 1e9+7;
using namespace std;

vector<int> g[MAX_N];
ll dp[MAX_N][2];
int n;

void dfs(int v,int p)
{
    for(auto x:g[v])
    {
        if (x!=p)
            dfs(x,v);
    }
    dp[v][0] = dp[v][1] = 1;
    for(auto x:g[v])
    {
        if (x!=p)
        {
            dp[v][0] *= (dp[x][1]+dp[x][0]) % MOD;
            dp[v][0] %= MOD;
            dp[v][1] *= dp[x][0];
            dp[v][1] %= MOD;
        }
    }
}

int main()
{
    cin >> n;
    for(int i = 2;i<=n;++i)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    cout << (dp[1][0]+dp[1][1])%MOD;
    return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

u64 digit(u64 n) {
  u64 ret = 0;
  while(n != 0) {
    n /= 10;
    ++ret;
  }
  return ret;
}

u64 g(u64 n, u64 d) {
  d = digit(n) - d - 1;
  rep(i, d) n /= 10;
  return n % 10;
} 

int main(int argc, const char* argv[]) {
  u64 s;
  cin >> s;
  
  u64 m = digit(s);
  u64 n = 1 << (digit(s) - 1);
  u64 ret = 0;
  rep(i, n) {
    debug(i);
    u64 t1 = 0;
    u64 t2 = 0;
    rep(j, m) {
      u64 msk = (1 << j) & i;
      if(msk != 0) {
        t2 = t2 * 10 + g(s, j);
      } else {
        t1 += t2 * 10 + g(s, j);
        t2 = 0;
      }
      debug(t1);debug(t2);
    }
    ret += t1;
    debug(ret);
  }
  cout << ret;
}


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

using namespace std;

int main() 
{
    int n, m, l;
    scanf("%d", &n);
    
    vector<int> v1;
    vector<int> v2;
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &m);
        v1.push_back(m);
    }
    
    scanf("%d", &m);
    
    for(int i = 0; i < m; i++)
    {
        scanf("%d", &l);
        v2.push_back(l);
    }
    
    printf("%d\n", (v1 < v2));
    
    return 0;
}


Measured memory_bytes: 3304
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, Q;
vector<long long> op;
long long all[100001];
long long ctr[100001];
long long G[100001];

void f(long long X, long long k) {
  if (X == 0) return;
  int pos = upper_bound(all(op), X) - op.begin();
  if (pos == 0) {
    // [0, X) += k
    G[X-1] += k;
    return;
  }
  pos--;
  long long q = op[pos];
  long long d = X/q;
  all[pos] += d*k;
  f(X%q, k);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Q;
  op.pb(N);
  rep(i, Q) {
    long long x;
    cin >> x;
    while (!op.empty() && x <= op.back()) op.pop_back();
    op.push_back(x);
  }
  //for (int q : op) cout<<q<<",";cout<<"\n";
  all[(int)op.size()-1] = 1;
  for (int i=(int)op.size()-1; i>0; i--) {
    long long q = op[i], next = op[i-1];
    long long d = q/next, r = q%next;
    all[i-1] += all[i] * d;
    f(r, all[i]);
  }

  long long add = 0;
  for (int i=N-1; i>=0; i--) {
    add += G[i];
    ctr[i] += add;
  }
  rep(i, op[0]) ctr[i] += all[0];
  rep(i, N) cout << ctr[i] << "\n";
  return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string s;
  cin >> s;
  string ans = "CODEFESTIVAL2016";
  int r = 0;
  rep(i,s.size()) {
    if (s[i] != ans[i]) {
      r++;
    } 
  }
  cout << r << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll n,k;
vec cnt(1e5+10,-1);
vec ans(1e5+10,-1);

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

ll dfs(ll t) {
  if(cnt[t]>0) return cnt[t];
  cnt[t]=mpow(k/t,n);
  ans[t]=0;
  for(ll i=2;i*t<=k;i++) {
    (cnt[t]+=mod-dfs(i*t))%=mod;
  }
  ans[t]=cnt[t]*t%mod;
  return cnt[t];
}

int main() {
  cin >> n >> k;
  ll sum=0;
  dfs(1);
  for(ll i=1;i<=k;i++) {
    (sum+=ans[i])%=mod;
  }
  cout << sum << endl;
}

Measured memory_bytes: 4696
N = int(input())
src = list(map(int,input().split()))
n = max(src)

d = n+1
r = min(src)
for a in src:
    if a == n: continue
    if abs(n - a*2) < d:
        d = abs(n - a*2)
        r = a
print(n, r)


Measured memory_bytes: 14428
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1000000007;
// const int MAXN = 3e5;
const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("mxnl.in", "r", stdin);
       // freopen("mxnl.out", "w", stdout);
#endif
}


void solve(){
    int n;
    cin >> n;
    map<string, int> kek;
    int mx = 0;
    for(int i=0; i<n; i++){
        string beta;
        cin >> beta;
        kek[beta]++;
        mx = max(kek[beta], mx);
    }
    for(pair<string, int> i:kek){
        if(i.second == mx){
            cout << i.first << endl;
        }
    }

}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 23808