akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A, B, C;
string S[101010];
//---------------------------------------------------------------------------------------------------
vector<char> ans;
bool dfs(int cu, int a, int b, int c) {
	if (cu == N) return true;

	if (S[cu] == "AB") {
		if (a == 0 && b == 0) return false;
		if (0 < a && dfs(cu + 1, a - 1, b + 1, c)) {
			ans.push_back('B');
			return true;
		}
		if (0 < b && dfs(cu + 1, a + 1, b - 1, c)) {
			ans.push_back('A');
			return true;
		}
		return false;
	}

	if (S[cu] == "AC") {
		if (a == 0 && c == 0) return false;
		if (0 < a && dfs(cu + 1, a - 1, b, c + 1)) {
			ans.push_back('C');
			return true;
		}
		if (0 < c && dfs(cu + 1, a + 1, b, c - 1)) {
			ans.push_back('A');
			return true;
		}
		return false;
	}

	if (S[cu] == "BC") {
		if (b == 0 && c == 0) return false;
		if (0 < b && dfs(cu + 1, a, b - 1, c + 1)) {
			ans.push_back('C');
			return true;
		}
		if (0 < c && dfs(cu + 1, a, b + 1, c - 1)) {
			ans.push_back('B');
			return true;
		}
		return false;
	}
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> A >> B >> C;
	rep(i, 0, N) cin >> S[i];

	dfs(0, A, B, C);

	if (ans.size() == 0) cout << "No" << endl;
	else {
		printf("Yes\n");
		reverse(all(ans));
		fore(c, ans) printf("%c\n", c);
	}
}







Measured memory_bytes: 14896
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
int A,B,Q;
vector<ll> As,Bs,Qs;
ll INF=(ll)1000*1000*1000*1000;
int main() {
  cout << fixed << setprecision(15);
  cin >> A >> B >> Q;
  As.resize(A);Bs.resize(B);Qs.resize(Q);
  REP(i,A)
    As[i]=getll();
  REP(i,B)
    Bs[i]=getll();
  REP(i,Q) {
    ll x=getll();
    auto ita=lower_bound(ALL(As),x);
    auto itb=lower_bound(ALL(Bs),x);
    // only go left
    ll ans=INF;
    vector<ll> alis,blis;
    if (ita!=As.end()) {
      alis.pb(*ita);
    }
    if (itb!=Bs.end()) {
      blis.pb(*itb);
    }
    if (ita!=As.begin()) {
      ita--;
      alis.pb(*ita);
    }
    if (itb!=Bs.begin()) {
      itb--;
      blis.pb(*itb);
    }
    for(ll a:alis)
      for(ll b:blis) {
        ans = min(ans,abs(a-x)+abs(b-a));
        ans = min(ans,abs(b-x)+abs(b-a));
      }
    prl(ans);
    pr("\n");
  }


  return 0;
}


Measured memory_bytes: 3712
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#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--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    if (n % 2 == 0) {
        ll res = 0;
        ll div = 10;
        while (div <= n) {
            res += n / div;
            div *= 5;
        }
        cout << res << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;

int n, a[405];
ll dp[405][405], sum[405];

ll get(int l, int r);

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

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    fill(dp[0], dp[404] + 405, -1);

    cout << get(1, n);

    return 0;
}

ll get(int l, int r) {
    if (l >= r)
        return 0;

    if (dp[l][r] != -1)
        return dp[l][r];

    dp[l][r] = 1e18;

    for (int i = l; i < r; i++)
        umin(dp[l][r], get(l, i) + get(i + 1, r) + sum[r] - sum[l - 1]);

    return dp[l][r];
}

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

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

