akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int INF = 1<<29;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

long long int i,j;

long long int solve(long long int a,long long int b,long long int c){
	return max(a,max(b,c))-min(a,min(b,c));
}

int main(){
	int n,m;
	cin>>n;
	char s[53];
	int zenbu[28],ima[28];
	for(i=0;i<26;i++){
		zenbu[i]=INF;
	}
	for(i=0;i<n;i++){
		cin>>s;
		m=strlen(s);
		memset(ima,0,sizeof(ima));
		for(j=0;j<m;j++){
			ima[s[j]-'a'] += 1;
		}
		for(j=0;j<26;j++){
			zenbu[j]=min(zenbu[j],ima[j]);
		}
	}
	int k=0,mozi;
	char ans[55];
	for(i=0;i<26;i++){
		mozi=zenbu[i];
		for(j=0;j<mozi;j++){
			ans[j+k] = i+'a';
		}
		k += mozi;
	}
	n=strlen(ans);
	for(i=0;i<k;i++){
		cout<<ans[i];
	}
	cout<<endl;
	//output
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main(){
  vector<vector<char>> c(3,vector<char>(3));
  rep(i,3) rep(j,3) cin >> c[i][j];
  cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

Measured memory_bytes: 384
a=[]
m=0
for i in range(3):
  b=list(map(int,input().split()))
  a.append(b)
n=int(input())
for i in range(n):
  k=int(input())
  for q in range(3):
    for p in range(3):
      if a[q][p]==k:
        a[q][p]=0
for i in range(3):
  if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
    print("Yes")
    m+=1
    break
  if a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
    print("Yes")
    m+=1
    break
  if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    print("Yes")
    m+=1
    break
  if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
    m+=1
    break
if m==0:
  print("No")

Measured memory_bytes: 3064
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
from collections import deque


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, ABs):
    tree_top = [[] for _ in range(N + 1)]
    for i in range(N - 1):
        tree_top[ABs[i][0]].append(i)
        tree_top[ABs[i][1]].append(i)

    max_color = 0
    for tt in tree_top:
        max_color = max(max_color, len(tt))

    ans = [0 for _ in range(N - 1)]
    for tt in tree_top:
        colored = []
        for i in tt:
            if ans[i] != 0:
                colored.append(ans[i])
        colored.sort()
        now_color = 1
        colored_point = 0
        for i in tt:
            if ans[i] != 0:
                continue
            if colored_point < len(colored) \
                    and now_color == colored[colored_point]:
                now_color += 1
                colored_point += 1
            ans[i] = now_color
            now_color += 1

    print(max_color)
    for a in ans:
        print(a)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    ABs = [[int(i) for i in input().split()] for _ in range(N - 1)]
    solve(N, ABs)


Measured memory_bytes: 40648
#include<iostream>
#include<algorithm>

using namespace std;
const int maxn = 1e5 + 5;
int cnt;
int par[maxn];
int n;

struct roads {
	int x, y, id;
	roads(int _x = 0, int _y = 0, int _z = 0) :x(_x), y(_y), id(_z) {};
}road[maxn], road2[maxn * 2];

bool cmp1(const roads &a, const roads &b) {
	return a.x < b.x;
}

bool cmp2(const roads &a, const roads &b) {
	return a.y < b.y;
}

bool cmp3(const roads &a, const roads &b) {
	return a.id < b.id;
}

void init() {
	for (int i = 1; i <= n; i++)
		par[i] = i;
}

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

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	par[x] = y;
}

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

int kruskal() {
	int sum = 0;
	init();
	for (int i = 0; i<cnt; i++) {
		roads r = road2[i];
		if (r.id == 0)unite(r.x, r.y);
		if (!same(r.x, r.y)) {
			unite(r.x, r.y);
			sum += r.id;
		}
	}
	return sum;
}

