akhauriyash/Code-Regression huggingface dataset:
'use strict'

function myXor(a,b){
	let sa = a.toString(2);
	let sb = b.toString(2);
	if(sa.length < sb.length){
		sa = ('0000000000000000000000000000000000000000000000000000000000000000000000'+sa).slice(-sb.length);
	}else if(sa.length > sb.length){
		sb = ('0000000000000000000000000000000000000000000000000000000000000000000000'+sb).slice(-sa.length);
	}


	let answer = 0;
	let bi = 1;
	for(let i=sa.length-1;i>=0;i--){
		if((sa[i]==="0"&&sb[i]==="1")||(sa[i]==="1"&&sb[i]==="0")){
			answer += bi;
		}
		bi *= 2;
	}
	// console.log(sa);
	// console.log(sb);
	// console.log("--------------------------");
	// console.log(('0000000000000000000000000000000000000000000000000000000000000000000000'+answer.toString(2)).slice(-sa.length));
	return answer;
}

function myShift(b,n){
	for(let i=0;i<n;i++){
		b *= 2;
	}
	return b;
}

function count1(X,i){
	let n = X % myShift(1,i);
	//console.log("n:",X,myShift(1,i));
	if(n < myShift(1,(i-1))) return 0;
	
	//console.log("return:",(X+1)%2)
	return (X+1)%2;
}

function getXorNumber(X){
	// //console.log("------",X);
	// let answer = new Number(0);

	// //2進1桁目だけ別計算
	// answer += Math.floor((X+1)/2)%2;

	// //console.log("bit:",1,answer,answer);

	// //2進2桁目以降
	// let bit = new Number(0);
	// for(let i=2;i<52;i++){
	// 	bit = 1;
	// 	for(let j=1;j<i;j++) bit *= 2;
	// 	if(bit > X) break;

	// 	if(count1(X,i) === 1) answer += bit;

	// 	//console.log("bit:",i,bit,answer);
	// }
	// return answer;

	if((X%2)===0){
		//偶数なら
		return myXor(Math.floor(((X-1)/2)+1)%2,X);
	}else{
		//奇数なら
		return Math.floor(((X-1)/2)+1)%2;
	}
}

function Main(input){
	let temp = input.trim().split(" ");
	let A = parseInt(temp[0]);
	let B = parseInt(temp[1]);

	if(A===B || A===0){
		console.log(B);
		return;
	}
	let u = getXorNumber(B);
	let l = getXorNumber(A-1);
	// console.log(u.toString(2));
	// console.log(l.toString(2));
	console.log(myXor(u,l));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
int high[100005],a[100005];
int main()
{
	ll x;
	scl(x);
	for(ll i=-200;i<=200;i++){
		for(ll j=-200;j<i;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){
				pf("%lld %lld\n",i,j);return 0;
			}
		}
	}
}


Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#define ll long long
#define INF (1<<30)
using namespace std;
int dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
struct Castle {
	int h;
	int w;
	int times;
};
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll H, W; cin >> H >> W;
	vector<vector<char>> sand(H, vector<char>(W));
	vector<vector<int>> m(H, vector<int>(W, 0));
	queue<Castle> q;
	for (int i = 0; i < H;i++) for (int j = 0; j < W;j++) cin >> sand[i][j];
	for (int i = 0; i < H;i++) {
		for (int j = 0; j < W;j++) {
			if (sand[i][j] == '.') m[i][j] = INF;
			else {
				for (int k = 0; k < 8;k++) {
					int vi = i + dx[k];
					int vj = j + dy[k];
					if (sand[vi][vj] == '.')m[i][j]++;
				}
				if (m[i][j] >= sand[i][j] - '0') {
					q.push({ i,j,1 });
				}
			}
		}
	}
	int ret = 0;
	while (!q.empty()) {
		Castle cas = q.front(); q.pop();
		ret = cas.times;
		for (int k = 0; k < 8;k++) {
			int vi = cas.h + dx[k];
			int vj = cas.w + dy[k];
			if (m[vi][vj] >= sand[vi][vj] - '0')continue;
			m[vi][vj]++;
			if (m[vi][vj] >= sand[vi][vj] - '0') q.push({ vi,vj,ret + 1 });
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 7816
// "include" {{{
    #include <deque>
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <deque>
    #include <list>
    #include <map>
    #include <queue>
    #include <set>
    #include <stack>
    #include <cstring>
    // }}}
    using namespace std;
    #define rep(i,n) for(int i=0;i<(n);++i)
    #define reps(i,n) for(int i=1;i<=(n);++i)
    #define all(x) (x).begin(),(x).end()
    #define pii pair<int,int>
    #define int long long
    const int INF = 0x3f3f3f3f;
    const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
    const long long mod = 1000000007;
     
     
    signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a * b * 1 % 2 == 1 || a * b * 3 % 2 == 1) cout << "Yes\n";
    else cout << "No\n";
    return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main()
{
  double x1, x2, y1, y2;

  cin >> x1 >> y1 >> x2 >> y2;

  cout << fixed << setprecision(6) << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) << endl;
  
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll,ll> P;

template <typename T> std::string tostr(const T& t)
{
    std::ostringstream os; os<<t; return os.str();
}

int main(){
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    vector<int> v(3,0);
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        if(tmp<=a){
            v[0]++;
        }else if(tmp>a&&tmp<=b){
            v[1]++;
        }else if(tmp>b){
            v[2]++;
        }
    }
    cout<<min(v[0],min(v[1],v[2]))<<endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
k=["t","x","y"]
c=[dict(zip(k,[0,0,0]))]
ans="Yes"
for i in range(1,n+1):
    c.append(dict(zip(k,list(map(int, input().split())))))

    if ((c[i]["x"]+c[i]["y"])%2==0) != (c[i]["t"]%2==0):
        ans="No"

    if abs(c[i]["x"]-c[i-1]["x"])+abs(c[i]["y"]-c[i-1]["y"]) > (c[i]["t"]-c[i-1]["t"]):
        ans="No"

print(ans)


Measured memory_bytes: 39924
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int n;
	cin >> n;

	double ave = 0;
	int arr[100];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		ave += arr[i];
	}

	ave /= n;
	int ans_num = 0;
	double mini = 1000;

	for (int i = 0; i < n; i++) {
		if (mini > abs(ave - arr[i])) {
			mini = abs(ave - arr[i]);
			ans_num = i;
		}
	}

	COUT(ans_num);

	return 0;
}


