akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


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

signed main(){
    string S; cin>>S;
    int N = S.size();
    int ans = 999;
    int X;
    REP(i,N-2){
        X = 100*(S[i]-'0')+10*(S[i+1]-'0')+(S[i+2]-'0');
        ans = min(ans,abs(X-753));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;
    map<pair<int, int>, int> store ;
    for (int i=0; i<n; i++){
        double no;
        long long lno;
        cin >> no;
        lno = llround(no*1e9);
        int two = 0, five = 0;
        while(lno%2==0)
            two++, lno >>= 1;
        while(lno%5==0)
            five++, lno /= 5;
        store[{two, five}]++;
    }
    long long ans = 0;
    for (auto i: store)
        for (auto j: store)
            if (i.first.first+j.first.first>=18 && i.first.second+j.first.second>=18){
                if (i.first<j.first)
                    ans += 1ll*i.second*j.second;
                else if (i.first==j.first)
                    ans += 1ll*i.second*(i.second-1)/2;
            }
    cout << ans <<"\n";
}


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

int main(){
  long long X;
  vector<long long> sum;
  cin >> X;
  for(long long i=1;(i+1)*i<2*X;i++)
    sum.push_back((i+1)*i);
  cout << sum.size()+1<<endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    vector<int> nu(n);
    REP(i,1,n+1) nu[i-1] = i;
    int count = 0;
    rep(i,n){
        if(p[i] != nu[i]) count++;
        if(count > 2){
            print("NO");
            return 0;
        }
    }
    print("YES");
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       string s;cin>>s;
       if(s == "Sunny")cout<<"Cloudy";
       if(s == "Cloudy")cout<<"Rainy";
       if(s == "Rainy")cout<<"Sunny";
    }
    


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

law_ans = 0
absminA = float('inf')
for a in A:
    law_ans += abs(a)
    absminA = min(absminA, abs(a))


cnt_neg = 0

for a in A:
    if a < 0:
        cnt_neg += 1

cnt_0 = A.count(0)

if cnt_neg%2 == 0:
    print(law_ans)
else:
    print(law_ans-2*absminA)



Measured memory_bytes: 19992
from math import gcd

def gcd3(x, y, z):
    return gcd(gcd(x, y), z)

K = int(input())

if __name__ == "__main__":
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                ans += gcd3(a, b, c)
    print(ans)

Measured memory_bytes: 68092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const int MAX = 2000005;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
 
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    ll H, W, A, B; cin >> H >> W >> A >> B;

    ll ans = 0;
    COMinit();

    // (1, 1) -> (H-A, i) -> (H-A+1, i) -> (H, W)
    for(int i=B+1; i<=W; ++i){
        ans += COM(H-A-1 + i-1, i-1)*COM(A-1 + W-i, A-1);
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 47104
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	/*

	 * AAA 35b50 1ª11b00 AA 37b50 1ª17b00 A 40b00 1ª23b00 B 43b00 1ª29b00 C

	 * 50b00 1ª45b00 D 55b00 1ª56b00 E 1ª10b00 2ª28b00

	 */

	double[] s = { 35.50, 37.50, 40, 43, 50, 55, 70 ,Double.MAX_VALUE};

	double[] l = { 71, 77, 83, 89, 105, 116, 148 ,Double.MAX_VALUE};

	String[] gm = {"AAA","AA","A","B","C","D","E","NA"};

	void run() {

		for (; sc.hasNextDouble();) {

			double ts = sc.nextDouble();

			double tl = sc.nextDouble();

			int gs = 0;

			int gl = 0;

			for(;s[gs] <= ts;gs++);

			for(;l[gl] <= tl;gl++);

//			System.out.println(gs+","+gl);

			int g = Math.max(gs, gl);

			System.out.println(gm[g]);

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int x = getInt(sc);
		int a = getInt(sc);
		int b = getInt(sc);

		System.out.println((x - a) % b);
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	long x;
	long tmpCoins;

	public Status(long x, long tmpCoins) {
		this.x = x;
		this.tmpCoins = tmpCoins;
	}
}


Measured memory_bytes: 23764
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int a = 0, b = 0, h = 0, area = 0;

    scanf("%d %d %d", &b, &h, &a);

    area = (b * h)/2;

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

    return 0;
}


Measured memory_bytes: 128
var
 n:int64; 
 i:longint;
 s:string;
begin
 readln(n);
 for i:=trunc(sqrt(n)) downto 1 do
  if n mod i=0 then break;
 if i>n div i then str(i,s)
              else str(n div i,s);
 writeln(length(s));
end.

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

int euq(int a, int b) {return b ? euq(b, a%b) : a;}

int main() {
    int N;
    cin >> N;
    int res = 0;
    rep(i, N) {
        int a;
        cin >> a;
        res = euq(res, a);
    }

    cout << res << endl;
    return 0;


}

Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
long long MAX(long long A,long long B){
    return A>B?A:B;
}
long long MIN(long long a,long long b){
    return a<b?a:b;
}
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main()
{   int a,b,c,d,e,x,y,n,m,k,i;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
    if(e-a>k)
    printf(":(");
    else printf("Yay!");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}

int main(){
ll N;
cin>>N;
vector<string> S(N);
ll m=0; ll a=0; ll r=0; ll c=0; ll h=0;
for(int i=0; i<N; ++i){
cin>>S[i];
if (S[i].at(0) == 'M') {m++;}
else if (S[i].at(0) == 'A') {a++;}
else if (S[i].at(0) == 'R') {r++;}
else if (S[i].at(0) == 'C') {c++;}
else if (S[i].at(0) == 'H') {h++;}
}
cout<<m*a*r+m*a*h+m*a*c+m*c*r+m*h*r+m*h*c+c*a*r+h*a*r+h*c*r+h*a*c<<endl;
}












Measured memory_bytes: 6144
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 220
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int a[N];
int n;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read()<<1;
	for(register int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);int ans=0;
	for(register int i=1;i<=n;i+=2)ans+=a[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> a(h);
  REP(i,h){
    cin>>a[i];
  }
  
  vector<vector<int>> d(h,vector<int>(w,-1));
  queue<pair<int,int>> q;
  REP(i,h){
    REP(j,w){
      if(a[i][j]=='S'){
        d[i][j]=0;
        q.push(make_pair(i,j));
      }
    }
  }
  
  pair<int,int> p;
  int x,y;
  int nx,ny;
  int dx[]={1,0,-1,0};
  int dy[]={0,1,0,-1};
  while(!q.empty()){
    p = q.front();
    x = p.first;y = p.second;
    q.pop();
    if(d[x][y]==k)continue;
    REP(i,4){
      nx = x + dx[i];ny = y+dy[i];
      if(0<=nx && nx<h && 0<=ny && ny<w && a[nx][ny] == '.' && d[nx][ny]<0){
        d[nx][ny] = d[x][y]+1;
        q.push(make_pair(nx,ny));
      }
    }
  }
  
  int ans = 1000;
  int temp;
  REP(i,h){
    REP(j,w){
      if(d[i][j]<0)continue;
      temp = (i+k-1)/k;
      temp = min(temp,(j+k-1)/k);
      temp = min(temp,(h-1-i+k-1)/k);
      temp = min(temp,(w-1-j+k-1)/k);
      ans = min(ans,temp+1);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>M;
    mat G(N, vec(N, INF));
    vec a(M), b(M), c(M);
    rep(i,M){
        cin>>A>>B>>c[i];
        --A, --B;
        G[A][B] = G[B][A] = c[i];
        a[i] = A;
        b[i] = B;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    ll ans = 0;
    rep(i,M){
        ans += G[a[i]][b[i]] < c[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
s = input()
s1 = s[:(len(s)-1)//2]
s2 = s[(len(s)+3)//2-1:]

flag = True
# [:] の指定は　左が閉区間、右が開区間 [ )こんな感じ
if s != s[::-1]:
    flag = False
if s1 != s1[::-1]:
    flag = False
if s2 != s2[::-1]:
    flag = False
print("Yes") if flag else print("No")


Measured memory_bytes: 3060
import java.util.*;
public class Main {
    static final long MODVAL = 998244353L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long result = 0L;
        while(X>0) {
            if(X >= 500) {
                X-=500;
                result+=1000;
                continue;
            }
            if(X >= 5) {
                X-=5;
                result+=5;
                continue;
            }
            break;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
import numpy as np

n = int(input())
v = np.array(list(map(int,input().split())))

# import ipdb; ipdb.set_trace()

if np.unique(v).size == 1:
    print(int(n/2))
else:
    # 偶数要素と奇数要素に分ける
    vo = v[::2]
    ve = v[1::2]
    # それぞれについて最大数の要素を見つける
    vof = np.bincount(vo).argmax()
    vef = np.bincount(ve).argmax()

    if vof == vef:
        if sum(vo == vof) > sum(ve == vef):
            vef = np.bincount(ve[ve!=vef]).argmax()
        elif sum(ve == vef) > sum(vo == vof):
            vof = np.bincount(vo[vo!=vof]).argmax()
        else :
            vof2 = np.bincount(vo[vo!=vof]).argmax()
            vef2 = np.bincount(ve[ve!=vef]).argmax()
            if (sum(vo == vof) + sum(ve == vef2)) > (sum(ve == vef) + sum(vo == vof2)):
                vef = vef2
            else:
                vof = vof2
    
    # それぞれについて最大数の数では無い要素数を数える
    vonf = sum(vo != vof)
    venf = sum(ve != vef)
    # 足しあげる
    print(vonf+venf)

Measured memory_bytes: 26028
#include<stdio.h>
#define MAX 250
int le(int);int ri(int);int par(int);
int main(){
  int H,A[MAX+1],i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i>1)printf("parent key = %d, ",A[par(i)]);
    if(le(i)<=H)printf("left key = %d, ",A[le(i)]);
    if(ri(i)<=H)printf("right key = %d, ",A[ri(i)]);
    printf("\n");
  }
  
  return 0;
}

int par(int i){
  return i/2;
}

int le(int i){
  return 2*i;
}

int ri(int i){
  return 2*i+1;
}



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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  string ans;
  ans = (a <= 8 && b <= 8) ? "Yay!":":(";
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import collections


def judge(balls):
    left_balls = collections.deque([0])
    right_balls = collections.deque([0])
    while balls:
        ball = balls.popleft()
        if ball > left_balls[-1]:
            left_balls.append(ball)
        elif ball > right_balls[-1]:
            right_balls.append(ball)
        else:
            return "NO"
    return "YES"


def main():
    n = int(input())
    for x in range(n):
        balls = collections.deque(map(int, input().split()))
        print(judge(balls))


if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,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;} }


int main(){
    ll A,B,N; cin>>A>>B>>N;
    if(N<B){
      cout << (ll)(A*N/B) <<"\n";
    }else{
      cout << (ll)(A*(B-1)/B) <<"\n";
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main(){

    //??\???
    while(1){
        int N, M; cin >> N >> M;
        if(N == 0) break;
    

        int r; cin >> r;
        vector<vector<int> > imos(M + 1, vector<int> (1000, 0));
        for(int i = 0; i < r; i++){
            int t, n, m, s; cin >> t >> n >> m >> s;
            t -= 500;
            if(s == 1) imos[m][t]++;
            else imos[m][t]--;
        }

        for(int i = 1; i <= M; i++){
            for(int j = 0; j < 1000; j++){
                imos[i][j+1] += imos[i][j];
            }
        }

        int q; cin >> q;
        for(int i = 0; i < q; i++){
            int s, e, m; cin >> s >> e >> m;
            s -= 500;
            e -= 500;
            int ans = 0;
            for(int j = s; j < e; j++){
                if(imos[m][j] > 0) ans++;
            }

            cout << ans << endl;
        }
    }
    return 0;

}

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

int main(){
	int x[10000];
	for (int i = 0; i < 10000; i++){
		cin >> x[i];
		if (x[i] == 0){
			break;
		}
	}
	for (int i = 0; i < 10000; i++){
		if (x[i] == 0){
			break;
		}
		cout << "Case " << i+1 << ": " << x[i] << endl;
	}
	cin >> x[0];
}

Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
#define INF ((ll)1e18)

int N;
ll a[(int)3e5];
ll lmax[(int)(1e5+1)];
ll rmin[(int)(1e5+1)];

int main(){
    cin >> N;
    for(int n=0; n<3*N; n++){
        cin >> a[n];
    }
    
    priority_queue<ll,vector<ll>,greater<ll> > que;
    lmax[0]=0;
    for(int i=0; i<N; i++){
        lmax[0] += a[i];
        que.push(a[i]);
    }
    for(int i=1; i<=N; i++){
        que.push(a[N+i-1]);
        lmax[i] = lmax[i-1] - que.top() + a[N+i-1];
        que.pop();
    }
    for(int i=0; i<=N; i++){
        cerr << i << ": " << lmax[i] << endl;
    }
    
    priority_queue<ll> que2;
    rmin[0]=0;
    for(int i=0; i<N; i++){
        rmin[0] += a[3*N-1-i];
        que2.push(a[3*N-1-i]);
    }
    for(int i=1; i<=N; i++){
        que2.push(a[2*N-i]);
        rmin[i] = rmin[i-1] - que2.top() + a[2*N-i];
        que2.pop();
    }
    for(int i=0; i<=N; i++){
        cerr << i << ": " << rmin[i] << endl;
    }
    
    ll res = -INF;
    for(int i=0; i<=N; i++){
        ll tmp;
        tmp = lmax[i] - rmin[N-i];
        if(tmp>res) res=tmp;
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 5876
#include <stdio.h>

int main()
{
	int n;
	int i,j;
	int times = 0, counts = 0;

	scanf("%d", &n);
	
	for (i = 1; 2 * i - 1 <= n; i++){
		times = 0;
		for (j = 1; j <= i; j++) {
			if ((2 * i - 1) % (2 * j - 1) == 0) {
				times++;
			}
			if (times > 8) {
				break;
			}
		}
		if (times == 8) {
			counts++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int k = scanner.nextInt();
		List<Pair>[] list = new List[n];
		for (int i = 0; i < n; i++)
			list[i] = new ArrayList<Pair>();
		while (m-- > 0) {
			int a = scanner.nextInt() - 1;
			int b = scanner.nextInt() - 1;
			int l = scanner.nextInt();
			list[a].add(new Pair(b, l));
			list[b].add(new Pair(a, l));
		}
		int[] dp = new int[n];
		Arrays.fill(dp, 1 << 25);
		PriorityQueue<Pair> pq = new PriorityQueue<Main.Pair>();
		for (int i = 0; i < k; i++) {
			int s = scanner.nextInt() - 1;
			dp[s] = 0;
			pq.offer(new Pair(0, s));
		}
		while (!pq.isEmpty()) {
			Pair pair = pq.poll();
			int f = pair.f;
			int s = pair.s;
			if (dp[s] < f)
				continue;
			for (Pair p : list[s]) {
				if (dp[p.f] <= f + p.s)
					continue;
				dp[p.f] = f + p.s;
				pq.offer(new Pair(f + p.s, p.f));
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if(dp[i]==0)
				continue;
			for (Pair p : list[i]) {
				if(dp[p.f]==0)
					continue;
				int a = Math.max(dp[i], dp[p.f]);
				int b = a + (p.s - Math.abs(dp[i] - dp[p.f]) + 1) / 2;
				ans = Math.max(ans, b);
			}
		}
		System.out.println(ans);
	}

	class Pair implements Comparable<Pair> {
		int f, s;

		public Pair(int f, int s) {
			super();
			this.f = f;
			this.s = s;
		}

		@Override
		public String toString() {
			return "Pair [f=" + f + ", s=" + s + "]";
		}

		@Override
		public int compareTo(Pair o) {
			return f - o.f;
		}

	}
}

Measured memory_bytes: 109144
def main():
    n = int(input())
    A = []
    for _ in range(n):
        a, b = list(map(int, input().split()))
        A.append([a, b])
    A.sort(key = lambda x: x[0], reverse = True)
    print(sum(A[0]))


if __name__ == '__main__':
    main()


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

using namespace std;
#define BUF (1000)

int n,m;




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

	long long A = (n-m)*100+m*1900;

	for(int i=0;i<m;i++) A*=2;

	cout << A <<endl;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535

int main() 
{
    FAST;
    ll k;
    cin>>k;
    set<ll> v1,v2;
    ll ans=0,x=sqrtl(k),y=sqrtl(k-1);
    for(int i=1;i<=x;i++)
        if(k%i==0)
        {
            v1.insert(i);
            v1.insert(k/i);
        }
    for(int i=1;i<=y;i++)
        if((k-1)%i==0)
        {
            v2.insert(i);
            v2.insert((k-1)/i);
        }
    ans=v2.size();
    v1.erase(1);
    for(auto i=v1.begin();i!=v1.end();i++)
    {
        x=k;
        while((x%(*i))==0)
            x=x/(*i);
        if(x%(*i)==1)
            ans++;
    }
    cout<<ans-1;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;
    int a = (s[5]-'0')*1000 + (s[6]-'0')*100 + (s[8]-'0')*10 + (s[9]-'0');
    if(a<500){cout <<"Heisei"<<endl;}
    else cout << "TBD" <<endl;
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,a[1000],b[1000],ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cin>>b[i];
	}
	
	for(int i=0;i<n;i++){
		ans=ans+(b[i]-a[i]+1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

vector<vector<int>> G;
vector<int> ans;
vector<int> vec[2];
vector<int> dis;

void dfs(int v) {
    vec[dis[v] % 2].push_back(v);
    for(int u : G[v]) {
        if(dis[u] >= 0) continue;
        dis[u] = dis[v] + 1;
        dfs(u);
    }
}

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

    int N;
    cin >> N;
    G.resize(N);
    ans.resize(N);
    dis.resize(N, -1);

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dis[0] = 0;
    dfs(0);

    ll num1, num2;
    num1 = num2 = N / 3;
    if(N % 3 > 0) num1++;
    if(N % 3 > 1) num2++;
    if(vec[0].size() >= num1 && vec[1].size() >= num2) {
        int nxt = 3;
        rep(i, vec[0].size()) {
            if(i < num1)
                ans[vec[0][i]] = i * 3 + 1;
            else {
                ans[vec[0][i]] = nxt;
                nxt += 3;
            }
        }
        rep(i, vec[1].size()) {
            if(i < num2)
                ans[vec[1][i]] = i * 3 + 2;
            else {
                ans[vec[1][i]] = nxt;
                nxt += 3;
            }
        }
        rep(i, N) cout << ans[i] << " ";
        return 0;
    }
    if(vec[0].size() >= num2 && vec[1].size() >= num1) {
        int nxt = 3;
        rep(i, vec[0].size()) {
            if(i < num2)
                ans[vec[0][i]] = i * 3 + 2;
            else {
                ans[vec[0][i]] = nxt;
                nxt += 3;
            }
        }
        rep(i, vec[1].size()) {
            if(i < num1)
                ans[vec[1][i]] = i * 3 + 1;
            else {
                ans[vec[1][i]] = nxt;
                nxt += 3;
            }
        }
        rep(i, N) cout << ans[i] << " ";
        return 0;
    } else {
        vector<int> &v = (vec[0].size() < vec[1].size() ? vec[0] : vec[1]);
        vector<int> &v2 = (vec[0].size() < vec[1].size() ? vec[1] : vec[0]);
        int nxt = 3;
        rep(i, v.size()) {
            ans[v[i]] = nxt;
            nxt += 3;
        }
        int nxt2 = 1;
        rep(i, v2.size()) {
            if(nxt <= N) {
                ans[v2[i]] = nxt;
                nxt += 3;
            } else {
                ans[v2[i]] = nxt2;
                nxt2++;
                if(nxt2 % 3 == 0) nxt2++;
            }
        }
        rep(i, N) cout << ans[i] << " ";
        return 0;
    }

    return 0;
}

Measured memory_bytes: 18804
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

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

const int inf=(int)2e9;
const long long mod=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=mod;a%=mod;
	}
	return ans;
}
ll mdinv(ll a){return powmod(a,mod-2); }


signed main(){
	IOS
	int n;cin>>n;
	vi v(n);
	forn(i,n) cin>>v[i];
	vvi DP(n,vi(n));
	for(int i=0;i<n;i++) DP[i][i]=0;

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

	for(int len=1;len<n;len++){
		for(int i=0;i<n;i++){
			int j=i+len;if(j>=n) break;
			DP[i][j]=min(DP[i][j-1],DP[i+1][j]);
			for(int op=i+1;op<j;op++)
				DP[i][j]=min(DP[i][j],DP[i][op]+DP[op+1][j]);
			DP[i][j]+=v[j];
			if(i)
				DP[i][j]-=v[i-1];
		}
	}
	cout<<DP[0][n-1];
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1e18;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  vi r(n,INF);
  rep(i,m) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    mins(r[a],b);
  }
  int x = INF, ans = 0;
  rep(i,n) {
    if (x == i) x = INF, ans++;
    mins(x, r[i]);
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 640
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int dp[100005];
int main() {
  int n;
  cin >> n;

  int h[n + 3];
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);

  dp[2] = abs(h[2] - h[1]);
  for (int i = 3; i <= n; i++) {
    dp[i] =
        min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
  }

  printf("%d\n", dp[n]);
  return 0;
}


Measured memory_bytes: 1024
#!/user/bin/env pypy3
import itertools
import sys


def fast_input():
    return sys.stdin.readline()[:-1]


def print_format(b: bool) -> str:
    return "YES" if b else "NO"


def solve(s: str) -> bool:
    for p in itertools.permutations(["dreamer", "eraser", "dream", "erase"]):
        work = s
        for token in p:
            work = work.replace(token, '')
        if work == "":
            return True
    return False


def main():
    result = solve(fast_input())
    print(print_format(result))


main()


Measured memory_bytes: 9220
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    sa = s[::1]
    sa = sa.replace("x", "")
    for i in range(len(sa)):
        if sa[i] == sa[-i - 1]:
            continue
        print(-1)
        return
    ans = 0
    i = 0
    j = len(s) - 1
    while i < j:
        if s[i] == s[j]:
            i += 1
            j -= 1
            continue
        ans += 1
        if s[i] == "x":
            i += 1
        if s[j] == "x":
            j -= 1
    print(ans)



    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 40304
N = int(input())
K = int(input())
if N > 1:
  x = list(map(int, input().split()))
  ans = 0
  for i in range(N):
    ans += min(2*x[i], 2*(K-x[i]))
else: 
  x = int(input())
  ans = min(2*x, 2*(K-x))
print(ans)

Measured memory_bytes: 62000
def main():
    N = int(input())
    C = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        C[a - 1].add(b - 1)
        C[b - 1].add(a - 1)
    if N == 1:
        return 'First'

    prv = set()
    cur = [0]
    while cur:
        nxt = []
        for c in cur:
            nxt.extend(k for k in C[c] if k not in prv)
        prv = set(cur)
        cur = nxt
    p = prv.pop()
    prv = set()
    cur = [p]
    d = 0
    while cur:
        nxt = []
        for c in cur:
            nxt.extend(k for k in C[c] if k not in prv)
        prv = set(cur)
        cur = nxt
        d += 1

    return 'First' if d % 3 in (0, 1) else 'Second'


print(main())


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
       String c1 = scan.next();
       String c2 = scan.next();
       String c3 = scan.next();
        System.out.print(c1.charAt(0));
        System.out.print(c2.charAt(1));
        System.out.print(c3.charAt(2));
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	char c;
	cin >> c;
	if(c - 'a' <= 26 and c - 'a' >= 0) cout << "a" << newl;
	else cout << "A" << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Infinite Coins
            int n = int.Parse(Console.ReadLine());
            int a = int.Parse(Console.ReadLine());

            if (n % 500 <= a)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;

    int l[N],r[N];
    int ans=0;
    rep(i,N){
        cin>>l[i]>>r[i];
        ans+=r[i]-l[i]+1;
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

int field[1010][1010];
pair<int, int> pos[1000001];  // 添字の番号の場所
int memo[1010][1010];
bool notPrime[1000001];
int ansx, ansy;
int m, n;
void rec(int x, int y, int cnt) {
  if (!notPrime[field[x][y]] &&
      (memo[ansx][ansy] < cnt ||
       (memo[ansx][ansy] == cnt && field[ansx][ansy] < field[x][y]))) {
    ansx = x;
    ansy = y;
  }
  
  int dx[] = {-1, 0, 1};
  int dy[] = {1, 1, 1};
  for (int i = 0; i < 3; i++) {
    int nx = x+dx[i];
    int ny = y+dy[i];

    if (field[nx][ny] == 0 || field[nx][ny] > m) continue;
    if (memo[nx][ny] != -1 &&
        memo[nx][ny] >= cnt+!notPrime[field[nx][ny]]) {
      continue;
    }
    memo[nx][ny] = cnt+!notPrime[field[nx][ny]];
    rec(nx, ny, memo[nx][ny]);
  }
  return ;
}

int main() {
  memset(notPrime, false, sizeof(notPrime));
  notPrime[1] = true;
  for (int i = 2; i*i <= 1000000; i++) {
    for (int j = i+i; j <= 1000000; j += i) {
      notPrime[j] = true;
    }
  }
  vector <int> prime;
  for (int i = 2; i <= 1000000; i++) {
    if (!notPrime[i]) {
      prime.push_back(i);
    }
  }
  
  memset(field, 0, sizeof(field));
  int bias = 1001/2;
  int dx[] = {1, 0, -1, 0};
  int dy[] = {0, -1, 0, 1};
  int x = bias, y = bias;
  field[x][y] = 1;
  pos[1] = make_pair(x, y);
  int p = 0;
  for (int i = 2; i <= 1000000; i++) {
    int nx, ny;
    nx = x+dx[p%4];
    ny = y+dy[p%4];
    if (field[nx][ny] != 0) {
      nx = x+dx[(p-1)%4];
      ny = y+dy[(p-1)%4];
      x = nx;
      y = ny;
      field[x][y] = i;
      pos[i] = make_pair(x, y);
    }else {
      x = nx;
      y = ny;
      field[x][y] = i;
      pos[i] = make_pair(x, y);
      p++;
    }
  }

  // for (int i = -10; i < 10; i++) {
  //   for (int j = -10; j < 10; j++) {
  //     std::cout << field[j+bias][i+bias] << "\t";
  //   }
  //   std::cout << "" << std::endl;
  // }
  // return 0;
  
  while (true) {
    cin >> m >> n;
    if (m == 0 && n == 0) break;

    memset(memo, -1, sizeof(memo));
    int tx = pos[n].first, ty = pos[n].second;
    // std::cout << tx-bias << " " << ty-bias << std::endl;
    ansx = tx; ansy = ty;
    memo[tx][ty] = !notPrime[n];
    rec(tx, ty, memo[tx][ty]);
    if (memo[ansx][ansy] == 0) {
      std::cout << 0 << " " << 0 << std::endl;
    }else {
      std::cout << memo[ansx][ansy] << " " << field[ansx][ansy] << std::endl;
    }
  }
}

Measured memory_bytes: 18352
#include<stdio.h>
#include<stdlib.h>
int add(int a,int b)
{
	return a+b;
}
int minus(int a,int b)
{
	return a-b;
}
void sign(int a)
{
	if(a)
	{
		printf("-");
	}
	else
	{
		printf("+");
	}
}
int main()
{
	int a[4];int b[3];
	char input[5];
	int (*op[2])(int a,int b);
	op[0]=add;
	op[1]=minus;
	int i,j,k,l;
	while(scanf("%s",input)!=-1)
	{
		for(i=0;i<4;i++)
		{
			a[i]=input[i]-48;
		}								//输入
		int count=0;
		for(i=0;i<=1;i++)
		{
			for(j=0;j<=1;j++)
			{
				for(k=0;k<=1;k++)
				{
					b[0]=op[i](a[0],a[1]);
					b[1]=op[j](b[0],a[2]);
					b[2]=op[k](b[1],a[3]);
					if(b[2]==7)
					{
						count++;
						break;
					}
					
				}
				if(count>0)break;
			}
			if(count>0)break;
		} 
		printf("%c",input[0]);
		sign(i);
		printf("%c",input[1]);
		sign(j);
		printf("%c",input[2]);
		sign(k);
		printf("%c=7\n",input[3]);
	}
}

Measured memory_bytes: 128