akhauriyash/Code-Regression huggingface dataset:
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var xyz=arr.shift().split(" ").map(Number);
   if(xyz.join(" ")=="0 0 0")break;
   var x=xyz[0];
   var y=xyz[1];
   var z=xyz[2];
   var v=arr.shift().split(" ").map(Number);
   var nea=[];
   for(var i=0;i<z;i++){
      var Z=arr.shift().split(" ").map(Number);
      nea[Z[0]]=[Z[1],Z[2]];
   }
   var dp=[];
   for(var i=0;i<=y;i++){
      dp[i]=[];
      for(var j=0;j<=5000;j++){
         dp[i][j]=0;
      }
   }
   dp[0][0]=1;
   for(var i=0;i<y;i++){
      for(var k=0;k<=5000;k++){
         for(var j=0;j<x;j++){
         var after=Math.min(y,i+v[j]);
            if(nea[after]!=undefined){
               var e=nea[after][0];
               var a=nea[after][1];
               if(e==1)dp[Math.min(y,after+a)][k]+=dp[i][k]/x;
               else if(e==2)dp[after][Math.min(5000,k+a)]+=dp[i][k]/x;
               else if(e==3)dp[after][Math.max(0,k-a)]+=dp[i][k]/x;
            }else{
               dp[after][k]+=dp[i][k]/x;
            }
         }
      }
   }
   var sum=0;
   for(var i=0;i<=5000;i++)sum+=i*dp[y][i];
   console.log(Math.floor(sum));
}

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

const long long int DENOMI = 1000000007;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	long long int ans = 1;
	auto cnt = vector<long long int>('z' + 1);
	for(auto c : s) ++cnt[c];
	for(auto i = (int)'a'; i <= 'z'; ++i){
		ans = (ans * (cnt[i] + 1)) % DENOMI;
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,h,w;
    cin>>n>>h>>w;
    cout<<((n-h)+1)*((n-w)+1)<<endl;
 return 0;   
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			dist = new int[h][w];
			map = new char[h][w];
			for (int i = 0; i < h; i++) {
				char[] cs = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					dist[i][j] = -1;
					char c = cs[j];
					map[i][j] = c;
					if (c == 'S') {
						sy = i;
						sx = j;
						map[i][j] = '.';
					} else if (c == 'G') {
						gy = i;
						gx = j;
						map[i][j] = '.';
					}
				}
			}
			int ID = 1;
			ice = new int[h * w];
			id = new int[h][w];
			ice[0] = INF;
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					if (id[i][j] == 0 && map[i][j] == 'X') {
						mark(i, j, ID);
						if (ice[ID] == 1)
							map[i][j] = '#';
						ID++;
					}

				}
			Deque<Point> deque = new ArrayDeque<Main.Point>();
			deque.offer(new Point(gy, gx));
			dist[gy][gx] = 0;
			while (!deque.isEmpty()) {
				Point p = deque.poll();
				for (int[] m : move) {
					int ny = p.y + m[0];
					int nx = p.x + m[1];
					if (!isOK(ny, nx))
						continue;
					if (map[ny][nx] != '#' && dist[ny][nx] == -1) {
						dist[ny][nx] = dist[p.y][p.x] + 1;
						deque.offer(new Point(ny, nx));
					}

				}
			}
			ans = dist[sy][sx];
			hit = new int[h * w];
			b = new boolean[h][w];
			b[sy][sx] = true;
			while (!f(sy, sx, 0)) {
				Arrays.fill(hit, 0);
				b = new boolean[h][w];
				b[sy][sx] = true;
				ans++;
			}
			System.out.println(ans);

		}
	}

	private boolean f(int y, int x, int depth) {
		if (ans < depth + dist[y][x])
			return false;
		if (y == gy && x == gx)
			return true;
		for (int[] m : move) {
			int ny = y + m[0];
			int nx = x + m[1];
			if (!isOK(ny, nx))
				continue;
			if (b[ny][nx] || map[ny][nx] == '#')
				continue;
			if (ice[id[ny][nx]] / 2 > hit[id[ny][nx]]) {
				hit[id[ny][nx]]++;
				b[ny][nx] = true;
				if (f(ny, nx, depth + 1))
					return true;
				hit[id[ny][nx]]--;
				b[ny][nx] = false;
			}
		}
		return false;
	}

	private void mark(int i, int j, int ID) {
		ice[ID]++;
		id[i][j] = ID;
		for (int[] m : move) {
			int ny = i + m[0];
			int nx = j + m[1];
			if (!isOK(ny, nx))
				continue;
			if (map[ny][nx] == 'X' && id[ny][nx] == 0)
				mark(ny, nx, ID);
		}
	}

	private boolean isOK(int y, int x) {
		if (0 <= y && y < h && 0 <= x && x < w)
			return true;
		return false;
	}

	int h, w, sx, sy, gx, gy, INF = 1 << 24, ans;
	char[][] map;
	int[][] dist, id;
	int[] ice, hit;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
	boolean[][] b;

	class Point {
		int y, x;

		public Point(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + "]";
		}

	}
}

