akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  string x = "MARCH";
  vector<int> cnts(5, 0);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < x.size(); ++j) {
      if(s[0] == x[j]) cnts[j]++;
    }
  }

  long long ans = 0;
  for (int i = 0; i < 5; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      for (int k = j + 1; k < 5; ++k) {
	ans += (long long)cnts[i] * cnts[j] * cnts[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

    int[] a;
    int cost;
    int N;
    int[] dp;
    int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        int M = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            M = Math.max(M, A[i]);
        }
        long g = A[0];
        for (int i = 1; i < N; i++) {
            g = gcd(g, A[i]);
        }
        if (K % g == 0 && K <= M) {
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }

    long gcd(long n, long m) {
        if (n < m) {
            return gcd(m, n);
        }
        if (m == 0) {
            return n;
        }
        return gcd(m, n % m);
    }
}


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

int main(){

string s,t,ans;
  int n;
  cin >> n;
  cin >> s >> t;
  
ans=s+t;
  
  rep(i,n){
  	ans[2*i]=s[i];
    ans[2*i+1]=t[i];
  }

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

Measured memory_bytes: 256
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.insertBack(e);}T deq(T)(ref Queue!T q){T e=q.front;q.removeFront;return e;} 
alias Stack=SList;auto push(T)(ref Stack!T s,T e){s.insert(e);}T pop(T)(ref Stack!T s){T e=s.front;s.removeFront;return e;} 
struct UnionFind(T){T[T]u;ulong[T] rank;@property{bool inc(T e){return e in u;}auto size(){return u.keys.length;}auto dup(){T[] child=u.keys;T[] parent=u.values;auto res=UnionFind!T(child);child.each!(e=>res.add(e));size.iota.each!(i=>res.unite(child[i],parent[i]));return res;}}this(T e){e.add;}this(T[] es){es.each!(e=>e.add);}auto add(T a,T b=a){assert(b.inc);u[a]=a;rank[a];if(a!=b)unite(a,b);}auto find(T e){if(u[e]==e)return e;return u[e]=find(u[e]);}auto same(T a,T b){return a.find==b.find;}auto unite(T a,T b){a=a.find;b=b.find;if(a==b)return;if(rank[a]<rank[b])u[a]=b;else{u[b]=a;if(rank[a]==rank[b])rank[a]++;}}}
struct PriorityQueue(T,alias less="a<b"){BinaryHeap!(T[],less) heap;@property{bool empty(){return heap.empty;}auto length(){return heap.length;}auto dup(){return PriorityQueue!(T,less)(array);}T[] array(){T[] res;auto tp=heap.dup;foreach(i;0..length){res~=tp.front;tp.removeFront;}return res;}void push(T e){heap.insert(e);}void push(T[] es){es.each!(e=>heap.insert(e));}}T look(){return heap.front;}T pop(){T tp=look;heap.removeFront;return tp;}this(T e){ heap=heapify!(less,T[])([e]);}   this(T[] e){ heap=heapify!(less,T[])(e);}}
//END OF TEMPLATE

void main(){
    auto r=scan!long;
    (2*r*3.141592).writeln;
}


Measured memory_bytes: 3808
n,k=map(int,input().split())
list_all=list(range(1,n+1))
for i in range(k):
    num=int(input())
    List=list(map(int,input().split()))
    for j in List:
        if j in list_all:
            list_all.remove(j)

print(len(list_all))       

Measured memory_bytes: 9200
import scala.io.StdIn.{readLong, readInt}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val arr = (1 to len).toArray.map(a => readLong)
        println(shellSort(arr, len).mkString("\n"))
    }
    
    def shellSort(arr: Array[Long], len: Int): Array[Long] = {
        val copy = new Array[Long](len)
        arr.copyToArray(copy)
        var cnt = 0
        val groups = genGroups(len).reverse
        println(groups.length + "\n" + groups.mkString(" "))
        for (g <- groups) {
            cnt += insertionSort(copy, len, g)
        } 
        println(cnt)
        copy
    }
    
    def insertionSort(arr: Array[Long], len: Int, group: Int): Int = {
        var cnt = 0
        def insert(target: Long, ptr: Int): Unit = ptr match {
            case a if (a < 0 || arr(ptr) <= target) => arr(ptr + group) = target
            case a => {
                cnt += 1
                arr(ptr + group) = arr(ptr)
                insert(target, ptr - group)
            }
        }
        for (targetIndex <- (0 until len)) { insert(arr(targetIndex), targetIndex - group)}
        cnt
    }
    
    def genGroups(len: Int): List[Int] =  {
        def go(len: Int, glen: Int, next: Int): List[Int] = next match {
            case a if (a == 1) || (a < len && glen < len) => a :: go(len, glen + 1, a * 3 + 1)
            case a => Nil
        }
        go(len, 0, 1)
    }
}


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

