akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


n = inp()
L = inpl()

ans = 0
L.sort()
for i in range(len(L)):
    for l in range(i+1,len(L)):
        ans += bisect.bisect_left(L, L[i]+L[l])-l-1

print(ans)

Measured memory_bytes: 4204
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll dp[N+1][K+1];
    rep(i,N+1){
        rep(j,K+1){
            dp[i][j]=(i+j==0?1:0);
        }
    }
    ll now[K+2];
    rep(i,N){
        now[0]=0;
        rep(j,K+1){
            now[j+1]=(now[j]+dp[i][j])%MOD;
        }
        /*rep(j,K+1){
            cout << now[j] << ' ';
        }*/
        rep(j,K+1){
            dp[i+1][j]=(now[j+1]-now[max((ll)0,j-A[i])]+MOD)%MOD;
        }
        /*rep(j,K+1){
            cout << i+1 << ' ' << j << ' ' << dp[i+1][j] << '\n';
        }*/
    }
    cout << dp[N][K] << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 83248
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

const int MAX = 2 * 1e5;

int main() {
    int A,B,M;
    cin >> A >> B >> M;
    veci a(A);
    veci b(B);
    REP(i,A) cin >> a.at(i);
    REP(i,B) cin >> b.at(i);
    int min_val = MAX;
    decltype(a)::iterator i = std::min_element(a.begin(), a.end());
    decltype(b)::iterator j = std::min_element(b.begin(), b.end());
    min_val = *i + *j;
    REP(i,M) {
        int x,y,c; cin >> x >> y >> c;
        chmin(min_val,a[x-1]+b[y-1]-c);
    }
    cout << min_val << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int a , b , c , i = 0;
    cin >> a >> b >> c;
    while (b != 0 && c != 0 && b >= a){
        b -= a;
        c--;
        i++;
    }
    cout << i;
    return 0;
}


Measured memory_bytes: 3592
#[allow(unused_macros)]
macro_rules! input {
  ($($r:tt)*) => {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
      bytes
        .by_ref()
        .map(|r|r.unwrap() as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect()
    };
    input_inner!{next, $($r)*}
  };
}

#[allow(unused_macros)]
macro_rules! input_inner {
  ($next:expr) => {};
  ($next:expr, ) => {};

  ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
    #[allow(unused_mut)]
    let mut $var = read_value!($next, $t);
    input_inner!{$next $($r)*}
  };
}

#[allow(unused_macros)]
macro_rules! read_value {
  ($next:expr, ( $($t:tt),* )) => {
    ( $(read_value!($next, $t)),* )
  };

  ($next:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
  };

  ($next:expr, chars) => {
    read_value!($next, String).chars().collect::<Vec<char>>()
  };

  ($next:expr, usize1) => {
    read_value!($next, usize) - 120 30
  };

  ($next:expr, [ $t:tt ]) => {{
    let len = read_value!($next, usize);
    (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
  }};

  ($next:expr, $t:ty) => {
    $next().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let stack_size = 104_857_600;
  let thd = std::thread::Builder::new().stack_size(stack_size);
  thd.spawn(|| work()).unwrap().join().unwrap();
}

fn work() {
  input! {
    a: i32,
    b: i32,
  };
  println!("{}", std::cmp::max(0, a - 2 * b));
}


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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i=a;i>b;i--)
#define int long long

//constant--------------------------------------------------------------------------------------
const int inf = 100100100100000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr){vector<int> ret = arr;rep(i,1,arr.size()){ret[i] += ret[i-1];}return ret;}
int ceil(int a, int b){if(a%b == 0) return a/b;else return a/b + 1;}
int digitlen(int i){int t = i;int count = 0;while(t){count += 1;t /= 10;}return count;}
int gcd(int m, int n){if((0== m)||(0 == n))return 0;while(m != n){if(m > n)m = m - n;else n = n - m;}return m;}
int lcm(int n, int m){return n*m/gcd(n,m);}

//io_method-------------------------------------------------------------------------------------
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
void print(int n){cout << n << endl;}
void print(vector<int> arr){cout << arr[0];rep(i,1,arr.size()) cout << " " << arr[i];cout << endl;}
void print(string s){cout << s << endl;}
void print(pair<int, int> p){cout << p.first << " " << p.second;}
void print(vector<vector<int>> arr){rep(i,0,arr.size()){print(arr[i]);}}
void print(double n){cout << n << endl;}

//main------------------------------------------------------------------------------------------


signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    while(true){
    int e = input();
    if(e == 0) break;
    int ans = inf;
    rep(i,0, 1000){
        rep(j,0, 1000){
            int x = e-i*i - j*j*j;
            if(x < 0) continue;
            ans = min(ans, x + i + j);
        }
    }
    print(ans);
    }
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
typedef long long ll;
typedef unsigned long long ull;
const int INF=0x3f3f3f3f,max_n=100005;
inline ll lowbit(ll x){return x&(-x);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
double r,pi=acos(-1);
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	cin>>r;
	cout<<pi*r*2;
	return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;


bool is_prime[10000001];

int main(){
    fill(is_prime,is_prime+10000001,true);
    is_prime[0] = false; is_prime[1] = false;
    for(int i=2;i<10000001;i++){
        if(is_prime[i]){
            for(int j=2*i;j<10000001;j+=i){
                is_prime[j] = false;
            }
        }
    }

    while(1){
        int n;
        scanf("%d",&n);
        if(!n)break;

        while(1){
            if(is_prime[n]&&is_prime[n-2]&&is_prime[n-6]&&is_prime[n-8]){
                cout << n << endl;
                break;
            }
            n--;
        }
    }

    return 0;
}

Measured memory_bytes: 10976
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cerr << #x << ' ' << x << endl;
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    int ans = 1;
    for(ll i = 2; i*i <= g; ++i) {
        if(g%i != 0)    continue;
        ans++;
        while(g%i == 0) g /= i;
    }
    if(g != 1)  ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

int main() {
    string S;cin >> S;
    int ans = 0;
    bool kurisage = false;
    for(int i = S.size()-1;i>=0;i--){
        if(i == 0 && kurisage){
            ans += S.at(0)-'0';
            ans--;
            break;
        }
        if(i == 0 && !kurisage){
            ans += S.at(0)-'0';
            break;
        }
        if(S.at(i) != '9'){
            kurisage = true;
        }
        if(i != 0){
            ans += 9;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int n,m;
    cin>>n>>m;
    int arr[n+10];
    memset(arr, 0, sizeof(arr));
    for(int i=0;i<m;i++)
    {
        int l, r;
        cin>>l>>r;
        arr[l]+=1;
        arr[r+1]-=1;
    }
    int count=0;
    int runn=0;
    for(int i=0;i<n+10;i++)
    {
        runn+=arr[i];
        if(runn==m)
            count++;
    }
    cout<<count;

}


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

void printVector(std::vector<int> &vec)
{
    int size = vec.size();
    for (int i = 0; i < size; ++i) {
        std::cout << (i ? " " : "") << vec[i];
    }
    std::cout << std::endl;
}

int main()
{
    int nums;
    std::cin >> nums;
    std::vector<int> v(nums);
    for (int i = 0; i < nums; ++i) {
        std::cin >> v[i];
    }
    printVector(v);
    
    for (int i = 1; i < nums; ++i) {
        int tmpVal = v[i];
        int idx = i - 1;
        while ((idx >= 0) && (v[idx] > tmpVal)) {
            v[idx + 1] = v[idx];
            --idx;
        }
        v[idx + 1] = tmpVal;
        printVector(v);
    }
    return 0;
}

Measured memory_bytes: 1200
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

inline void solve(){
    ld a,b,c; cin>>a>>b>>c; 
    ld eps=.00000000000001;
    if (sqrt(a)+sqrt(b)+eps<sqrt(c)) cout << "Yes" << endl; 
    else cout << "No" << endl;
}

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


Measured memory_bytes: 3736
h, w = [int(i) for i in input().split()]
date = [[int(q) for q in input().split()] for e in range(h)]
date2=[]
date3=[]
for r in range(0, h):
    for t in range(0, w):
        print(date[r][t], end=' ')
    print(sum(date[r]))

for k in range(0,w):
   for j in range(0,h):
      date2.append(date[j][k])

for n in range(0,w*h,h):
   print(sum(date2[n:(n+h)]),end=' ')

for m in range(h):
   date3.append(sum(date[m]))
print(sum(date3))

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  string s; cin >> s;
  for(int i = 0; i < s.length()-1; i++) {
    if(s[i] == 'A' && s[i+1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

temp = ""
is_restorable = False
for i in range(len(S) - len(T) + 1):
    cand = S[i:i + len(T)]
    for ci, ti in zip(cand, T):
        if ci not in ["?", ti]:
            break
    else:
        temp = S[:i] + T + S[i + len(T):]
        is_restorable = True

if is_restorable:
    print(temp.replace("?", "a"))
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3060
N, M, Q = map(int, input().split())
dp = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    dp[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        dp[i][j + 1] += dp[i][j]
for j in range(N + 1):
    for i in range(N):
        dp[i + 1][j] += dp[i][j]
for k in range(Q):
    p, q = map(int, input().split())
    print(dp[q][q] - dp[p - 1][q])


Measured memory_bytes: 57816
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
int main(void){
  int i,len,flg;
  char s[84];
 
  while(fgets(s,84,stdin) != NULL){
    len = strlen(s) - 1;
    flg = 1;
 
    while(flg){
      for(i=0;i<len;i++)
    if(islower(s[i]))
      s[i] = (s[i] - 'a' + 1) % 26 + 'a';
 
      for(i=0;i<len;i++){
    if(!strncmp(&s[i],"the",3) || !strncmp(&s[i],"this",4) || !strncmp(&s[i],"that",4)){
      flg = 0;
      break;
    }
      }
    }
    printf("%s",s);
  }
 
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
using namespace std;
struct stu{int x,y;}a[1005];
int main()
{
    int n;
    long long t,t1,t2,cnt=0,a1=0,b1=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i].x>>a[i].y;
    for(int i=1;i<=n;i++)
    {
        if(a[i].x>=a1&&a[i].y>=b1)
        {
                cnt=a[i].x+a[i].y;
                a1=a[i].x;
                b1=a[i].y;
        }
        else
        {
            t=a1/a[i].x;
            if(t<b1/a[i].y)
                t=b1/a[i].y;
            t1=a[i].x*t;
            t2=a[i].y*t;
            while(t1<a1||t2<b1)
            {
                t1+=a[i].x;
                t2+=a[i].y;
            }
            cnt=t1+t2;
            a1=t1;
            b1=t2;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
M = 10 ** 10

if H == 2 and W == 2:
    M = 1

if H > 2:
    HH = H // 3
    S1 = HH * W
    HH = H - H // 3
    HHH = HH // 2
    S2 = HHH * W
    HHH = HH - HH // 2
    S3 = HHH * W
    m = max(S1, S2, S3) - min(S1, S2, S3)
    M = min(M, m)

    HH = H // 3
    S1 = HH * W
    WW = W // 2
    S2 = (H - HH) * WW
    WW = W - W // 2
    S3 = (H - HH) * WW
    m = max(S1, S2, S3) - min(S1, S2, S3)
    M = min(M, m)

    HH = H // 3 + 1
    S1 = HH * W
    WW = W // 2
    S2 = (H - HH) * WW
    WW = W - W // 2
    S3 = (H - HH) * WW
    m = max(S1, S2, S3) - min(S1, S2, S3)
    M = min(M, m)

if W > 2:
    WW = W // 3
    S1 = WW * H
    WW = W - W // 3
    WWW = WW // 2
    S2 = WWW * H
    WWW = WW - WW // 2
    S3 = WWW * H
    m = max(S1, S2, S3) - min(S1, S2, S3)
    M = min(M, m)

    WW = W // 3
    S1 = WW * H
    HH = H // 2
    S2 = (W - WW) * HH
    HH = H - H // 2
    S3 = (W - WW) * HH
    m = max(S1, S2, S3) - min(S1, S2, S3)
    M = min(M, m)

    WW = W // 3 + 1
    S1 = WW * H
    HH = H // 2
    S2 = (W - WW) * HH
    HH = H - H // 2
    S3 = (W - WW) * HH
    m = max(S1, S2, S3) - min(S1, S2, S3)
    M = min(M, m)

print(M)

Measured memory_bytes: 9340
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def myfunc(K):
    if K == 1:
        return 1
    elif K == 2:
        return 9

    temp = K
    for a in range(2,K):
        temp += sum([gcd(K,a,b) for b in range(1,a)])*6
    temp += sum([gcd(K,a,a) for a in range(1,K)])*6

    return myfunc(K-1) + temp           

K = int(input())

print(myfunc(K))


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

#define N_MAX 5

typedef struct {
    int num;
	int room;
} ver;

int cmp( const void *p, const void *q ) {
    return ((ver*)p)->room - ((ver*)q)->room;
}


int main(void){
	int a;
	char s[200010];
	char t[200010];

	int ret = 0;
	int i,n;

	scanf("%s",s);
	scanf("%s",t);

	n = strlen(s);

	for(i=0;i<n;i++){
		if(s[i] != t[i]){
			ret++;
		}
	}

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


	
	return 0;
}

Measured memory_bytes: 2100
def resolve():
    '''
    code here
    '''
    import collections
    n = int(input())
    vs = [int(item) for item in input().split()]
    num_max = max(vs)

    cnt_od = collections.Counter(vs[::2])
    cnt_ev = collections.Counter(vs[1::2])

    cnt_od = cnt_od.most_common()
    cnt_ev = cnt_ev.most_common()

    if cnt_od[0][0] == cnt_ev[0][0]:
        if (len(cnt_od)>1) and (len(cnt_ev)>1):
            ans = min(n - cnt_od[1][1] - cnt_ev[0][1], n - cnt_od[0][1] - cnt_ev[1][1])
        elif len(cnt_od) > 1:
            ans = n//2 - cnt_od[1][1]
        elif len(cnt_ev) > 1:
            ans = n//2 - cnt_ev[1][1]
        else:
            ans = n//2
    else:
        ans = n - cnt_ev[0][1] - cnt_od[0][1]

    print(ans)
if __name__ == "__main__":
    resolve()


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


int main() {
string  s;
while(cin>>s){
int l=s.size();
int ans1=0,ans2=0;
for(int i=0;i<l-2;i++){
	if(s.substr(i,3)=="JOI") ans1=ans1+1;
		if(s.substr(i,3)=="IOI") ans2=ans2+1;

	
	
}

cout<<ans1<<endl<<ans2<<endl;

}
	return 0;
}

Measured memory_bytes: 1216
# coding: utf-8
#  100: 100-105
#  200: 200-210
#  300: 300-315

# 1000:1000-1050
# 2000:2000-2100

x = int(input())

if x >= 2000:
    ans = 1
else:
    n = x // 100
    if x <= n * 105:
        ans = 1
    else:
        ans = 0

print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
template<class T> void chmax(T &a,T b){if(a<b) a = b ; }
template<class T> void chmin(T &a,T b){if(a>b) a = b ; }

void solve(){
	cin.tie(nullptr) ;
	ios::sync_with_stdio(false) ;
	
	ll n,k,c ;
	cin >> n >> k >> c ;
	string s ; cin >> s ;
	vll a(k) ;
	ll pos = 0 ;
	for(int i=0;i<n;i++){
		if(pos==k) break ;
		if(s.at(i)=='o'){
			a.at(pos) = i ;
			pos++ ;
			i += c ;
		}
	}
	vll b(k) ;
	pos = k-1 ;
	for(int i=n-1;i>=0;i--){
		if(pos==-1) break ;
		if(s.at(i)=='o'){
			b.at(pos) = i ;
			pos-- ;
			i -= c ;
		}
	}
	for(int i=0;i<k;i++){
		if(a.at(i)==b.at(i)) cout << a.at(i)+1 << endl ;
	}
}

int main(){
	solve() ;
}

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

ulong diff(ulong a, ulong b){
    return __builtin_ctzl(a^b);
}

ulong hd(ulong a, ulong b){
    return __builtin_popcountl(a^b);
}

ulong bit_remove(ulong a, ulong n){
    ulong low  = a & ((1<<n)-1);
    ulong high = (a >> (n+1)) << n;
    return high | low;
}

ulong bit_insert(ulong a, ulong n, ulong b){
    ulong low  = a & ((1<<n)-1);
    ulong high = (a >> n) << (n+1);
    return high | (b<<n) | low;
}

vector<long> solve(const ulong n, const ulong a, const ulong b){
    vector<long> v;
    if(n==1){
        v.push_back(a);
        v.push_back(b);
        return v;
    }
    ulong d = diff(a, b);
    ulong aa = bit_remove(a, d);
    ulong ab = bit_remove(a, d) ^ 1;
    ulong bb = bit_remove(b, d);
    auto v0 = solve(n-1, aa, ab);
    auto v1 = solve(n-1, ab, bb);
    for(auto& e : v0){
        e = bit_insert(e, d, (a&(1<<d)) >> d);
    }
    for(auto& e : v1){
        e = bit_insert(e, d, (b&(1<<d)) >> d);
    }
    v0.insert(v0.end(), v1.begin(), v1.end());
    return v0;
}

int main(void){
    ulong n, a, b;
    cin >> n >> a >> b;
    if(__builtin_popcountl(a)%2 == __builtin_popcountl(b)%2){
        std::cout << "NO" << std::endl;
        return 0;
    }
    auto v = solve(n, a, b);
    size_t m = v.size();
    std::cout << "YES" << std::endl;
    for(size_t i=0; i<m-1; i++){
        std::cout << v[i] << " ";
    }
    std::cout << v[m-1] << std::endl;
    return 0;
}


Measured memory_bytes: 2416
#include<stdio.h>
#include<stdlib.h>

int F[44];
int fibonacci(int);

int main(){
  int n;

  scanf("%d", &n);
  if(n < 0 || 44 < n)
    exit(0);

  fibonacci(n);

  printf("%d\n", F[n]);

  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1)
    return F[n] = 1;
  if(F[n] != NULL)
    return F[n];
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

Measured memory_bytes: 596
L, R = map(int, input().split())

m1 = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        a = (i*j) % 2019
        if a == 0:
            print(0)
            exit()
        if a < m1:
            m1 = a
print(m1)

Measured memory_bytes: 3060
n = int(input())
s = [input() for _ in range(n)]
d = {}
for i in s:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1
vmax = max(d.values())
ans = [kv[0] for kv in d.items() if kv[1] == vmax]
ans.sort()
print('\n'.join(ans))

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

using namespace std;

#define prev prevv

int graph[101][101];
int dist[101][101];
int vis[101][101];
int V;

void floydWarshall ()
{
    int i, j, k;
 
    for (i = 0; i < V; i++)
        for (j = 0; j < V; j++) {
            dist[i][j] = graph[i][j];
        }
 
    for (k = 0; k < V; k++)
    {
        // Pick all vertices as source one by one
        for (i = 0; i < V; i++)
        {
            for (j = 0; j < V; j++)
            {
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }
}

int main(void) {

	
	int n, m;
	cin>>n>>m;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < n; ++j)
			graph[i][j] = 1000000001;
	memset(vis, 0, sizeof(vis));


	for(int i = 0; i < m; ++i) {
		int a, b, c;
		cin>>a>>b>>c;
		
		--a, --b;
		graph[a][b] = c;
		graph[b][a] = c;
	}
	V = n;
	floydWarshall();
	

	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			if(graph[i][j] == dist[i][j] && graph[i][j] != 1000000001)	{
				vis[j][i] = 1, vis[i][j] = 1;
			}
		//cout<<endl;
		}
	}

	int ans = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i+1; j < n; ++j) {
			if(graph[i][j] == 1000000001)	continue;
			if(!vis[i][j])	ans++;
			
		}
	}

	cout<<ans;

	return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
int main(void) {
	int a[52] = {0};
	char b[4] = {'S','H','C','D'};
	int d, n;
	char c;
	int e, f;

	scanf("%d", &n);
	for (f = 0; f < n; f++)
	{
		scanf(" %c %d", &c, &d);
		for (e = 0; b[e] != c; e++)
		{
			d += 13;
		}
		a[d - 1] = 1;
	}

	for (f = 0; f < 4; f++)
	{
		for (e = 0; e < 13; e++) 
		{
			if (a[f * 13 + e] == 0) 
			{
				printf("%c %d\n", b[f], e + 1);
			}
		}
	}

	return 0;
}

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

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);

int main(void) {
	int   i,len,j=1;
	char  S[100001];
	
	s_cin(S);
	len = strlen(S);

	
	for (i = 2; i < len; i += 2) {
		S[j] = S[i];
		j++;
	}
	S[j] = 0x00;
	s_cout(S);
   
	return 0;
}

//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
//
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h> 
int main(void) {
  int l;
  for(l = 1; ; ++l ) {
  int i, j, k, n, w;
  scanf("%d", &w);
  if(!w) break;
  scanf("%d", &n);
  int dp[w + 1], v[n], we[n];
  for(i = 0; i <= w; ++i) dp[i] = 0;
  for(i = 0; i < n; ++i) scanf("%d,%d", &v[i], &we[i]);
  for(i = 0; i < n; ++i) for(j = w; j >= 0; --j) if(j + we[i] <= w && dp[j + we[i]] < dp[j] + v[i]) dp[j + we[i]] = dp[j] + v[i];
  int ans = 0, ansn;
  for(i = 0; i <= w; ++i) if(ans < dp[i]) ans = dp[i], ansn = i;
  printf("Case %d:\n%d\n%d\n", l, ans, ansn);
  }
  return 0; 
} 


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

using s64 = long long;
using r32 = double;

const int MaxN = 6;
const int MaxM = 50;

int n, m;
int a[MaxN];

int per[MaxN - 1];

s64 f[MaxN * MaxM + 1][1 << MaxN - 1];

inline s64 solve()
{
	int all = 1 << n - 1;
	for (int i = 0; i <= n * m; ++i)
		fill(f[i], f[i] + all, 0);

	f[n * a[n - 1]][0] = 1;
	for (int i = 0; i < n * m; ++i)
		for (int j = i; j <= n * m; ++j)
			for (int s = 0; s < all; ++s)
			{
				if (i % n == 0)
					continue;

				int k = per[i % n - 1];
				int p = min(max(j, i + n * a[k]), n * m);
				if (~s >> k & 1)
					f[p][s | 1 << k] += f[j][s];
			}

	return f[n * m][all - 1];
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	sort(a, a + n);

	for (int i = 0; i < n - 1; ++i)
		per[i] = i;

	s64 res = solve();
	while (next_permutation(per, per + n - 1))
		res += solve();

	s64 all = 1;
	for (int i = 1; i < n; ++i)
		all *= i * m;

	printf("%.16f\n", (r32)res / all);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, t;
    cin >> n >> t;

    vector<pair<ll, ll>> p(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(all(p));

    vvl dp(n+1, vl(t));  // dp[i+1][j] : i番目までの料理で食べる時間がj以下のときの満足度の最大値
    rep(i, n) {
        rep(j, t) {
            if(j >= p[i].first) {
                dp[i+1][j] = max(dp[i][j], dp[i][j - p[i].first] + p[i].second);
            }
            else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    ll ans = 0;
    rep(k, n) {  // k番目の料理を最後に食べる
        chmax(ans, dp[k][t-1] + p[k].second);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;
vector<pair<pair<int, int>,int> >edge;
vector<int>d;
int32_t main(){
	ios::sync_with_stdio(false);
    int n, m;
    cin>>n;cin>>m;
    d.resize(n+1);
    REP(i,0,n+1){
        d[i]=1e18;
    }
    REP(i,0,m){
        int a, b, c;
        cin>>a>>b>>c;
        edge.PB({{a,b},-1*c});
    }
    d[1]=0;
    for(int i=1;i<n;i++){
        for(int j=0;j<m;j++){
            if(d[edge[j].F.F]<1e18){
                d[edge[j].F.S]=min(d[edge[j].F.S],d[edge[j].F.F]+edge[j].S);
            }
        }
    }
    int now=d[n];
    for(int j=0;j<m;j++){
        if(d[edge[j].F.F]<1e18){
            d[edge[j].F.S]=min(d[edge[j].F.S],d[edge[j].F.F]+edge[j].S);
        }
    }
    int after=d[n];
    if(after!=now){
        cout<<"inf"<<"\n";
    }
    else{
        cout<<(-d[n])<<"\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N;
  cin >> S;
  int ret = 0;
  for (int i=0; i<N-2; i++) {
    if (S[i] == 'A') {
      if (S[i+1] == 'B') {
        if (S[i+2] == 'C') {
          ret++;
        }
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int i,a[100001];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	int max11=0,max11i=0,b[100001]={0},max12=0,max12i=0;
	for(i=0;i<n;i=i+2){
		b[a[i]]++;
		if(b[a[i]]>max11i){
			max11i=b[a[i]];
			max11=a[i];
		}else{
			if(b[a[i]]>max12i){
				max12i=b[a[i]];
				max12=a[i];
			}
		}
	}
	int max21=0,max22=0,max21i=0,max22i=0,c[100001]={0};
	for(i=1;i<n;i=i+2){
		c[a[i]]++;
		if(c[a[i]]>max21i){
			max21i=c[a[i]];
			max21=a[i];
		}else{
			if(c[a[i]]>max22i){
				max22i=c[a[i]];
				max22=a[i];
			}
		}
	}
	if(max11==max21){
		if(max12i>max22i){
			max11=max12;
		}else{
			max21=max22;
		}
	}
	int sum=0;
	for(i=0;i<n;i++){
		if(i%2==0){
			if(a[i]!=max11){
				sum++;
			} 
		}else{
			if(a[i]!=max21){
				sum++;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
} 


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(void){
    char s[4];
    cin >> s;
    
    int k[26] = {};
    for (int i = 0; i < 4; i++) {
        k[s[i] - 'A']++;
    }
    
    int ok = 0;
    for (int i = 0; i < 26; i++) {
        if (k[i] == 2) ok++;
    }
    
    if (ok == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] like = new int[m];
		for(int i = 0; i < n; i++){
		    int k = sc.nextInt();
		    for(int j = 0; j < k; j++){
		        int a = sc.nextInt() - 1;
		        like[a]++;
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		}
		
		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 23468
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(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 _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int A, B;
    cin >> A >> B;
    if ( B / A > 0 && B % A == 0) {
        cout << (A + B) << endl;
    } else {
        cout << (B - A) << endl;
    }
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
A = list(map(int,input().split()))
ans = []
All = A[0]
for i in range(1,N):
    All = All ^ A[i]
for i in range(N):
    a = All ^ A[i]
    ans.append(a)
print(*ans)


Measured memory_bytes: 110856
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static System.Math;


class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(n < 105 ? 0 : n < 135 ? 1 : n < 165 ? 2 : n < 189 ? 3 : n < 195 ? 4 : 5);
    }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main {

	public static void main(String[] args) {
		
Scanner sc=new Scanner(System.in);
int l=sc.nextInt();
int r=sc.nextInt();
int d=sc.nextInt();
int a[]=new int [101];
for(int i=d;i<101;i+=d) {
	a[i]++;
}
int count=0;
for(int i=l;i<=r;i++) {
	if(a[i]>=1) {
		count++;
	}
}
System.out.println(count);
	}

}


Measured memory_bytes: 35600
import sys
INF=100000000
def frog(i,h,dp):
    global INF
    if dp[i]!=INF:
        return dp[i]
    else:
        if i==1:
            dp[i]=0
            return dp[i]
        elif i==2:
            dp[i]=abs(h[1]-h[0])
            return dp[i]
        else:
            dp[i]=min(frog(i-2,h,dp)+abs(h[i-1]-h[i-3]),frog(i-1,h,dp)+abs(h[i-1]-h[i-2]))
            return dp[i]
sys.setrecursionlimit(INF)
N=int(input())
h=list(map(int,input().split()))
dp=[INF for i in range(N+1)]
print(frog(N,h,dp))


Measured memory_bytes: 51236
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[11];

int main(){

	scanf("%s",buf);

	buf[0] = '2';
	buf[1] = '0';
	buf[2] = '1';
	buf[3] = '8';

	printf("%s\n",buf);

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  deque<char> q;
  for (int i = 0; i < s.length(); i++) {
    q.push_back(s[i]);
  }
  ll cnt = 0;
  if (s.length() == 1) {
    cout << 0 << endl;
    return 0;
  }
  while (!q.empty()) {
    if (q.front() == q.back()) {
      q.pop_front();
      q.pop_back();
    } else if (q.front() == 'x') {
      cnt++;
      q.pop_front();
    } else if (q.back() == 'x') {
      cnt++;
      q.pop_back();
    } else {
      cout << -1 << endl;
      return 0;
    }
    if (q.size() == 1 || q.size() == 0) break;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define popb pop_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
typedef vector<int> vi;
 
int main(){
    fast;
    ll t;cin>>t;
    int r=t%10;
    if(r==3) cout<<"bon"<<" ";
    else if(r==0 || r==1 || r==6 || r==8) cout<<"pon"<<" ";
    else cout<<"hon"<<" ";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	map<int,int> m;
	for(int i=1;i<=n;i++)
	{
	    int temp;
	    cin>>temp;
	    m[temp]=i;
	}
	for(int i=1;i<=n;i++)
	{
	    cout<<m[i]<<" ";
	}
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef long long LL;
typedef pair<int ,int > pii;
typedef pair<string ,int > psi;
typedef pair<string ,string > pss;
typedef pair<LL, LL> pLL;

const long long oo = 1e9 + 7;

int n,m;
int cnt[123456];
int a[1234],b[1234];
vector<int > edge[12345];
int ans ;

int main(){
   // freopen("test.txt","r",stdin);
    cin >> n >> m;
    for (int i =1 ; i <= m ; i++) {
        cin >> a[i] >> b[i];
        cnt[a[i]]++;
        cnt[b[i]]++;
        edge[a[i]].pb(b[i]);
        edge[b[i]].pb(a[i]);
    }

    for (int i =1 ; i <= n ;i++) {
        for (int k =1 ; k <= n ; k++) {
            if (cnt[k] == 0 ) continue;
            if ( cnt[k] == 1) {
                    ans++;
                cnt[k]--;
                for (int j = 0 ; j < edge[k].size() ; j++) {
                    cnt[edge[k][j]]--;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
const main = (inputs) => {

  const array = inputs[0].split(" ");
  var eight = Number(array[0]);
  var ten = Number(array[1]);

  var answer = -1;
  var price = 0;
  var i = 0;

  var eightFlag = false;
  var tenFlag = false;

  while (price < ten + 1) {
    if (Math.floor(i * 0.08) === eight) {
      eightFlag = true;
    }
    if (Math.floor(i * 0.1) === ten) {
      tenFlag = true;
    }
    if (eightFlag === true && tenFlag === true) {
      answer = i;
      break;
    }
    eightFlag = false;
    tenFlag = false;
    price = Math.floor(i * 0.1);
    i++;
  }
  console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

Measured memory_bytes: 7500
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    S = input()
    T = input()
    cnt = 0
    for s, t in zip(S, T):
        if s != t:
            cnt += 1
    print(cnt)
    return


if __name__ == '__main__':
    main()


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

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int n;
    int a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int i,len,len1;
    cin>>s;
    for (i=0;i<s.length();i++)
    if (s[i]=='Z') len=i;
    for (i=s.length()-1;i>=0;i--)
    if (s[i]=='A') len1=i; 
    cout<<len-len1+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int dice[7],side[5]={2,3,5,4,2};
    int a,b,i,j,k,l,n;
    char move[8]={"00NWESn"};
    
    for(i=1;i<=6;i++) scanf("%d",&dice[i]);
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        for(j=1;dice[j]!=a;j++);
        
        dice[0]=dice[1];
        
        switch(move[j]){
            case 'E':
            dice[1]=dice[4];
            dice[4]=dice[6];
            dice[6]=dice[3];
            dice[3]=dice[0];
            break;
            
            case 'N':
            dice[1]=dice[2];
            dice[2]=dice[6];
            dice[6]=dice[5];
            dice[5]=dice[0];
            break;
            
            case 'S':
            dice[1]=dice[5];
            dice[5]=dice[6];
            dice[6]=dice[2];
            dice[2]=dice[0];
            break;
            
            case 'W':
            dice[1]=dice[3];
            dice[3]=dice[6];
            dice[6]=dice[4];
            dice[4]=dice[0];
            break;
            
            case 'n':
            dice[1]=dice[6];
            dice[6]=dice[0];
            dice[0]=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[0];
            break;
        }
        
        for(l=0;dice[side[l]]!=b;l++);
        printf("%d\n",dice[side[l+1]]);
    }
   
    return 0;
}





Measured memory_bytes: 2036
#include<stdio.h>
#include<string.h>	
#include<math.h>

int main(){
	int n,d,ans=0;
	long long b,c;
	scanf("%d %d",&n,&d);
	while(n--){
		scanf("%lld %lld",&b,&c);
		double sum=sqrt(pow(b,2)+pow(c,2));
		if(sum<=d)ans++;
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
long long N;
long long ans;
vector<int> use;
void dfs(long long a, long long b, vector<int> use){
    if(b == 3) use[0] = 1;
    else if(b == 5) use[1] = 1;
    else if(b == 7) use[2] = 1;
    if(a * 10 + b > N) return;
    else{
        int flag = 0;
        for(int i = 0; i < 3; i++){
            if(use[i] == 0) flag = 1;
        }
        if(flag == 0) {
            ans++;
        }

    }
    dfs(a * 10 + b, 3, use);
    dfs(a * 10 + b, 5, use);
    dfs(a * 10 + b, 7, use);
}
int main(){
    cin >> N;
    use.resize(3, 0);
    ans = 0;
    dfs(0, 3, use);
    dfs(0, 5, use);
    dfs(0, 7, use);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
const long long int mod = 1e9 + 7;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl

int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll res = N;
    rep(i,1,N){
        if(S[i] == S[i-1]) res--;
    }
    COUT(res);
}


Measured memory_bytes: 512
L, R = map(int, input().split())
MOD = 2019
ans = float("inf")
if R - L >= MOD - 1:
    ans = 0
else:
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j) % MOD)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    if(a>b){
        cout << 0 << endl;
        return 0;
    }
    else if(b-a>n){
        cout << 0 << endl;
        return 0;
    }
    cout << (ll)(n-2)*(b-a) + 1;
}

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

int main() {
  string s;
  int diff = 999;
  cin >> s;
  for (int i=2; i<s.length(); i++) {
    //cout << stoi(s.substr(i-2,3)) << endl;
    if (abs(stoi(s.substr(i-2,3))-753)<diff) diff = abs(stoi(s.substr(i-2,3))-753);
  }
  cout << diff;
  return 0;
}

Measured memory_bytes: 256