akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    val b = (0 until n).map { sc.next().toLong() }
    val c = (0 until n).map { sc.next().toLong() }
    println(problem077c(n, a, b, c))
}

fun problem077c(
    n: Int,
    a: List<Long>,
    b: List<Long>,
    c: List<Long>
): Long {
    var answer = 0L
    val a = a.sorted()
    val b = b.sorted()
    val c = c.sorted()

    fun lowerBound(list: List<Long>, key: Long): Int {
        var ng = -1
        var ok = list.size

        while (ok - ng > 1) {
            val mid = (ok + ng) / 2
            if (list[mid] >= key) ok = mid else ng = mid
        }
        return ok
    }

    for (i in b) {
        answer += lowerBound(a, i).toLong() * (n - lowerBound(c, i + 1))
    }

    return answer
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) {
        cin >> a[i];
        a[i]--;
    }
    int ans = 0;
    rep(i, 0, n){
        if(a[a[i]] == i) ans++;
    }
    cout << ans/2 << endl;
    return 0;
}


Measured memory_bytes: 3692
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N;
const int cycle[] = {55440,13,17,19,23};
vector<vi> v[5];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N && N){
		rep(i,5)v[i].clear();
		rep(i,N){
			int d,t,q[25];
			cin>>d>>t;
			rep(j,d)cin>>q[j];
			int c=0;
			while(cycle[c] % d)c++;
			vi w;
			rep(j,cycle[c]){
				w.pb(q[(j+t)%d]);
			}
			v[c].pb(w);
		}
		int ans=0;
		rep(i,5){
			int mx=0;
			rep(j,cycle[i]){
				int sum=0;
				rep(k,sz(v[i])){
					sum += v[i][k][j];
				}
				mx=max(mx,sum);
			}
			ans+=mx;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 29812
# AtCoder
from collections import deque
S = input()
Q = int(input())
qs = [input().split() for i in range(Q)]

ans = deque(S)
flag = 0
count = 0
for q in qs:
    if q[0] == '1':
        if flag == 0:
            flag = 1
        else:
            flag = 0
        count += 1
    else:
        if flag == 0:
            if q[1] == '1':
                ans.appendleft(q[2])
            else:
                ans.append(q[2])
        else:
            if q[1] == '1':
                ans.append(q[2])
            else:
                ans.appendleft(q[2])

if count % 2 == 1:
    ans.reverse()

print(*ans, sep='')


Measured memory_bytes: 150620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k) cout<<s<<endl;
    else{
        cout<<s.substr(0,k)<<"..."<<endl;
    }
}


Measured memory_bytes: 3628
'use strict'

const main = (input) => {
    const vowel = ['a', 'e', 'i', 'o', 'u']
    const c = input.split('\n')[0]
    if(vowel.indexOf(c) !== -1){
        console.log('vowel')
    }else{
        console.log('consonant')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

int main() {
	int a=1e9, z=-1;

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); ++i){

		a = min(a, (s[i] == 'A' ? i : 1000000));
		z = max(z, (s[i] == 'Z' ? i + 1 : -1));
	}

	cout << z - a << endl;
}


Measured memory_bytes: 640
fn main() {
    // loop{ //For test
        solve();
    // }
}

#[allow(dead_code)]
fn solve(){
    let mut nk: Vec<i64> = read_vec();
    let mut N: i64 = nk[0];
    let mut K: i64 = nk[1];
    let mut H: Vec<i64> = read_vec();
    if K > 0{
        H.sort();
        for i in 0..K {
            H.pop();
        }
    }
    println!("{}", H.iter().sum::<i64>());

}

fn is_even(arr: &Vec<i32>) -> bool {
    return arr.iter().all(|x| x%2==0);
}

/// 標準入力から一行を読み取り、指定の型に変換する関数
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    let _ = std::io::stdin().read_line(&mut s);
    s.trim().parse().ok().unwrap()
}

/// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

/// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

