akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int ();
        int[] A = Ints ();
        int[] B = Ints ();
        int[] C = Ints ();

        int ret = 0;
        for (int i = 0; i < N; i++) {
            ret += B[i];
        }

        for (int i = 0; i < N - 1; i++) {
            if (A[i] + 1 == A[i + 1]) {
                ret += C[A[i] - 1];
            }
        }

        Console.WriteLine (ret);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

void solve()
{
	int n;
	cin >> n;
	ll x, y, X, Y, a, i;
	x = y = X = Y = i = 0;
	while (cin >> a && ++i)
	{
		x += a, y += a;
		if (i % 2)
		{
			if (x > -1)
				X += x + 1, x = -1;
			if (y < 1)
				Y += 1 - y, y = 1;
		}
		else
		{
			if (y > -1)
				Y += y + 1, y = -1;
			if (x < 1)
				X += 1 - x, x = 1;
		}
	}
	cout << min(X, Y);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007*1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n;
	ll sum = 0;
	ll a[5] = {};
	string s;
	cin >> n;
	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]++;
	}
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				sum += a[i] * a[j] * a[k];
			}
		}
	}
	cout << sum << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	char a[10],s[10],d,f;
	int g,h;
	scanf("%s %s",a,s);
	g=1;
	if(a[0]=='D')
		g=-1;
	if(s[0]=='D')
		g*=-1;
	if(g==-1)
		printf("D\n");
	if(g==1)
		printf("H\n");
	return 0;
}

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

using namespace std;

int main()
{
    static int p[300001];
    
    for (int i = 1; i <= 300000; i++) p[i] = 1;
    p[1] = 0;
    
    for (int i = 2; i <= 300000; i++){
        if (i % 7 != 1 && i % 7 != 6) p[i] = 0;
    }
    
    for (int i = 6; i <= 300000; i++){
        if (p[i]){
            for (int j = 2 * i; j <= 300000; j += i){
                if (j / i % 7 == 1 || j / i % 7 == 6) p[j] = 0;
            }
        }
    }
    
    int n;
    
    while (scanf("%d", &n) && n != 1){
        printf("%d: ", n);
        
        vector<int> v;
        for (int i = 6; i * i <= n; i++){
            if (i && n % i == 0){
                if (i % 7 == 1 || i % 7 == 6) if (p[i]) v.push_back(i);
                if (n / i % 7 == 1 || n / i % 7 == 6) if (i * i != n && p[n / i]) v.push_back(n / i);
            }
        }
        if (v.empty()) v.push_back(n);
        sort(v.begin(), v.end());
        
        for (int i = 0; i < v.size(); i++){
            printf("%d%c", v[i], i + 1 == v.size() ? '\n' : ' ');
        }
    }
    
    return (0);
}

Measured memory_bytes: 2384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll x;
  cin >> x;
  cout << x*x;
}


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

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

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


Measured memory_bytes: 256
#include <stdio.h>

int n,tmp,ans=10000 ;

int main(void){
    
    scanf ("%d",&n) ;
    
    for (int i=0; i<=n; i++) {
        
        tmp = 0 ;
        int j = i ;
        int k = n-j ;
        
        while (j>=1) {
            
            tmp += j%6 ;
            j /= 6 ;
            
        }    
        
        while (k>=1) {
            
            tmp += k%9 ;
            k /= 9 ;
            
        }
        
        if (ans>tmp) {
            
            ans = tmp ;
            
        }
        
    }

    printf ("%d\n",ans) ;
    
    return 0 ;
    
}