Measured memory_bytes: 256
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

tmp = sorted(dic.items(), key=lambda x:(-x[1], x[0]))
for i in range(len(tmp)):
  if tmp[i][1] == tmp[0][1]:
    print(tmp[i][0])
  else:
    break

Measured memory_bytes: 59224
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#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=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

typedef pair<string, int> value_type;

struct second_order {
  bool operator()(const value_type& x, const value_type& y) const {
    if( x.second != y.second) return x.second < y.second;
    return x.first > y.first;
  }
};

int main(void){
    int n;
    cin >> n;
    map<string, int> dict;
    REP(i, n) {
        string s;
        cin >> s;
        dict[s]++;
    }
    
    priority_queue<value_type, vector<value_type>, second_order> que;
    for(auto it=dict.begin(); it!=dict.end(); ++it) {
        que.push(*it);
    }
    
    int max_count = que.top().second;
    while ( !que.empty() ) {
        value_type item = que.top();
        if(max_count != item.second) break;
        std::cout << item.first << std::endl;
        que.pop();
    }
    return 0;
}

Measured memory_bytes: 29680
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<string> jR(N);
    for(int i = 0; i < N; i++){
        cin >> jR[i];
    }
    
    int acNum = 0;
    int waNum = 0;
    int tleNum = 0;
    int reNum = 0;
    
    for(int i = 0; i < N; i++){
        if(jR[i] == "AC"){
            acNum++;
        }else if(jR[i] == "WA"){
            waNum++;
        }else if(jR[i] == "TLE"){
            tleNum++;
        }else if(jR[i] == "RE"){
            reNum++;
        }
    }
    
    cout << "AC x " << acNum << endl;
    cout << "WA x " << waNum << endl;
    cout << "TLE x " << tleNum << endl;
    cout << "RE x " << reNum << endl;
    
}


Measured memory_bytes: 6428
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  int q;
  cin >> n >> q;
  REP(i , 0, q) {
    ll v, w;
    cin >> v >> w;
    if (n == 1) {
      cout << min(v, w) << "\n";
    } else {
      while (v != w) {
	if (v > w) {
	  swap(v, w);
	}
	w = (w + n - 2) / n;
      }
      cout << v << endl;
    }
  }
}


Measured memory_bytes: 1280
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class template
{
	static Scanner sc;
	public static void Main(string[] args)
	{
		sc = new Scanner();
		int N, M;
		var nm = sc.nextIntArray();
		N = nm[0]; M = nm[1];
		double[][] elem = new double[N][];
		for (int i = 0; i < N; i++)
		{
			elem[i] = sc.nextDoubleArray();
		}
		double ans = 0.0;
		List<double[]> list = new List<double[]>();
		for (int i = 0; i < (1 << N); i++)
		{
			list.Clear();
			for (int j = 0; j < N; j++)
			{
				if ((i & (1 << j)) != 0)
				{
					list.Add(elem[j]);
				}
			}
			if (list.Count != M) continue;
			double buf = 0.0;
			for (int k = 0; k < M; k++)
			{
				for (int l = k + 1; l < M; l++)
				{
					for (int m = 0; m < 3; m++)
					{
						buf += Math.Pow(list[k][m] - list[l][m], 2);
					}
				}
			}
			ans = Math.Max(ans, buf);
		}
		Console.WriteLine(ans);
	}
}