Measured memory_bytes: 13560
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	string s[55];
	int t[55];
	for(int i=0; i<n; i++){
		cin>>s[i]>>t[i];
	}
	string x; cin>>x;
	int ans=-1;
	for(int i=0; i<n; i++){
		if(ans>=0) ans+=t[i];
		if(s[i]==x) ans=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
function main(arg) {
	var tmp = arg.split("\n")[0]

	tmp = tmp.split(" ")

	tmp  = tmp.map(e => Number(e))
	
	tmp.sort()

	tmp = tmp.join("")

	if (tmp === "1479") {
		console.log("YES")
	} else {
		console.log("NO")
	}

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
    string s;
    cin >> s;
    rep(i,s.size()) cout << 'x';
    cout << endl;
    return 0;
}

Measured memory_bytes: 3560
# https://atcoder.jp/contests/abc145/tasks/abc145_c

import itertools


def calc_dist(p1, p2):
    x_delta = p1[0] - p2[0]
    y_delta = p1[1] - p2[1]
    return (x_delta ** 2 + y_delta ** 2) ** (1/2)


if __name__ == "__main__":
    N = int(input())
    A = []
    for _ in range(N):
        x, y = map(int, input().split())
        A.append((x, y))

    dist_list = []
    for permutated in itertools.permutations(A):
        dist = 0
        for i in range(1, len(permutated)):
            dist += calc_dist(permutated[i], permutated[i-1])
        dist_list.append(dist)

    print(sum(dist_list) / len(dist_list))


Measured memory_bytes: 43500
a,b=map(int, input().split())
s = list(map(str,input().split()))
num=int(a)
D = set(s)
numbers = {str(i) for i in range(10)}
available = numbers - D

for i in range(a,100000):
  nums = set(str(i))
  if nums <= available:
    print(i)
    break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}




void solve()
{
  
  int n,k;
  cin >> n >> k;

  int dp[n+1] , h[n+1];
  
  

  forf(i,1,n+1) cin >> h[i];
  dp[1]=0;

  forf(i,2,n+1)
  {
    dp[i] = INT_MAX;
    for(int j=1;j<=k;j++)
    if((i-j)>=1)
    {
         dp[i] = min(dp[i] , dp[i-j] + abs(h[i]-h[i-j]));
    }

  }

  cout<<dp[n];
}


int32_t main()
{
  pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

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

string S;

int main() {
    cin >> S;

    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '+') ans++;
        else ans--;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
using namespace std;

int main(void){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n;
    cin>>n;
    vl l(n);
    rep(i,n) cin>>l[i];
    sort(l.begin(),l.end());
    ll sum = 0;
    rep(i,n-1) sum += l[i];
    if(sum > l[n-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main(){
  int N;
  cin >> N;
  int answer = 0;
  int count = 0;
  for(int i = 1; i <= N; i+=2){
    for(int j = 1; j <= i; j++){
      if(i % j == 0){
        count++;
      }
    }
    if(count == 8){
      answer++;
      count = 0;
    }
    count = 0;
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                int sum = 0;
                int[] t = new int[n];
                for(int i = 0 ; i < n ; i++){
                        t[i] = Integer.parseInt(sc.next());
                        sum += t[i];
                }
                int m = Integer.parseInt(sc.next());
                int[][] p = new int[2][m];
                for(int i = 0 ; i < m ; i++){
                        for(int j = 0 ; j < 2 ; j++){
                                p[j][i] = Integer.parseInt(sc.next());
                        }
                        ou.print(sum - t[p[0][i] - 1] + p[1][i] + "\n");
                }
                sc.close();
                ou.flush();
        }
}

Measured memory_bytes: 38568
def main():
    N, M, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]

    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])

    for i in range(M):
        b.append(b[i] + B[i])

    ans, j = 0, M
    for i in range(len(a)):
        if a[i] > K:
            break
        while a[i] + b[j] > K:
            j -= 1
        ans = max(ans, i + j)

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  int h[n];
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    mx = max(mx, h[i]);
  }

  // 1マス分ずつ下げていく
  int ans = 0;
  for (int i = mx; i >= 1; i--) {
    int idx = 0;
    while (idx < n) {
      if (h[idx] == 0) {
        idx++;
      } else {
        ans++;
        while (idx < n && h[idx] > 0) {
          idx++;
        }
      }
    }
    for (int j = 0; j < n; j++) {
      if (h[j]) h[j]--;
    }
  }

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

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