using namespace std;


int main()
{
	int n,k; 
	cin >> n >> k;
	int arr[n];
	for(int i = 0; i < n; i++) cin >> arr[i];
	sort(arr, arr+n);
	int ans = 0;
	for(int i = 0; i < k; i++) ans += arr[i];
	cout << ans;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>


int main() {
	int n, m; std::cin >> n >> m;
	std::vector<std::string> state(m);
	for (auto& line : state) std::cin >> line;
	std::vector<int> west_count(n, 0);
	std::vector<int> east_count(n, 0);
	auto all_west = 0;
	auto all_east = 0;
	for (auto i = 0; i < n; ++i) {
		for (auto j = 0; j < m; ++j) {
			if (state[j][i] == 'W') {
				west_count[i]++;
			}
			else {
				east_count[i]++;
			}
		}
		all_west += west_count[i];
		all_east += east_count[i];
	}
	int min = all_west;
	int pos = 0;
	int left_east = 0;
	int right_west = all_west;
	for (auto i = 0; i < n; ++i) {
		left_east += east_count[i];
		right_west -= west_count[i];
		if (left_east + right_west < min) {
			min = left_east + right_west;
			pos = i + 1;
		}
	}
	std::cout << pos << ' ' << pos + 1 << std::endl;
}


Measured memory_bytes: 4460
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


n = ip()                                     #入力整数1つ
#a,b,c,k= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しに4 3sum変数使用はsum関数使用できないので注意
ct = 0
if n==1:j(1)
for i in range(n):
    if a[i]%2:ct+=1
if ct%2:j(0)
j(1)

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

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

    int a;
    int b = 0;
    cin >> a;
    if (a / 100 == 1) {
      b++;
    }

    if (a % 100 >= 10) {
      b++;
    }

    if (a % 10 > 0) {
      b++;
    }
    cout << b << endl;
}

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

using namespace std;

int main()
{
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        if (x < a || x >= b) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	
	int n;
	cin>>n;
	cout<<n*n<<endl;

	

	return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int D, N;
    cin >> D >> N;
    int ans;
    if(N == 100) ans = 101 * pow(100, D);
    else ans = N * pow(100, D);
    cout << ans << endl;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    string ch;
    cin>>ch;
    if (ch[0]!=ch[1])
        cout<<"Yes";
    else if (ch[0]!=ch[2])
        cout<<"Yes";
    else if (ch[1]!=ch[2])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#define ll long long int
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

//using namespace __gnu_pbds;

#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 998244353;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)2e5 + 2;

ll power( ll x , ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod ;
        y = y >> 1;
        x = (x * x) % mod ;
    }
    return res % mod ;
}

//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
// }

//ll sev[100006];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 100006 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 100006 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}
long double dp[3000][3000];
void solve()
{
    ll n;
    cin >> n;
    long double arr[n + 1];
    for(ll i = 1 ; i <= n ; i ++)
        cin >> arr[i];
    dp[0][0] = 1;
    for(ll i = 1 ; i <= n ; i ++)
    {
        for(ll j = 0 ; j <= n ; j ++)
        {
            dp[i][j] = dp[i - 1][j] * (1 - arr[i]) + ((j > 0) ? dp[i - 1][j - 1] * (arr[i]) : 0);
        }
    }
    long double ans = 0.0;
    for(ll i = n / 2 + 1 ; i <= n ; i ++)
    {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(10);
    print(ans);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t , s;
    t = 1;
    //cin >> t ;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


Measured memory_bytes: 140928
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        x: u32,
        m: [u32;n]
    }
    let x = x - m.iter().sum::<u32>();
    let res = x / m.iter().min().unwrap();
    println!("{}", res + (m.len() as u32));
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int cnt[9];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        if(a >= 3200) cnt[8]++;
        else cnt[a/400]++;
    }
    int mi = 0, ma = 0;
    rep(i,8){
        if(cnt[i] > 0){
            ++mi;
            ++ma;
        }
    }
    ma += cnt[8];
    chmax(mi, 1);
    cout << mi << " " << ma << endl;
    return 0;
}


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