public class Scanner
{
	public Scanner() { }
	public string next()
	{
		return Console.ReadLine();
	}
	public int nextInt()
	{
		return int.Parse(next());
	}
	public double nextDouble()
	{
		return double.Parse(next());
	}
	public long nextLong()
	{
		return long.Parse(next());
	}
	public string[] nextArray()
	{
		return next().Split(' ');
	}
	public int[] nextIntArray()
	{
		return Array.ConvertAll(nextArray(), e => int.Parse(e));
	}
	public long[] nextLongArray()
	{
		return Array.ConvertAll(nextArray(), e => long.Parse(e));
	}
	public double[] nextDoubleArray()
	{
		return Array.ConvertAll(nextArray(), e => double.Parse(e));
	}
}

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

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

void solve() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll d = B - A;
  if (d % 2 == 0) {
    cout << d / 2 << endl;
  } else {
    cout << min(min(N - A, B - 1),
                min((B - A + 1) / 2 + (A - 1), (B - A + 1) / 2 + (N - B)))
         << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    /**
     * @return mixed
     */
    public function next() {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    /**
     * @return bool
     */
    public function hasNext() {
        return $this->pointer < $this->count;
    }

    /**
     * @return int
     */
    public function nextInt() {
        return (int)$this->next();
    }

    /**
     * @return float
     */
    public function nextDouble() {
        return (double)$this->next();
    }
}

/**
 * 距離が最小のノードを探す(-1はなかった場合)
 * @param $result
 * @param $nodeCostList
 * @return int
 */
function getMinDistNode($nodeCostList, $result)
{
    $minDistNode = -1;
    $minDist = INF;
    foreach ($nodeCostList as $node=>$nodeCost) {
        // 確定済みは無視
        if (isset($result[$node])) {
            continue;
        }
        
        if ($nodeCost < $minDist) {
            $minDistNode = (int)$node;
            $minDist = $nodeCost;
        }
    }
    
    return $minDistNode;
}

// 初期化
$sc = new Scanner();
$n = $sc->nextInt();
$nodeCostList = array();
$edgeList = array();
$fixedList = array();
foreach (range(0,$n-1) as $lineNum) {
    $u = $sc->nextInt();
    $nodeCostList[$u] = INF;
    
    $k = $sc->nextInt();

    foreach (range(0, $k-1) as $setNum) {
        $v = $sc->nextInt();
        $c = $sc->nextInt();
        $edgeList[$u][$v] = $c;
    }
}


$nodeCostList[0] = 0;

$result = array();
while (true) {
    // 距離が最小のノードを探す。なければ終了
    $targetNode = getMinDistNode($nodeCostList, $result);
    if ($targetNode < 0) {
        break;
    }
    // 距離確定させる
    $result[$targetNode] = $nodeCostList[$targetNode];
    
    // 対象ノードと繋がっているノードごと
    foreach ($edgeList[$targetNode] as $adjNode => $cost) {
        // 確定済みは見ない
        if (isset($result[$adjNode])) {
            continue;
        }
        
        // 今のコストより短ければ更新
        if ($nodeCostList[$targetNode] + $cost < $nodeCostList[$adjNode]) {
            $nodeCostList[$adjNode] = $nodeCostList[$targetNode] + $cost;
        }
    }
}

ksort($result);
foreach ($result as $node=>$resultCost) {
    echo $node . ' ' . $resultCost . "\n";
}






Measured memory_bytes: 10248
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    //出力
    cout << max(a*b,c*d) << ENT;
    return 0;
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int n = s.length();
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            char cc;
            boolean flg = Character.isLowerCase(c);
            if (flg == true) {
                cc = Character.toUpperCase(c);
            } else {
                cc = Character.toLowerCase(c);
            }
            System.out.print(cc);
        }
        System.out.println();
        sc.close();
    }
}


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