#define lint long long
#define P pair<int, int>
#define 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 repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct unionFind{
    vector<int> par, siz;

    void init(int N){
        par.resize(N);
        siz.resize(N);
        for(int i = 0 ; i < N ; ++i){
            par[i] = i;
            siz[i] = 1;
        }
    }

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

    bool unite(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y){
            return false;
        }

        if(siz[x] > siz[y]){
            swap(x, y);
        }
        
        par[x] = y;
        siz[y] += siz[x];

        return true;
    }

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

    int size(int x){
        return siz[root(x)];
    }
};

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

    int n, m;
    cin >> n >> m;

    vector<int> a(m), b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }

    vector<lint> ans(m);
    lint now = n * (n - 1LL) / 2LL;
    unionFind uf;
    uf.init(n);
    repr(i, m){
        ans[i] = now;
        lint sa = uf.size(a[i]);
        lint sb = uf.size(b[i]);
        if(uf.unite(a[i], b[i])){
            now -= sa * sb;
        }
    }

    rep(i, m){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
  	cout << "vowel" << endl;
  } else {
  	cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import math
mod = 10**9+7
N = int(input())

iwashi01 = 0
iwashi10 = 0
iwashi00 = 0
iwashi = dict()
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        iwashi00 += 1
    elif a == 0:
        iwashi01 += 1
    elif b == 0:
        iwashi10 += 1            
    else:
        g = math.gcd(abs(a), abs(b))
        a //= g; b //= g
        if a*b > 0:
            if a < 0 and b < 0:
                a *= -1
                b *= -1
            iwashi.setdefault((a, b), [0, 0])
            iwashi[(a, b)][0] += 1
        if a*b < 0:
            if a < 0 and b > 0:
                a *= -1
                b *= -1
            a, b = -b, a
            iwashi.setdefault((a, b), [0, 0])
            iwashi[(a, b)][1] += 1

r = 2**iwashi01 % mod - 1 + 2**iwashi10 % mod - 1 + 1
for s, t in iwashi.values():
    r *= 2**s % mod -1 + 2**t % mod -1 + 1
    r %= mod
print((r + iwashi00 - 1) % mod)

Measured memory_bytes: 62824
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
const long double PI = acos(-1);
using namespace std;
int main (){
    int a, b; 
    cin >> a >> b;
    while(a!=0&&b!=0){
        for(int i=0; i<a; i++){
             for(int j=0; j<b; j++){
                 if(i%2==1){
                     if(j%2==1) cout << "#";
                     else cout << ".";
                 } 
                 else{
                     if(j%2==1) cout << ".";
                     else cout << "#";
                 } 
             }
            cout << endl;
        }
        cout << endl;
        cin >> a >> b;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int n,k;
    cin>>n>>k;
    int a[n+1];
    int s;
    vector<int>x,y,z;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        if(s>0)
        {
            x.push_back(s);
        }
        else if(s<0)
        { 
            y.push_back(-s);
        }        
        else
        {
            z.push_back(s);
        }        
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    int sz1=x.size(),sz2=y.size();
    if(sz1*sz2>=k)
    {
        int mx=0;
        int l=1,r=1e18;
        while (l<=r)
        {
            int mid=l+(r-l)/2;
            int ini=0;
            int cnt=0;
            for(int i=sz1-1;i>=0;i--)
            {
                if(ini!=sz2)
                while (y[ini]*x[i]<mid)
                {
                    ini++;
                    if(ini==sz2)
                        break;
                }
                cnt+=sz2-ini;
            }
            if(cnt>=k)
            {
                mx=max(mx,mid);
                l=mid+1;
            }
            else
            {
                r=mid-1;
            }            
        }
        cout<<-mx;
    }
    else
    {
        int sz3=z.size();
        int tot=sz1*sz2+(sz1+sz2)*sz3+(sz3*(sz3-1))/2;
        if(tot>=k)
        {
            cout<<0;
            return 0;
        }
        else
        {
            k-=tot;
            int mn=5e18;
            int l=1,r=1e18;
            while (l<=r)
            {
                int mid=l+(r-l)/2;
                int ini=sz1-1;
                int cnt=0;
                for(int i=0;i<sz1;i++)
                {
                    if(ini>i)
                    while (x[ini]*x[i]>mid)
                    {
                        ini--;
                        if(ini<=i)
                            break;
                    }
                    if(ini>i)
                        cnt+=ini-i;
                }
                ini=sz2-1;
                for(int i=0;i<sz2;i++)
                {
                    if(ini>i)
                    while (y[ini]*y[i]>mid)
                    {
                        ini--;
                        if(ini<=i)
                            break;
                    }
                    if(ini>i)
                        cnt+=ini-i;
                }
                if(cnt>=k)
                {
                    mn=min(mn,mid);
                    r=mid-1;
                }
                else
                {
                    l=mid+1;
                }            
            }
            cout<<mn;
        }        
    }
    

} 



Measured memory_bytes: 2548
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new InputStream();
            var x = cin.ReadInt();
            WriteLine(Ceiling((Sqrt(1 + 8 * (long)x) - 1)/2));
        }
    }

    public class InputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public InputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine()   => Console.ReadLine();
        public int    ReadInt()    => int.Parse(Read());
        public long   ReadLong()   => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	if (S == "ABC") puts("ARC");
	else puts("ABC");
	return 0;
}