Measured memory_bytes: 128
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    string s;
    cin >> s;
    if((int)(s.size()) % 2 == 1){
        cout << "No\n";
        return;
    }
    for(int i = 0; i < s.size() / 2; i += 2){
        if(s[i] != 'h' || s[i + 1] != 'i'){
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <algorithm>      //sort,二分探索,など
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <iterator>       //集合演算(積集合,和集合,差集合など)
#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>         //可変長配列
#include <list>           //双方向連結リスト

using namespace std;


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

	string s;
    cin >> s;
    stack<int> field;
    stack<pair<int, int>> pond;
    int count = 0;
    for(auto&& c : s){
        if(c == '\\'){
            field.push(count);
        }else if(!field.empty() && c == '/'){
            int f_top = field.top();
            field.pop();
            int a = count - f_top;
            while(!pond.empty() && pond.top().first > f_top){
                a += pond.top().second;
                pond.pop();
            }
            pond.push(make_pair(f_top, a));
        }
        ++count;
    }
    list<int> sq;
    while(!pond.empty()){
        sq.emplace_front(pond.top().second);
        pond.pop();
    }
    cout << accumulate(sq.begin(), sq.end(), 0) << "\n";
    cout << sq.size();
    for(auto i = sq.begin(), end = sq.end(); i != end; ++i){
        cout << " ";
        cout << *i;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3276
import std;

long calc(long x) {
    long s = 100;
    for (int i = 1; ; i++) {
        s = s + cast(long)(s * 0.01);
        if (s >= x) return i;
    }
    assert(false);
}

void main() {
    long x; scan(x);
    writeln(calc(x));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 3720
n = int(input())
s = []
for i in range(n):
    s.append(input())

ac_cnt = 0
wa_cnt = 0
tle_cnt = 0
re_cnt = 0

for st in s:
    if st == 'AC':
        ac_cnt = ac_cnt + 1
    elif st == 'WA':
        wa_cnt = wa_cnt + 1
    elif st == 'TLE':
        tle_cnt = tle_cnt + 1
    elif st == 'RE':
        re_cnt = re_cnt + 1

print('AC  x ' + str(ac_cnt))
print('WA  x ' + str(wa_cnt))
print('TLE  x ' + str(tle_cnt))
print('RE  x ' + str(re_cnt))


Measured memory_bytes: 16332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N;
    int A[100];
    int ans = 0;
    cin >> N;
    REP(i, N)
    cin >> A[i];
    int ii = 0;
    int jj;
    REP(i, N - 1)
    {
        FOR(j, i + 1, N)
        {
            ans = ans + A[i] * A[j];
        }
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c,d=MI()
    
    ans=max(a*c,a*d,b*c,b*d)
    print(ans)

main()


Measured memory_bytes: 61724
(set! *unchecked-math* true)

(defrecord Pair [^int y ^int x])
(def ^:const D-Y-X
  [(Pair. -1 -1) (Pair. -1 0) (Pair. -1 1)
    (Pair. 0 -1) (Pair. 0 1)
    (Pair. 1 -1) (Pair. 1 0) (Pair. 1 1)])

(defn get_H_W []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn set_Array [^"[[C" Array H W]
  (dotimes [h H]
    (->> (read-line)
      (char-array W)
      (aset Array h))))

(defn Minesweeper [^"[[C" Array H W]
  (let [X (apply vector-of :int (range W))
        Y (apply vector-of :int (range H))]
    (doseq [x X
            y Y
            :when (not= \# (aget ^"[C" (aget Array y) x))]
      (with-local-vars [counts (unchecked-int 0)]
        (doseq [d-y-x D-Y-X
                :let [dx (unchecked-add-int x (:x d-y-x))
                      dy (unchecked-add-int y (:y d-y-x))]
                :when (and
                        (<= 0 dx)
                        (< dx W)
                        (<= 0 dy)
                        (< dy H)
                        (= \# (aget ^"[C" (aget Array dy) dx)))]
          (var-set counts (unchecked-inc-int @counts)))
        (->> @counts
          (unchecked-add-int (unchecked-int \0))
          unchecked-char
          (aset ^"[C" (aget Array y) x))))))

(defn output [^"[[C" Array]
  (-> (areduce Array idx ret ""
        (str ret
          (apply str (aget Array idx))
          "\n"))
    print))

(let [[H W] (get_H_W)]
  (doto (make-array Character/TYPE H W)
    (set_Array H W)
    (Minesweeper H W)
    (output)))

Measured memory_bytes: 70288
a = gets.to_i

array = []
array << a

res = 0
range = 0..100000
range.each do |i|
  if array[i].to_i.even?
    #偶数
    if array.include?( (array[i].to_i / 2) )
      res = i + 2
      break
    else
      array << (array[i].to_i / 2)
    end
  else
    if array.include?( (3 * array[i].to_i + 1) )
      res = i + 2
      break
    else
      array << (3 * array[i].to_i + 1)
    end
  end
end
puts res

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    map<char, ll> mp;

    // M, A, R, C, Hから始まる文字列の数をカウント
    rep(i, n){
        string s;
        cin >> s;
        mp[s[0]]++;
    }

    // 全ての組み合わせを考える
    ll total = mp['M']*mp['A']*mp['R']
             + mp['M']*mp['A']*mp['C']
             + mp['M']*mp['A']*mp['H']
             + mp['M']*mp['R']*mp['C']
             + mp['M']*mp['R']*mp['H']
             + mp['M']*mp['C']*mp['H']
             + mp['A']*mp['R']*mp['C']
             + mp['A']*mp['R']*mp['H']
             + mp['A']*mp['C']*mp['H']
             + mp['R']*mp['C']*mp['H'];
    cout << total << endl;
}

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

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

  vector<int> a_kouyaku;
  vector<int> b_kouyaku;
  vector<int> ans;

  for(int i=0; i < a; i++){
    if(a % (a - i) == 0){
      a_kouyaku.push_back(a - i);
    }
  }

  for(int i=0; i < b; i++){
    if(b % (b - i) == 0){
      b_kouyaku.push_back(b - i);
    }
  }

  for(int i=0; i < a_kouyaku.size(); i++){
    for(int ii=0; ii < b_kouyaku.size(); ii++){
      if(a_kouyaku.at(i) == b_kouyaku.at(ii)){
        ans.push_back(a_kouyaku.at(i));
        break;
      }
    }
  }

  cout << ans.at(k - 1) << endl;
}

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

Int n;
priority_queue<double, vector<double>, greater<>> pq;
double ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(Int i=0; i<n; ++i){
		Int v; cin >> v;
		pq.push(v);
	}
	while(!pq.empty()){
		double p = pq.top(); pq.pop();
		if(pq.empty()){
			cout << fixed << setprecision(10) << p << "\n";
			return 0;
		}
		double q = pq.top(); pq.pop();
		pq.push((p+q)/2);
	}
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
    
  if ((a <= b) && (c <= b)) cout << a + c << endl; 
  else if ((a <= c) && (b <= c)) cout << a + b << endl;
  else  cout << c + b << endl;
}

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


void solve(long long N, std::string S){
  for(long long i = 0; i < S.size(); i++) {
    cout << (char)('A' + ((S[i] - 'A') + N) % 26);
  }

  cout << endl;
}

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


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
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> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

ll dp[2][5] , nxt[2][5];

void solve(){
  string S; int K; cin >> S >> K;
  dp[0][0] = 1;
  for(auto &c : S){
    memset(nxt , 0 , sizeof(nxt));
    rep(f , 2) rep(k , K + 1) rep(d , 10){
      if(f == 0 && c < d + '0') continue;
      int nf = f | (c > d + '0');
      int nk = k + !!d;
      nxt[nf][nk] += dp[f][k];
    }
    swap(dp , nxt);
  }
  out(dp[0][K] + dp[1][K]);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  string s;
  cin>>n>>s;
  vector2d<int> cum(3,vector<int>(n,0));
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      cum[0][i]++;
    }else if(s[i]=='G'){
      cum[1][i]++;
    }else{
      cum[2][i]++;
    }
    for(int j=0;j<3;j++){
      if(i>=1){
        cum[j][i]+=cum[j][i-1];
      }
    }
  }
  lint result=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n-1;j++){
       int diff=j-i;
       if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R')){
          result+=cum[2][n-1]-cum[2][j];
          if(j+diff<n&&s[j+diff]=='B') result--;
       }
      if((s[i]=='G'&&s[j]=='B')||(s[i]=='B'&&s[j]=='G')){
        result+=cum[0][n-1]-cum[0][j];
        if(j+diff<n&&s[j+diff]=='R') result--;
      }
      if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R')){
        result+=cum[1][n-1]-cum[1][j];
        if(j+diff<n&&s[j+diff]=='G') result--;
      }
    }
  }
  cout<<result<<endl;
  return 0;
}




Measured memory_bytes: 3656
/* kadai 3_3
   nabe9393 */
 
#include<stdio.h>
 
int main(void){
  int data, base;//dataは入力値、baseは進法を表す。
  int digit = 1;//digitは桁数
  scanf("%d %d", &data, &base);//入力
  while (data / base > 0){
    digit += 1 ;
    data = data / base;
  }
  printf("%d\n", digit);
  return 0;
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;






void one_case() {
    int n;
    cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i + 1 < n; ++i) {
        cin >> c[i] >> s[i] >> f[i];
    }

    vector<int> res(n);
    s.pb(1e9);
    for (int i = n - 2; i >= 0; --i) {
        int j = i + 1;
        int to_next = s[i] + c[i];
        while (to_next > s[j]) {
            to_next += (f[j] - to_next % f[j]) % f[j] + c[j];
            ++j;
        }
        if (j + 1 == n) {
            res[i] = to_next;
        } else {
            res[i] = res[j];
        }


    }

    for (auto& el : res) {
        cout << el << "\n";
    }
}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int a,b,c,d,e,f;
    float x,y;
     
    while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f) != EOF){
             
    x = (float)(c*e-f*b)/(a*e-d*b);
    y = (float)(c*d-f*a)/(b*d-e*a);
     
    if(x == -0){
        x = 0;
    }
    if(y == -0){
        y = 0;
    }
    printf("%.3f %.3f\n",x,y);
    }
     
    return(0);
}