int main() {
	ios::sync_with_stdio(false);
	while (cin >> n) {
		for (int i = 0; i < n; i++) {
			cin >> road[i].x >> road[i].y;
			road[i].id = i + 1;
		}
		cnt = 0;
		sort(road, road + n, cmp1);
		for (int i = 1; i < n; i++) {
			road2[cnt++] = roads( road[i].id,road[i - 1].id,road[i].x - road[i - 1].x );
		}
		sort(road, road + n, cmp2);
		for (int i = 1; i < n; i++) {
			road2[cnt++] = roads(road[i].id, road[i - 1].id, road[i].y - road[i - 1].y);
		}
		sort(road2, road2 + cnt, cmp3);
		int t = kruskal();
		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 4352
using System;

class Program
{
    static void Main(string[] args)
    {
        var abc = Console.ReadLine().Split(' ');
        var a = int.Parse(abc[0]);
        var b = int.Parse(abc[1]);
        var c = int.Parse(abc[2]);

        var n = Math.Max(Math.Max(a, b), c);
        Console.WriteLine(a + b + c - n + n * 10);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    cin >> n;
    int h = n / 15 * 200;
    cout << n*800-h;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool flag=true;
    if(s.size()&1) flag=false;
    for(int i=0;i<s.size();i+=2)
        if(!(s[i]=='h'&&s[i+1]=='i'))flag=false;
    printf(flag?"Yes\n":"No\n");
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
xy = [None]*n
for i in range(n):
    xy[i] = tuple(map(int, input().split()))

from itertools import permutations
ans = 0
num = 0
for p in permutations(range(n)):
    val = 0
    prv = p[0]
    for i in p[1:]:
        val += ((xy[i][0]-xy[prv][0])**2 + (xy[i][1]-xy[prv][1])**2) ** 0.5
        prv = i
    ans += val
    num += 1
print(ans/num)

Measured memory_bytes: 74032
#include <iostream>
using namespace std;
int main(void){
	int a;
	int b;
	a=0;
	b=0;
	cin >> a;
	cin >> b;
	if(a<b)
	{	
		cout << "a < b" <<endl;
	}
	if(a==b)
	{	
		cout << "a == b" << endl;
	}

	if(a>b)
	{
		cout << "a > b" << endl;
	}
return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main() {
  int nr=0, nb=0; string s; cin >> s;
  for (int i=0; i<s.size(); i++) { if (s[i]=='0') nr++; else nb++; }
  cout << 2 * min(nr, nb) << endl; return 0;
}


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

#define BUF_SIZE 1500000

int comp(const void* a, const void* b) {
  return *(int*)a - *(int*)b;
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;

  int num, limits, time;
  sscanf(line, "%d %d %d", &num, &limits, &time);
  int i;
  int *arr = malloc(sizeof(int)*num);
  for(i = 0; i < num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    sscanf(line, "%d", &arr[i]);
  }

  qsort(arr, num, sizeof(int), comp);

  int res = 0;
  for(i = 0; i < num;) {
    int cur = i;
    int count = 1;
    while(++i < num && ++count <= limits && arr[cur]+time >= arr[i]) ;
    res++;
  }
  printf("%d\n", res);
  return 0;
}

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

// 0-indexed
template <class T>
struct SegmentTree {
  // a,b,c: T, e:T(unit)
  // abc = (ab)c = a(bc)
  // ae = ea = a
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) { init(newn); }
  SegmentTree(const vector<T> &v, F f, T t) : f(f), unit(t) {
    int _n = v.size();
    init(v.size());
    for (int i = 0; i < _n; ++i) dat[n + i] = v[i];
    for (int i = n - 1; i; --i) dat[i] = f(dat[i << 1], dat[(i << 1) | 1]);
  }
  void init(int newn) {
    n = 1;
    while (n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while (k >>= 1) {
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vl = f(vl, dat[l++]);
      if (r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};

using P = pair<int, int>;
int n;
vector<int> p;
SegmentTree<P> odd, ev;
vector<vector<int>> memo;
vector<P> res, v;

int solve(int l, int r);

int main() {
  cin >> n;
  p.resize(n);
  memo.assign(n, vector<int>(3, -1));
  for (int &x : p) cin >> x;
  {
    auto f = [](P l, P r) { return min(l, r); };
    odd = SegmentTree<P>(n / 2, f, P(2 * n, 2 * n));
    ev = SegmentTree<P>(n / 2, f, P(2 * n, 2 * n));
    for (int i = 0; i < n / 2; ++i) {
      ev.update(i, P(p[2 * i], 2 * i));
      odd.update(i, P(p[2 * i + 1], 2 * i + 1));
    }
  }
  {
    auto f = [](int l, int r) { return v[l] > v[r]; };
    priority_queue<int, vector<int>, decltype(f)> pq(f);
    pq.push(solve(0, n));
    assert(v.size() == n / 2);
    while (pq.size()) {
      int now = pq.top();
      pq.pop();
      res.push_back(v[now]);
      for (int i = 0; i < 3; ++i)
        if (memo[now][i] >= 0) pq.push(memo[now][i]);
    }
  }
  for (int i = 0; i < n / 2; ++i)
    cout << res[i].first << " " << res[i].second << " \n"[i == n / 2 - 1];
  return 0;
}

int solve(int l, int r) {
  if (l >= r) return -1;
  int lid, rid;
  P now;
  if (l & 1) {
    P op = odd.query(l >> 1, r >> 1);
    lid = op.second;
    P ep = ev.query((lid + 1) >> 1, (r + 1) >> 1);
    rid = ep.second;
    now = P(op.first, ep.first);
  } else {
    P ep = ev.query((l + 1) >> 1, (r + 1) >> 1);
    lid = ep.second;
    P op = odd.query(lid >> 1, r >> 1);
    rid = op.second;
    now = P(ep.first, op.first);
  }
  int num = v.size();
  v.emplace_back(now);
  memo[num][0] = solve(l, lid);
  memo[num][1] = solve(lid + 1, rid);
  memo[num][2] = solve(rid + 1, r);
  return num;
}

Measured memory_bytes: 51080
def search(p, l, r)
  if l % p == 0
    return true
  else
    x = (l / p) * p + p
    return (x <= r) ? true : false
  end
end

l, r = gets.split.map(&:to_i)
if search(2019, l, r)
  puts 0
elsif search(3, l, r) && search(673, l, r)
  puts 0
else
  min = 2019
  for i in l..(r-1) do
    for j in (i+1)..r do
      res = i * j % 2019
      min = res if res < min
    end
  end
  puts min
end


Measured memory_bytes: 1788
n = int(input())
strings = [list(input()) for _ in range(n)]

s_1 = list(strings.pop(0))
for s in strings:
    tmp = []
    for s_tmp in s_1:
        if s_tmp in s:
            tmp.append(s_tmp)
            s.remove(s_tmp)
    else:
        s_1 = tmp
s_1.sort()
print(''.join(s_1))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int[] s = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				s[i] = sc.nextInt();
				sum += s[i];
			}
			double m = (double) sum / n;
			double std = 0.0;
			for (int i = 0; i < n; i++) {
				std += (s[i] - m) * (s[i] - n);
			}
			System.out.println(Math.sqrt(std / n));
		}

	}

}



Measured memory_bytes: 30888
#include <stdio.h>

int main(void)
{
	int a;
	char s[10];
	
	scanf("%d", &a);
	scanf("%s", s);
	
	if(a >= 3200){
		printf("%s\n", s);
	}
	else{
		printf("red\n");
	}
	return 0;
}


Measured memory_bytes: 128
D = int(input())
c = list(map(int, input().split()))
S = []
last = [0]*26

for _ in range(D):
  s = list(map(int, input().split()))
  S.append(s)

def sat(d):
  s = 0
  for i in range(26):
    s += c[i] * (d - last[i])
  return s

ans = 0

for i in range(D):
  t = int(input())
  ans += S[i][t-1]
  last[t-1] = i+1
  ans -= sat(i+1)
  print(ans)

Measured memory_bytes: 9240
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long

int d = 365;
vector<vector<int>> s(d, vector<int>(26, 0));
vector<int> c(26);
vector<int> t(d);

ll calc(vector<int> out) {
    ll score = 0;
    vector<ll> last(26, 0);
    for(int i = 0; i < out.size(); i++) {
        last[out[i]] = i+1;
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
        score += s[i][out[i]];
    }
    return score;
}

void init() {
    cin >> d;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    return;
}

int main() {
    init();
    vector<int> out;
    ll ans = 0;
    ll tmp = 0;
    for(int i = 0; i < d; i++) {
        ll max_v = 0;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            out.pop_back();
        }
        out.push_back(best);
    }
    
    for(int i = 0; i < d; i++) {
        cout << out[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
using ll = long long;

template <typename T>
class FenwickTree {
	const ll n;
	unordered_map<ll, T> data;
public:
	FenwickTree(ll n_, int pmax = 1e5) : n(n_), data(pmax) {}
	T find(ll p) {
		T res = 0;
		while (p >= 0) {
			res += data[p];
			p = (p & (p + 1)) - 1;
		}
		return res;
	}
	void add(ll p, T val) {
		while (p < n) {
			data[p] += val;
			p |= p + 1;
		}
	}
};

template <typename T>
class RARS {
	const ll n;
	FenwickTree<T> bit0, bit1;
public:
	RARS(ll n_) : n(n_), bit0(n), bit1(n) {}
	T find(ll p) {
		return bit1.find(p) * (p + 1) + bit0.find(p);
	}
	T find(ll l, ll r) {
		return find(r) - find(l - 1);
	}
	void add(ll l, ll r, T val) {
		bit0.add(l, -val * l);
		bit1.add(l, val);
		bit0.add(r + 1, val * (r + 1));
		bit1.add(r + 1, -val);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	RARS<ll> rars(n);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type >> s >> t; s--; t--;
		if (type) {
			printf("%lld\n", rars.find(s, t));
		}
		else {
			cin >> x;
			rars.add(s, t, x);
		}
	}
	return 0;
}



Measured memory_bytes: 10308
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    lint a, b, c, d, n;
    cin >> a >> b >> c >> d >> n;
    b = min(b, 2 * a);
    c = min(c, 2 * b);
    d = min(d, 2 * c);
    cout << n / 2 * d + n % 2 * c;
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
S= input()
q=int(input())
h=0
a=[]
for i in range(q):
    a.append(input())
t=""
w=""
for i in range(1,q+1):
    if a[q-i][0]=="2":
        if a[q - i][2] == "1":
            if h%2==0:
                t=t+a[q-i][4]
            else:
                w =  w+a[q - i][4]
        else:
            if h%2==0:
                w=w+a[q-i][4]
            else:
                t = t + a[q - i][4]
    else:
        h+=1
if h%2==0:
    print(t+S+w[::-1])
else:
    print(t+S[::-1]+w[::-1])

Measured memory_bytes: 16912
#include<stdio.h>

int main() {
  int n, m;
  int x, y;
  int i, j;
  int flag = 1;
  int sw[100000] = {};
  scanf("%d %d", &n, &m);
  for (i=0; i < m; i = i+1){
    scanf("%d %d", &x, &y);
    sw[x] = sw[x] + 1;
    sw[y] = sw[y] + 1;
  }
  for (i = 0; i < 100000; i = i+1){
    if (sw[i] % 2 == 1){
      flag = 0;
      break;
    }
  }
  if (flag == 1){
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

const int MAX_N = 50;

bool graph[MAX_N][MAX_N];
bool node[MAX_N];
vector<pair<int, int> > pairs;
int skip_node = 0;
int N, M;

int dfs(int id) {
    if (id > N)
        return 0;
    if (node[id])
        return 0;
    node[id] = true;
    int sum = 1;
    REP(i, 1, N + 1) {
        // cout << "debug: " << id << " " << i << " " << graph[id][i] << endl;
        if (!graph[id][i])
            continue;
        if (pairs[skip_node].first == i && pairs[skip_node].second == id)
            continue;
        if (pairs[skip_node].first == id && pairs[skip_node].second == i)
            continue;
        sum += dfs(i);
    }
    return sum;
}

int main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        pairs.push_back(make_pair(a, b));
        graph[a][b] = true;
        graph[b][a] = true;
    }
    int ans = 0;
    rep(i, M) {
        REP(i, 0, N + 1) node[i] = false;
        int node_num = dfs(1);
        // dump(node_num)
        if (node_num != N)
            ans += 1;
        skip_node += 1;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
 /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  char a,b;
  cin>>a>>b;
  if(a=='H')
  {
    if(b=='H')
    {
       cout<<"H"<<endl;
    }
    else
    {
      cout<<"D"<<endl;
    }
  }
  else
  {
    if(b=='H')
    {
          cout<<"D"<<endl;
    }
    else
    {
         cout<<"H"<<endl;
    }
  }

}
return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val pList = readLine()!!.split(' ').map(String::toLong)
    val sortedP = pList.sorted()

    var count = 0
    (0 until n).forEach { if (pList[it] != sortedP[it]) count++ }

    if (count <= 2) {
        println("YES")

    } else {
        println("NO")
    }
}

Measured memory_bytes: 36388
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

int main() {
    int num, weight;
    std::vector< std::pair<int, int> > list;
    std::vector< std::vector<int> > dp;
    std::cin >> num >> weight;
    for(int i = 0; i < num; i++) {
        int v, w;
        std::cin >> v >> w;
        list.push_back(std::make_pair(v, w));
    }
    dp.resize(num + 1);
    for(auto itr = dp.begin(); itr != dp.end(); itr++) {
        itr->resize(weight + 1);
    }

    for(int i = 0; i <= num; i++) {
        for(int j = 0; j <= weight; j++) {
            if(i == 0 || j == 0) {
                dp[i][j] = 0;
                continue;
            }

            dp[i][j] = dp[i - 1][j];

            int v = list[i - 1].first;
            int w = list[i - 1].second;
            if(w <= j) {
                dp[i][j] = std::max(dp[i][j], dp[i - 1][j - w] + v);
            }
        }
    }

    std::cout << dp.back().back() << std::endl;

    return 0;
}

Measured memory_bytes: 4956
// Copyright 2017 wu_qing
#include <stdint.h>
#include <cstdio>
#include <algorithm>
int64_t cur, tot, n, t, c;
int main() {
    scanf("%lld%lld", &n, &t);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &c);
        tot += std::min(t, c + t - cur);
        cur = c + t;
    }
    printf("%lld\n", tot);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct _nd {
	int cost;
	int x,y;
	int a,b,c;
};
int main()
{
	int h,w;
	const int dx[] = {0,1,0,-1}; // up, right, down, left
	const int dy[] = {-1,0,1,0};
	const int inf = 99999999;
	while( cin>>h>>w, h|w ){
		int field[10][10];
		int memo[7][7][7][10][10];
		int sx,sy,gx,gy;
		int ans = inf;
		
		for(int a=0; a<7; a++)for(int b=0; b<7; b++)for(int c=0; c<7; c++)
			for(int d=0; d<10; d++)for(int e=0; e<10; e++)memo[a][b][c][d][e] = inf;
		for(int i=0; i<h; i++)
			for(int j=0; j<w; j++)
				cin>>field[i][j];
		
		cin>>sy>>sx;
		cin>>gy>>gx;
		
		struct _nd nd;
		nd.cost = 0;
		nd.x=sx; nd.y=sy;
		nd.a=1; nd.b=2; nd.c=3;
		vector< struct _nd > vs;
		vs.push_back( nd );
		memo[1][2][3][sy][sx] = 0;
		while( vs.size() ){
			int tmin = inf;
			int ind;
			for(int i=0; i<vs.size(); i++){
				if( tmin > vs[i].cost ){
					tmin = vs[i].cost;
					ind = i;
				}
			}
			nd = vs[ind];
			if( (nd.x==gx && nd.y==gy) || nd.cost>=ans )break;
			vs.erase( vs.begin()+ind );
			
			for(int k=0; k<4; k++){
				int tx = nd.x + dx[k];
				int ty = nd.y + dy[k];
				int na = k==0 ? nd.b   : k==1 ? 7-nd.c : k==2 ? 7-nd.b : nd.c ;
				int nb = k==0 ? 7-nd.a : k==1 ? nd.b   : k==2 ? nd.a   : nd.b ;
				int nc = k==0 ? nd.c   : k==1 ? nd.a   : k==2 ? nd.c   : 7-nd.a ;
				
				//printf("k:%d  (%d,%d),[na:nb:nc]=[%d:%d:%d]\n",k,tx,ty,na,nb,nc);
				if( tx<0 || ty<0 || tx>=w || ty>=h ||
						memo[na][nb][nc][ty][tx] <= field[ty][tx]*(7-na)+nd.cost ) continue;
				//printf("k:%d  (%d,%d),[na:nb:nc]=[%d:%d:%d]  _old[%d:%d:%d]\n",k,tx,ty,na,nb,nc
				//																															,nd.a,nd.b,nd.c);
				memo[na][nb][nc][ty][tx] = field[ty][tx]*(7-na) + nd.cost;
				if( tx==gx && ty==gy ){ ans = min( ans, field[ty][tx]*(7-na) + nd.cost ); }
				//printf("memo[%d][%d][%d][%d][%d] = %d\n",na,nb,nc,ty,tx,field[ty][tx]*(7-na) + nd.cost);
				struct _nd tmp = {field[ty][tx]*(7-na)+nd.cost, tx, ty, na, nb, nc};
				vs.push_back( tmp );
			}
			//printf("_\n");
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
	int n;
	while(cin >> n, n) {
		int id, dis;
		id = -1, dis = -1;
		for(int i = 0; i < n; i++) {
			int p;
			int d1, d2; cin >> p >> d1 >> d2;
			if(dis < d1+d2) {
				id = p; dis = d1+d2;
			}
		}
		cout << id << " " << dis << endl;
	}
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define fs first 
#define sc second 
#define INF 1e9
#define LINF 1e15
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> P;


struct edge{
    ll from,to;   
};



ll n,m,k,s,p,q,c[100000] = {0},d[100000] = {0},cost[100000] = {0};
bool is_zombied[100000] = {false},is_used[100000] = {false},is_visited[100000] = {false};
vector<edge> G[100000];
queue<P> que;

void dijkstra(ll s){
    priority_queue<P , vector<P>,greater<P> > p_que;
    fill(d,d+n,LINF);
    d[s] = 0;
    p_que.push(P(0,s));
    
    while(!p_que.empty()){
        P pair_dijk = p_que.top(); p_que.pop();
        ll v = pair_dijk.sc;
        
        if(d[v] < pair_dijk.fs) continue;
        
        rep(i,0,G[v].size()){
            edge e = G[v][i];
            
            if(d[e.to] > d[v] + cost[e.to] && !is_used[e.to]){
                d[e.to] = d[v] + cost[e.to];
                p_que.push(P(d[e.to],e.to));
            }
        }
    }
    
    
    return;
}

int main(){
    cin >> n >> m >> k >> s >> p >> q;
    
    rep(i,0,k){
        cin >> c[i];
        c[i]--;
        is_used[c[i]] = true;
        is_zombied[c[i]] = true;
    }
    
    ll a,b;
    
    rep(i,0,m){
        cin >> a >> b;
        a--;b--;
        edge e;
        
        e.from = a; e.to = b;
        G[a].push_back(e);
        e.from = b; e.to = a;
        G[b].push_back(e);
    }
    
    rep(i,0,k){
        que.push(pair<ll, ll>(c[i],0));
        rep(i,0,n) is_visited[i] = false;
        is_visited[c[i]] = true;
        
        while(que.size()){
            P pair_bfs = que.front(); que.pop();
            
            rep(j,0,G[pair_bfs.fs].size()){
                if(!is_visited[G[pair_bfs.fs][j].to] && pair_bfs.sc < s){
                    is_zombied[G[pair_bfs.fs][j].to] = true;
                    is_visited[G[pair_bfs.fs][j].to] = true;
                    que.push(P(G[pair_bfs.fs][j].to, pair_bfs.sc+1));
                }
            }
        }
    }
    
    
    
    rep(i,0,n){
        if(i == n-1) cost[i] = 0;
        else if(is_zombied[i]) cost[i] = q;
        else cost[i] = p;
    }
    
    
    dijkstra(0);
    
    /*
    rep(i,0,n){
        cout <<i << " : " <<  d[i] << endl;
        
    }
  	*/
    
    cout << d[n-1] << endl;
    
    return 0;
}




Measured memory_bytes: 17956
<?php

$isBlow = function ($a, $b) {
    for ($i = 0; $i < 4; $i++) {
        yield $a[$i] == $b[$i] ? 1 : 0;
    }
};
while (true) {
    list($r, $a) = explode(' ', trim(fgets(STDIN)));
    if (0 == $r && 0 == $a) break;

    $cnt = 0;
    $r_dash = str_split($r);
    $a_dash = str_split($a);
    foreach ($isBlow($r_dash, $a_dash) as $num) {
        $cnt += $num;
    }

    $non_blow = count(array_diff($r_dash, $a_dash));
    list($hit, $blow) = array($cnt, 4 - $non_blow - $cnt);
    echo $hit . ' ' . $blow . PHP_EOL;
}


Measured memory_bytes: 9344
N = int(input())
S = input()
CNTR = 0
CNTG = 0
CNTB = 0
for i in range(N):
    if S[i] == 'R':
        CNTR += 1
    if S[i] == 'G':
        CNTG += 1
    if S[i] == 'B':
        CNTB += 1
CONB = CNTR * CNTG * CNTB
CNT = 0
for i in range(N):
    for j in range(i,N):
        if S[j] != S[i]:
            k = j + (j-i)
            if k > N-1:
                continue
            if S[k] != S[i] and S[k] != S[j]:
                CNT += 1
print(CONB - CNT)

Measured memory_bytes: 9200
n, d = map(int, input().split())
x = [[int(i) for i in input().split()] for i in range(n)] 
t = 0
ans = 0

for i in range(n): #1個目のセット
    for j in range(i+1,n): #2個目のセット
        for k in range(d): #セットからの取り出し
            t += (x[i][k]-x[j][k])**2
        tem = t**0.5
        t = 0
        if tem.is_integer():
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
using namespace std;
#define inRange(x,a,b) (a <= x && x <= b)

double p, e, t;

double dfs(int k, double l, double r){
    double m = (l+r)/2;
    if(k == 0){
        return inRange(m,t-e,t+e) ? 1.0 : 0.0;
    }
    if(r < t-e || l > t+e) return 0.0;
    if(t-e <= l && r <= t+e)    return 1.0;
    if(m >= t)    return (1-p)*dfs(k-1, l, m) + p*dfs(k-1, m, r);
    else          return p*dfs(k-1, l, m) + (1-p)*dfs(k-1, m, r);
}

int main(){
    int k;
    double l, r;
    cin >> k >> l >> r >> p >> e >> t;
    cout << fixed << setprecision(12) << dfs(k, l, r) << endl;
    return 0;
}


Measured memory_bytes: 3292
import sys
input = lambda : sys.stdin.readline().rstrip()

import heapq
h = []
heapq.heapify(h)

n, m, s = list(map(int, input().split()))
a, b = [[None] * m for _ in range(2)]
c, d = [[None] * n for _ in range(2)]

ns = {}
uv2e = {}
for i in range(m):
    u,v,a[i],b[i] = list(map(int, input().split()))
    ns.setdefault(u-1, set())
    ns.setdefault(v-1, set())
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
for i in range(n):
    c[i], d[i] = list(map(int, input().split()))

maxs = max(a)*(n-1)
s = min(s, maxs)
state = (0, 0, s) # (距離, ノード, 銀貨枚数)
ans = [[None] * (maxs+1) for _ in range(n)]
heapq.heappush(h, state)
count = 0
while h:
    count += 1
    dd, u, ss = heapq.heappop(h)
#     print(dd, u, ss)
    if ans[u][ss] is not None and ans[u][ss] <= dd:
        continue
    ans[u][ss] = dd
    
    # グラフの隣接点
    for v in ns[u]:
        e= uv2e[u,v]
        if ss<a[e] or ans[v][ss-a[e]] is not None:
            continue
        heapq.heappush(h, (dd + b[e], v, ss-a[e]))
    # 両替
    if ss+c[u] <= maxs:
        heapq.heappush(h, (dd + d[u], u, ss+c[u]))
    elif ss < maxs:
        heapq.heappush(h, (dd + d[u], u, maxs))

for item in ans[1:]:
    print(min(item))

Measured memory_bytes: 123684
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int N,K; cin >> N >> K;
    vector<int> v(N);
    REP(i,N) cin >> v[i];

    REP(i,N) {
        if (v[i] != 1) continue;
        // cerr << i << endl;
        auto left = i;
        auto right = N - i - 1;

        auto left_cost = (i+K-1-1)/(K-1);
        if (left_cost && (left_cost * (K-1)) > left) right -= (left_cost * (K-1)) - left;

        chmax(right,0);
        auto right_cost = (right+K-2)/(K-1);
        cout << left_cost+right_cost << endl;
    }
    assert("bugged");
}


int main() {
    solve();
    return 0;
}

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

int main() {
    int N, H, W;
    cin >> N >> H >> W;
    int A, B, ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> A >> B;
        if (A < H || B < W) continue;
        ans++;
    }
    cout << ans << 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++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S;
    string ans = "No";
    int N = S.size();
    REP(i, N/2) {
        if (S[i] != S[N-1-i]) {
            cout << ans << endl;
            return 0;
        }
    }
    REP(i,N/4) {
        if (S[i] != S[N/2-1-i]) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	string s;
	cin >> s;
	int ans = 0;
	rep(i, 0, s.size()) {
		if(s[i] == '+') ans++;
		else if(s[i] == '-') ans--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef vector<vector<ll>> vvll;

typedef pair<int, int> Pair;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

//nが素数かをO(√n)で判断
bool is_prime(int n) {
    bool res = true;

    if (n == 1) return false;
    else if (n == 2) return true;

    else {
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                res = false;
                break;
            }
        }
    }

    return res;
}



int perm(int n, int r) {
    if (r == 1) return n;
    return n * perm(n - 1, r - 1);
}

int fact(int n) {
    if (n == 1) return 1;
    return fact(n - 1) * n;
}

int comb(int n, int r) {
    int a = min(n, r), b = max(n, r);
    return perm(a, b) / fact(a);
}



/*
ll pow_mod(ll a, ll n, ll mod) {
    ll res = 1;

    ll base = a;
    while (n) {
        if (n & 1) res = res * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return res;
}
*/

//aの逆元　（a^(-1)）を求める
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

/*
ll fact_mod(ll n, ll mod) {
    if (n == 1) return 1;
    return n * fact_mod(n - 1, mod) * mod;
}
*/

// 階乗 (mod とりバージョン)
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}

ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

// 組み合わせ nCr を求める (modあり)
ll comb_mod(ll n, ll r, ll mod) {
    if (r > n - r) r = n - r;
    if (r == 0) return 1;
    ll a = 1;
    for (int i = 0; i < r; i++) a = a * ((n - i) % mod) % mod;
    ll b = pow_mod(fact_mod(r, mod), mod - 2, mod);
    return (a % mod) * (b % mod) % mod;
}











int main() {
    int x; cin >> x;
    cout << 1 - x << endl;
    return 0;
}

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

auto counter = 0;

void merge(vector<int> &S, int left, int mid, int right) {
  vector<int> lv(S.begin() + left, S.begin() + mid);
  vector<int> rv(S.begin() + mid, S.begin() + right);
  lv.push_back(SENTINEL);
  rv.push_back(SENTINEL);
  auto i = 0, j = 0;
  for (int k = left; k < right; k ++){
    counter ++;
    if (lv[i] <= rv[j]) {
      S[k] = lv[i++];
    } else {
      S[k] = rv[j++];
    }
  }
}

void merge_sort(vector<int> &S, int left, int right) {
  if (left + 1 < right) {
    auto mid = (left + right) / 2;
    merge_sort(S, left, mid);
    merge_sort(S, mid, right);
    merge(S, left, mid, right);
  }
}



int main() {
  int n;
  cin >> n;
  vector<int> S;
  int temp;
  rep(_, n) {
    cin >> temp;
    S.push_back(temp);
  }
  auto left = 0;
  auto right = int(S.size());
  merge_sort(S, left, right);
  auto first = true;
  for(auto &item: S) {
    if (first) {
      first = false;
      cout  << item;
    } else{
      cout << " " << item;
    }
  }
  cout << endl <<  counter << endl;
}



Measured memory_bytes: 8608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s="hi";
	string t;
	cin>>t;
	if(t.length()%2==0)
	{
		bool p=true;
		for(int i=0;i<t.length();i++)
		{
			if(i%2==0&&t[i]!='h')
			p=false;
			if(i%2==1&&t[i]!='i')
			p=false;
		}
		if(p)
		cout<<"Yes";
		else
		cout<<"No";
	}
	else
	cout<<"No";
} 

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.math;

void main(){
	int n = readln.chomp.to!int;
	int[] tmp = readln.chomp.split.map!(to!int).array;
	int t = tmp[0], a = tmp[1];
	int[] hs = readln.chomp.split.map!(to!int).array;
	
	real f(int x){
		return abs(a.to!real - (t.to!real - x.to!real * 0.006));
	}
	
	int i0 = 0;
	real min = f(hs[0]);
	for(int i = 0; i < n; i ++){
		if(f(hs[i]) < min){
			min = f(hs[i]);
			i0 = i;
		}
	}
	
	writeln(i0 + 1);
}


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

using namespace std;

void solve()
{
	int N, M;
	cin >> N >> M;
	vector<int> R(N);
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		--a; 
		--b;
		++R[a];
		++R[b];
	}
	for (int i = 0; i < N; ++i)
	{
		cout << R[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for _ in range(D)])


def s7(c, s, last_date, di, i, mul):
    score = s[di - 1][i]
    score += mul * c[i] * (di - last_date[i])
    return score


def f7(D, c, s):
    last_date = np.zeros(26)
    mul = np.mean(s) / np.mean(c)

    t = []
    for di in range(1, D + 1):
        score_list = []
        for i in range(26):
            score_list.append(s7(c, s, last_date, di, i, mul))

        select_index = score_list.index(max(score_list))
        t.append(select_index)
        last_date[select_index] = di

    return t


for ti in f7(D, c, s):
    print(ti + 1)

Measured memory_bytes: 27504
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
alist = list(sorted(d.keys(), reverse = True))
amax = alist[0]
t = 1
power_of_two = []
while t < 2 * amax:
  t *= 2
  power_of_two.append(t)
result = 0
for a in alist:
  if d[a] == 0:
    continue
  t = power_of_two[bisect_right(power_of_two, a)] - a
  if t not in d or d[t] == 0:
    continue
  if a != t:
    i = min(d[a], d[t])
  else:
    if d[a] == 1:
      continue
    i = d[a] // 2
  result += i
  d[a] -= i
  d[t] -= i
print(result)


Measured memory_bytes: 44592
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=100010;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,len,pos[N],sum[N];
char s[N],a[N];
inline bool check()
{
	For(i,1,len)if(a[i]!=a[len-i+1])return 0;
	return 1;
}
int main()
{
	file();
	scanf("%s",s+1);
	n=strlen(s+1);
	For(i,1,n)
	{
		if(s[i]!='x')a[++len]=s[i],pos[len]=i;
		sum[i]=sum[i-1]+(s[i]=='x');
	}
	pos[len+1]=n;
	if(check())
	{
		int ans=0;
		if(len&1)
		{
			int mid=(len+1)/2;
			For(i,1,mid)
			{
				int x=sum[pos[mid-i+1]]-sum[pos[mid-i]];
				int y=sum[pos[mid+i]]-sum[pos[mid+i-1]];
				ans+=max(x,y)-min(x,y);
			}
		}
		else
		{
			int mid=len/2;
			For(i,1,mid)
			{
				int x=sum[pos[mid-i+1]]-sum[pos[mid-i]];
				int y=sum[pos[mid+i+1]]-sum[pos[mid+i]];
				ans+=max(x,y)-min(x,y);
			}
		}
		printf("%d\n",ans);
	}
	else puts("-1");
	return 0;
}


Measured memory_bytes: 1280
def calc(x):
    if x == 'r': n = P
    elif x == 's': n = R
    else: n = S
    
    return n

N, K = map(int, input().split())
R, S, P = map(int, input().split())

T = input()

ans = 0
prev = [False] * K

for i in range(N):
    if i < K: ans += calc(T[i])
    else:
        if T[i] == T[i-K]:
            if not prev[i%K]: prev[i%K] = True
            else:
                ans += calc(T[i])
                prev[i%K] = False
            
        else: 
            ans += calc(T[i])
            prev[i%K] = False
            
print(ans)

Measured memory_bytes: 3956
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <functional>
#include <climits>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> v(3);
  for(int i=0;i<3;i++)cin>>v[i];
  sort(v.begin(),v.end());
  int cnt=0;
  for(int i=1;i<3;i++) cnt+=v[i]-v[i-1];
  cout<<cnt<<endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int cnt = 0;
    while (true) {
        int flag = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 1) flag = 1;
        }
        if (flag == 1) break;
        for (int i = 0; i < n; i++) {
            a[i] /= 2;
        }
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;
    
    while (1) {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?')    break;
        
        if (op == '+') {
            printf("%d\n", a + b);
        } else if (op == '-') {
            printf("%d\n", a - b);
        } else if (op == '*') {
            printf("%d\n", a * b);
        } else if (op == '/') {
            printf("%d\n", a / b);
        }
    }
    
    return 0;
}

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

int main(void) {

    int N;
    int a[100010];
    int b[100010];
    int c[100010];
    long long dp[100010][3];

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 1; i < N; i++) {
        dp[i][0] = max(dp[i-1][1] + a[i],dp[i-1][2] + a[i]);
        dp[i][1] = max(dp[i-1][0] + b[i],dp[i-1][2] + b[i]);
        dp[i][2] = max(dp[i-1][0] + c[i],dp[i-1][1] + c[i]);
    }

    cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])) << endl;

    return 0;

}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long r;
	cin >> r;
	
	cout << (r * r) << endl;

	return 0;
}

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