Measured memory_bytes: 3624
#![allow(non_snake_case)]

use std::io;

// std::i32::MAX ≒ 2e9なので途中でも用いて問題なさそう

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let mut stack: Vec<i32> = vec![];

    for v in buf.split_whitespace() {
        // println!("{}", &v);
        match v.parse::<i32>() {
            Ok(ok) => stack.push(ok),
            Err(_) => {
                    let a = stack.pop().unwrap();
                    let b = stack.pop().unwrap();
                    let s = v.to_string();
                    match s.as_str() {
                        "+" => stack.push(a+b),
                        "-" => stack.push(b-a),
                        "*" => stack.push(a*b),
                        _ => panic!("not match"),
                }
            }
        }
    }
    let res = stack.pop().unwrap();
    println!("{}", res);
}



Measured memory_bytes: 5020
#include<iostream>
#include<cstdio>
#include<map>
#define MN 100000
#define ll long long
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char s[MN+5];ll L;
int n,c[MN+5][2],mark[MN+5],cnt,ans[65];
inline void GetSg(ll x)
{
	if(x&1) ans[0]^=1;
	else if(x%4==2) ans[1]^=1;
	else
	{
		int res=0;
		for(;~x&1;x>>=1) ++res;
		ans[res]^=1;	
	}
}
void dfs(int x,int dep)
{
	if(mark[x]) return;
	if(c[x][0]) dfs(c[x][0],dep+1); else GetSg(L-dep);
	if(c[x][1]) dfs(c[x][1],dep+1); else GetSg(L-dep);	
}
int main()
{
	n=read();cin>>L;
	for(int i=1;i<=n;++i)
	{
		scanf("%s",s+1);int x=0;
		for(int j=1;s[j];++j)
		{
			if(!c[x][s[j]-'0']) c[x][s[j]-'0']=++cnt;
			x=c[x][s[j]-'0']; 
		}
		mark[x]=1;
	}
	dfs(0,0);
	for(int i=0;i<=60;++i) if(ans[i]) return 0*puts("Alice");
	puts("Bob");
	return 0;
}



Measured memory_bytes: 3456
#pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse2")
 
    #include <bits/stdc++.h>
    #include <vector> 
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace std;
 
    #define int         long long
    #define ll          long long
    #define pb          push_back
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define mp          make_pair
    #define all(a)      (a).begin(),(a).end()
    #define FF           first
    #define SS           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define rep(i,a,b)  for(int i=a;i<b;i++)
     ll hell=1000000007;

     

    int solve(){    
      
      int n;
      cin>>n;
      vi  a(n+1);
      a[0]=0;
      rep(i,0,n)cin>>a[i+1];
      sort(all(a));

      int ans=0;
      rep(i,1,n+1)
      rep(j,i+1,n+1)
      if(a[i]!=a[j])
      rep(k,j+1,n+1)
      if(a[i]!=a[k]&&a[j]!=a[k])
      if(a[i]+a[j]>a[k])ans++;
      cout<<ans<<endl;
      
   return 0;
    }  
 
 
    signed main()
    {    
    
       

 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
 
    int t=1,k=1;                                                                                                                  
    //cin>>t;
   
 
    while(t--)
    {
     
     // cout<<"Case #"<<k++<<": ";
     solve();
     //cout<<endl;
    }
    return 0;
    } 

Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	vector<int>a[500];
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = false;
	ans = 0;
	scanf("%d", &n);
	f(i, 500){
		x = i*(i + 1);
		x = x / 2;
		if (x == n){
			v = true;
			k = i + 1;
			break;
		}
	}
	if (!v){
		printf("No\n");
		return 0;
	}
	x = 1;
	f(i, k){
		f(j, i){
			a[i].push_back(x);
			a[j].push_back(x);
			x++;
		}
	}

	printf("Yes\n");
	printf("%d\n", k);
	f(i, k){
		printf("%d", a[i].size());
		f(j, a[i].size())printf(" %d", a[i][j]);
		printf("\n");
	}


	return 0;
}

Measured memory_bytes: 2304
n = int(input())
p = input().split()
a = int(p[0])
b = int(p[1])
first = []
second = []
third = []
q = input().split()
for i in q:
    i = int(i)
    if i <= a:
        first.append(i)
    elif i <= b:
        second.append(i)
    else:
        third.append(i)