Measured memory_bytes: 23040
#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 p(int x, int y){
    if(y==0){return 1;}
    if(y==1){return x;}
    return p(x,y-1)*x;
}

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

    int a,b,t;
    cin >> a >> b >> t;
    t /= a;
    cout << b*t << endl;
    
    return 0;
}

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

int main() {
  int x,a,b,c,d;
  cin >> x;
  a=x/1000;
  b=x%1000/100;
  c=x%100/10;
  d=x%10;
  if ((a==b && b==c) || (b==c && c==d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++ i) cin >> A[i] >> B[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	if (N % 2 == 0) {
		int x = A[N/2]+A[N/2-1];
		int y = B[N/2]+B[N/2-1];
		cout << y-x+1 << endl;
	} else {
		cout << B[N/2]-A[N/2]+1 << endl;
	}
}


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

int main() {
  string s;

  cin >> s;

  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    rep(i, M){
        cin >> a.at(i) >> b.at(i);
    }
    auto check = [&](int _a, int _b) {
        rep(j, M)
        {
            if(a.at(j) == _a && b.at(j) == _b)
            {
                return true;
            }
            else if(a.at(j) == _b && b.at(j) == _a)
            {
                return true;
            }
        }
        return false;
    };

    vector<int> num(N-1);
    iota(num.begin(), num.end(), 2);
    int count = 0;
    do{
        bool c = true;
        vector<int> num2(N - 1);
        num2 = num;
        auto it = num2.begin();
        num2.insert(it, 1);
        rep(i, N-1){
            if(!check(num2.at(i), num2.at(i+1))){
                c = false;
            }
        }
        if(c){
            count++;
        }
    } while (next_permutation(num.begin(), num.end()));

    cout << count << endl;
}

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

int main(void){
  int h,w;
  int i,j;
  char input[51][256];
  scanf("%d %d",&h,&w);

  for(i=0;i<h;i++)
    scanf("%s",input[i]);

  for(i=1;i<h;i++){
    for(j=1;j<w;j++){
      if(input[i][j]=='#'){
        if((input[i][j-1]=='.')&&(input[i-1][j]=='.')&&(input[i][j+1]=='.')&&(input[i+1][j]=='.')){
          printf("No\n");
          exit(0);
        }
      }
    }
  }

  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll n;
char str[10000];

void name(ll n, int len = 0) {
    if (n < 26) {
        str[len] = 'a' + n;
        str[len + 1] = '\0';
        return;
    }
    str[len] = 'a' + n % 26;
    return name(n / 26 - 1, len + 1);
}

int main() {
    cin >> n;
    name(n - 1);
    reverse(str, str + strlen(str));
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 3676
import java.util.*;
import java.io.*;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		
		boolean flag = false;
		if(k < Math.abs(a-b) ) flag = true;
		if(k < Math.abs(a-c) ) flag = true;
		if(k < Math.abs(a-d) ) flag = true;
		if(k < Math.abs(a-e) ) flag = true;
		if(k < Math.abs(b-c) ) flag = true;
		if(k < Math.abs(b-d) ) flag = true;
		if(k < Math.abs(b-e) ) flag = true;
		if(k < Math.abs(c-d) ) flag = true;
		if(k < Math.abs(c-e) ) flag = true;
		if(k < Math.abs(d-e) ) flag = true;
		
		if(flag==false) System.out.println("Yay!");
		else System.out.println(":(");
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(m);
    vector<string> s(m);
    rep(i,m) cin>>p[i]>>s[i];
    vector<int> ans (n);
    vector<int> pena(n);
    int wa=0;
    int ac=0;
    rep(i,m){
        if (ans[p[i]-1]!=1){
           if (s[i]=="WA") pena[p[i]-1]++;
           else if (s[i]=="AC") {ans[p[i]-1]=1;ac++;}
        }
    }
    int penasum=0;
    rep(i,n){
        if (ans[i]==1) penasum += pena[i];
    }
    cout << ac <<" "<<penasum;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
    // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  ll a, b, c; cin >> a >> b >> c;
  ll N; cin >> N;
  
  ll ans = 0;
  bool ok = false;

  while(b <= a) {
    b *= 2;
    ans ++;
  }
  while(c <= b) {
    c *= 2;
    ans ++;
  }
  
  // cout << ans << endl;
  cout << (ans <= N?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
    int A, B, i, j, c[5], d, ans;
    ans = 0;
    scanf("%d %d", &A, &B);
    for(i = A; i <= B; i++){
        d = i;
        for(j = 0; j < 5; j++){
            c[j] = d % 10;
            d /= 10;
        }
        if(c[0] == c[4] && c[1] == c[3]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


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

int main() {
	int n ,d;
	cin >> n >> d;

	if(n % (2 * d + 1) == 0) cout << n / (2 * d + 1) << endl;
	else cout << n / (2 * d + 1) + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
const int N=1505;
int b[N][N],S[N],n,u[N][N],l[2][N],r[2][N],flag[N][N];
char A[N][N];
int main(){
	scanf("%d",&n);
	for (register int i=1;i<=n;++i)scanf("%s",A[i]+1);
	for (register int i=1;i<=n;++i)
		for (register int j=1;j<=n;++j)flag[i][j]=A[i][j]>='0'&&A[i][j]<='9',b[i][j]=A[i][j]-'0';
	for (register int i=0;i<=n;++i)
		for (register int j=0;j<=n;++j)u[i][j]=flag[i][j]?min(i,min(u[i-1][j],u[i][j-1])):1<<30;
	long long ans=0;
	for (register int x=1;x<=n;++x){
		int t=x&1;
		for (register int j=1;j<=n;++j)S[j]=S[j-1]+(u[x][j]<=x?b[x][j]:0);
		for (register int j=n+1;j;--j){
			if (flag[x][j]){
				l[t][j]=j;
				r[t][j]=max(r[t][j+1],j);
				if (l[t][j]<=r[t][j])ans+=b[x][j]*(S[r[t][j]]-S[l[t][j]-1]-b[x][j]);
			}
			else l[t][j]=1e9,r[t][j]=-1;
		}
		for (register int i=x-1;i;--i){
			int t=i&1;
			for (register int j=1;j<=n;++j)S[j]=S[j-1]+(u[x][j]<=i?b[x][j]:0);
			for (register int j=n+1;j;--j){
				if (flag[i][j]){
					l[t][j]=min(l[t][j+1],l[t^1][j]);
					r[t][j]=max(r[t][j+1],r[t^1][j]);
					if (l[t][j]<=r[t][j])ans+=b[i][j]*(S[r[t][j]]-S[l[t][j]-1]);
				}
				else l[t][j]=1e9,r[t][j]=-1;
			}
		}
	}
	printf("%lld\n",ans);
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


const ll INF = LLONG_MAX;

typedef long double LD;



void dij1(int nV, vector<vector<LD>>& table, vector<LD>& d, int start) {
	// nV: |V|
	d.assign(nV, INF);
	d[start] = 0;
	vector<int> prev(nV, -1);

	priority_queue<pair<LD, int>> Q;
	Q.push(make_pair(0, start));

	vector<bool> visited(nV, false);

	while (!Q.empty()) {
		LD du = -Q.top().first;
		int u = Q.top().second; Q.pop();
		if (visited[u]) continue;
		visited[u] = true;

        rep(v, nV) {
            if (v == u) continue;
			LD alt = du + table[u][v];
			if (d[v] > alt) {
				d[v] = alt;
				prev[v] = u;
				Q.push(make_pair(-alt, v));
			}
		}
	}
}


int N;
vector<int> x,y,r;

LD distance(int i, int j) {
    int dx = abs(x[i] - x[j]), dy = abs(y[i] - y[j]);
    int rsum = r[i] + r[j];
    LD d = hypotl(dx, dy);
    if (d <= rsum) return 0;
    else return d - rsum;
}

LD solve() {
#ifdef DEBUG
    cerr << "N:" << N << endl;
    cerr << "x:" << x << endl;
    cerr << "y:" << y << endl;
    cerr << "r:" << r << endl;
#endif
    vector<vector<LD>> table(N, vector<LD>(N, INF));
    rep(i,N) table[i][i] = 0;
    repC2(i,j,N) table[i][j] = table[j][i] = distance(i, j);

    vector<LD> d(N, INF);
    dij1(N, table, d, 0);
#ifdef DEBUG
    cerr << d << endl;
#endif
    return d[1];
}

int main() {
    int xs,ys,xt,yt; cin >> xs >> ys >> xt >> yt;
    cin >> N;
    x.resize(N+2);
    y.resize(N+2);
    r.resize(N+2);
    x[0] = xs; y[0] = ys; r[0] = 0;
    x[1] = xt; y[1] = yt; r[1] = 0;
    rep(i,N){
        cin >> x[2+i] >> y[2+i] >> r[2+i];
    }
    N += 2;
    printf("%.10Lf\n", solve());
    return 0;
}


Measured memory_bytes: 26092
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());

		if(A+B == 3) {
			System.out.println(3);
		} else if(A+B == 4) {
			System.out.println(2);
		} else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	string s;

	cin >> s;

	string nox;

	vector <int> numx;
	int x = 0;
	for (int i = 0; i < SZ(s); ++i)
	{
		if (s[i] != 'x')
		{
			nox += s[i];
			numx.push_back(x);
			x = 0;
		}
		else
		{
			x++;
		}
	}

	numx.push_back(x);

	string rev(nox);
	reverse(rev.begin(), rev.end());

	if (rev == nox)
	{
		int ans = 0;

		for (int i = 0; i < SZ(numx)/2; ++i)
		{
			ans += abs(numx[i] -  numx[SZ(numx)-1-i]);
		}
		printf("%d\n", ans);
	}
	else
	{
		printf("-1\n");
	}
	return 0;
}



Measured memory_bytes: 1148
#include <stdio.h>

#define EPS 1e-5

int main(void) {
    double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;

    while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf\n",
           &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2, &yb2) != EOF) {
        if (xa1 <= xb2 && xb1 <= xa2 &&
            ya1 <= yb2 && yb1 <= ya2) {
            puts("YES");
        }
        else {
            puts("NO");
        }
    }
    return 0;
}

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

const int inf = 1e8;
int n,k,a[8888],dp[8888];

int main(){
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);

  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=a[i]-i+1;j++)dp[j] = inf;
    int arg = 0;
    for(int j=i;j<a[i]-1;j++){
      if(a[i]<a[j]){
	int tmp = lower_bound(dp,dp+arg+1,a[j]) - dp;
	dp[tmp++] = a[j];
	if(arg<tmp)arg = tmp;
      }
    }
    if(ans < arg){
      ans = arg;
      if(ans+1+k>=n/2){ printf("%d\n",n/2); return 0; }
    }
  }
  printf("%d\n",ans+1+k);
}

Measured memory_bytes: 1256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;
int M;

int mul(int x, int y) {
    return (1ll * x * y) % M;
}

const int MX = 100 * 1000 + 7;

int f[MX];
vector<int> g[MX];

int ans[MX];

void dfs1(int v, int p) {
    for (int i = 0; i < g[v].size(); i++) {
        if (g[v][i] == p) {
            g[v].erase(g[v].begin() + i);
            break;
        }
    }

    f[v] = 1;
    for (int to : g[v]) {
        dfs1(to, v);
        f[v] = mul(f[v], f[to] + 1);
    }
}

void dfs2(int v, int up) {
    vector<int> pref(g[v].size());
    vector<int> suf(g[v].size());

    int cm = 1;
    for (int i = 0; i < g[v].size(); i++) {
        cm = mul(cm, f[g[v][i]] + 1);
        pref[i] = cm;
    }

    cm = 1;
    for (int i = int(g[v].size()) - 1; i >= 0; i--) {
        cm = mul(cm, f[g[v][i]] + 1);
        suf[i] = cm;
    }

    ans[v] = (up + 1) % M;
    if (g[v].size()) {
        ans[v] = mul(ans[v], pref.back());
    }

    for (int i = 0; i < g[v].size(); i++) {
        int cf = 1;
        if (i) {
            cf = mul(cf, pref[i - 1]);
        }
        if (i + 1 < g[v].size()) {
            cf = mul(cf, suf[i + 1]);
        }
        dfs2(g[v][i], mul(cf, up + 1));
    }
}


int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n >> M;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs1(1, -1);
    dfs2(1, 0);

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 17664
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=200005;

void solve()
{
	ll a,b,i;
	cin>>a>>b;
	for(i=max(-100000LL,b-a+1);i<=min(100000LL,b+a-1);i++)
		cout<<i<<" ";
	
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 256
def rect(h, w):
	for i in range(h):
		if i % 2 == 0:
			for j in range(w):
				if j % 2 == 0:
					print('#', end='')
				else:
					print('.', end='')
			print('\n', end='')
		else:
			for j in range(w):
				if j % 2 == 0:
					print('.', end='')
				else:
					print('#', end='')
			print('\n', end='')

while True:
	h, w = map(int, input().split())
	if h == 0 & w == 0:
		break
	else:
		rect(h, w)
		print('\n', end='')



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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll r;cin >> r;
	cout << 3 * r * r << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdint>

inline int64_t sum(int64_t x) { return x*(x+1)/2; }

int main() {
  int64_t N; std::cin >> N;
  std::cout << sum(N) - 3*sum(N/3) - 5*sum(N/5) + 15*sum(N/15) << std::endl;
  return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
char s[200001], t[200001];
int main() {
	scanf("%s%s", s, t);
	int ans = 0;
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

vector<int> v[101010];
ll a[101010];
ll mi;
ll ans;

void init(int x,int p){
    for(auto to:v[x]){
        if(to==p)continue;
        init(to,x);
        a[x]+=a[to];
    }
}
void dfs(int x,int p){
    mi = min(mi,a[x]);
    ans += a[x];
    for(auto to:v[x]){
        if(to==p)continue;
        a[to]+=a[x];
        dfs(to,x);
    }
}



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    rep(i,n-1){
        int x,y;
        cin>>x>>y;
        --x;--y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    rep(i,n)cin>>a[i];
    rep(i,n){
        int x;cin>>x;
        a[i]=-x+a[i];
    }
    init(0,-1);
    dfs(0,-1);
    cout<<ans+n*-mi<<endl;
    
    return 0;
}


Measured memory_bytes: 15104
/*input
3242
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a,b,c,d;
bool solve(int i){
	int w=a,x=b,y=c,z=d;
	if(!(i&1)) x*=-1;
	if(!(i&2)) y*=-1;
	if(!(i&4)) z*=-1;
	return (w+x+y+z==7);
}
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p;
	string s;
	cin>>s;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
	for(int i=0;i<8;++i) 
		if(solve(i))
			return cout<<a<<(i&1?"+":"-")<<b<<(i&2?"+":"-")<<c<<(i&4?"+":"-")<<d<<"=7",0;
}

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


int main(){
    ll N, M; cin >> N >> M;
    vector<pair<ll, ll>> vec(100010);
    for (int i = 0; i < N; i++) cin >> vec.at(i).first >> vec.at(i).second;

    sort(vec.begin(), vec.begin() + N);

    ll ans = 0, m = M;

    for (int i = 0; i < N; i++) {
        if (m <= vec.at(i).second) {
            ans += (vec.at(i).first) * m;
            break;
        }

        ans += (vec.at(i).first) * (vec.at(i).second);
        m -= vec.at(i).second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(long long a){
    cout << pow(a, 2) + pow(a, 3) + a << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    solve(a);
    return 0;
}


Measured memory_bytes: 4348
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

mx = 3*10**10
a,b,q = ma()
S = [0 for i in range(a+2)]
T = [0 for i in range(b+2)]
S[0] = -mx;S[a+1] = mx
T[0] = -mx;T[b+1] = mx
for i in range(a):
    S[i+1]=ni()
for i in range(b):
    T[i+1]=ni()

def bs(x,ls):##ls == S or T
    ok =0
    ng = len(ls)-1
    while ng-ok > 1:
        idx = (ok+ng)//2
        if ls[idx] < x:
            ok = idx
        else:
            ng = idx
    return ok  #xよりも左にあるidxを返す
def solve(x):
    ids = bs(x,S)
    s1 = S[ids] #自分より左
    s2 = S[ids+1] #自分と同じか右
    idt = bs(x,T)
    t1 = T[idt]
    t2 = T[idt+1]

    s1t1 = max(x-s1,x-t1)
    s1t2 = 2*min(x-s1,t2-x) + max(x-s1,t2-x)
    s2t1 = 2*min(s2-x,x-t1) + max(s2-x,x-t1)
    s2t2 = max(s2-x,t2-x)
    print(min(s1t1,s1t2,s2t1,s2t2))

for i in range(q):
    x = ni()
    solve(x)


Measured memory_bytes: 17320
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  string s;cin >> s;
  map<string, int> mp;
  for (int i =0; i< s.size();++i){
    auto sub = s.substr(i,1);
    if(mp.find(sub) != mp.end()){
      mp[sub] = mp[sub] + 1;
    } else {
      mp[sub] = 1;
    }
  }
  if(mp.size() != 2){
    cout << "No" << endl;
  } else {
    for(auto itr = mp.begin(); itr != mp.begin(); ++itr){
      if(itr->second !=2){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read(){
	int x=0,w=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')w=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-48,c=getchar();
	return x*w;
}
const int N=1e5+5;
bool bj[N];
int sum[N];
int main(){
	int n=read(),m=read();
	int AC=0,WA=0;
	for(int i=1;i<=m;++i){
		int a=read();
		char opt[5];
		scanf("%s",opt);
		if(opt[0]=='A'){if(!bj[a])++AC,bj[a]=1;}
		else if(!bj[a])++sum[a];
	}
	for(int i=1;i<=n;++i)if(bj[i])WA+=sum[i];
	cout<<AC<<" "<<WA<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));


int main(int argc, const char *argv[])
{
  int N;
  cin>>N;
  vector<int> vec(N-1,0);
  vector<int> vec_2(N,0);
  for (int i = 0; i < N -1 ; i++)
  {
    cin>>vec[i];
  }

  for (int i = 0; i < N; i++)
  {
    if(i == 0)
    {
      vec_2[i] = vec[i];
    }
    else if(i == N -1)
    {
      vec_2[i] = vec[i -1];
    }
    else
    {
      vec_2[i] = min(vec[i-1],vec[i]);
    }

  }

  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    sum += vec_2[i];
  }
  
  cout<<sum;
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}


const int MAX = 10000000 ;
// UFT�N���X��錾����Ƃ��̓O���[�o���ϐ����Astatic�����ĐÓI�ϐ��ɂ��邱��
class UFT{
public :
	int par[MAX] ;
	int rank[MAX] ;
	int size[MAX] ;
	bool root[MAX] ;
	int graph ;
	int tree ;

	void init(int n){
		for(int i=0;i<n;i++){
			par[i] = i ;
			rank[i] = 0 ;
			size[i] = 1 ;
			root[i] = true ;
		}
		tree = n ;
		graph = n ;
	}

	int find(int x){
		if(par[x]==x) return x ;
		return par[x] = find(par[x]) ;
	}

	void unite(int x,int y){
		x = find(x) ;
		y = find(y) ;
		if(x==y){
			if(root[x]){
				root[x] = false ;
				tree-- ;
			}
			return ;
		}
		if(rank[x]<rank[y]){
			par[x] = y ;
			size[y] += size[x] ;
			graph-- ;
			if(root[x]){
				root[x] = false ;
				tree-- ;
			}
		}else{
			par[y] = x ;
			size[x] += size[y] ;
			if(rank[x]==rank[y]) rank[x]++ ;
			graph-- ;
			if(root[y]){
				root[y] = false ;
				tree-- ;
			}
		}
	}

	bool same(int x,int y){
		return find(x)==find(y) ;
	}
};

int main(){
    ll n,m ;
    cin >> n >> m ;
    static UFT uft ;
    uft.init(n) ;
    for(int i=0;i<m;i++){
        ll a,b ;
        cin >> a >> b ;
        a-- ; b-- ;
        uft.unite(a,b) ;
    }
    ll ans = 0 ;
    for(int i=0;i<n;i++){
        chmax(ans,(ll)uft.size[uft.find(i)]) ;
    }
    cout << ans << endl ;
}


Measured memory_bytes: 6188
let s = read_line ()
let t = read_line ()

let s_len = String.length s
let t_len = String.length t

let ch_pos =
  let ss = s ^ s in
  let len = s_len * 2 in
  let rec f arr i =
    if i = -1 then arr
    else begin
      arr.(i) <- Array.copy arr.(i + 1);
      arr.(i).(int_of_char ss.[i] - int_of_char 'a') <- i;
      f arr (i - 1)
    end
  in
  f (Array.init (len + 1) (fun _ -> Array.make 26 (-1))) (len - 1)

let rec loop sum i pos =
  if i = t_len then
    print_int sum
  else 
    let next = ch_pos.(pos + 1).(int_of_char t.[i] - int_of_char 'a') in
    if next = -1 then begin
      print_int (-1); exit 0;
    end else loop (sum + next - pos) (i + 1) (next mod s_len)

let () = 
  let start = ch_pos.(0).(int_of_char t.[0] - int_of_char 'a') in
  if start = -1 then print_int (-1) else loop (start + 1) 1 start

Measured memory_bytes: 88384
from itertools import combinations

M = 'MARCH'
d = {i: set() for i in M}
for _ in range(int(input())):
    s = input()
    if s[0] in M:
        d[s[0]].add(s)

cmb = list(combinations(M, 3))
ans = 0
for c in cmb:
    t = 1
    for k in c:
        t *= len(d[k])
    ans += t

print(ans)

Measured memory_bytes: 14316
N, Y = gets.split.map(&:to_i)

(0..N).each do |_10000_count|
  (0..N).each do |_5000_count|
    _1000_count = N - _10000_count - _5000_count
    yen = 10000 * _10000_count + 5000 * _5000_count + 1000 * _1000_count
    if _1000_count >= 0 && yen == Y
      puts [_10000_count, _5000_count, _1000_count].join(' ')
      exit 0
    end
  end
end
puts '-1 -1 -1'


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) cout << S << "\n";
    else cout << S.substr(0, K) << "...\n";
}


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

int main() {
    string s; cin >> s;
    int K; cin >> K;
    for(int i=0; i<s.size(); ++i) {
        if(s[i] == 'a') continue;
        if((int)('z' - s[i]) + 1 <= K) {
            K -= (int)('z' - s[i]) + 1;
            s[i] = 'a';
        }
    }
    K %= 26;
    s[s.size() - 1] = char(int(s[s.size() - 1]) + K);
    cout << s << '\n'; 
}

Measured memory_bytes: 512
import sys
for line in sys.stdin:
    a, b, c, d, e, f = [float(x) for x in line.split()]
    x = (f * b - e * c) / (d * b - a * e)
    y = (c - a * x) / b
    if abs(x) < 0.00001:
        x = 0.000
    if abs(y) < 0.00001:
        y = 0.000
    print("%.3f %.3f" % (x, y) )


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int n, m;

int main() {

	n = ri(), m = ri();
	printf("%d\n", 1 + (n - 2) / (m - 1));

	return 0;
}


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

using ll = long long;
using namespace std;
using i128 = __int128_t;
void solve(){
	ll x, k, d; cin >> x >> k >> d;
  i128 X = abs(x);
  while (k) {
    ll k2 = (k + 1) / 2;
    X = abs(X - i128(k2) * d);
    k /= 2;
  }
  cout << ll(X) << endl;

}


int main(){
/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    string s;
    cin >> n >> s;
    int r = 0, g = 0, b = 0;
    for (char c : s) {
        if (c == 'R') ++r;
        if (c == 'G') ++g;
        if (c == 'B') ++b;
    }
    ll ans = ll(r) * g * b;
    rep(i, n) for (int j=i+1; j<n; ++j) {
        int k = i+2*(j-i);
        if (k >= n) continue;
        if (s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k]) --ans;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int a, b, k;

    cin>> a>> b>>k;

    vector <int > v;

    for(int i= 1; i<=a && i<=b; i++)
    {
        if( b%i==0 && a%i==0)
            v.push_back(i);
    }

    cout << v[v.size()- k];
    nl;

    return 0;
}




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

int cmp(const void *a, const void *b)
{
        int x = *(int *)a;
        int y = *(int *)b;

        if (x < y) {
                return -1;
        } else if (x == y) {
                return 0;
        } else {
                return 1;
        }
}

int main(void)
{
        int n, i, ans = 0;
        int *list;

        scanf("%d", &n);
        list = calloc(sizeof(int), n);
        for (i = 0; i < n; i++) {
                scanf("%d", &list[i]);
        }
        qsort(list, n, sizeof(int), cmp);

        ans++;
        for (i = 1; i < n; i++) {
                if (list[i] == list[i - 1]) {
                        continue;
                }
                ans++;
        }
        printf("%d\n", ans);
        return 0;
}

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


int main()
{

    int n,k,mn=1000000005;
    cin>>n>>k;
    int x[n];
    for(int i=0;i<n;i++)cin>>x[i];

    sort(x,x+n);
    for(int i=0;i<n-k+1;i++)
        mn=min(mn,(x[i+k-1]-x[i]));


    cout<<mn<<endl;

	return 0;

}


Measured memory_bytes: 640
H,N = list(map(int,input().split()))

magics = []
for i in range(N):
    magics.append(list(map(int,input().split())))

#どう考えてもTLEだけどとりあえず
DP = [10**9]*(H+1)
DP[0] = 0
for i in range(N):
    for j in range(min(magics[i][0],H+1)):
        DP[j] = min(DP[j],magics[i][1])
    for j in range(magics[i][0],H+1):
        DP[j] = min(DP[j],DP[j-magics[i][0]]+magics[i][1])

print(DP[H])


Measured memory_bytes: 42484
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
int n,m;
vector<int> g[100005];
int vs[100005];
int ans = 0;
void dfs(int u){
	vs[u] = 1;
	for(int v: g[u]) if(!vs[v])
		dfs(v);
}
signed main(){
	cin >> n >> m;
	for(int i = 1 ; i <= m ; i ++){
		int x, y, z;
		cin >> x >> y >> z;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i = 1 ; i <= n ; i ++){
		if(!vs[i]){
			dfs(i);
			ans ++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 9600
def dfs4(bi, a):
    res = 0
    for j in range(len(a)):
        for i in range(W):
            if bi[i] == 1 and a[j][i] == '#':
                res += 1
    if res == K:
        ans[0] += 1
    return

def dfs3(bi, a):
    if len(bi) == W:
        return dfs4(bi, a)
    for i in range(2):
        bi.append(i)
        dfs3(bi, a)
        bi.pop()
    return

def dfs2(bits):
    a = []
    for i in range(H):
        if bits[i] == 1:
            a.append(maze[i])
    dfs3([], a)
    #print(a)
    return

def dfs(bits):
    if len(bits) == H:
        return dfs2(bits)
    for i in range(2):
        bits.append(i)
        dfs(bits)
        bits.pop()
    return

H, W, K = map(int, input().split())
maze = [list(input()) for _ in range(H)]

ans = [0]
dfs([])
print(ans[0])

Measured memory_bytes: 9264
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2==0){
        cout << (b-a)/2 << endl;
        return 0;
    }
    
    cout << min(n-b,a-1) + 1 + (b-a)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
ll a,b,c;
cin>>a>>b>>c;
if(a*c<=b)
printf("%lld\n",c);
else
{
	printf("%lld\n",b/a);
}
}



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

#define LLINF (1LL<<60)
typedef long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    ll Q,H,S,D,N;
    cin >>Q>>H>>S>>D>>N;

    //-----------------------------------
    ll minlt=min(8*Q,4*H);
    chmin(minlt,S*2);
    chmin(minlt,D);
    ll minlo=min(4*Q,2*H);
    chmin(minlo,S);
    ll ans=N/2*minlt+N%2*minlo;
    

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

Measured memory_bytes: 256
const main = (inputs) => {
  var N = inputs[0].length;
  var map = inputs[0].split("");
  var rarr = [];

  var tmp = 0;
  for(var i=0;i<N;i++){
    rarr[i] = 0;
    if(map[i] == "R"){
      tmp++;
    }else if(tmp>0){
      rarr[i] = ~~(tmp/2);
      rarr[i-1] = tmp-rarr[i];
      tmp = 0;
    }
  }
  tmp = 0;
  var larr = [];
  for(var i=N-1;i>=0;i--){
    larr[i] = 0;
    if(map[i] == "L"){
      tmp++;
    }else if(tmp>0){
      larr[i] = ~~(tmp/2);
      larr[i+1] = tmp-larr[i];
      tmp = 0;
    }
  }
  var anss = [];
  for(var i=0;i<N;i++){
    anss[i] = rarr[i] + larr[i];
  }
  console.log(anss.join(" "));
}

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


Measured memory_bytes: 18508
# Aizu Problem ITP_1_3_C: Swapping Two Numbers
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    a, b = [int(_) for _ in input().split()]
    if a == b == 0:
        break
    print(min(a, b), max(a, b))

Measured memory_bytes: 7656
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
   ll i, w; 
   ll K[n+1][W+1]; 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 
int main()
{
	ll n,W;
	cin>>n>>W;
	ll dp[n+1][W+1];
	ll w[n],v[n];

	for(ll i = 0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
 cout<<knapSack(W,  w,  v,  n);
 return 0;
}

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

using namespace std;


int main(){
    
    int N;
    cin >> N;
    //N = 100000;
    int d[N];
    for (int i = 0; i < N; i++) {
        cin >> d[i];
        //d[i] = N-i;
    }
    
    
    
    sort(d, d+N);
    
    
    cout << d[N/2] - d[N/2-1] << endl;
    
}


Measured memory_bytes: 640
N, *X = map(int, open(0).read().split())
Y = [(i, x) for (i, x) in enumerate(X)]
Y = sorted(Y, key=lambda x:x[1])
ans = []
for i in range(N//2):
  ans.append((Y[i][0], Y[N//2][1]))
for i in range(N//2, N):
  ans.append((Y[i][0], Y[N//2-1][1]))
ans = sorted(ans)
for a in ans:
  print(a[1])

Measured memory_bytes: 52804
a, b, m = map(int, input().split())
A_lst = list(map(int, input().split()))
B_lst = list(map(int, input().split()))
dis_lst = [[0]*3 for _ in range(m)]
for i in range(m):
    x, y, c = map(int, input().split())
    dis_lst[i][0] = x - 1
    dis_lst[i][1] = y - 1
    dis_lst[i][2] = c

min_num = min(A_lst) + min(B_lst)
for dis in dis_lst:
    sum_num = A_lst[dis[0]] + B_lst[dis[1]] - dis[2]
    if sum_num < min_num:
        min_num = sum_num

print(min_num)

Measured memory_bytes: 30764