template<typename T>
vector<T> accum_sum(vector<T> a) {
    T l = a.size();
    vector<T> ret(l);

    ret[0] = a[0];

    repr(i, 1, l) {
        ret[i] = a[i] + ret[i - 1];
    }

    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) {
        cin >> a[i];
    }

    // 累積和
    vector<ll> a_sum(N);
    a_sum = accum_sum(a);

    ll min = -1;
    rep(i, N - 1) {
        // sunuke's sum of cards
        ll sum_1 = a_sum[i];
        // araiguma's sum of cards
        ll sum_2 = a_sum[N - 1] - a_sum[i];

        ll diff = abs(sum_1 - sum_2);

        if (min == -1 || diff < min) {
            min = diff;
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 6528
/*
n本の棒があり、各棒iの端点の座標は(pix,piy)と(qix,qiy)
指定されたm個の棒のペア(ai,bi)について、それらが連結であるか判定せよ。

2つの棒が共有点を持つとき連結
*/
using namespace std;
#include<iostream>
#include<cmath>
#include<algorithm>

const double EPS = 1e-10;
const double g = 9.8;
int N, V, X, Y;
int L[50], B[50], R[50], T[50];

//速度vyで上に打ち出した際のt秒後の位置を計算する
double calc(double vy, double t) {
    return vy * t - g * t * t / 2;
}
//aのlbとubに対する相対的な位置 -1 0 1 のどれかを返す
int cmp (double lb, double ub, double a) {
    return a < lb + EPS ? -1 : a > ub - EPS ? 1 : 0;
}
//点(qx,qy)を通るように打ち出したときに豚に卵をぶつけられるか判定
bool check(double qx, double qy) {
    //初速のx方向成分をvx, y方向成分をvyとし、(qx,qy)を通る時刻をtとしたときの連立方程式
    double a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
    double D = b * b - 4 * a * c;
    if (D < 0 && D > -EPS) D = 0;
    if (D < 0) return false;
    for (int d = -1; d <= 1; d+=2) { //連立方程式の二つの解を試すループ
        double t2 = (-b + d * sqrt(D)) / (2 * a);
        if (t2 <= 0) continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = (qy + g * t * t / 2) / t;

        //豚より上を通過できるか判定
        double yt = calc(vy, X / vx);
        if (yt < Y - EPS) continue;

        bool ok = true;
        for (int i = 0; i < N; i++) {
            if (L[i] >= X) continue;
            //豚の真上まで来たときに、間に障害物がないか判定
            if (R[i] == X && Y <= T[i] && B[i] <= yt) ok = false;
            //途中で障害物にぶつからないか判定
            int yL = cmp(B[i], T[i], calc(vy, L[i] / vx)); //左端での相対位置
            int yR = cmp(B[i], T[i], calc(vy, R[i] / vx)); //右端での相対位置
            int xH = cmp(L[i], R[i], vx * (vy / g)); //最も高くなる地点の相対位置
            int yH = cmp(B[i], T[i], calc(vy, vy / g)); //右端での相対位置
            if (xH == 0 && yH >= 0 && yL < 0) ok = false;
            if (yL * yR <= 0) ok = false;
        }
        if (ok) return true;
    }
    return false;
}

void solve() {
    //豚より右にある障害物を縮めておく
    for (int i = 0; i < N; i++) {
        R[i] = min(R[i], X);
    }
    bool ok = check(X, Y); //直接ぶつける
    for (int i = 0; i < N; i++) {
        ok |= check(L[i], T[i]); //左上の角を通る場合
        ok |= check(R[i], T[i]); //右上の角を通る場合
    }
    cout << (ok ? "Yes\n" : "No\n");
}

int main() {
    cin >> N >> V >> X >> Y;
    for (int i = 0; i < N; i++) {
        cin >> L[i] >> B[i] >> R[i] >> T[i];
    }
    solve();
}






Measured memory_bytes: 3092
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    boolean ok = true;

    int n = nextInt();
    int[] a = new int[n];
    for(int i=0;i<n;i++){
      a[i] = nextInt();
      if(a[i]%2==0){
        if(a[i]%3!=0 && a[i]%5!=0){
          ok = false;
        }
      }
    }

    if(ok){
      System.out.println("APPROVED");
    }
    else{
      System.out.println("DENIED");
    }

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 23764
X, N = list(map(int, input().split()))
if N == 0: print(X)
else:
    p = list(map(int, input().split()))
    if not X in p:
        print(X)
    else:
        q = [X-1, X+1]

        while True:

            if not q[0] in p:
                print(q[0])
                break
            elif not q[1] in p:
                print(q[1])
                break
            q = [q[0]-1, q[1]+1]

Measured memory_bytes: 9036
<?php
while(1) {
     if(feof(STDIN)) {
        break;
    }
    $a = trim(fgets(STDIN));
    $ff = explode(",",trim($a));
    if(isset($ff[1])) {
    $m[] = $ff[1];
        
    }
}
$bb = array(
    "A" => 0,
    "B" => 0,
    "AB" => 0,
    "O" => 0,
    );
foreach($m as $v) {
    $bb[$v]++;
}
foreach($bb as $k => $v) {
    echo $v . PHP_EOL;
}


Measured memory_bytes: 9268
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());

        for(int i = 0; i < 10; i++) {
            x = r * x - D;
            System.out.println(x);
        }
    }
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static List<ArrayList<Integer>> to;
	static int dp[];
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int N = fs.nextInt();
		to = new ArrayList<>();
		for(int i=0;i<N;i++) to.add(new ArrayList<Integer>());
		int edges[][] = new int[N-1][2]; //片方の頂点だけ分かればいい。ただしdfsの原点はだめ。
		for(int i=0;i<N-1;i++) {
			int A = fs.nextInt()-1, B = fs.nextInt()-1;
			to.get(A).add(B);
			to.get(B).add(A);
			edges[i][0] = B;
			edges[i][1] = A;
		}
		dp = new int[N];
		rec(0, -1);
		long mulsum = 0;
		for(int e[]:edges) {
			int candidate1 = e[0];
			int candidate2 = e[1];
			int child = candidate1;
			if(dp[candidate1]>dp[candidate2])child = candidate2;
			
			long a = dp[child];
			long b = N - a;

			long mul = (modpow(2, a) - 1)*(modpow(2, b) - 1)%mod;			
			mulsum += mul;
			mulsum %= mod;
			//分母は全てmodpow(2, n)になる
		}
		long cases = modpow(2, N);
		long PN = ((mulsum + (cases - (N+1) + mod)%mod ) %mod + N)%mod;//全ケースの含まれる頂点の合計
		long BN = N * modpow(2, N-1) %mod; 
		long WN = (PN - BN + mod)%mod;//期待値を出すまではできたようだけど
		long ans = WN * modpow(cases, mod-2);
		ans %= mod;
		
		System.out.println(ans);
	}
	
	static int rec(int v, int parent) {
		int res = 1;
		for(int next:to.get(v)) {
			if(next == parent) continue;
			res += rec(next, v);
		}
		return dp[v] = res;
	}
	

	static long modpow(long x, long y) {
		if(y==0) return 1;
		if(y%2!=0) return x * modpow(x, y-1) % mod;
		long tmp = modpow(x, y/2);
		return tmp * tmp % mod; 
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 109400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC161B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            string[] Ainput = Console.ReadLine().Split(' ');
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Ainput[i]);
            }
            int sum = A.Sum();
            //Console.WriteLine(sum);
            Array.Sort(A);
            Array.Reverse(A);
            //Console.WriteLine(A[0]);
            if (A[M - 1] * 4 * M >= sum)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27852