print(min([len(first), len(second), len(third)]))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>
//#include <DEBUG.h>
#define NNNN 1000000
#define LL long long
char str[1000000];
long num[1000000];
long baka[100];
long ran[1000000][2],p[1000000];
bool cmp(long &a,long &b)
{
	long l,i,j;
	for (i=ran[a][0],j=ran[b][0];(i<=ran[a][1])&&(j<=ran[b][1]);i++,j++)
	{
		if (num[i]!=num[j])
		{
			return num[i]<num[j];
		}
	}
	if (j<=ran[b][1]) {return true;}
	return false;
}
long cmp2(long a,long b)
{
	long l,i,j;
	for (i=ran[a][0],j=ran[b][0];(i<=ran[a][1])&&(j<=ran[b][1]);i++,j++)
	{
		if (num[i]!=num[j])
		{
			return num[i]-num[j];
		}
	}
	return (ran[a][1]-ran[a][0])-(ran[b][1]-ran[b][0]);
}
int main()
{
	LL i,j,k,a,b,c,l,r;
	scanf("%s",&str);
	for (i=0,j=0;str[i]>0;i++)
	{
		if (islower(str[i])!=0)
		{
			num[++j]=str[i]-'a'+1;
		}
	}
	*num=j;l=0;
	scanf("%lld",&k);
	for (i=1;i<=5;i++)
	{
		for (j=1;j<=*num;j++)
		{
			if (j+i-1<=*num)
			{
				ran[++l][0]=j;
				ran[l][1]=j+i-1;
				p[l]=l;
//				printf("%ld %ld\n",j,j+i-1);
			}
		}
	}
	std::sort(p+1,p+l+1,&cmp);
//	print(p,l);
	k-=1;
	for (i=2;i<=l;i++)
	{
		if (k==0) {a=p[i-1];break;}
		if (cmp2(p[i],p[i-1])!=0)
		{
			k-=1;
		}
	}
	if (i>l) {a=p[l];}
	for (i=ran[a][0];i<=ran[a][1];i++)
	{
		printf("%c",num[i]+'a'-1);
	}
	printf("\n");
//	format(num,26,baka,num);
//	SuffixArray(num,lcp,rank,num2);

	return 0;
}

Measured memory_bytes: 6528
fun main(args: Array<String>) = abc158c()

fun abc158c() {
    val (a, b) = readLine()!!.split(' ').map { it.toLong() }

    for (i in 1..10000) {
        val value8 = Math.floor(i.toDouble() * 0.08).toLong()
        val value10 = Math.floor(i.toDouble() * 0.1).toLong()
        if (value8 == a && value10 == b) return println(i)
    }

    println(-1)
}


Measured memory_bytes: 38120
#include <stdio.h>