int main(){
    int n;
    cin>>n;
    string rep, prep;
    int l=0, r=n;

    cout<<0<<endl;
    cin>>prep;
    if(prep=="Vacant") return 0;

    while(1){
        int m=(l+r)/2;
        cout<<m<<endl;
        cin>>rep;
        if(rep=="Vacant") return 0;
        bool fa=((m-l)%2==0), fb=(prep!=rep);
        if((fa && fb) || ((!fa) && (!fb))) r=m;
        else{
            l=m;
            prep=rep;
        }
    }
    return 0;
}


Measured memory_bytes: 852
N = int(input())
ans = 0
for i in range(1, N+1):
  if i % 3 == 0 and i % 5 == 0:
    continue
  elif i % 3 == 0:
    continue
  elif i % 5 == 0:
    continue
  else:
    ans += i
print(ans)

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

int main() {
  string A, B;
  cin >> A >> B;
  string s = A + B;
  int t = stoi(s);
  bool can = false;
  for (int i = 1; i < 1000; i++) {
    if (t == pow(i, 2)) {
      can = true;
      break;
    }
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import fractions


def calc(x1, y1, x2, y2):
    return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2


n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    cx1, cy1, z1 = calc(x1, y1, x2, y2)
    cx2, cy2, z2 = calc(x1, y1, x3, y3)
    gcd = fractions.gcd(cx1, cx2)
    r1, r2 = cx2 // gcd, cx1 // gcd
    dcy = r1 * cy1 - r2 * cy2
    dz = r1 * z1 - r2 * z2
    y = dz / dcy
    x = (z1 - cy1 * y) / cx1 if cx1 else (z2 - cy2 * y) / cx2
    r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
    print('{:.3f} {:.3f} {:.3f}'.format(x, y, r))

Measured memory_bytes: 10160
N, K = list(map(int, input().split()))
d = [0] * K
A = set()

sunuke = [i for i in range(1, N+1)]
sunuke = set(sunuke)

for i in range(K):
    d[i] = int(input())
    a = (list(map(int, input().split())))
    for j in range(len(a)):
        A.add(a[j])
    a = []

ans = len(sunuke - A)

print(ans)

Measured memory_bytes: 9164
from math import ceil
from bisect import bisect

n, a, b = map(int, input().split())
raw_hs = [int(input()) for _ in range(n)]
hs = sorted(raw_hs, reverse=True)
diff = a - b

c_min = 0
c_max = int(10e9)

while c_max - c_min > 1:
	c = (c_min + c_max) // 2
	tmp_hs = [h - c * b for h in hs]
	rem = sum([ceil(h / diff) for h in tmp_hs if h > 0])
	if rem > c:
		c_min = c
	else:
		c_max = c

print(c_max)


Measured memory_bytes: 17312
#include<bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int N=2e5+100;
using namespace std;
int a[N];
int main()
{
	io;
	int n;
	while(cin>>n)
	{
		int sum=0;
		for(int i=1;i<=n;++i)cin>>a[i],sum+=a[i];
		int ave=sum/n;
		sort(a+1,a+1+n);
		int ans1=0;
		int ans2=0;
		int ans=INF;
		if(n&1)
		{
			for(int i=1;i<=n;++i)ans1+=(a[n/2+1]-a[i])*(a[n/2+1]-a[i]);
			ans=min(ans,ans1);
		}
		else 
		{
			for(int i=1;i<=n;++i)ans1+=(a[n/2+1]-a[i])*(a[n/2+1]-a[i]);
			for(int i=1;i<=n;++i)ans2+=(a[n/2]-a[i])*(a[n/2]-a[i]);
			ans=min(ans1,ans2);
		}
		for(int i=1;i<=n;i++)
		{
			ans1=0;
			ans2=0;
			for(int i=1;i<=n;++i)ans1+=(ave-a[i])*(ave-a[i]);
			for(int i=1;i<=n;++i)ans2+=(ave+1-a[i])*(ave+1-a[i]);
			ans=min(ans,ans1);
			ans=min(ans,ans2);
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	string S;
	int size,num,n;
	n = 0;
	num = 0;
	cin >> S;
	size = S.length();
	for (int i = 2; i <= size-2; i++) {
		if (S[i] == 'C')num++;
	}
	
	for (int i = 1; i <= size - 1; i++) {
		if ((S[i] == 'C') || (S[i] >= 'a'&&S[i] <= 'z'))n++;
	}
	
	if (S[0] == 'A'&&num == 1 && n == size - 1)cout << "AC" << endl;
	else cout << "WA" << endl;
}



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

using namespace std;
using ll = long long;

string s;

int main(){
    cin >> s;
    int n = s.size();
    int K = 0;
    if (n == 1) {
        K = 1;
    } else if (n % 2 == 0) {
        int cnt0 = 0;
        int i = n / 2 - 1;
        while (s[i] == '0' && s[n - 1 - i] == '0' && i >= 0){
        --i; cnt0++;
        }
        //cout << cnt0 << endl;
        K = n - (n / 2 - cnt0);

        int cnt1 = 0;
        i = n / 2 - 1;
        while (s[i] == '1' && s[n - 1 - i] == '1' && i >= 0){
        --i; cnt1++;
        }
        //cout << cnt1 << endl;
        K = max(K,n - (n / 2 - cnt1));
    } else {
        char c = s[n / 2];
        
        int cnt = 0;
        int i = n / 2 - 1;
        while (s[i] == c && s[n - 1 - i] == c && i >= 0){
        --i; cnt++;
        }
        K = n - (n / 2 - cnt);
    }
    

    cout << K << endl;
}


Measured memory_bytes: 1144