n = int(input())
sp ={}
l = [] 
for i in range(n):
    s,p = input().split()
    sp ={}
    sp["index"] = i+1
    sp["name"] = s
    sp["score"] = int(p)
    l.append(sp)


for dic in sorted(l, key=lambda x: (x["name"], -x["score"])):
    print(dic["index"])

Measured memory_bytes: 9192
until (a = $<.gets.split.map(&:to_i)) == [0, 0]
  n, m = a
  circle = [*1..n]
  try = ->(po) {
    return circle.first if circle.size == 1
    po += m - 1
    po = po - circle.size while po >= circle.size
    circle = circle[0...po] + circle[po + 1..-1]
    try.(po)
  }
  puts try.(n)
end


Measured memory_bytes: 18840
import sys
from itertools import combinations
N = int(input())

S = [0] * N

S_dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(N):
    S[i] = str(input())
    if S[i][0] in S_dic.keys():
        S_dic[S[i][0]] += 1

zero_count = 0
for value in S_dic.values():
    if value == 0:
        zero_count += 1
if zero_count >= 3:
    print(0)
    sys.exit()

total = 0
for item in list(combinations(S_dic.keys(), 3)):
    total += (S_dic[item[0]] * S_dic[item[1]] * S_dic[item[2]])
print(total)

Measured memory_bytes: 9716
#include<stdio.h>
#define m 1000000007
#define LL long long int

LL modpow(LL a, LL b, LL mod){
	LL ret = 1;
	for(a %= mod; b; a = a * a % mod, b = b>>1){
		if(b&1) ret = ret * a % mod;
	}
	return ret;
}

