akhauriyash/Code-Regression huggingface dataset:
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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) - 1
    };

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

use std::collections::VecDeque;

fn main() {
    input!{
        h: usize,
        w: usize,
        board: [chars; h],
    }

    let mut dist: Vec<Vec<i32>> = vec![vec![-1; w]; h];
    let mut black_cells: VecDeque<(i32, i32)> = VecDeque::new();

    for i in 0..h {
        for j in 0..w {
            if board[i][j] == '#' {
                dist[i][j] = 0;
                black_cells.push_front((i as i32, j as i32));
            }
        }
    }

    let mut d = 0;
    while !black_cells.is_empty() {
        match black_cells.pop_front() {
            Some((y, x)) => {
                d = dist[y as usize][x as usize];
                // for (dy, dx) in &[(1, 0), (0, 1), (-1, 0), (0, -1)] {
                for &(dy, dx) in [(1, 0), (0, 1), (-1, 0), (0, -1)].iter() {
                    let nh = y + dy;
                    let nw = x + dx;
                    if nh < 0 || h as i32 <= nh || nw < 0 || w as i32 <= nw {
                        continue
                    }
                    if dist[nh as usize][nw as usize] == -1 {
                        dist[nh as usize][nw as usize] = d + 1;
                        black_cells.push_back((nh, nw));
                    }

                }
            }
            None => break
        }
    }

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


Measured memory_bytes: 21752
import java.util.*;
public class Main {
 
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
  	String[] input = sc.nextLine().split(" ");
  	
  	int a=Integer.parseInt(input[0]);
  	String op = input[1];
  	int b=Integer.parseInt(input[2]);
 
    int ans=0;
  	
  	switch (op){
  	case "+":
  		ans = a+b;
  		break;
  	case "-":
  		ans = a-b;
  		break;
  	}
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    ll ans = 700;
    for(ll i = 0; i < 3; i++)if(s[i] == 'o')ans += 100;
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    long long k; cin >> k;
    vector<long long> len(n + 1), pate(n + 1);
    len[0] = pate[0] = 1;
    for (int i = 1; i <= n; i++) {
        len[i] = 1 + len[i - 1] + 1 + len[i - 1] + 1;
        pate[i] = pate[i - 1] + 1 + pate[i - 1];
    }
    auto rec = [&](auto rec, int m, long long k) {
        if (k == len[m]) return pate[m];
        long long ans = 0;
        k--;
        if (k > 0) {
            long long l = min(k, len[m - 1]);
            ans += rec(rec, m - 1, l);
            k -= l;
        }
        if (k > 0) {
            ans++;
            k--;
        }
        if (k > 0) {
            long long l = min(k, len[m - 1]);
            ans += rec(rec, m - 1, l);
            k -= l;
        }
        return ans;
    };
    cout << rec(rec, n, k) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
signed main()
{
    int n, a[80];
    long long money, kabu, ans;
    
    cin >> n;
    for(int i=0 ;i<n; i++ ){
        cin >> a[i];
    }
    
    ans = 1000;
    for(int i=1 ;i<n ;i++ ){
        money = 1000, kabu = 0;
        for(int j=0 ;j<i ;j++ ){
            if(a[j] < a[j+1]){
                kabu += money / a[j];
                money = money % a[j];
            } else if(a[j] > a[j+1]) {
                money += a[j] * kabu;
                kabu = 0;
            }
        }
        ans = max(money + kabu * a[i], ans);
    }
    
    cout << ans << endl;
    
    return (0);
}

Measured memory_bytes: 3636
/**
 *   created: 01 September 2019  17:13:12
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vi  v(n);
		rep(i,0,n)
			cin>>v[i];
		int res = 0;
		int i=1;
		while(i<n){
			int temp =0;
			while(i<n && v[i]<=v[i-1]){
				temp++;
				i++;
			}
			res = max(temp,res);
			i++;
		}
		cout<<res;
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define sz 200005
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

int main()
{
    faster_io;
    ll r,d,x;
    cin>>r>>d>>x;
    int n=10;

    while(n--){
        x = x*r-d;
        cout<<x<<endl;
    }

    return 0;
}




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

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

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, i, j;
	string s, ans = "Yes";
	cin >> n >> s;
  	if(n & 1) {
      cout << "No" << endl;
      return 0;
    }
	for(i = 0, j = n/2; i < n/2 && j < n; i++, j++) {
		if(s[i] != s[j]) {
			ans = "No";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();//敵の数
        int A = scan.nextInt();//Aダメージ
        int B = scan.nextInt();//Bダメージ
        int C = A-B;//差分
        long E[] = new long[N];//各個体のHP
        long l = 0;//殴る回数（最小）
        long r = 1000000001;//殴る回数（最大）
        long m = 500000000;
        int x;

        for(int i = 0;i<N;i++){
            E[i] = scan.nextInt();//各個体のHPを入力
        }


        while(l < r-1){
            long Ex[] = new long[N];
            long d =0;
            int flag = 0;
            m = (l+r)/2;

            for(int i = 0;i<N;i++){
                Ex[i] = E[i] - B*m;
                if(Ex[i]>0){
                    if(Ex[i] % C == 0){
                        d += Ex[i]/C;
                    }else {
                        d += Ex[i] / C + 1;
                    }
                }
            }

            if(d>m) {flag = 1;}

            if(flag == 1) {
                l = m;
            }
            else{
                r = m;
            }
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 65096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		
		if(a + b <= k) {
			System.out.println(0 + " "+ 0);
		}
		else if(k >= a) {
			System.out.println(0+" "+ (b-(k-a)));
		}
		else {
			System.out.println((a-k)+" "+b);
		}
	}

}


Measured memory_bytes: 23636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
// 大きい順
#define rall(v) v.rbegin(), v.rend()
#define vi vector<int>
#define vl vector<ll>
const  long long INF = 1LL << 60;
typedef  long long ll;
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;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}

int main(){
int N; cin >> N;
map <int,int>d;
rep(i,N){
    int a; cin >> a;
    if(!d.count(a)){
        d[a] = 1;
    }
    else d[a] +=1;
}
int M; cin >> M;
vi T(M);
rep(i,M) cin >> T[i];
bool ok = true;
rep(i,M){
    if(d.count(T[i])){
        d[T[i]] -=1;
        
        if(d[T[i]] == -1) {
            ok = false;
            break;
        } 
    }
    else {
        ok = false;
        break;
    }
}
if(ok) cout << "YES" << endl;
else cout << "NO" << endl;
}

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

  int a[200]={},dp1[1000010],dp2[1000010];
  for(int i=1;i<200;i++) a[i]=i*(i+1)*(i+2)/6;
  for(int i=0;i<1000000;i++) dp1[i]=dp2[i]=i;
  for(int i=2;i<200;i++) for(int j=0;j<1000000;j++) if(j+a[i]<1000000) dp1[j+a[i]]=min(dp1[j+a[i]],dp1[j]+1);
  for(int i=2;i<200;i++) if(a[i]%2) for(int j=0;j<1000000;j++) if(j+a[i]<1000000) dp2[j+a[i]]=min(dp2[j+a[i]],dp2[j]+1);
  for(int n;cin>>n,n;) cout<<dp1[n]<<" "<<dp2[n]<<endl;
  return 0;

}

Measured memory_bytes: 10884
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
    char c;
    int l=4;
    while(cin>>c)
    {
    	l--;
    	if(l==0) cout<<char(c+1);
    	else cout<<c;
	}
	puts("");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var c = new int[3][].Select(x => Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray()).ToArray();

            var a11b22c33 = c[0][0] + c[1][1] + c[2][2];
            var a12b23c31 = c[0][1] + c[1][2] + c[2][0];
            var a13b21c32 = c[0][2] + c[1][0] + c[2][1];

            Console.WriteLine(a11b22c33 == a12b23c31 && a12b23c31 == a13b21c32 ? "Yes" : "No");

        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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 ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

int main(){
  int n; ll k; cin >> n >> k;
  rep(i, n) {
    cin >> to[0][i];
    to[0][i]--;
  }
  rep(i, D - 1){
    rep(j, n){
      to[i + 1][j] = to[i][to[i][j]];
    }
  }

  int v = 0;
  for (int i = D - 1; i >= 0; --i){
    ll l = 1LL<<i;
    if (l <= k){
      v = to[i][v];
      k -= l;
    }
  }
  cout << v + 1 << endl;
}


Measured memory_bytes: 50512
#include <iostream>

int main(){
    std::string str[] = {"Sunny", "Cloudy", "Rainy"};
    std::string inp;
    std::cin >> inp;
    if(inp == "Sunny")std::cout << "Cloudy";
    else if(inp == "Cloudy")std::cout << "Rainy";
    else std::cout << "Sunny";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        String[] input = Console.ReadLine().Split();
        double A = double.Parse(input[0]);
        double B = double.Parse(input[1]);
        double H = double.Parse(input[2]);
        double M = double.Parse(input[3]);
        H = H + M / 60 ;
        M = M / 5;
        double rad = Math.Min(12 - Math.Abs(H - M), Math.Abs(H - M)) * Math.PI / 6;     
        double c = A * A + B * B - 2 * A * B * Math.Cos(rad);
        Console.WriteLine(Math.Sqrt(c));
    }
}

Measured memory_bytes: 27872
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n,z,w;
    scanf("%ld%ld%ld", &n,&z,&w);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }

    long max=0;

    for(i=0; i<n-1; i++) {
        long tmp = abs(a[i]-a[n-1]);
        if(i<n-2) {
            long tmp2 = abs(a[n-2]-a[n-1]);
            tmp = min(tmp2, tmp);
        }
        max = MAX(max, tmp);
    }
    long tmp = abs(a[n-1]-w);
    max = MAX(max, tmp);

    printf("%ld\n", max);
 
    return 0;
}


Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int k;
    cin>>k;

    int ans=0;
    for(int i=1;i<=k;++i)
    {
        for(int j=1;j<=k;++j)
        {
            int x=gcd(i,j);
            for(int l=1;l<=k;++l)
                ans+=gcd(x,l);
        }
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3640
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define NIL  -1


bool prime_number(int x) {
	if (x == 1)return false;
	for (int i = 2; i*i <= x; i++) {
		if (x%i == 0)return false;
	}
	return true;
}

long long Pow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

int A[100000];


int main() {
	cin.tie(0);
	cout.tie(0);

	
	ios::sync_with_stdio(false);
	CST(10);

	int N, M;
	cin >> N >> M;
	FOR(i, 0, M) {
		int cur; cin >> cur;
		N -= cur;
	}

	if (N < 0)cout << -1 << endl;
	else cout << N << endl;
	
	return 0;
}


Measured memory_bytes: 3664
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll H, W;
	cin >> H >> W;
	auto grid = make_vec_nd(0, W, H);
	rep(h,0,H) {
		rep(w,0,W) {
			cin >> grid[w][h];
		}
	}
	rep(h,0,H) {
		rep(w,0,W) {
			ll b;
			cin >> b;
			grid[w][h] = abs(grid[w][h] - b);
		}
	}
	auto dp = make_vec_nd(false, W, H, 80 * 160);
	dp[0][0][grid[0][0]] = true;
	rep(x,0,W) {
		rep(y,0,H) {
			rep(i,0,2) {
				ll rx = x, ry = y;
				if (i == 0) {
					rx++;
				} else {
					ry++;
				}
				if (!(rx < W && ry < H)) {
					continue;
				}
				ll v = grid[rx][ry];
				rep(w,0,80*160) {
					if (dp[x][y][w]) {
						dp[rx][ry][w+v] = true;
						dp[rx][ry][abs(w-v)] = true;
					}
				}
			}
		}
	}
	rep(w,0,80*160) {
		if (dp[W-1][H-1][w]) {
			cout << w << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define mk make_pair
#define ll long long
using namespace std;
const int N = 2e3 + 5;
int n, z, w, a[N];
int dp[N][2];
int cal(int k, int t) {
	if (dp[k][t] != -1) return dp[k][t];
	if (k == n) return dp[k][t] = abs(a[n - 1] - a[n]);
	int res;
	if (t == 0) {
		res = 0;
		for (int i = k; i < n; i++) 
			res = max(res, cal(i + 1, 1));
		res = max(res, abs(a[n] - a[k - 1]));
	} else {
		res = 2e9;
		for (int i = k; i < n; i++) 
			res = min(res, cal(i + 1, 0));
		res = min(res, abs(a[n] - a[k - 1]));
	}
	return dp[k][t] = res;
}
int main() {
	cin >> n >> z >> w;
	a[0] = w;
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	memset(dp, -1, sizeof(dp));
	cout << cal(1, 0) << endl;
} 


Measured memory_bytes: 384
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int balls = in.nextInt(), color = in.nextInt();
		int res=color;
		for(int i=2; i<=balls; i++) {
			res*=color-1;
		}
		System.out.print(res);
		in.close();
	}
}

Measured memory_bytes: 21844
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

vector<int> E[110];
int N;
int D[110], F[110];

int tim = 0;
void dfs(int cur) {
  tim += 1;
  D[cur] = tim;
  for (auto it = E[cur].begin(); it != E[cur].end(); ++it) {
    if (D[*it] == 0) {
      dfs(*it);
    }
  }
  tim += 1;
  F[cur] = tim;
}

int main() {
  cin >> N;
  int c, k;
  for (int i = 1; i <= N; i++) {
    cin >> c >> k;
    int t;
    for (int j = 0; j < k; j++) {
      cin >> t; E[i].push_back(t);
    }
  }
  for (int i = 1; i <= N; i++) {
    D[i] = 0; F[i] = 0;
  }
  for (int i = 1; i <= N; i++) {
    if (D[i] == 0)
      dfs(i);
  }
  for (int i = 1; i <= N; i++)
    cout << i << ' ' << D[i] << ' ' << F[i] << endl;
}



Measured memory_bytes: 3132
/*
	DATE:		2020-03-02 14:38:17
	NAME:		
	PROBLEM:	ABC157D
*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5;

int a[MAXN + 7];

int r[MAXN + 7][2];
int p[MAXN + 7][2];

vector<int> edges[MAXN + 7];

int findset(int x, int type) {
  if (p[x][type] == x) {
    return p[x][type];
  }
  return p[x][type] = findset(p[x][type], type);
}

void link(int u, int v, int type) {
  u = findset(u, type);
  v = findset(v, type);

  // cerr << "> " << u << " " << v << "\n";

  if (u == v) {
    return;
  }

  if (r[u][type] > r[v][type]) {
    p[v][type] = u;
    r[u][type] += r[v][type];
  }
  else {
    p[u][type] = v;
    r[v][type] += r[u][type];
  }
}

map<int, int> cnt[MAXN + 7];

set<int> edges2[MAXN + 7];

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  for (int i = 1; i <= n; i++) {
    r[i][0] = r[i][1] = 1;
    p[i][0] = p[i][1] = i;
  }

  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    link(u, v, 0);
    edges[u].push_back(v);
    edges[v].push_back(u);
  }

  for (int i = 1; i <= k; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    // link(u, v, 1);
    if (findset(u, 0) == findset(v, 0)) {
      cnt[findset(u, 0)][u]++;
      cnt[findset(u, 0)][v]++;
      edges2[u].insert(v);
      edges2[v].insert(u);
    }
  }

  for (int u = 1; u <= n; u++) {
    cnt[findset(u, 0)][findset(u, 1)]++;
  }

  for (int u = 1; u <= n; u++) {
    int x = r[findset(u, 0)][0] - edges[u].size() - cnt[findset(u, 0)][u];
    for (int i = 0; i < (int) edges[u].size(); i++) {
      int v = edges[u][i];
      if (edges2[u].find(v) != edges2[u].end()) {
        x++;
      }
    }
    printf("%d ", x);
  }

  return 0;
}


Measured memory_bytes: 31736
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    c = readi(3, 3)
    d = list(zip(*c))
    print(
        "Yes"
        if all(
            len(set(i - j for i, j in zip(e[n], e[m]))) == 1
            for e in [c, d]
            for n in range(3)
            for m in range(n)
        )
        else "No"
    )


if __name__ == "__main__":
    main()


Measured memory_bytes: 3832
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n){
    cin >> p[i];
  }

  int ans = 0;
  for(int i = 1; i < n - 1; ++i){
    if((p[i] > p[i - 1] && p[i + 1] > p[i]) || (p[i] < p[i - 1] && p[i + 1] < p[i])){
      ans++;
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void showArray(int[] nums){
    for(int i = 0; i < nums.length - 1; i++){
      System.out.print(nums[i] + " ");
    }
    System.out.print(nums[nums.length - 1]);
    System.out.println("");
  }

  public static void main(String[] args) {
    Scanner scanInt = new Scanner(System.in);
    int n;
    int i, j;
    int dummy;
    n = scanInt.nextInt();
    int[] nums = new int[n];
    for(i = 0; i < n; i++){
      nums[i] = scanInt.nextInt();
    }

    for(i = 0; i < n; i++){
      dummy = nums[i];
      j = i - 1;
      while(j >= 0 && nums[j+1] < nums[j]){
        nums[j+1] = nums[j];
        nums[j] = dummy;
        j--;
      }
      showArray(nums);
    }



  }
}



Measured memory_bytes: 32032
N = int(input())
plus = []
minus = []
for i in range(N):
    x,y = map(int,input().split())
    plus.append(x+y)
    minus.append(x-y)
plus.sort()
minus.sort()

ans_1 = plus[-1]-plus[0]
ans_2 = abs(minus[-1]-minus[0])
print(max(ans_1,ans_2))

Measured memory_bytes: 99944
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666;
int n,m,head[N],to[N],nxt[N],edgenum,a[N];bool vis[N];
int cnt[N][2],q[N],f=1,r=1;
char s[N];
void add(int u, int v){
	to[++edgenum]=v;nxt[edgenum]=head[u];head[u]=edgenum;
}
bool ok(int i){return cnt[i][0]&&cnt[i][1];}
int main() {
	read(n);read(m);scanf("%s",s+1);rep(i,1,n)a[i]=s[i]=='A';
	rep(i,1,m){int u,v;read(u);read(v);add(u,v);add(v,u);}
	rep(u,1,n)L(i,u)cnt[u][a[to[i]]]++;
	rep(i,1,n)if(!ok(i))q[r++]=i,vis[i]=1;
	while(f!=r){
		int u=q[f++];
		L(i,u){
			cnt[to[i]][a[u]]--;if(!ok(to[i])&&!vis[to[i]]){
				vis[to[i]]=1;q[r++]=to[i];
			}
		}
	}
	bool b[2]={0};rep(i,1,n)b[a[i]]|=!vis[i];
	if(b[0]&&b[1])puts("Yes");else puts("No");
	return 0;
}

Measured memory_bytes: 15488
/*
Task:
Author: John_05
State: Unknown
Lang: C++
Solution:
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int  n,m,c,tot;
int a[110][110];
int b[110];

int main() {
	n=read();
	m=read();
	c=read();
	for(int i=1;i<=m;i++) b[i]=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=read();
	for(int i=1;i<=n;i++){
		int ans=c;
		for(int j=1;j<=m;j++) ans+=a[i][j]*b[j];
//		printf("%d\n",ans);
		if(ans>0) tot++;
	}
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

tmp = input().split(" ")
N = int(tmp[0])
K = int(tmp[1])
a = input().split(" ")

a.sort()
c = Counter(a)
m = len(c)
min = c.most_common()[::-1]
p = 0
ans = 0
while(m > K):
  ans += min[p][1]
  m -= 1
  p += 1
    
print(ans)

Measured memory_bytes: 44056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int a = scan.nextInt();
			char op = scan.next().charAt(0);
			int b = scan.nextInt();
			
			if(op == '?') {
				break;
			}
			
			if(op == '+') {
				System.out.println(a + b);
			}else if(op == '-') {
				System.out.println(a - b);
			}else if(op == '*') {
				System.out.println(a * b);
			}else if(op == '/') {
				System.out.println(a / b);
			}
			
		}
		
	}

}



Measured memory_bytes: 26288
inp1 = input().split(' ')
inp1 = [int(i) for i in inp1]
inp2 =  input().split(' ')
inp2 = [int(i) for i in inp2]

H, W = inp1[0], inp1[1]
h, w = inp2[0], inp2[1]

print(H*W - h*W - H*w + h*w )

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main{

	static final Scanner	s	=new Scanner(System.in);

	public static void main(String args[]){
		input();
		solve();
	}

	private static void input(){
	}

	private static void solve(){
		System.out.println(Math.max(s.nextInt()*s.nextInt(),s.nextInt()*s.nextInt()));
	}
}


Measured memory_bytes: 21076
def main():
    N, M = map(int, input().split())

    if min(N, M) == 1:
        i = max(N, M)
        if i == 1:
            back = 1
        elif i == 2:
            back = 0
        else:
            back = i - 2
    elif N == 2 or M == 2:
        back = 0
    else:
        back = N * M - ((N + M) * 2 - 4)
    print(back)

main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define pb push_back 
#define ff first 
#define ss second
#define all(c) c.begin(), c.end()
#define sz(z) (int)z.size()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rev(i,a,b) for(int i=a; i>=b; i--)
//Debugging tools 
#define debug(v) cout<<#v<<endl;for(ll i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define debugn(v,n) cout<<#v<<endl;for(ll i=0; i<n; i++) cout<<v[i]<<" "; cout<<endl;
#define deb(sum) cout<<#sum<<" = "<<sum<<endl;
//Predefined values
#define INF (ll)243000000000000001
#define endl "\n"
#define pi 3.142857142857143
const ll MOD = 1e9 + 7;


int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.in","r",stdin);
        freopen("output.in","w",stdout);
    #endif
    int t=1;    
    //cin>>t;
    while(t--){
        long long int a,b,c,d;
        cin >> a >> b >> c >> d;
        cout<< max({a*c, a*d, b*d, b*c})<<endl;
    }
    return 0;
}
        
        

















Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  int no_of_input,input;
  vector<int> vect1;
  cin >> no_of_input;
  int ans = 0;
  for(int i=0;i<no_of_input;i++){
    cin >> input;
    vect1.push_back(input);
  }
  int curr = 1;
  for(int i=0;i<vect1.size();i++){
    if(curr==vect1[i]){
      curr++;
    }
    else{
      ans++;
    }
  }
  if(ans==no_of_input){
    cout << -1;
    return 0;
  }
  cout << ans;
}

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

int main(){
  string S;
  cin >> S;
  int sum=0;
  vector<int> v(4);
  for(int i=0;i<4;i++)v[i]=S[i]-'0';

  for(int bit=0;bit<(1<<3);bit++){
    int tmp=v[0];
    for(int k=0;k<3;k++){
      if(bit&(1<<k)){
        tmp+=v[k+1];
      }else{
        tmp-=v[k+1];
      }
      if(tmp==7){
        cout<<v[0];
        for(int k=0;k<3;k++){
          if(bit&(1<<k))cout<<'+';
          else cout << '-';
          cout << v[k+1];
        }
        cout << "=7" <<endl;
        return 0;
      }      
    }
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll T, t, A, a, B, b;
  cin >> T >> t >> A >> a >> B >> b;

  ll d1 = T * A - T * B;
  ll d2 = (T * A + t * a) - (T * B + t * b);
  if (d1 > 0)
    d1 *= -1, d2 *= -1;
  cerr << d1 << " " << d2 << endl;

  if (d2 == 0)
    FINALANS("infinity");
  if (d2 < 0)
    FINALANS(0);

  ll n = -d1 / d2;
  cout << 2 * n + (-d1 % d2 != 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N;
ll a[10010];
ll cnt[10010];

ll f(ll n) {
	ll ret = 0;
	while (n % 2 == 0) {
		n /= 2;
		ret++;
	}
	return ret;
}

void solve() {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			cnt[i] = f(a[i]);
		}
	}

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

	cout << ans << endl;



	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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


int main() {
	
	int k, s;
	cin >> k >> s;
	int cnt = 0;
	for(int i=0; i<=k; i++){
		for(int j=0; j<=k; j++){
			int x = s - i - j; 
			if ( ( x >= 0 ) && ( x <= k) ) cnt ++;
		}
	}
	cout << cnt << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
typedef long long ll;
const int INF=1e+09;



int main(){    
    //入力
    string S;

    cin >> S;
    if(S[0]==S[1]&&S[1]==S[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

int main(){
	int N, i, j;
	scanf("%d", &N);
	vector<vector<int>> a(N, vector<int>(N, -1));
	for(i = 0; i < N; i++){
		for(j = i + 1; j < N; j++){
			int d = j - i;
			int v = 1;
			while(1){
				if(d % 2 == 1){
					break;
				}
				d = (d + 1) / 2;
				v++;
			}
			a[i][j] = v;
		}
	}
	for(i = 0; i < N - 1; i++){
		for(j = i + 1; j < N; j++){
			printf("%d ", a[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = (int) 1e5 + 100;
char str[N];

int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    scanf("%s", str);
    int len = strlen(str);

    int l = 0, r = len - 1;
    int ans = 0;

    while (l < r)
    {
        eprintf("l = %d, r = %d\n", l, r);
        bool f = false;
        while (l < r && str[l] == str[r] )
        {
            f = true;
            l++;
            r--;
        }
        while (l < r && str[l] == 'x')
        {
            f = true;
            l++;
            ans++;
        }
        while (l < r && str[r] == 'x')
        {
            f = true;
            r--;
            ans++;
        }
        if (!f)
        {
            printf("-1\n");
            return 0;
        }
    }
    printf("%d\n", ans);




	return 0;
}



Measured memory_bytes: 384
import numpy as np
a,b,h,m = map(int, input().split())
short_arg = (h*60+m) * 0.5  
long_arg = m * 6 
theta = np.abs(short_arg - long_arg)
c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(theta * np.pi/180))
print(c)

Measured memory_bytes: 27196
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

typedef pair<bool, bool> anst;
anst dfs (int x, int p, const vvi &g)
{
    vector<anst> sons;
    for (int dest : g[x]) if (dest != p)
        sons.pb(dfs(dest, x, g));

    anst res(false, true);
    for (auto pr : sons)
        res.snd &= pr.fst;
    int cnt = 0, who = -1;
    forn (i, sz(sons))
    {
        if (!sons[i].fst)
        {
            cnt++;
            who = i;
        }
    }
    forn (i, sz(sons))
    {
        if (sons[i].snd && who == -1)
        {
            who = i;
        }
    }

    if (who != -1 && cnt <= 1 && sons[who].snd)
        res.fst = true;
    return res;
}

void solve (int n)
{
    vvi g(n);
    forn (i, n - 1)
    {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].pb(v);
        g[v].pb(u);
    }

    anst res = dfs(0, -1, g);
    cout << (res.fst ? "Second" : "First") << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 5888
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int f(int n) {
  if (n & 1) return 3 * n + 1;
  else return n / 2;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int s; cin >> s;
  vector<bool> exist(1000001, false);
  int tmp = s;
  exist[tmp] = true;
  REP(i, 999999) {
    tmp = f(tmp);
    if (exist[tmp]) {
      cout << i + 2 << '\n';
      return 0;
    } else exist[tmp] = true;
  }
}


Measured memory_bytes: 384
#include <bitset>
#include <cmath>
#include <cstdio>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <set>
#include <iterator>
#include <climits>
#include <stack>
#include <cstring>
#include <cmath>
#include <utility>
#include <list>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
using namespace std;


#define ll long long
#define vi vector<int>
#define mod 1000000007
ll _sieve_size;
bitset<10000010> bs;
vi primes;

void sieve(ll upperbound) {
    _sieve_size = upperbound + 1;
    bs.set();
    bs[0] = bs[1] = 0;
    for (ll i = 2; i <= _sieve_size; i++) if (bs[i]) {
            for (ll j = i * i; j <= _sieve_size; j += i) bs[j] = 0;
            primes.push_back((int) i);
        }
}

bool isPrime(ll N) {
    if (N <= _sieve_size) return bs[N];
    for (int i = 0; i < (int) primes.size(); i++)
        if (N % primes[i] == 0) return false;
    return true;
}

int binarysearch(int n, int arr[], int value) {
    int upper = n;
    int lower = 0;
    int mid = n / 2;
    while (lower <= upper) {
        mid = (lower + upper) / 2;
        if (arr[mid] == value)
            return mid;
        else if (arr[mid] < value)
            lower = mid + 1;
        else
            upper = mid - 1;
    }
    return -1;
}

ll binaryPower(ll a,ll b){
    if(b == 0)
        return 1;
    ll res = binaryPower(a,b/2)%mod;
    if(b%2)
        return (((res * res)%mod) * a)%mod;
    else
        return (res*res)%mod;        return (((res * res)%mod) * a)%mod;

}
int main(void){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    string s;
    cin >> n >> k >> s;
    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    H,W = map(int,input().split())

    if (H == 1) or (W == 1):
        res = 1
        print(res)
        sys.exit()

    res = H * W

    if (H % 2 == 1) and (W % 2 == 1):
        res += 1

    res //= 2

    print(res)



main()


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	 public static void main(String[] args){
		 Scanner stdIn=new Scanner(System.in);
		 String s=stdIn.next();
		Outer:
		for(int i=0;i<s.length()-1;i++){
			 for(int j=i+1;j<s.length();j++){
				 if(s.charAt(i)==s.charAt(j))
					 break Outer;
				 if((i==s.length()-2)&&(j==s.length()-1)){
					 System.out.println("yes");	
					 return;
				 }
			 }
		 }
		 
	
	 System.out.println("no");
		 
		 
	 }

}


Measured memory_bytes: 22612