int main(void) {
  int a,b;
  int total=0;
  scanf("%d%d",&a,&b);
  for(int i=1;i<=2;i++) {
    if(a>=b) {
      total+=a;
      a--;
    }else{
      total+=b;
      b--;
    }
  }
  printf("%d\n",total);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() { 


  long long n,d; cin >> n >> d;
  long long cnt = 0;

  for(int i = 0;i<n;i++)
  {
      long long x,y; cin >> x >> y;

      if ((x*x) + (y*y) <= d*d) cnt++;
  }

  cout << cnt << endl;
    
    
  return 0; 
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
char S[15];
int len;
ll ans=0;
ll DFS(int pos,ll s,ll t) {
//	printf("%d %lld %lld\n",pos,s,t);
	if(pos>len)
		return s+t;
	ll ret=DFS(pos+1,s+t,S[pos]-'0')+DFS(pos+1,s,t*10+S[pos]-'0');
	return ret;
}
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%s",S+1);
	len=strlen(S+1);
	ans=DFS(1,0,0);
	printf("%lld\n",ans/2);
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, m int64
	fmt.Scan(&n, &m)
	var ans int64
	if m >= 2*n { // Sを全部使い切れる
		ans = n + (m-2*n)/4
	} else { // Sを全部使いきれない
		ans = m / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
ll p[N],cnt;
void pbreak(ll n)
{
    if(n==0)return ;
    for(ll i=2; i*i<=n; i++)
    {
        if(n%i==0)p[++cnt]=i;
        while(n%i==0)n/=i;
    }
    if(n!=1)p[++cnt]=n;
}
ll sum,sum2;
ll qpow(ll a,ll b,ll p)
{
    ll ans=1;
    while(b)
    {
        if(b&1)ans=ans*a%p;
        a=a*a%p;
        b>>=1;
    }
    return ans;
}
bool vis[N];
ll a[N],b[N];
int n;
bool ok(int p) {
    if (a[0] % p) {
        return false;
    }
    for (int i = 0; i <= n; ++i) {
        b[i] = a[i];
    }
    for (int i = n; i >= p - 1; --i) {
        (b[i - (p - 1)] += b[i]) %= p;
        b[i] = 0;
    }
    for (int i = 0; i <= n; ++i) {
        if (b[i] % p) {
            return false;
        }
    }
    return true;
}
bool isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)return false;
    }
    return true;
}
int main()
{
 
    ll m=-1;
    ll x;
    scanf("%d",&n);
    for(int i=n; i>=0; i--)
    {
        scanf("%lld",a+i);
    }
    ll g=0;//cout<<" "<<endl;
    for(int i=n;i>=0;i--)
    {
        g=__gcd(g,abs(a[i]));
        //cout<<g<<endl;
    }
    pbreak(g);
    ll summ=0;
    for(int i=2;i<=n;i++)
    {
        if(isprime(i))p[++cnt]=i;
    }
    //for(int i=1;i<=cnt;i++)cout<<p[i]<<" ";
    /*for(int k=2; k<=100; k++)
    {
        for(int j=1; j<=cnt; j++)
        {
            summ=0;
            for(int i=n; i>=1; i--)
            {
                summ+=((a[i]%p[j]+p[j])%p[j])*((qpow(k,i,p[j])+p[j])%p[j])%p[j];
            }
            if(summ%p[j]!=0)vis[j]=true;
        }
    }*/
    sort(p+1,p+1+cnt);
    int cntt=unique(p+1,p+cnt+1)-(p+1);
    for(int i=1; i<=cntt; i++)
    {
        if(ok(p[i]))cout<<p[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        int n = readInteger(br);

        int ichi = n % 10;

        if(ichi == 3){
            System.out.println("bon");
            return;
        }

        switch (ichi) {
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                return;
            default:
                System.out.println("hon");
        }

    }


    private static int readInteger(BufferedReader br) throws IOException {
        return Integer.parseInt(br.readLine());
    }

    private static int[] readIntegers(BufferedReader br) throws IOException {
        String[] s = br.readLine().split(" ");
        int[] ret = new int[s.length];
        for (int i = 0; i < s.length; i++) {
            ret[i] = Integer.parseInt(s[i]);
        }
        return ret;
    }

}


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

using namespace std;

#define endl "\n"
#define F first
#define S second
#define B begin()
#define E end()
#define PB push_back
#define int long long

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

const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e7 + 9;

int qpow(int a,int b)
{
    if(b==0)
        return 1;
    int t = qpow(a,b/2);
    if(b%2==1)
    return t*t*a;
    else
        return t*t;

}

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);


    int x;
    cin >> x;
    for(int i=-500;i<=500;i++)
    {
        for(int j=-500;j<=500;j++)
        {
            int a = qpow(i,5) , b = qpow(j,5);
            if(a-b==x)
            {
                cout << i << ' ' << j ;
                return 0;
            }
        }
    }

	return 0;
}


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

long long n,a,b,c,f1[100010],f2[100010],f3[100010],m=1e10; 
main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        f1[i]=max(f2[i-1],f3[i-1])+a;
        f2[i]=max(f1[i-1],f3[i-1])+b;
        f3[i]=max(f1[i-1],f2[i-1])+c;
    }
    cout<<max(f1[n-1],max(f2[n-1],f3[n-1]));
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n,q;
	while(1){
		cin >> n >> q;
		if(n==0&&q==0) break;
		vector <string> sdata;
		vector <int> a;
		vector <int> b;
		REP(i,n){
			string tmp;
			int a1,a2;
			cin >> tmp >> a1 >> a2;
			sdata.pb(tmp);
			a.pb(a2-a1+1);
			b.pb(a2);
		}
		REP(i,q){
			int tmp;
			cin >> tmp;
			bool found = false;
			REP(j,a.size()){
				if(a[j]<=tmp&&tmp<=b[j]){
					found = true;
					cout << sdata[j] << " " << tmp-a[j]+1 << endl;
				}
			}
			if(!found) cout << "Unknown" << endl;
		}
	}
}