bool dp[110][10010];

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> v[i];
        sum += v[i];
    }

    dp[0][0] = true;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= sum; j++) {
            if(j-v[i-1] >= 0) dp[i][j] |= dp[i-1][j-v[i-1]];
            dp[i][j] |= dp[i-1][j];
        }
    }

    int ans = 0;
    for(int i = sum; i >= 0; i--) {
        if(dp[N][i] && i % 10 != 0) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

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

long long roop(long long num){
  if(num == 1) return 1;
  
  return roop(num/2) * 2 + 1;
}

int main() {
  long long num;
  long long cnt = 0;
  bool chk = true;
  
  cin >> num;
  
  cnt = roop(num);
  
  cout << cnt;
}


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

    int ans[55];
    for(int i = 0; i<n; i++){
        ans[i] = 0;
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a[j] ==i || b[j] == i){
                ans[i] += 1;
            }
        }
    }

    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
}

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

using namespace std;
int main(void){
    string c;
    cin>>c;
    if (c=="a" or c=="i" or c=="u" or c=="e" or c=="o"){
        puts("vowel");
    }else{
        puts("consonant");
    }
}


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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

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


int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }

    ll ans = a[0];
    for(int i=1;i<n;++i) ans = gcd(ans, a[i]);
    cout << ans << endl;
}


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

int main() {
    int a[4];
    rep(i,4)cin>>a[i];
    cout<<max(a[0]*a[1],a[2]*a[3])<<endl;
	return 0;
}

Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;

class Main{
	static int G;
	static int D;
	static int[] p;
	static int[] c;
	static boolean[] used;
	static long ans = 1000000000;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		long[] a = new long[n+1];
		for(int i = 1;i <= n;i++){
			a[i] = sc.nextLong();
		}
		long[] sum = new long[n+1]; 
		for(int i = 1;i <= n;i++){
			sum[i] = a[i] + sum[i-1];
//			System.out.print(sum[i] + " ");
		}
//		System.out.println();
		long ans = 1000000000;
		for(int i = 2;i <= n-2;i++){				//真ん中の仕切りのいち
//			System.out.println("ans "+ans);
			long left = lowerbond(sum[i]/2, sum,0,1,i);			//左の仕切りのいち
			//System.out.println("left "+left);

			long A1 = sum[(int)left];
			long B1 = sum[i] - sum[(int)left];
			
			left = higherbond(sum[i]/2, sum,0,1,i-1);			//左の仕切りのいち
			//System.out.println("left "+left);

			long A2 = sum[(int)left];
			long B2 = sum[i] - sum[(int)left];
			
			long A = 0;
			long B = 0;
			if(Math.abs(A2- B2) < Math.abs(A1-B1)){
				A = A2;
				B = B2;
			}else{
				A = A1;
				B = B1;
			}
			
			long right = lowerbond((sum[n]-sum[i])/2, sum,sum[i],i+1,sum.length-1);			//右の仕切りのいち
			long C1 = sum[(int)right] - sum[i];
			long D1 = sum[n] - sum[(int)right];

			right = higherbond((sum[n]-sum[i])/2, sum,sum[i],i+1,sum.length-1);			//右の仕切りのいち
			long C2 = sum[(int)right] - sum[i];
			long D2 = sum[n] - sum[(int)right];
			
			long C = 0;
			long D = 0;
			if(Math.abs(C2- D2) < Math.abs(C1-D1)){
				C = C2;
				D = D2;
			}else{
				C = C1;
				D = D1;
			}
			
//			System.out.println("i "+i+" left "+left+" right "+right);
//			System.out.println("A "+A+" B "+B+" C "+C + " D "+D);

			Long[] hako = {A,B,C,D};
			Arrays.sort(hako);
			ans = (long)Math.min(ans, hako[3]-hako[0]);
			
			
			
//			System.out.println("ans " +ans);
//
//			System.out.println();

		}
		