long long layer_num[51], patty_num[51];

long long getPatty(long long n, long long x) {
    if (n == 0) {
        return (x == 1 ? 1 : 0);
    } else if (x <= 1 + layer_num[n - 1]) {
        return getPatty(n - 1, x - 1);
    } else if (x == 2 * layer_num[n - 1] + 2 || x == 2 * layer_num[n - 1] + 3) {
        return 2 * patty_num[n - 1] + 1;
    } else {
        return patty_num[n - 1] + 1 + getPatty(n - 1, x - (layer_num[n - 1] + 2));
    }
}

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

    layer_num[0] = 1;
    patty_num[0] = 1;
    for (int i = 1; i <= 50; i++) {
        layer_num[i] = 2 * layer_num[i - 1] + 3;
        patty_num[i] = 2 * patty_num[i - 1] + 1;
    }

    cout << getPatty(N, X) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int x, y;
    cin >> x >> y;

    int ans = 0;
    ans += max((4 - x) * 100000, 0);
    ans += max((4 - y) * 100000, 0);
    if(x == 1 && y == 1){
        ans += 400000;
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val slimeCount = readLine()!!.toInt()
    val slimes = readLine()!!
    val melted = mutableListOf(slimes[0])
    for(i in (1 until  slimeCount)) {
        if(slimes[i] == melted.last()) {
            continue
        }
        melted.add(slimes[i])
    }
    println(melted.size)
}

Measured memory_bytes: 34864
A, B, C, K = map(int, input().split())

if K%2==0:
    ans = A-B
    if ans >= 10**18:
        print('Unfair')
    else:
        print(ans)
else:
    ans = B-A
    if ans >= 10**18:
        print('Unfair')
    else:
        print(ans)

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