Measured memory_bytes: 1788
n = int(input())

def dfs(x):
  if x != '' and n < int(x):
    return 0
  if set(x) == {'3','5','7'}:
    c = 1
  else:
    c = 0
  for i in '357':
    c += dfs(x+i)
  return c

print(dfs(''))

Measured memory_bytes: 9068
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef complex<double> P;

// 角度関連
double angle(const P &a, const P &b) {        // ベクトルａからみたベクトルｂの角度の計算[0,2pi]
  double ret = arg(b)-arg(a);
  return (ret>=0) ? ret : ret + 2*PI;
}
double angle2(const P &a, const P &b) { // ベクトルaとベクトルbの間の角度
  return min(angle(a,b), angle(b,a));
}
double rtod(double rad) {       // ラジアン→度
  return rad*180/PI;
}
double dtor(double deg) {       // 度→ラジアン
  return deg*PI/180;
}


P p[20];
double dp[20][20][10010];       // dp[i][j][k] = i->jでk個取るときの最小合計距離
double dis[20][20];
bool ok[20][20][20];            // i->j->k がいけるならok[i][j][k]=1

int main() {
  int n;
  cin >> n;
  double r,th;
  cin >> r >> th;
  th = dtor(th);
  REP(i,n) cin >> p[i].real() >> p[i].imag();
  REP(i,n)REP(j,n) {
    if (i==j)continue;
    dis[i][j] = abs(p[i]-p[j]);
    REP(k,n) {
      if (j==k) continue;
      if (angle2(p[j]-p[i],p[k]-p[j]) <= th) ok[i][j][k] = 1;
    }
  }
  //REP(i,n)REP(j,n)REP(k,n) if (ok[i][j][k]) cout << i << " "<< j << " "<< k << endl;
  REP(i,n)REP(j,n)REP(k,10010)dp[i][j][k]=INF;
  REP(i,n) {
    if (i==0) continue;
    dp[0][i][1] = dis[0][i];
  }
  REP(k,10010-1) {
    REP(i,n) {
      REP(j,n) {
        REP(l,n) {
          if (!ok[i][j][l]) continue;
          dp[j][l][k+1] = min(dp[j][l][k+1], dp[i][j][k]+dis[j][l]);
        }
      }
    }
  }
  int ans = 0;
  REP(k,10010) {
    REP(i,n)REP(j,n)if(dp[i][j][k]<=r) {
      ans=k;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 31000
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                    cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)             cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll deg[101];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin >> n >> m;
    rep(i,0,m){
        ll x,y;
        cin >> x >> y;
        deg[x]++;
        deg[y]++;
    }
    rep(i,1,n+1) cout << deg[i] << "\n";
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
// Function that returns true if n
// is prime else returns false
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

// Function to return the smallest
// prime number greater than N
int nextPrime(int N)
{

    // Base case
    if (N <= 1)
        return 2;

    int prime = N;
    bool found = false;

    // Loop continuously until isPrime returns
    // true for a number greater than n
    while (!found) {
        prime++;

        if (isPrime(prime))
            found = true;
    }

    return prime;
}

// Driver code
int main()
{
    ll N;
    cin>>N;

    cout << nextPrime(N-1)<<endl;

    return 0;
}


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

int main(){
	map<string,int>M;
	M["lu"]=1;
	M["ru"]=2;
	M["ld"]=-1;
	M["rd"]=-2;
	for(int n;cin>>n,n;){
		int ans=0,asi=0,k=n,nx=3;
		for(string s;k--;){
			cin>>s;
			asi+=M[s];
			if(asi==nx){
				nx=(nx==0?3:0);
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1216
#include "bits/stdc++.h"
using namespace std;

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}

// no change 
const ll MOD = 1e9+7;  
int n;
int x[10],y[10];
ld dist(int i ,int j){
	ld dx = x[i-1] - x[j-1];
	ld dy = y[i-1] - y[j-1];
	return pow(dx*dx + dy*dy, 0.5);
}
void Titan(){
	read(n);
	fo(n)
		read(x[i],y[i]);
	vi v(n);
	fo(n)
		v[i] = i+1;

	ld  sum =0;
	do{
		fo(i,1,n)
			sum+=dist(v[i],v[i-1]);
		

	
	}while(next_permutation(all(v)));

	ld factorial = 1;
	fo(i,2,n+1){
		factorial *= i;
	}
	cout.precision(10);
   cout << fixed << sum/factorial;
   debug() << imie(factorial);


}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3792
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int team[] = new int [n];
		int a=0,b=0,as=0,bs=0;
		for(int i=0 ; i<n*(n-1)/2 ; i++){
			a=sc.nextInt();
			b=sc.nextInt();
			as=sc.nextInt();
			bs=sc.nextInt();
			if(as<bs){
				team[b-1]+=3;
			}else if(as>bs){
				team[a-1]+=3;
			}else{
				team[a-1]+=1;
				team[b-1]+=1;
			}
		}
		for(int i=0 ; i<n ; i++){
			int c=1;
			for(int j=0 ; j<n ; j++){
				if (team[i] < team[j]) {
                    c++;
                }
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 42012
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<cmath>
#include<iomanip>
using namespace std;

int main(void){
	int a[6],c,q,hokan,ue,mae;
	cin>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6];
	cin>>q;
	for(int kibou=0;kibou<q;kibou++){
		cin>>ue>>mae;
		c=0;
		for(int x=0;4>x;x++){
		for(int b=0;4>b;b++){
			if(a[1]==ue&&a[2]==mae){

			break;
			}
			hokan=a[1];
			a[1]=a[2];
			a[2]=a[6];
			a[6]=a[5];
			a[5]=hokan;
			c++;
			if(a[1]==ue&&a[2]==mae){
				break;
			}
		}
		if(a[1]==ue&&a[2]==mae){
			break;
		}	hokan=a[1];
		a[1]=a[4];
		a[4]=a[6];
		a[6]=a[3];
		a[3]=hokan;
		c++;
		if(a[1]==ue&&a[2]==mae){
		break;
	}}
		for(;;){
			hokan=a[1];
			a[1]=a[2];
			a[2]=a[6];
			a[6]=a[5];
			a[5]=hokan;
			c++;
			hokan=a[1];
			a[1]=a[4];
			a[4]=a[6];
			a[6]=a[3];
			a[3]=hokan;
			c++;
			for(int b=0;4>b;b++){
				if(a[1]==ue&&a[2]==mae){
					break;
				}
				hokan=a[1];
				a[1]=a[2];
				a[2]=a[6];
				a[6]=a[5];
				a[5]=hokan;
				c++;
				if(a[1]==ue&&a[2]==mae){
					break;
				}
			}
			if(a[1]==ue&&a[2]==mae){
								break;
							}
			hokan=a[1];
			a[1]=a[4];
			a[4]=a[6];
			a[6]=a[3];
			a[3]=hokan;
			c++;
			hokan=a[1];
			a[1]=a[4];
			a[4]=a[6];
			a[6]=a[3];
			a[3]=hokan;
			c++;
			for(int b=0;4>b;b++){
				if(a[1]==ue&&a[2]==mae){
					break;
				}
				hokan=a[1];
				a[1]=a[2];
				a[2]=a[6];
				a[6]=a[5];
				a[5]=hokan;
				c++;
				if(a[1]==ue&&a[2]==mae){
					break;
				}
			}if(a[1]==ue&&a[2]==mae){
				break;
			}
		}
		cout<<a[3]<<endl;

	}
	return 0;
}



Measured memory_bytes: 3084
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 1
ans_sato = 0
pat = []
mizu = set()
for i in range(int(F/100)+1):
    for j in range(int(F/100)+1):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo/C)+1):
        for j in range(int(howaryo/D)+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                ans_sato = max(ans_sato,sato)
                
    pat.append([m+ans_sato,ans_sato])
    ans_mizu = 1
    ans_sato = 0
    
pat.sort(key = lambda x:x[1]/(x[0]+x[1]), reverse = True)
print(pat[0][0],pat[0][1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
typedef long long int ll;
 
#define min(x,y)(x<y?x:y)
 
using namespace std;
 
#define MAX 1000
 
int main() {
	FAST;
 
	int D, N;
	int res;
 
	cin >> D;
	cin >> N;
 
	if (D==0) { 
		if (N!= 100) res = N;
		else res = N+1;
	}
 
	else {
		if (N!=100) res = pow(100,D)*N;
		else res = pow(100,D) * (N+1);
	}
	cout << res << "\n";
 
    return 0;
}

Measured memory_bytes: 256
class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * 2
        for idx in range(2, max_fact + 1):
            f += [f[idx - 1] * idx % mod]
        fi = [pow(f[-1], mod - 2, mod)]
        for idx in range(max_fact, 0, -1):
            fi += [fi[-1] * idx % mod]
        fi = fi[::-1]
        self.mod = mod
        self.f = f
        self.fi = fi

    def factorial(self, n):
        return self.f[n]

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = 5 * 10**5
mod = 10**9 + 7
fact_instance = Factorial(max_fact, mod)
comb = fact_instance.combination
perm = fact_instance.permutation

N, M = [int(_) for _ in input().split()]
ans = 0
for p in range(N + 1):
    ans += (-1)**p * comb(N, p) * perm(M - p, N - p)
    ans %= mod
ans *= perm(M, N)
ans %= mod
print(ans)


Measured memory_bytes: 52308
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>    //pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init, i, n) for (ll i = init; i < (n); i++)
#define ll long long
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end())
using namespace std;
//コード自動整形 Shift + Alt + F @vscode
ll bimin(ll);


/////main/////
int main()
{
    ll H, W, K, bc;
    cin >> H >> W >> K;
    vector<vector<char>> c(H, vector<char>(W));
    //cout<<"H="<<H<<endl;//
    //cout<<"W="<<W<<endl;//
    //cout<<"K="<<K<<endl;//
    bc = 0;
    rep(0, i, H)
    {
        rep(0, j, W)
        {
            cin >> c.at(i).at(j);

        }
    }

    /*rep(0, i, H)
    {
        rep(0, j, W)
        {
            cout << "c{"<<i<<","<<j<<"}=" << c.at(i).at(j)<<endl;;

        }
    }*/

    ll cnt = 0;
    ll tempi=0;
    ll tempj=0;
    rep(0,i,(1<<H)-1)rep(0,j,(1<<W)-1){
        tempi=i;
        tempj=j;
        rep(0,k,H)rep(0,m,W){
            if((tempi>>k & 1)==(ll)0 && (tempj>>m & 1)==(ll)0){
                if (c.at(k).at(m) == '#'){
                    bc += 1;
                }

            }
            tempi=i;
            tempj=j;

        }
        if(bc == K){cnt++;}
        bc = 0;
    }

cout<<cnt<<endl;

}




/////function/////


ll bimin(ll x){
//入力よりも大きい最小の2の累乗を返す
ll upper = 1;
rep(0,i,x){
    if(x<=upper){
        return upper;
    }else{
        upper *= 2;
    }
}
return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using pii = pair<int,int>;
using ll = long long;

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

    int N;
    bool f = false;
    cin >> N;
    for (int i=0; i<=400; ++i) {
        for (int j=0; j<=400; ++j) {
            if (4*i + j*7 == N) f= true;
        }
    }

    outl(f ? "Yes" : "No");

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int q;
  cin >> q;
  std::set<string> st;
  
  rep(i, q){
     string s;
     cin >> s;
     st.insert(s);
  }
  cout << st.size() << endl;
}


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

int dp[100001][3];
int a[100001][3];
int main(){
	int N;
	cin >> N;
	for(int i =0; i < N; i++){
		for(int j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}
	
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for(int i = 1; i < N; i++){
		for(int j = 0; j < 3; j++){
			if(j==0){
				dp[i][j] = max(dp[i-1][1],dp[i-1][2])+a[i][j];
			}else if(j==1){
				dp[i][j] = max(dp[i-1][0],dp[i-1][2])+a[i][j];
			}else if(j==2){
				dp[i][j] = max(dp[i-1][1], dp[i-1][0]) + a[i][j];
			}
		}
	}

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

}


Measured memory_bytes: 5932
N = int(input())
a = list(map(int,input().split()))

c=0
z=1
f=0

for i in range(0,N):
  if a[i]!=z:
    c+=1
  else:
    f=1
    z+=1
if f==0:
  print("-1")
else:
  print(c)

Measured memory_bytes: 24744
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<long long int> h(n);
	rep(i,n)cin>>h[i];
	long long int prev=h[n-1];
	int cnt=0,max=0;
	for(int i=n-2;i>=0;i--){
		if(prev<=h[i]){
			cnt++;
			if(max<cnt)max=cnt;
		}else{
			cnt=0;
		}
		prev=h[i];
	}
	cout<<max<<endl;


	return 0;
}

Measured memory_bytes: 1024
N = int(input())
restrante = [input().split() for i in range(N)]

for i in range(N):
    restrante[i].append(i+1)
    restrante[i][1] = int(restrante[i][1])

sorted_res= sorted(restrante, key = lambda x:(x[1]), reverse=True)
sorted_ans = sorted(sorted_res, key = lambda x:(x[0]))

for i in range(N):
    print(sorted_ans[i][2])
    


Measured memory_bytes: 3060
#組み合わせ、コンビネーション
def cmb(n,r):
    if n==0:return 0
    else:
        r=min(r,n-r)
        result=1
        for i in range(n-r+1,n+1):
            result*=i
        for i in range(1,r+1):
            result//=i
        return result

#素因数分解、辞書を返す
def factorize(n):
    i=2
    result={}
    while True:
        if i**2>n:
            break
        count=0
        while n%i==0:
            n//=i
            count+= 1
        if count!=0:
            result[i]=count
        i+=1
    if n>1:
        result[n]=1
    return result

N = int(input())
l={}
for i in range(1,N+1):
    for i,j in factorize(i).items():
        l[i] = l.get(i,0)+j


l2 = [0]*5

r = 0
for j,i in l.items():
    if i>=74:
        l2[4]+=1
    elif i>=24:
        l2[3]+=1
    elif i>=14:
        l2[2]+=1
    elif i>=4:
        l2[1]+=1
    elif i>=2:
        l2[0]+=1

r += l2[4]
r += sum(l2[3:])*(sum(l2)-1)
r += sum(l2[2:])*(sum(l2[1:])-1)
r += cmb(sum(l2[1:]),2)*(sum(l2)-2)
print(r)

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

int main() {
	int N, sum=0; cin >>N;
  	vector<int> a(N); for (int i = 0; i < N ; i++)  cin >> a.at(i);
  	vector<int> b(N); for (int i = 0; i < N ; i++)  cin >> b.at(i);
  	vector<int> c(N-1); for (int i = 0; i < N-1 ; i++)  cin >> c.at(i);
  
  	for (int i = 0; i < N-1; i++) {
    	sum += b.at(a.at(i)-1);
      	if(a.at(i+1)-a.at(i) == 1) sum += c.at(a.at(i)-1);
    }
  	sum += b.at(a.at(N-1)-1);
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printve(vector<T>& v) {int n = sz(v); REP(i, n) cerr << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int x,y;
    cin >> x >> y;
    int g[13]={114514,0,2,0,1,0,1,0,0,1,0,1,0};
    if(g[x]==g[y]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
int main() {
    int n,r;
    scanf("%d", &n);
    scanf("%d", &r);
    if(n >= 10) {
        printf("%d" , r);
    } else {
        printf("%d", r + 100* (10 - n));
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 600000

int H;

void maxHeapify(int *A, int i){
  int l,r,largest,temp;
  l = i*2;
  r = i*2+1;
  if(l<=H && A[l] > A[i]) largest = l;
  else largest = i;
  
  if(r<=H && A[r] > A[largest])largest = r;

  if(largest != i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i=H/2;i>=1;i--) {
    maxHeapify(A, i);
  }
}

int main(){
  int i,heap[N];

  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&heap[i]);

  buildMaxHeap(heap);
  
  for(i=1;i<=H;i++) printf(" %d",heap[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2560