		System.out.println(ans);
		


	}
	static long lowerbond(long k, long[] data,long d,int min,int max){		//kより小さい最小の値をdataの中から探し、返す二分探索
//		int min = -1;
//		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
//			System.out.println("max "+max + " mid "+mid+" min "+min);

			if(data[mid]-d >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
//		System.out.println("ok");

		return min;
	}
	
	static long higherbond(long k, long[] data,long d,int min,int max){		//kより小さい最小の値をdataの中から探し、返す二分探索
//		int min = -1;
//		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
//			System.out.println("max "+max + " mid "+mid+" min "+min);

			if(data[mid]-d >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
//		System.out.println("ok");

		return max;
	}



}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 94636
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

setrecursionlimit(10**6)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

S = input()
w = read()

s = ""
for i in range(0, len(S), w):
  s += S[i]

print(s)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

string str[100000];
signed main(){
  int n;cin >> n;
  rep(i,n)cin >> str[i];
  int a = 0, b = 0, ab = 0;
  rep(i,n)a += (str[i][str[i].size()-1] == 'A');
  rep(i,n)b += (str[i][0] == 'B');
  rep(i,n)ab += (str[i][0] == 'B' and str[i][str[i].size()-1] == 'A');
  int ans = 0;
  rep(i,n){
    rep(j,str[i].size()-1){
      if(str[i][j] == 'A' and str[i][j+1] == 'B')ans++;
    }
  }
  if(a == b and a == ab)cout << ans+max(0LL, a-1) << endl;
  else cout << ans+min(a,b) << endl;
  return 0;
}






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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll N;
    cin >> N;
    map<ll, ll>  B, C;
    ll a;
    rep(i, N){
        cin >> a;
        B[i+1-a] += 1;
        C[i+1+a] += 1;
    }
    ll ans=0;
    rep(i, N+1) ans += B[i]*C[i];
    out(ans);
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 46368
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int  N=0;int a=0;
	scanf("%d",&N);
	int p[N]={0};
	for(int i=0;i<N;i++){
		scanf("%d",&p[i]);
	}
	for(int j=N-2;j>0;j--){
		if(p[j]>p[j-1]){
			if(j==N-2){
				a=a+(2*p[j-1]);p[j]=p[j]-p[j-1];p[j-1]=0;
			}
			else{
				p[j]=p[j]-p[j-1];
				a=a+(2*p[j-1])+p[j]*2;p[j]=0;p[j-1]=0;
			}
		}
		else if(p[j]==p[j-1]){
			a=a+p[j]*2;p[j]=0;p[j-1]=0;
		}
		else if(p[j]<p[j-1]){
			a=a+p[j]*2;p[j-1]=p[j-1]-p[j];p[j]=0;
		}
	}
	a=a+p[0];
	if(p[N-2]>0){
		if(p[N-2]>p[N-1]){
			a=a+p[N-2]*2;
		}
		else{
			a=a+p[N-2]*2;p[N-1]=p[N-1]-p[N-2];a=a+p[N-1];
		}
	}
	else{
		a=a+p[N-1];
	}
	printf("%d\n",a);
	a=0;
	
	return 0;
}


Measured memory_bytes: 3240
import math
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = 0
hand = {"r":P, "s":R, "p":S}
for i in range(K):
    tmp = T[i::K]
    #print(T[i::K])
    score += hand[tmp[0]]
    flag = True
    for j in range(1,len(tmp)):
        if tmp[j] == tmp[j - 1]:
            flag = not flag
        else:
            flag = True
        if flag:
            score += hand[tmp[j]]
print(score)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    char c;
    cin >> c;
    if (c > 90) cout << 'a';
    else cout << 'A';

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<endl)
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


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

int main() {
  int a,b,c; cin >>a >>b >>c;
  vector<int> n = {a,b,c};
  sort(n.begin(), n.end());
  int sub = n.at(2)-n.at(0) + n.at(2)-n.at(1);
  int ans = sub/2;
  if (sub%2!=0) ans += 2;
  
  cout <<ans;
  cout <<endl;
}


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

    typedef long long ll;
    typedef long double ld;
    ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
    ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
    #define endl '\n'
    #define max3(a,b,c) max(a,max(b,c))
    #define min3(a,b,c) min(a,min(b,c))
    #define FOR(i,a,n,j) for(int i=a;i<n;i+=j)

    const int INF = 1e9+9;




    int main()
    {
        ll n,k,d,ans=0;
        cin>>n>>k;
        int a[n];
        a[0]=1;
        for(int i=1;i<=n;i++) a[i]=0;

        for(int i=0;i<k;i++){
            cin>>d;
            int q;
            for(int j=0;j<d;j++){
                cin>>q;
                a[q]++;
            }
        }
        for(int i=1;i<=n;i++){
            if(a[i]==0) ans++;
        }
        cout<<ans<<endl;

    return 0;
    }
        // gotcha;


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
long n,m;
cin >> n>>m;
double arr[n];
double vote =0;
for(int i= 0; i< n;i++)
{
cin>>arr[i];
vote+= arr[i];
}
sort(arr,arr+n);
reverse(arr, arr+n);