Measured memory_bytes: 1304
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
using namespace std;
int main() {
    int k, s;
    int ans = 0;
    cin >> k >> s;
    for(int a = 0; a <= k; a++) {
        for(int b = 0; b <= k; b++){
            int c = s - a - b;
            if(0 <= c && c <= k) ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=1100000;
const int inf=0x3f3f3f3f;

signed main() {
//	freopen("test.in","r",stdin);
	int n,l,r;read(n,l,r);
	printf("%d",(n-l+1)*(n-r+1));
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int
int F(int A, int B) {
    int ansA = 0;
    int ansB = 0;
    while(A > 0) {
        A /= 10;
        ansA++;
    }
    while(B > 0) {
        B /= 10;
        ansB++;
    }
    return max(ansA, ansB);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int tmp = N;
    int di = 2;
    int k = 1;
    int ans = F(N, k);
    for (int i = 2; i*i <= N; i++) {
        if (N % i != 0) continue;
        ans = min(ans, F(i, N / i));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
const int nax = 101;
int a[nax];
void solve()
  {
   int n;
   cin>>n;
   loop(i,0,n)
    cin>>a[i];
   int cnt = 0;
   loop(i,0,n)
    loop(j,i+1,n)
     loop(k,j+1,n)
      if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i])
         cnt++;
    cout<<cnt;  
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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

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

int main(){

    ll n;

    cin >> n;
    
    vector<pair<int,int> > a(n);
    ll suma=0,sumb=0;

    rep(i,n){
        cin >> a[i].second;
        suma += a[i].second;
    }
    rep(i,n){
        cin >> a[i].first;
        sumb += a[i].first;
    }

    if(suma<sumb){
        cout << -1 << endl;
        return 0;
    }

    ll le=0;
    ll ans =0;
    vector<ll> b;

    rep(i,n){
        if(a[i].first>a[i].second){
            ans++;
            le+=a[i].first-a[i].second;
        }else{
            b.push_back(a[i].second-a[i].first);
        }
    }

    if(ans==0){
        cout << ans << endl;
        return 0;
    }

    sort(b.begin(),b.end());

    ll su=0;

    rep(i,n){
        su+=b.back();
        ans++;
        b.pop_back();
        if(su>=le){
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
n,m,x,y=map(int,input().split())

X=list(map(int,input().split()))
Y=list(map(int,input().split()))

X.append(x)
X.sort()
Y.append(y)
Y.sort()

if max(X)<min(Y):
    print('No War')
else:
    print('War') 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 1e3 + 5;

const LL mod = 1e9 + 7;

LL ksm(LL a, LL b) { LL ans = 1LL; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; }  return ans; }

char a[11][N];
int tmp[11], tot = 0;
int n, m, k;
int c1[11], c2[11];

int dfs(int x) {
    mem(c2, 0);
    tot = 0;
    tmp[tot++] = 0;
    rep(i, 0, n - 1) {
        if((x >> i) & 1) tmp[tot++] = i + 1;
    }

    tmp[tot] = n;

    int ans = tot - 1;

    rep(i, 1, m) {
        bool ok = 1; mem(c1, 0);
        rep(j, 0, tot) {
            rep(l, tmp[j] + 1, tmp[j + 1]) c1[j] += (a[l][i] == '1');
            if(c1[j] > k) return INF;
            if(c1[j] + c2[j] > k) ok = 0;
        }
        if(ok) rep(j, 0, tot) c2[j] += c1[j];
        else {
            ans++;
            rep(j, 0, tot) c2[j] = c1[j];
        }
    }

    return ans;

}

void solve() {

    scanf("%d %d %d", &n, &m, &k);

    rep(i, 1, n) scanf("%s", a[i] + 1);

    int ans = INF;
    rep(i, 0, (1 << n) - 1) {
        ans = min(ans, dfs(i));
    }

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

}


int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();


    solve();

    return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	string S; cin >> S;
	int N = S.size();
	if(S[0] == '0' || S[N-1] == '1') return cout << -1 << endl, 0;
	repp(i,0,N-1) if(S[i] != S[N-2-i]) return cout << -1 << endl, 0;
	int z = 1;
	repp(i,1,N) if(S[i] == '1'){
		while(z <= i){
			cout << z << ' ' << i+1 << endl;
			++z;
		}
	}
	repp(i,z+1,N+1) cout << z << ' ' << i << endl;
	return 0;
}


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

using namespace std;

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int>x(N), y(M);

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

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

	int XMAX = X;
	int YMIN = Y;

	for (int i = 0; i < N; i++) {
		XMAX = max(XMAX, x[i]);
	}

	for (int i = 0; i < M; i++) {
		YMIN = min(YMIN, y[i]);
	}

	if (XMAX < YMIN) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;

#[fastout]
fn main() {
    input!{
        N: String,
    }
    println!("{}", format!("{}{}", "ABC".to_string(), N));
}


Measured memory_bytes: 2144
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

bool inrange(int k) {
	return (k >= 1 && k <= 12);
}

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

	int k1 = (s[0] - '0') * 10 + s[1] - '0';
	int k2 = (s[2] - '0') * 10 + s[3] - '0';

	if (inrange(k1) && inrange(k2)) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (inrange(k1)) {
		cout << "MMYY" << endl;
	}
	else if (inrange(k2)) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
use std::error::Error;
use std::io;

pub fn main() {
    if let Err(_e) = run() {
        panic!("failed.");
    }
}

fn run() -> Result<(), Box<dyn Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let mut nk: Vec<i32> = input
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    let n = nk[0];
    let k = nk[1];
    input.clear();

    io::stdin().read_line(&mut input)?;
    let mut nums: Vec<i32> = input
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    input.clear();
    nums.sort();

    let mut result = 0;
    for i in 0..k {
        result += nums[i as usize];
    }
    println!("{}", result);

    Ok(())
}


Measured memory_bytes: 2100
H,W = map(int,input().split())
S = [input() for i in range(H)]
T = [[False]*W for i in range(H)]
Q = [(1,0,0)]
cnt = 0
while Q:
    q = Q.pop(0)
    if min(q)<0 or q[1]>=H or q[2]>=W:continue
    if S[q[1]][q[2]]=="#" or T[q[1]][q[2]]:continue
    if q[1]==H-1 and q[2]==W-1:
        cnt = q[0]
        break
    T[q[1]][q[2]]=True
    Q.append((q[0]+1,q[1]+1,q[2]))
    Q.append((q[0]+1,q[1]-1,q[2]))
    Q.append((q[0]+1,q[1],q[2]+1))
    Q.append((q[0]+1,q[1],q[2]-1))
ans = 0
for s in S:ans+=s.count(".")
print(ans-cnt if cnt else -1)

Measured memory_bytes: 41180
def path(w,h,sm):
	global mx
	if w < 0 or len(inp[h])-1 < w: return 0
	sm += inp[h][w]
	if sm < mx[h][w]: return 0
	else: mx[h][w] = sm
	if h == c-1: return sm
	if h < c/2:	return max(path(w,h+1,sm),path(w+1,h+1,sm))
	else: return max(path(w,h+1,sm),path(w-1,h+1,sm))
		
c = 0
inp = []
while True:
	try:
		inp.append(map(int, raw_input().split(",")))
		c += 1
	except:
		mx = [[0 for i in range((c+1)/2)] for i in range(c)]
		print path(0,0,0)
		break

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

int main()
{
	int k;
	cin >> k;
	int even = 0, odd = 0;

	for (int i = 1; i <= k; i++)
	{
		if (i % 2 == 0)
		{
			even++;
		}
		else
		{
			odd++;
		}
	}
	
	cout << even * odd << endl;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	const int answer = (k == 1) ? 0 : ((n - (k - 1)) - 1);
	cout << answer << endl;
	return 0;
}



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

using namespace std;

const int mod = 998244353;
char s[301];
int a[300];
int dp[301][301][301][4];

int main() {
    int n, k, i, j, l, r;
    long long ans = 0;
    
    scanf("%s %d", s, &k);
    
    n = strlen(s);
    
    for (i = 0; i < n; i++) a[i] = s[i] - '0';
    
    dp[0][0][0][0] = 1;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            for (l = 0; l < n && l <= k; l++) {
                for (r = 0; r < 4; r++) {
                    if (dp[i][j][l][r] == 0) continue;
                    
                    if (a[i] == 0) {
                        dp[i + 1][j][l][0] += dp[i][j][l][r];
                        if (dp[i + 1][j][l][0] >= mod) dp[i + 1][j][l][0] -= mod;
                        
                        if (i > 0 && a[i - 1] == 1 && r >= 2) continue;
                        
                        dp[i][j + 1][l + 1][0] += dp[i][j][l][r];
                        if (dp[i][j + 1][l + 1][0] >= mod) dp[i][j + 1][l + 1][0] -= mod;
                    } else {
                        dp[i + 1][j][l][r | 1] += dp[i][j][l][r];
                        if (dp[i + 1][j][l][r | 1] >= mod) dp[i + 1][j][l][r | 1] -= mod;
                        
                        if (j > 0 && (r & 1) == 0) {
                            dp[i + 1][j - 1][l][r | 2] += dp[i][j][l][r];
                            if (dp[i + 1][j - 1][l][r | 2] >= mod) dp[i + 1][j - 1][l][r | 2] -= mod;
                        }
                    }
                }
            }
        }
    }
    
    for (i = 0; i <= k && i <= n; i++) {
        for (j = 0; j < 4; j++) {
            ans += dp[n][0][i][j];
        }
    }
    
    printf("%lld\n", ans % mod);
    
    return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  string n;
  cin >> n;
  if(n[0]=='9'||n[1]=='9')cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256