int main(){
	int N, K;
	scanf("%d %d", &N, &K);
	LL a[K + 1];
	int b, i, x;
	LL ret = 0;
	for(x = K; x >= 1; x--){
		b = 1;
		b = modpow(K/x, N, m);
		a[x] = b;
		for(i = 2; i <= K/x; i++){
			a[x] = a[x] - a[i*x];
		}
		//printf("%lld\n", a[x]);
	}
	for(i = 1; i <= K; i++){
		ret = ret + (a[i]%m) * (i %m);
		ret = ret%m;
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 2956
#include <iostream>
using namespace std;
 
int main()
{
int x,y;
   scanf("%d%d",&x,&y);
  int a=(y-(x*2));
  if(a!=0)
  a=a/2;
  else
  a=0;
  int b=((x*4)-y);
  if(b!=0)
  b=b/2;
  else
  b=0;
  if(((a+b))==x && a>=0 && b>=0)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  ll id;
  for(ll i=1;i<=n;i++) {
    ll a;
    cin >> a;
    if(a==1) id=i;
  }
  cout << ((n-1)+k-2)/(k-1) << endl;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,ans=0;
    string s;
    cin >> n >> s;
    for(i=0;i<n-2;i++)
    {
        if(s[i] == 'A'  &&  s[i+1] == 'B'  &&  s[i+2] == 'C')++ans,i+=2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 892
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

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

  int n,m;
  string s,t;
  cin >> s >> t;
  n = s.size();
  m = t.size();
  for (int i = 0; i < n+m; i++){
    if (i % 2 == 0){
      cout << s[i/2];
    }else{
      cout << t[i/2];
    }  
  }
  
  cout << '\n';

  return 0;
}

Measured memory_bytes: 3556
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
const ll M=1e5+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll n;
ld x,d;
ld res;

int main()
{
    cin >> n >> x >> d;
    while (n)
    {
        res+=x+(2*n-1)*d/2;
        ld xp=(n+1)*x/n+5*d/(2*n);
        d+=2*d/n;
        x=xp;
        n--;
    }
    RETD(res);            
}    


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

using namespace std;


int main()
{
	string str;
	cin >> str;

	for (int i = 0; i < str.length() - 1; i++) {
		if (str[i] == str[i + 1]) {
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    string a[1000];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    for(int i = 0; i < n; i++){
        cout << a[i];
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    """
    Nを-2べきで展開したときの末端項がmod 2で決定できるから
    末尾から再帰的に桁が決められたのか。。。
    """
    N = int(input())
    if N == 0:
        print(0)
        return
    idx = 0
    ans = deque([])
    while N != 0:
        if N % 2 == 0:
            ans.appendleft(0)
        if N % 2 != 0:
            ans.appendleft(1)
            N -= (-1) ** idx
        N //= 2
        idx += 1
    print("".join(map(str, ans)))    

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void doIt() {
		sB();
	}
	
	void sB() {
		int cnt[] = new int[5];
		Arrays.fill(cnt, 0);
		for(int i = 0; i < 3; i++) {
			cnt[sc.nextInt()]++;
			cnt[sc.nextInt()]++;
		}
		int one = 0, two = 0;
		for(int i = 1; i <= 4; i++) {
			if(cnt[i] == 1) one++;
			else if(cnt[i] == 2) two++;
		}
		if(one == 2 && two == 2) {
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23380
#include <iostream>

using namespace std;

int main(void)
{
	int n;
	cin.exceptions(ios::failbit);

	try{
		cin >> n;
	}
	catch (...)
	{
		return 0;
	}

	if (n > 0 && n < 1000)
	{
		int tmp = n % 100;
		tmp = tmp % 10;

		if (tmp == 3)
		{
			cout << "bon" << endl;
		}
		else if (tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8)
		{
			cout << "pon" << endl;
		}
		else
		{
			cout << "hon" << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 3636
use std::io::stdin;

fn main() {
    let n = read_vec()[0];
    let ta: Vec<i64> = read_vec();
    let h: Vec<u64> = read_vec();
    
    let mut min_index = 0;
    let mut min = -1.;
    for i in 0..n {
        let tt = h[i as usize] as f64 * 0.006;
        let m = ta[0] as f64 - tt - ta[1] as f64;
        let m = if m < 0. {
            m * -1.
        } else {
            m
        };
        if min == -1. {
            min = m;
            min_index = i;
        } else {
            if min > m {
                min = m;
                min_index = i;
            }
        }
    }
    println!("{}", min_index + 1);
}

fn read_vec<T>() -> Vec<T> where T: std::str::FromStr,
          <T as std::str::FromStr>::Err: std::fmt::Debug
{
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    
    s.trim().split(" ").map(|s| s.parse().unwrap()).collect::<Vec<T>>()
}

Measured memory_bytes: 4352
import sys
S = input()
if S[0] == 'A' and S[2:-1].count('C') == 1:
    S = list(S)
    S.remove('A')
    S.remove('C')
    S = ''.join(S)
    if S == S.lower():
        print('AC')
        sys.exit(0)
print('WA')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    if (n>=30)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, m, ans = 1e9, max, mn;
  scanf("%lld%lld", &n, &m);
  ll a[n][m], now[n], cnt[m];
  bool flg[m];
  for(i = 0; i < n; ++i) for(j = 0; j < m; ++j) scanf("%lld", &a[i][j]), a[i][j]--;
  for(i = 0; i < n; ++i) now[i] = 0;
  for(i = 0; i < m; ++i) flg[i] = false;
  for(i = 0; i < m; ++i) {
    for(j = 0; j < m; ++j) cnt[j] = 0;
    for(j = 0; j < n; ++j) cnt[a[j][now[j]]]++;
    max = 0;
    for(j = 0; j < m; ++j) if(max < cnt[j]) max = cnt[j], mn = j;
    if(ans > max) ans = max;
    flg[mn] = true;
    for(j = 0; j < n; ++j) for(; now[j] < m && flg[a[j][now[j]]]; ++now[j]);
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 896
/* 
    Reverse the problem: Imagine we have stick of length N and are told to cut it in the specified places*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
 
const int MOD = 1e9+7;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    int n;
    cin >> n;
    vector<vector<int>> can(n, vector<int>(n));
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            cin >> can[i][j];
        }
    }

    int limit = 1 << n;
    vector<int> dp(limit);
    dp[0] = 1;

    for(int i = 1; i < limit; ++i)
    {
        int numOn = __builtin_popcount(i);
        for(int b = 0; b < n; ++b)
        {
            if(can[numOn-1][b] && (i & (1<<b)))
            {
                dp[i] += dp[i ^ (1<<b)];
                if(dp[i] >= MOD) dp[i] %= MOD;
            }
        }
    }
    cout << dp[limit-1] << "\n";
    return 0; 
}

Measured memory_bytes: 8448
N = int(input())
H = list(map(int, input().split()))
th = H[0]
f = True
for i in range(1, N):
    if th <= H[i]:
        th = H[i]
    if H[i] < th - 1:
        f = False
        break
if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
int n,a[1000005],b[1000005],s,jc[1000005]= {1,1,0,0},ny[1000005]= {1,1,0,0};
int Power(int x,int y,int mod) {
	int ret=1;
	while(y) {
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod,y>>=1;
	}
	return ret;
}
int C(int n,int m,int p) {
	if(n<m)return 0;
	return 1ll*jc[n]*ny[m]%p*ny[n-m]%p;
}
int Lucas(int n,int m,int p) {
	if(n<m)return 0;
	if(!n)return 1;
	return 1ll*Lucas(n/p,m/p,p)*C(n%p,m%p,p)%p;
}
int main() {
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		char x;
		cin>>x;
		a[i]=x-'0';
	}
	int flag=1;
	yyyy:;
	s=0;
	for(int i=1; i<=n; i++)s+=1ll*a[i]*Lucas(n-1,i-1,2);
	if(s%2)return cout<<flag,0;
	int tot=0,cnt[5]= {0};
	for(int i=1; i<=n; i++) {
		b[++tot]=a[i];
	}
	for(int i=1; i<tot; i++)a[i]=abs(b[i]-b[i+1]),cnt[a[i]]++;
	n=tot-1;
	if(cnt[1]||cnt[0]==n)return puts("0"),0;
	for(int i=1; i<tot; i++)a[i]/=2;
	flag=2;
	goto yyyy;
	return 0;
}

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

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

    ll ans = 1000;
    for (int i = 1; i < n; i++)
    {
        if (a[i] > a[i - 1])
        {
            ll t = ans / a[i - 1];
            ans += t * (a[i] - a[i - 1]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
import collections
n = int(input())
a = list(map(int,input().split()))

count = collections.Counter(a)
rmv = 0

for i in count:
    if count[i] >= 2 and count[i]%2 == 1:
        rmv += (count[i]-1)
        count[i] = 1
    elif count[i] >= 2:
        rmv += (count[i]-2)
        count[i] = 2

two = 0
for i in count:
    if count[i] == 2:
        two += 1
if two%2 == 0:
    rmv += two
else:
    rmv += two+1
print(n-rmv)

Measured memory_bytes: 18656
#include<bits/stdc++.h>
using namespace std;
struct q
{
long b;
long s;
long t1;
long t2;
};
long long rmax(long a,long b,long c)
{
if(a>=b && a>=c)
return 1;
else if(b>=a && b>=c)
return 2;
else return 3;
}
long long rnext(long a,long b,long c)
{
if((a>=b && a<=c) || (a>=c && a<=b))
return 1;
else if((c>=b && c<=a) || (c<=b && c>=a))
return 3;
else return 2;
} 

int main()
{
long long n;
cin>>n;
long  arr[n][3];
long a,b,c;
long int j[3];

for(long i=0;i<n;i++)
{
cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
}
long long dp[n][3];
dp[0][0]=arr[0][0];
dp[0][1]=arr[0][1];
dp[0][2]=arr[0][2];
for(long i=1;i<n;i++)
{
dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
}
long long ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
cout<<ans<<endl;
return 0;
}



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

int main() {
   int m,n;
   cin >> m >> n;
   long long count=1;
   long long M=m;
   while(true) {
       if (n==0) break;
       if (n%2==1) {
           count*=M;
           count%=1000000007;
       }
       M*=M;
       M%=1000000007;
       n/=2;
   }
   cout << count << endl;
}


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

int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void){

  long x,y,a,b,c;
  scanf("%ld %ld %ld %ld %ld", &x, &y, &a, &b, &c);
  long p[a];
  for (long i = 0; i < a; i++) {
    scanf("%ld", &p[i]);
  }
  long q[b];
  for (long i = 0; i < b; i++) {
    scanf("%ld", &q[i]);
  }
  long r[c];
  for (long i = 0; i < c; i++) {
    scanf("%ld", &r[i]);
  }

  qsort(p, sizeof(p) / sizeof(p[0]), sizeof(long), cmpnum);
  qsort(q, sizeof(q) / sizeof(q[0]), sizeof(long), cmpnum);
  qsort(r, sizeof(r) / sizeof(r[0]), sizeof(long), cmpnum);

  long left[x+y+c];
  for (long i = 0; i < x; i++) {
    left[i] = p[i];
  }
  for (long i = 0; i < y; i++) {
    left[x+i] = q[i];
  }
  for (long i = 0; i < c; i++) {
    left[x+y+i] = r[i];
  }

  qsort(left, sizeof(left) / sizeof(left[0]), sizeof(long), cmpnum);

  long score = 0;
  for (long i = 0; i < x+y; i++) {
    score += left[i];
  }

  printf("%ld\n", score);

  return 0;
}

Measured memory_bytes: 7660
#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>;

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

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      ;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define LL long long
#define mod 1000000007
#define N 200100
using namespace std;

int d1[N],d2[N],n;

inline int qr()
{
	char a=0;int w=1,x=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<1)+(x<<3)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	n=qr();
	for(register int i=1;i<=n;i++)
	{
		int x,y;
		x=qr();
		y=qr();
		d1[i]=x+y;
		d2[i]=x-y;
	}
	sort(d1+1,d1+n+1);
	sort(d2+1,d2+n+1);
	printf("%d\n",max(abs(d1[n]-d1[1]),abs(d2[n]-d2[1])));
	return 0;
} 

Measured memory_bytes: 5268
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

struct UnionFind{
    vint v;
    UnionFind(int n){ v.assign(n,-1); }
    int  find(int x){ return v[x]<0? x:v[x]=find(v[x]); }
    void unite(int x,int y){
        x=find(x),y=find(y); if(x==y) return;
        if(v[x]>v[y]) swap(x,y); v[x]+=v[y],v[y]=x;
    }
    int  size(int x){ return -v[find(x)]; }
    bool same(int x,int y){ return find(x)==find(y); }
    bool root(int x){ return v[x]<0; }
};

signed main()
{   
    int N,M; cin>>N>>M;
    vint a(M),b(M);
    REP(i,M){
        cin>>a[i]>>b[i];
        a[i]--; b[i]--;
    }

    vint ans(M);
    ans[M-1]=N*(N-1)/2;
    UnionFind tree(N);

    for(int i=M-1;i>=1;i--){
        if(tree.same(a[i],b[i])) ans[i-1]=ans[i];
        else{
            ans[i-1]=ans[i]-tree.size(a[i])*tree.size(b[i]);
            tree.unite(a[i],b[i]);
        }
    }
    REP(i,M) cout<<ans[i]<<endl;
}


Measured memory_bytes: 4480
import queue

N = int(input())
S = list(input())

R, W = queue.PriorityQueue(), queue.PriorityQueue()
for i in range(N):
    if S[i] == 'R':
        R.put(-i)
    else:
        W.put(i)

steps = 0
while True:
    if R.qsize() == 0 or W.qsize() == 0:
        break
    r, w = -R.get(), W.get()
    if r < w:
        break
    steps += 1

print(steps)



Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  ll N,K;
  cin>>N>>K;
  if(K==1){
    cout<<N*N*N<<endl;
  }else if(K%2==1){
    ll x=N/K;
    cout<<x*x*x<<endl;
  }else{
    ll x=N/K;
    ll y=N/(K/2)-x;
    cout<<x*x*x+y*y*y<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
    double x1 = kbd.nextDouble();
    double y1 = kbd.nextDouble();
    double x2 = kbd.nextDouble();
    double y2 = kbd.nextDouble();
    double d = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    d = Math.sqrt(d);
    System.out.println(d);
    }
}

Measured memory_bytes: 18300
#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;


int gcd(int x, int y)
{
    int r;

    if(x == 0 || y == 0)  // 引数チェック                                                                              
    {
        return 0;
    }

    // ユーグリッドの互除法                                                                                            
    while((r = x % y) != 0)  // yで割り切れるまでループ                                                                
    {
        x = y;
        y = r;
    }
    return y;
}


int main()
{
  long long N, X;
  cin >> N >> X;

  vector <long long> x(N);
  for( int i=0;i<N;i++ )
    {
      cin >> x[i];
      x[i] = abs(x[i]-X);
    }

  long long ans = x[0];
  for( auto xx: x)
    {
      ans = gcd(ans, xx);
    }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int ans;
int main() {
	string h;
	cin >> h;
	for (int i = 0; i < h.length(); ++i) {
		if (ans % 2 == 0 && h[i] == 'A') { ++ans; }
		else if (ans % 2 == 1 && h[i] == 'Z') { ++ans; }
	}
	if (ans % 2) { --ans; }
	if (ans == 0) { cout << -1 << endl; }
	else {
		for (int i = 0; i < ans; ++i) {
			if (i % 2 == 0) { cout << 'A'; }
			else { cout << "Z"; }
		}
		cout << endl;
	}
}


Measured memory_bytes: 3224
#include<iostream>
using namespace std;
int main(){
 	int n,x;
  	int sum;
  	cin>>n;
  for(int i=0;i<n;i++){
   	cin>>x;
    int tmp=0;
    while(x%2==0){
     	tmp++;
     x/=2;
    }
    sum+=tmp;
  }
  cout<<sum;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

template <typename Tp>Tp Max(const Tp &a, const Tp &b) {return a > b ? a : b;}
template <typename Tp>Tp Min(const Tp &a, const Tp &b) {return a < b ? a : b;}

template <typename Tp>void Read(Tp &x) {
    Tp in = 0, f = 1; char ch = getchar();
    while(ch<'0' || ch >'9') {if(ch=='-') f = -1; ch = getchar();}
    while(ch>='0' && ch<='9') {in = in * 10 + ch - '0'; ch = getchar();}
    x = in * f;
}

int a[4];

bool cmp(int a, int b) {
    return a > b;
}

int main() {

    Read(a[1]), Read(a[2]), Read(a[3]);

    std :: sort(a + 1, a + 3 + 1, cmp);

    int A = a[1] - a[2], B = a[1] - a[3];

    int ans = 0;
    
    if((A - B) % 2) ans++, A++;

    ans += B, A -= B;

    if(A) ans += A / 2;

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<string> S(N);
		rep(i, N) cin >> S[i];
		sort(S.begin(), S.end());
		vector<string> ans;
		UL n = 1;
		UL p = 1;
		ans.push_back(S[0]);
		for (UL i = 1; i < N; i++) {
			if (S[i] == S[i - 1]) { p++; }
			else { p = 1; }
			if (n == p) ans.push_back(S[i]);
			if (n < p) { ans.clear(); ans.push_back(S[i]); n = p; }
		}
		rep(i, ans.size()) cout << ans[i] << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 15988
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        k: usize,
        a: [[Usize1]; k],
    }
    println!("{}",
             (0..n).into_iter().filter(|i| a.iter().all(|a| ! a.contains(&i))).count());
}


Measured memory_bytes: 2196
#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() {
  int n;
  cin >> n;
  vector<int> ans(n);
  rep(i, n-1) {
    int x;
    cin >> x;
    ans[x-1]++;
  }
  for (int a : ans) {
    cout << a << '\n';
  }
  return 0;
}

Measured memory_bytes: 4056
#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() {
  int x,n,mi=1000,ans;
  cin >>x>>n;
  vector<int> w(120),work(n);
  iota(w.begin(),w.end(), 0);
  rep(i,n){
    cin>> work[i];
  }
  sort(work.begin(),work.end());
  rep(i,work.size()){
    w.erase(w.begin()+work[i]-i);
  }
  rep(i,w.size()){
    if(abs(x-w[i])<mi){
      mi=abs(x-w[i]);
      ans=w[i];
    }
  }
  cout << ans<<endl;
}

Measured memory_bytes: 3592
import math
n = int(raw_input())
x = []
y = []
# input part
in_line = raw_input().split()
for i in range(n):
    x.append(float(in_line[i]))
in_line = raw_input().split()
for i in range(n):
    y.append(float(in_line[i]))
# output part
# p=1
d = 0.0
for i in range(n):
    d += math.fabs(x[i]-y[i])
print d
# p=2
d = 0.0
for i in range(n):
    d += math.fabs(x[i]-y[i])**2
print math.sqrt(d)
# p=3
d = 0.0
for i in range(n):
    d += math.fabs(x[i]-y[i])**3
print d**(1.0/3.0)
# p=inf
d = 0.0
for i in range(n):
    if d < math.fabs(x[i]-y[i]):
        d = math.fabs(x[i]-y[i])
print d

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

int main(void){
    int N, M;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
    }
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++) {
        cin >> t.at(i);
    }
    
    int X = 0;
    for (int i = 0; i < N; i++) {
        int tmp_X = 0;
        for (int j = 0; j < N; j++) {
            if (s.at(i) == s.at(j)) {
                tmp_X++;
            }            
        }
        for (int j = 0; j < M; j++) {
            if (s.at(i) == t.at(j)) {
                tmp_X--;
            }
        }
        if (tmp_X > X) {
            X = tmp_X;
        }
    }
    
    cout << X << endl;
}

Measured memory_bytes: 256
//Author: Abitnav
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){

ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	int n,m,c=0,t=1,i,j,k,sum=0,ans,f=0,x,y;
	//cin>>t;
	while(t--){
		//vector<int> v;map<int,int> mp;set<int> st;
		cin>>n;
		double pi=3.1415926535;
		double ans=2*(pi*n);
		printf("%0.15lf",ans);
		//int a[n];rep(i,n) cin>>a[i];

	}
	return 0;
}













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

int main()
{int n,ans = 0;
cin>>n;
string s ;
cin>>s;
string z(s);
sort(s.begin(),s.end());
for(int i =0 ;i<n;i++)
if(z[i]!=s[i])
ans++;
cout<<(ans+1)/2<<endl;

       return 0;
}

Measured memory_bytes: 3816
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
 
using namespace std;
 
#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair
 
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;
 
typedef pair<int,string> pis;
 
bool cmp(const pii& a,const pii& b)
{
    return a.first==b.first?a.second<b.second:a.first>b.first;
}
 
bool ok(vector<pii>& favs,vector<pii>& oths,int k,int l,int num)
{
    if(oths.size()<=k-num)
        return true;
     
    ll need=0;
    rep(i,num){
        if(favs[i].first>oths[k-num].first)
            continue;
        else{
            int diff=oths[k-num].first-favs[i].first;
            bool after=favs[i].second>oths[k-num].second;
            need+=diff+after;
        }
    }
    return need<=l;
}
 
void solve(vs& names,vi& votes,vs& fnames,int k,int l)
{
    int n=names.size(),m=fnames.size();
     
    vector<pii> favs,oths; // vote,id
    {
        map<string,int> ma;
        rep(i,n)
            ma[names[i]]=0;
        {int i=0; foreach(it,ma)
            it->second=i++;
        }
        vi isfav(n);
        rep(i,m)
            isfav[ma[fnames[i]]]=1;
        rep(i,n){
            vector<pii>& chrs=isfav[ma[names[i]]]?favs:oths;
            chrs.push_back(mp(votes[i],ma[names[i]]));
        }
    }
     
    sort(allof(favs),cmp);
    sort(allof(oths),cmp);
     
    int left=0,right=1+min(m,k);
    while(right-left>1){
        int mid=(left+right)/2;
        if(ok(favs,oths,k,l,mid))
            left=mid;
        else
            right=mid;
    }
     
    cout<<left<<endl;
}
 
int main()
{
    for(int n,m,k,l;scanf("%d%d%d%d",&n,&m,&k,&l),n|m|k|l;){
        vs names(n);
        vi votes(n);
        for(int i=0;i<n;i++){
            char tmp[11];
            scanf("%s%d",tmp,&votes[i]);
            names[i]=tmp;
        }
        vs favs(m);
        rep(i,m){
            char tmp[11];
            scanf("%s",tmp);
            favs[i]=tmp;
        }
        solve(names,votes,favs,k,l);
    }
     
    return 0;
}


Measured memory_bytes: 22272