int main()
{
	unsigned N;
	unsigned long long result = 1;

	cin >> N;

	for (size_t i = 1; i <= N; i++)
	{
		result = (result * i) % 1000000007;
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
while 1:
    N = int(input())
    if N == 0:
        break
    q = []
    M = {}
    for i in range(N):
        m, a, b = map(int, input().split())
        M[a] = M.get(a, 0) + m
        M[b] = M.get(b, 0) - m
    *q, = M.items()
    q.sort()
    ok = 1
    cur = 0
    for t, v in q:
        cur += v
        if cur > 150:
            ok = 0
    print("OK" if ok else "NG")



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

int main()
{
  int N;
  cin >>N;
  vector<int> mochi(N);
  for(int i=0; i<N; i++)
  {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(),mochi.end());
  int ans=1;
  for(int i=1; i<N; i++)
  {
    if(mochi.at(i-1)==mochi.at(i)) continue;
    else ans++;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
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; }
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);



int main() {
	IOS
	int n,q;
	string s;
	cin >> n >> s >> q;
	
	set<int> st[30];
	rep(i,n) st[s[i]-'a'].insert(i+1);
	rep(i,26) st[i].insert(INF);
	rep(i,q){
		int x;
		cin >> x;
		if(x == 1){
			int iq;
			char c;
			cin >> iq >> c;
			rep(j,26) st[j].erase(iq);
			st[c-'a'].insert(iq);
		}else{
			int l,r,cnt = 0;
			cin >> l >> r;
			rep(j,26) if(*st[j].lower_bound(l) <= r) cnt++;
			cout << cnt << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 24220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)
typedef long long ll;

int main(){
	int N;
	cin >> N;

	vector<pair<int, int>> A(N);
	rep(i, N){
		cin >> A.at(i).first;
		A.at(i).second = 3;
	}
	int sum = 0;
	rep(i, N){
		int tmp = 0;
		if (A.at(i).first % 2){
			tmp = 2;
			A.at(i).second = 1;
		}
		else {
			tmp = 1;
			A.at(i).second = 2;
		}
		rep(n, N){
			if (n == i) continue;
			tmp *= A.at(n).second;
		}
		sum += tmp;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void solve() {
	string s, t;
	cin >> s >> t;
	int N = s.size();
	int M = t.size();
	s += s;
    vector<vector<int>> next(s.size(), vector<int>(26, 0));
    vector<int> cur_next(26, -1);

    for (int i = s.size() - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            next[i][j] = cur_next[j];
        }
        cur_next[s[i] - 'a'] = i;
    }


    vector<vector<ll>> add(N, vector<ll>(26, -1));
    for (int i = 0; i < N; i++) {
        for (int c = 0; c < 26; c++) {
            if (next[i][c] == -1) continue;
            add[i][c] = next[i][c] - i;
        }
    }

    ll ans = 0;
    int now = N - 1;
    for (int j = 0; j < M; j++) {
        if (add[now][t[j] - 'a'] == -1) {
        	cout << -1 << endl;
        	return;
        }
    	ans += add[now][t[j] - 'a'];
    	now += add[now][t[j] - 'a'];
    	now %= N;
        
    }

    cout << ans << endl;


}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 51308
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;


int main() {
	int n;
	cin >> n;
	if (n==1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace Tree
{
    class Rooted_Trees
    {
        struct Node
        {
            public int id;
            public int parent;
            public int depth;
            public int[] childlen;
            public string type;
        }
        static void Main(string[] args)
        {
            int size = int.Parse(Console.ReadLine());
            var nodes = new Node[size];

            for (int i = 0; i < size; i++)
                nodes[i].parent = -1;

            for (int i = 0; i < size; i++)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var id = token[0];
                nodes[id].id = id;

                var k = token[1];
                if (k == 0) nodes[id].type = "leaf";
                else nodes[id].type = "internal node";
                nodes[id].childlen = new int[k];
                for (int j = 0; j < k; j++)
                {
                    nodes[id].childlen[j] = token[2 + j];
                    nodes[token[2 + j]].parent = id;
                }
            }

            for (int i = 0; i < size; i++)
                if (nodes[i].parent == -1)
                {
                    nodes[i].type = "root";
                    SetDepth(nodes, i, 0);
                    break;
                }

            for (int i = 0; i < size; i++)
                Console.WriteLine("node {0}: parent = {1}, depth = {2}, {3}, ["+ string.Join(", ", Array.ConvertAll(nodes[i].childlen, n => n.ToString()))+"]", nodes[i].id, nodes[i].parent, nodes[i].depth, nodes[i].type);
        }

        static void SetDepth(Node[] nodes, int id, int depth)
        {
            nodes[id].depth = depth;
            for (int i = 0; i < nodes[id].childlen.Length; i++)
                SetDepth(nodes, nodes[id].childlen[i], depth + 1);
        }
    }
}

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

#define FOR( i, m, n )   for( int i = m; i < n; i++ )
#define REP( i, n )      FOR( i, 0, n )
#define ALL( a )         (a).begin(), (a).end()

int main(){
  int a, b; cin >> a >> b;
  int n; cin >> n;

  vector<int> s( n );
  vector<int> f( n );

  REP( i, n ){
    cin >> s[i] >> f[i];
    if( ( s[i] <= a && f[i] >= b ) || ( s[i] == a && f[i] > a ) || ( s[i] < b && f[i] == b ) || ( s[i] > a && s[i] < b ) || ( f[i] > a && f[i] < b ) ){
      cout << 1 << endl;
      return 0;
    }
    
  }
  cout << 0 << endl;
}



Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <tuple>
#include <iomanip>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

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


int main(void){
	vector<int> v(5);

	for (int i = 0; i < 5; i++){
		cin >> v[i];
	}

	int k;
	cin >> k;

	bool ok = true;

	for (int i = 0; i < 5; i++){
		for (int j = 0; j < 5; j++){
			if (i == j)continue;

			if (abs(v[j] - v[i]) > k){
				ok = false;
				break;
			}
		}
		if (!ok)break;
	}

	if (ok){
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}


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

int main(){
    double N,K;
    double ans = 2.0;
    int num = 0;   
    std::cin >> N >> K;

    ans = N;
    while(ans>=1.0){
        ans = ans/K;
        num++;
    }

    std::cout << num;
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main()
{
  vector <int> A(3);
  cin >> A[0] >> A[1] >> A[2];
 
  sort(A.begin(), A.end());
 
  cout << abs(A[2]-A[1])+abs(A[1]-A[0]) << endl;
 
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1.0)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define pii pair<ll,pair<ll,ll> >
using namespace std;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9+7;
const double eps = 1e-6;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll mul(ll a,ll b){ll ans=0;a%=mod,b%=mod;while(b) { if(b&1) ans = (ans+a)%mod; a = (a*2)%mod; b >>= 1; }return ans;}
ll powmod(ll a,ll b){ ll ans = 1, pow = a; while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; } return ans;}
//(b/a)%p=b*a^(p-2)%p
//int pr(ll num){//判素
//     if(num == 1) return 0;
//     if(num ==2|| num==3 ) return 1 ;
//     if(num %6!= 1&&num %6!= 5) return 0 ;
//     int tmp =sqrt( num);
//     for(int i= 5;i <=tmp; i+=6 )
//          if(num %i== 0||num %(i+ 2)==0 )return 0 ;
//     return 1 ;
//}
int Day(int y,int m, int d){if(m==1||m==2) { m+=12; y--; }int w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;return w+1;}
//int pri[10000005];
//void getpri(){
//    memset(pri,true,sizeof(pri));
//    pri[0]=pri[1]=0;
//    for(int i=2;i<=10000000;i++){
//        if(pri[i]){
//            for(int j=2*i;j<=10000000;j+=i) pri[j]=0;
//        }
//    }
//}
//struct ac{
//    int x,y;
//    int fa;
//} pre[10000005];
//void init(){
//    for(int i=1; i<=10000005;++i) pre[i].fa=i;
//}
//int getf(int x){
//    if(pre[x].fa == x) return x;
//    else return pre[x].fa = getf(pre[x].fa);
//}
//void join(int x,int y){
//    int a = getf(x);
//    int b = getf(y);
//    if(a!=b) pre[b].fa=a;
//}
//大小写转换
//String s;
//Form(s.begin(),s.end(),s.begin(),::toupper);
//Form(s.begin(),s.end(),s.begin(),::tolower);
//(char)toupper('a')
//(char)tolower('B')
//#pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈
//stable_sort 排序不处理相同元素
//map<int,int>::reverse_iterator rit;
//for(rit=mp.rbegin();rit!=mp.rend();rit++)
//vec动态二维数组
//vector<vector<int>> g(26,vector<int>(100005));
//初始化vec里面套了n个vec
//lower_bound(begin,end,num) 有序数列中返回第一个>=num的数字的地址
//upper_bound( begin,end,num) 返回第一个>num的数字的地址
const int maxn=405;
ll a[maxn],s[maxn];
ll dp[maxn][maxn];
int main(){
    int n;
    cin>>n;
    memset(dp,0x3f,sizeof(dp));
    for(int i=1;i<=n;++i){
        cin>>a[i];
        s[i]=s[i-1]+a[i];
        dp[i][i]=0;
    }
    for(int len=1;len<=n;++len){
        for(int j=1;j+len-1<=n;++j){
            int ends=j+len-1;
            for(int i=j;i<ends;++i){
                dp[j][ends] = min(dp[j][ends],dp[j][i]+dp[i+1][ends]+s[ends]-s[j-1]);
            }
        }
    }
    cout<<dp[1][n]<<endl;
    return 0;
}


Measured memory_bytes: 4884
odd='RUD'
even='LUD'
s=input()
flag=0
for i in range(len(s)):
  a=i+1
  if a%2==0:
    if s[i] not in even:
      flag=1
      break
  else:
    if s[i] not in odd:
      flag=1
      break
if flag==1:
  print ('No')
else:
  print ('Yes')

Measured memory_bytes: 9124
n = gets.to_s.to_i
a = gets.to_s.split.map{|t|t.to_i}.sort

if n == 1 || (a[0] == 1 && a[1] != 1)
  puts 1
  exit
elsif a[0] == 1 && a[1] == 1
  puts 0
  exit
end

MAX_A = a[-1]
hantei = [true] * ( MAX_A + 1 )

a.each_with_index do |t, i|
  
  if hantei[t]
    
    hantei[t] = false if t == a[i+1]

    s = t + t
    while s <= MAX_A
      hantei[s] = false
      s += t
    end
  end
end

ans = 0
a.each do |t|
  ans += 1 if hantei[t]
end

puts ans

Measured memory_bytes: 38440
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,K;

int main(){

	scanf("%d %d",&N,&K);

	double minus = 0;
	double D = N;

	for(int i = 1; i <= min(K-1,N); i++){

		double tmp = 1.0/D,add = 0;
		int work = i;

		while(work <= K-1){

			tmp *= 0.5; //0になる
			add += tmp;
			work *= 2; //2倍になる
		}

		minus += add;
	}

	printf("%.15lf\n",1.0-minus);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

int a[1000009];
set<int>st;

signed main(){
  int n;
  cin>>n;
  int s=0;
  r(i,n)cin>>a[i];
  r(i,110){
    int p=0;
    r(j,n){
      if(a[j]&&!p){s++;p=1;}
      else if(!a[j]){p=0;}
      if(a[j])a[j]--;
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 5e5 + 5;

int a[N];

signed main(){
    IOS;
    string s;
    cin >> s;
    int n = s.length();
    string t = ">";
    for (int i = 0; i < n; i++)
        t += s[i];
    n++;
    n++;
    t += '<';
    for (int i = 0; i < N; i++)
        a[i] = -inf;
    for (int i = 0; i < n; i++) {
        if (t[i] == '>' && t[i+1] == '<') {
            a[i] = 0;
            for (int j = i-1; j >= 0; j--) {
                a[j] = max(a[j], a[j+1] + 1);
                if (t[j] == '<') break;
            }
            for (int j = i+1; j < n; j++) {
                a[j] = max(a[j], a[j-1] + 1);
                if (t[j+1] == '>') break;
            }
        }
    }
    int ss = 0;
    for (int i = 0; i < n-1; i++) {
        ss += a[i];
    }
    cout << ss << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n;
	//ll ans = 0;
	float ans = 0;
	cin >> n;

	V v(n);
	rep(i, n) {
		cin >> v[i];
	}

	sort(ALL(v));

	ans = v[0];
	rep(i, n - 1) {
		ans = (ans + (float)v[i + 1]) / 2;
	}

	cout << ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_c();

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort()
pow2 = [2**i for i in range(1, 31)]
nums = []
counts = {}

for a in A:
	if a not in counts:
		nums.append(a)
		counts[a] = 0
	counts[a] += 1
nums.reverse()
ans = 0
for n in nums:
	if n not in counts:
		continue
	for p in pow2:
		if p > n and (p-n) in counts:
			if n == p - n:
				if counts[p-n] >= 2:
					ans += counts[p-n] // 2
					counts[p-n] = counts[p-n] % 2
			else:
				cnt = min(counts[p-n], counts[n])
				ans += cnt
				counts[p-n] -= cnt
				counts[n] -= cnt
print(ans)

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

int main(){
    string S;
    cin >> S;
    int n = S.length();
    vector<int> res(n,0);

    for(int i = 0; i < n; i++){
        if(S[i] == 'R'){
            int cnt = 0;
            int j = i;
            while(S[j] != 'L'&&j<n){
                j++;
                cnt++;
            }
            while(cnt>0){
            if(cnt%2==0){
                res[j]++;
            }else{
                res[j-1]++;
            }
            cnt--;
            }
            i = j-1;
        }
    }
    reverse(S.begin(),S.end());
    for(int i = 0; i < n; i++){
        if(S[i] == 'L'){
            int cnt = 0;
            int j = i;
            while(S[j] != 'R'&&j<n){
                j++;
                cnt++;
            }
            while(cnt>0){
            if(cnt%2==0){
                res[n-(j+1)]++;
            }else{
                res[n-j]++;
            }
            cnt--;
            }
            i = j-1;
        }
    }
    for(auto e : res){
        cout << e << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  priority_queue<pair<long long, int> >pq;
  long long res = 0;
  for(int i=0;i<N;i++){
    long long A;
    cin >> A;
    pq.push(make_pair(A, 1));
  }
  for(int i=0;i<M;i++){
    int B;
    long long C;
    cin >> B >> C;
    pq.push(make_pair(C, B));
  }

  for(int i=0;i<N;i++){
    auto x = pq.top(); pq.pop();
    // cout << x.first << endl;
    res += x.first;
    if(x.second != 1){
      pq.push(make_pair(x.first, x.second-1));
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    double A,B,flag=0;
    cin >> A >> B;
    for(int i=10; i<=1000; i++){
        double c=i*0.08;
        double d=i*0.10;
        if( (int)c==A && (int)d==B){
            flag=1;
            cout << i << endl;
            break;

        }
    }
    if(flag==0){
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3716
#include <iostream>
#include <iomanip>
#define ld long double
using namespace std;
 
int main(){
	ld a;
  	cin>>a;
  	ld ans=(a/3);
  	ans*=ans;
  	ans*=a/3;
  	cout<<fixed<<setprecision(15)<<ans;
  	return 0;
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          List<string> s = new List<string>();
          for(int i=0;i<a[0];i++)
            s.Add(Input.ScanStr());
          s.Sort();
          for(int i=0;i<a[0];i++)
            Console.Write(s[i]);
          Console.WriteLine();
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> pic(H);

    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        pic[i] = "#" + s + "#";
    }

    pic.insert(pic.begin(), string(W + 2, '#'));
    pic.push_back(string(W + 2, '#'));

    for (auto p : pic)
    {
        cout << p << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='1')
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int H,W;
vector<vector<char>> MAP(52,vector<char>(52,'#'));
vector<vector<int>> dist(52,vector<int>(52,-1));
int siro = 0;
bool can_clear = false;

int bfs(){
    queue<int> qRow;
    queue<int> qCol;
    qRow.push(1);qCol.push(1);
    dist[1][1]=1;
    can_clear = true;
    
    int aR[4] = {-1,0,1,0};
    int aC[4] = {0,1,0,-1};

    while(!qRow.empty()){
        int row=qRow.front(); qRow.pop();
        int col=qCol.front(); qCol.pop();

        for (int i = 0; i < 4; ++i) {
            if(MAP[row+aR[i]][col+aC[i]]!='#' && dist[row+aR[i]][col+aC[i]]==-1){
                dist[row+aR[i]][col+aC[i]] = dist[row][col] + 1;
                qRow.push(row+aR[i]);
                qCol.push(col+aC[i]);
            }
        }
    }

    if(dist[H][W]==-1) can_clear=false;
    int ret = siro - dist[H][W];

    return ret; //
}


int main(void){

    cin>>H>>W;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            cin>>MAP[i][j];
            if(MAP[i][j]=='.') siro++;
        }
    }

    if(MAP[1][1]!='.' || MAP[H][W]!='.'){
        cout<<-1<<endl;
        return 0;
    }
    int ans = bfs();
    if(can_clear==0){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }


    return 0;
}

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

int main() {
	long long A, M, B2;
	double B;

	cin >> A >> B;

	B2 = llround(B * 100.0);
	M = A * B2 / 100;

	cout << M << endl;

	return 0;
}


Measured memory_bytes: 3772
def how_many_ways(n, x):
    ways = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if i+j+k == x:
                    ways += 1

    return ways

def main():
    while True:
        n, x = [int(x) for x in input().split()]
        if n == x == 0:
            break

        print(how_many_ways(n, x))

if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		System.out.println(Math.max(a * b, Math.max(a + b, a - b)));
	}
}

Measured memory_bytes: 23380
#include <stdio.h>


int main(void)
{
	int min,max,num;
	char str[72];
	
	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d%d%d",&min,&max,&num);
	
	if((min <= num)&&(max >= num))
	{
		puts("Yes");
	}else
	{
		puts("No");
	}
	return 0;
}



Measured memory_bytes: 128
n, h = map(int,input().split())
a = []
b = []
for i in range(n):
    ca, cb = map(int,input().split())
    a.append(ca)
    b.append(cb)

amax = max(a)
b.sort(reverse=True)
cnt = 0
while h > 0:
    if b and b[0] > amax:
        h -= b.pop(0)
        cnt += 1
    else:
        cnt += h//amax
        h -= amax * (h//amax)
        if h > 0:
            h -= amax
            cnt += 1
print(cnt)


Measured memory_bytes: 17188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    int c = b - a;
    int ans = 0;
    for(int i = 1; i <= c; i++)
    {
        ans += i;
    }
    cout << ans - b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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 rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int main() {
  int N; cin >> N;
  vector <int> A(N);
  rep(i, N) cin >> A[i];
  
  sort(A.begin(), A.end());
  cout << abs(A[0] - A[A.size()-1]) << endl;
}

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

using real = long double;
const real inf = 1e12 ;

struct Point {
    real x, y, arg;
};

int main() {
    int n;
    std::cin >> n;
    std::vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        real x, y;
        std::cin >> x >> y;
        real arg = std::atan2(y, x);
        p[i] = {x, y, arg};
    }

    std::sort(p.begin(), p.end(), [](Point p1, Point p2) {
        return p1.arg < p2.arg;
    });

    real ans = 0;
    for (int i = 0; i < n; i++) { // 始点
        for (int j = i + 1; j <= i + n; j++) { // 終点
            real xs = 0, ys = 0;
            for (int k = i; k < j; k++) { // 和
                xs += p[k % n].x;
                ys += p[k % n].y;
            }

            ans = std::max(ans, xs * xs + ys * ys);
        }
    }

    std::cout << std::fixed << std::setprecision(12) << std::sqrt(ans) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    int n;
    scanf("%d", &n);
    if (n < 1200) {
        printf("ABC\n");
    } else if (n < 2800) {
        printf("ARC\n");
    } else {
        printf("AGC\n");
    }
}


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

int main(){
    int ans=1000;
    
    vector<int> v(5);
    rep(i,5) cin >> v[i];
    
    do{
        int total = 0;
        for(int i=0;i<5;i++){
            if(i==4) total+=v[i];
            else total+=((v[i]-1)/10+1)*10;
        }
        ans=min(ans,total);
    }while(next_permutation(v.begin(),v.end()));
    
    cout << ans << endl;
    
    return 0;
}





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

using namespace std;

typedef long long LL;
typedef long double LD;


int main()
{
  LL N;
  cin >> N;
  //vector<LL> A(N + 1, 0);
  LL M;
  cin >> M;

  LL Left_max = 1;
  LL Right_min = N;


  for (LL m = 0; m < M; ++m) {
    LL Left;
    LL Right;
    cin >> Left;
    cin >> Right;

    Right_min = min(Right, Right_min);
    Left_max  = max(Left, Left_max);
    //for (LL i = Left; i <= Right; ++i) {
    //  A[i] ++;
    //}

  }

  /*
  LL counter = 0;
  for (LL i = 1; i <= N; ++i) {
    //cerr << i << " : " << A[i] << endl;
    if (A[i] == M) {
      counter++;
    }
  }
  cout << counter;
  */
  cout << max((LL)0,Right_min - Left_max+1) ;
  return 0;
}



int main_()
{
  LL N;
  cin >> N;
  vector<LL> A(N + 1, 0);
  LL M;
  cin >> M;

  LL Left_max = N;
  LL Right_min = 1;


  for (LL m = 0; m < M; ++m) {
    LL Left;
    LL Right;
    cin >> Left;
    cin >> Right;
    for (LL i = Left; i <= Right; ++i) {
      A[i] ++;
    }
  }

  LL counter = 0;
  for (LL i = 1; i <= N; ++i) {
    //cerr << i << " : " << A[i] << endl;
    if (A[i] == M) {
      counter++;
    }
  }
  cout << counter;
  return 0;
}





Measured memory_bytes: 256