double acc = vote/(m*4);
if(arr[m-1] >=acc)
{
cout << "Yes" << endl;
}
else if(arr[m-1] < acc)
{
cout << "No" << endl;
}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
map<int,int>mp;
main()
{
    int x,n;
    cin>>x>>n;
    for(int i=0;i<n;i++)
    {
        int p;
        cin>>p;
        mp[p]++;
    }
    int ans,now=1e9;
    for(int i=x-200;i<=x+200;i++)
    {
        if(mp[i]==0)
        {
            if(abs(i-x)<now)
            {
                now=abs(i-x);
                ans=i;
            }
        }
    }
    cout<<ans;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// typedef pair<ll,ll> Pair;
// ll mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,c,i,j,k,temp,temp2,n,m,sum=0;
    // string a,b,tem;
    vector <ll> a,b;
    cin >> n >> m >> k;
    ll mina=1000000,minb=1000000,ans=1000000;
    for(i=0;i<n;i++){
        cin >>temp;
        a.push_back(temp);
        mina = min(mina,temp);
    }
    for(i=0;i<m;i++){
        cin >> temp;
        b.push_back(temp);
        minb= min(minb,temp);
    } 
    ans = min(ans,mina+minb);
    for(i=0;i<k;i++){
        cin >> t >> temp >> temp2;
        ans = min(ans,a[t-1]+b[temp-1]-temp2);
    }
    cout << ans;
    
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main()
{
	int n;
	string str;
	cin >> n >> str;
	vector<vector<ll> > dp(n + 1, vector<ll>(n + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			(dp[i + 1][j + 1] += dp[i][j] * 2) %= MOD;
			(dp[i + 1][max(j - 1, 0)] += dp[i][j]) %= MOD;
		}
	}
	ll ans = dp[n][str.size()];
	for (int i = 0; i < str.size(); i++) {
		ans = ans * (MOD + 1) / 2 % MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 195840
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, C, ans;

int main()
{
	in >> N >> C;
	std::vector<LL>x(N), v(N), imos1(N, 0), imos2(N, 0), res1(N, 0), res2(N, 0);
	rep(i, N) in >> x[i] >> v[i];
	rep(i, N)
	{
		imos1[i] -= x[i];
		imos2[i] += v[i];
	}
	rep(i, N - 1) imos2[i + 1] += imos2[i];
	rep(i, N) res1[i] = imos1[i] + imos2[i];
	rep(i, N - 1) res1[i + 1] = std::max(res1[i + 1], res1[i]);
	imos1.resize(N); imos2.resize(N);
	rep(i, N)
	{
		imos1[i] = imos2[i] = 0;
		imos1[i] -= C - x[N - i - 1];
		imos2[i] += v[N - i - 1];
	}
	rep(i, N - 1) imos2[i + 1] += imos2[i];
	rep(i, N) res2[i] = imos1[i] + imos2[i];
	rep(i, N - 1) res2[i + 1] = std::max(res2[i + 1], res2[i]);
	for (LL r = 0; r <= N; ++r)
	{
		LL l = N - r, res = 0, dis = 1123456789012345;
		if (r > 0)
		{
			res += res1[r - 1];
			dis = std::min(dis, x[r - 1]);
		}
		if (l > 0)
		{
			res += res2[l - 1];
			dis = std::min(dis, C - x[N - l]);
		}
		if (r > 0 && l > 0) res -= dis;
		ans = std::max(ans, res);
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var ABHM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B, H, M) = (ABHM[0], ABHM[1], ABHM[2], ABHM[3]);

        var angleA = (H + M / 60.0) / 12.0 * 2.0 * Math.PI;
        var angleB = M / 60.0 * 2.0 * Math.PI;

        var (xA, yA) = (A * Math.Cos(angleA), A * Math.Sin(angleA));
        var (xB, yB) = (B * Math.Cos(angleB), B * Math.Sin(angleB));

        var ans = Math.Sqrt(Math.Pow(xB - xA, 2) + Math.Pow(yB - yA, 2));

        WriteLine(ans);
    }
}

Measured memory_bytes: 28700
#include<stdio.h>

int main(void) {
	long int n, k;
	scanf("%ld %ld", &n, &k);
	long int a[n];
	scanf("%ld", (long)&a);
	long int cont,b;
	long int j;
	
	b = n - k;
	for (j = 0; j < n; j++) {
		if (b > 0) {
			b = b - k + 1;
			cont++;
		}
		else { break; }

	}
	printf("%ld\n", cont + 1);
	return 0;
}
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define P pair<int, int>
#define PP pair<P, P>
#define mk make_pair
#define fi first
#define se second
#define V vector<int>
#define VV vector<V>
#define pb push_back

using namespace std;
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;

    int t = 0, res = 0;
    if(B == 1) {
        cout << 0 << endl;
        return 0;
    }
    t = A; res++;
    while(t < B) {
        t--;
        t += A;
        res++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input().strip()
qn = int(input())
qs = list(map(int, input().split()))
dd,mm,cc = [0],[0],[0]
As = [0]*qn
d=m=dm=0
for i, w in enumerate(S):
    i += 1
    if w=="D":
        d+=1
    elif w == "M":
        m+=1
        dm+=d
    elif w == "C":
        for j, q in enumerate(qs):
            ll = max(i-q, 0)
            As[j] += dm - cc[ll] - dd[ll]*(m-mm[ll])
    dd.append(d)
    mm.append(m)
    cc.append(dm)
for a in As:
    print(a)


Measured memory_bytes: 150040
#include <stdio.h>
int main()
{
    long long n;
    scanf("%lld",&n);
    char S[100]={0};
    int i=0;
    n--;
    while(n>=0){
        S[i]=n%26+'a';
        n/=26;
        i++;
        n--;
    }
    for(int j=i-1;j>=0;j--){
        printf("%c",S[j]);
    }
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int H, W, N; cin >> H >> W >> N;
	int sr, sc; cin >> sr >> sc;
	string S, T; cin >> S >> T;
	string pat = "DRUL";

	for (int d = 0; d < 4; d++) {
		int s = sc;
		int size = W;
		if (d%2 == 0) s = sr, size = H;
		
		auto in = [&](int pos) {
			return (1 <= pos && pos <= size);
		};

		for (int i = 0; i < N; i++) {
			if (pat[d] == S[i]) s += (dx[d]+dy[d]);
			if (s < 1 || size < s) {
				cout << "NO" << el;
				return;
			}
			if (pat[(d+2)%4] == T[i] && in(s-(dx[d]+dy[d])) ) s -= (dx[d]+dy[d]);
		}
	}
	cout << "YES" << el;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll a,b,n;
   cin>>a>>b>>n;
   ll k = min(b-1,n);
   
   ll ans = floor(double(a*k)/double(b));
   cout<<ans;
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3756
s = input()

l_counter = 0
r_counter = 0
onthelist =False
ans = 0
for l in s:
    if l == 'A':
        break
    l_counter += 1

for l in s[::-1]:
    if l == 'Z':
        break
    r_counter += 1


ans = len(s) - l_counter - r_counter

# print(l_counter, r_counter, len(s))
print(ans)


Measured memory_bytes: 3516
n = int(input())
AC = 0
TLE = 0
WA = 0
RE = 0
for i in range (0, n):
    a = input()

    if a == "AC":
        AC += 1
    elif a == "TLE":
        TLE += 1
    elif a == "WA":
        WA += 1
    elif a == "RE":
        RE += 1

print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)

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

ll h,w;
ll su = 0;
int main(){
	cin >> h >> w;
	if(h == 1 || w == 1){ cout << 1 << "\n"; return 0;}
	cout << (w/2+(w%2))*(h/2+(h%2)) + (w/2)*(h/2) << "\n";
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().strip().split(" ")]
vs=set()

def dfs(v, path):
    lp = 0
    l = N+1
    for u in d[v]:
        if u in pvs:
            for i, c in enumerate(path):
                if c == u:
                    break
            nlp = path[i+1:]+[u]
            nl = len(nlp)
            if nl < l:
                lp, l = nlp, nl
        if u in vs:
            continue
        pvs.add(u)
        vs.add(u)
        nl, nlp = dfs(u,path+[u])
        if nl < l:
            lp, l = nlp, nl
        pvs.remove(u)
    return l, lp

d = [set() for _ in range(N+1)]
for _ in range(M):
    a, b = map(int,input().split(" "))
    d[a].add(b)
for i in range(N):
    v=i+1
    pvs = set([v])
    l, lp = dfs(i+1, [v])
    if l != N+1:
        print(l)
        for l in lp:
            print(l)
        break
else:
    print(-1)

Measured memory_bytes: 44524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << ", "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << ", "; cerr << "\n"; }
#define dbm(map) cerr << #map << ":"; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "\n";
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mli = map<ll, int>; using mll = map<ll, ll>;

int main() {
	int H, W; cin >> H >> W;
	vvb g(H, vb(W));
	vvi d(H, vi(W, -1));
	int white = 0;
	rep(i, H) {
		string s; cin >> s;		
		rep(j, W)	{
			if (s[j] == '.') {
				g[i][j] = true;
				white++;
			}
		}
	}
	// dbvv(g); dbl(white);
	queue<pii> q;
	pii s(0, 0); q.push(s); d[0][0] = 1;
	vi di = { 1, 0, -1, 0 }, dj = { 0, 1, 0, -1 };
	while (!q.empty()) {
		int ui, uj; tie(ui, uj) = q.front(); q.pop();
		rep(k, 4) {
			int vi = ui + di[k], vj = uj + dj[k];			
			if (vi < 0 or vi >= H or vj < 0 or vj >= W) continue;
			if (!g[vi][vj] or d[vi][vj] != -1) continue;
			d[vi][vj] = d[ui][uj] + 1;
			q.push(make_pair(vi, vj));
		}
	}
	// dbvv(d);	
	cout << (d[H - 1][W - 1] != -1 ? white - d[H - 1][W - 1] : -1) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define ins insert
#define F first
#define S second
#define var auto
using namespace std;
typedef long long ll;
const int Max = 1e5 + 10;
const int Mod = 1e9 + 7;


int A[3][Max];
ll dp[3][Max];

int main()
{
	int n;cin >> n;
	for(int i = 1; i <= n ; i++)
		cin >> A[1][i];
	for(int i = 1; i <= n ; i++)
		cin >> A[2][i];

	for(int i = 1; i<= n ;i++)
	{
		dp[1][i] = dp[1][i - 1] + A[1][i];
		dp[2][i] = max(dp[1][i] , dp[2][i - 1]) + A[2][i];
	}
	cout << dp[2][n] << '\n';;
}



Measured memory_bytes: 3640
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vi vector<int>
#define vll vector<ll>
#define be begin
#define en end
#define endl '\n'
#define SIZE 1000000
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1000000007
#define reset(dp) memset(dp,0,sizeof(dp))

typedef long long ll;
using namespace std;
using namespace __gnu_pbds; 

int dp[SIZE][4];
int a[SIZE];
int b[SIZE];
int c[SIZE];
int n;
int solve(int n)
{

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

	}

	return max({dp[n][1],dp[n][2],dp[n][3]});
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];
	cout<<solve(n);


	return 0;
		
		

	
	
}
	
	


Measured memory_bytes: 12928
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1 = max(xs)
    key_max = xs.index(max_1)
    
    for i in range(n):
        if key_max == i:
            print(max(xs[:i]+xs[i+1:]))
        else:
          	print(max_1)

if __name__ == '__main__':
    main()


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

int main() {
  int R,G,ans;
  cin >> R >> G;
  ans = 2 * G - R;
  cout << ans << endl;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 3000;

double dp[maxn][maxn];
double a[maxn];
int n;

double solve(int idx, int head) {
	if(idx == n){
		if(head == 0){return 1;}
		else
			return 0;
	}
	
	if(fabs(dp[idx][head] + 1) > eps){return dp[idx][head];}
	return dp[idx][head] = a[idx] * solve(idx+1, head-1) + (1.0 - a[idx]) * solve(idx+1, head);
}

int main(){
	int i,j;
	for(i=0;i<maxn;i++){
		for(j=0;j<maxn;j++){
			dp[i][j] = -1;
		}
	}
	
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%lf",&a[i]);}
	int minim = n/2 + 1;
	double ans = 0;
	for(i=minim;i<=n;i++){
		ans += solve(0, i);
	}
	printf("%.10lf\n",ans);
	return 0;
};

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

int main()
{
	string s;
	cin >> s;
	int a = stoi(s.substr(0, 2));
	int b = stoi(s.substr(2, 2));
	bool c = (1 <= a && a <= 12);
	bool d = (1 <= b && b <= 12);
	cout << (!c && d ? "YYMM" : c && !d ? "MMYY" : !c && !d ? "NA" : "AMBIGUOUS") << endl;

	return 0;
}

Measured memory_bytes: 256
/*raghav0307 - Raghav Gupta*/

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

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;

int main(){
	fast_io();
	string s; cin >> s;
	int k = s.length();
	int cnt = 0;
	for(int i = 0; i < k; i++){
		if(s[i] == 'x')	cnt++;
	}
	if(cnt > 7)	cout << "NO\n";
	else cout << "YES\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

bool check(std::pair<intt, intt> a, std::pair<intt, intt> b) {
	return a.second < b.second;
}

int main(){
	intt N;  std::cin >> N;
	std::vector<std::pair<intt, intt>> A(N);
	for (int i = 0; i < N; ++i)
		std::cin >> A[i].first >> A[i].second;
	std::sort(A.begin(), A.end(), check);
	bool flag = true;
	intt sum{ 0 };
	for (int i = 0; i < N; ++i) {
		sum += A[i].first;
		if (sum > A[i].second)
			flag = false;
	}
	std::cout << (flag ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 6380
#include<iostream>
#include<string>
using namespace std;
int Euclid(long a, long b){
  if(a%b == 0){
  	return b;
  }
  else{
  	return Euclid(b,a%b);
  }
}
int main(){
	long in[2],res;
  	cin >> in[0] >> in[1];
  	res = Euclid(in[0], in[1]);
  	cout << in[0]*in[1]/res << endl;
  	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import math

while True :
    n = int(input())
    
    if n == 0 :
        break
    else :
        S = [int(s) for s in input().split()]
        a2 = 0
        
        m = sum(S) / n
        
        for i in range(n) :
            a2 += (S[i] - m) ** 2
            
        a = math.sqrt(a2 / n)

    print(f"{a:.5f}")


Measured memory_bytes: 5728