akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
#include <chrono>
#include <random>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <bitset>

#pragma comment(linker, "/STACK:36777216")
using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

typedef long double ptype;

long long mod = /*27449*//*998244353*/ 1e9 + 7 /*1e9 + 9*/;
int inf = 1e9;
double eps = 1e-8;
long double pi = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ifstream in("input.txt");
ofstream out("output.txt");

void solve()
{
	long long ans = 0;
	int n;
	cin >> n;
	int mx = 0;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		if (t < mx)
		{
			ans += mx - t;
		}
		else
		{
			mx = t;
		}
	}
	cout << ans;
}

int main()
{
	cout << setprecision(20) << fixed;
	cin.tie();
	cout.tie();
	clock_t t1 = clock();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
		//test();
	}
	//cout << (clock() - t1) * 1.0 / CLOCKS_PER_SEC;
	gg;
}

Measured memory_bytes: 3640
def count_how_many_divide(n):
    ans = 0
    while n % 2 == 0:
        n /= 2
        ans += 1
    return ans

from sys import stdin

data = stdin.read().splitlines()

a = int(data[0])

b = [int(s) for s in data[1].split()]

print(min(map(count_how_many_divide, b)))

Measured memory_bytes: 9212
#include <stdio.h>

double a,b,c,d,e,f;
double g,h;
int main(void)
{
  while(scanf("%lf %lf %lf %lf %lf %lf", &a,&b,&c,&d,&e,&f) != EOF){
  
       g = (c*d - a*f)/(b*d - a*e);
       h = (c - b*g)/a;
       printf("%.3f %.3f\n",h,g);
  }
return 0;
}


Measured memory_bytes: 2032
N = int(input())
a = list(map(int, input().split()))
a0 = 0
a2 = 0
a4 = 0

for i in a:
    if i % 4 == 0:
        a4 += 1
    elif i % 2 == 0:
        a2 += 1
    else:
        a0 += 1

if a4 >= a0:
    print('Yes')
elif a4 +1 == a0 and a2 ==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10 ** 9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def combMod(n, r, p):
    numer = 1
    denom = 1
    for i in range(1, r+1):
        numer = numer * (n-r+i) % p
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

def resolve():
    N, K = LI()

    for i in range(1, K + 1):
        if i <= N - K + 1:
            # 青玉をi個の1個以上含むグループに分ける
            # 赤玉は青玉の隙間に1個ずつ置いた後、0個以上のグループに分ける
            ans = combMod(K - 1, i - 1, MOD) * combMod(N - K + 1, i, MOD) % MOD
            print(ans)
        else:
            print(0)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10232
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    rr = []

    def f(n,w,h):
        wd = {}
        hd = {}
        kf = 0
        uf = UnionFind(n+1)
        uc = 0
        for i in range(n):
            x,y = LI()
            if x in wd:
                if uf.union(wd[x], i):
                    uc += 1
            else:
                wd[x] = i
            if y in hd:
                if uf.union(hd[y], i):
                    uc += 1
            else:
                hd[y] = i
            if x == 1 or y == 1 or x == w or y == h:
                kf = 1
        r = uc
        nk = n - uc
        if nk == 1:
            return r
        r += nk - kf + nk - 1

        return r

    while 1:
        n,w,h = LI()
        if n == 0:
            break
        rr.append(f(n,w,h))
        # print(n, rr[-1])
        break

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 15340
import sys

a,b = (int(_) for _ in input().split())
s = str(input())

if '-' not in s or s.count('-') > 1:
    print("No")
    sys.exit(0)

s1,s2 = s.split('-',1)
if len(s1) > 0 and len(s2) > 0 and a == len(s1) and b == len(s2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
abcd = "abcdefghijklmnopqrstuvwxyz"

x = input()
index = abcd.find(x)

print(abc[index+1])

Measured memory_bytes: 3060
def resolve():
    li = list()
    for i in range(2):
        line = input()
        li.append(line)
    ans = list()
    for i in range(2):
        line = li[1-i]
        al = line[2] + line[1] + line[0]
        ans.append(al)
    sp = ""
    for i in range(2):
        if ans[i] != li[i]:
            sp = "NO"
            break
    if sp != "NO":
        sp = "YES"
    print(sp)
resolve()

Measured memory_bytes: 8872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    char fi[h][w];
    rep(i,h) rep(j,w) cin>>fi[i][j];

    int ans=0;
    rep(bith,1<<h){
        rep(bitw,1<<w){
            char fic[h][w];
            rep(i,h) rep(j,w) fic[i][j]=fi[i][j];
            rep(i,h){
                if(bith & 1<<i){
                    rep(j,w) fic[i][j]='r';
                }
            }
            rep(j,w){
                if(bitw & 1<<j){
                    rep(i,h) fic[i][j]='r';
                }
            }
            int cnt=0;
            rep(i,h){
                rep(j,w){
                    if(fic[i][j]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3596
#include<stdio.h>

int n, A[50];

int solve(int i, int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    int res =solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main(){
    int q, M, i;

    scanf("%d", &n);
    for(i=0;i<n;i++)scanf("%d", &A[i]);
    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d", &M);
        if(solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 2680
s=list(input())
t=list(input())

def solve():
    if(len(s)!=len(t)):
        print("No")
        return
    for i in range(len(s)):
        s.append(s.pop(0))
        if(s==t):
            print("Yes")
            return
    print("No")
    return

solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

double W,H;
double x,y;

signed main(){
   cin>>W>>H>>x>>y;
   cout<<(double)(W*H/2.0)<<endl;
   if(2*x==W&&2*y==H)cout<<1<<endl;
   else cout<<0<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int res = N % B == 0 ? N / B : N / B + 1;
        System.out.println(res);
    }
}


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

#define ll long long
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

int N;
int A[5][200];

int main() {
   cin >> N;
   int shita = 0;
   rep (i, 0, 2) {
      rep (j, 0, N) {
         cin >> A[i][j];
         if (i == 1) {
            shita += A[i][j];
         }
      }
   }

   int ue = 0;
   int ans = 0;
   rep (i, 0, N) {
      ue += A[0][i];
      if (i >= 1) {
         shita -= A[1][i-1];
      }
      ans = max(ans, shita + ue);
   }

   cout << ans << endl;

   return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N, K;
    cin >> N >> K;
    ll res = 0;
    for(int k=K;k<=N+1;k++){
        ll tmp = k*(N-k+1)+1;
        tmp %= mod;
        res += tmp;
        res %= mod;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();
            List<int> lstInp = new List<int>();
            for (int i = 0; i < sS.Length; i++)
            {
                lstInp.Add(int.Parse(sS.Substring(i, 1)));
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "";
            if (lstInp[0] + lstInp[1] + lstInp[2] + lstInp[3] == 7) { sOut = lstInp[0].ToString() + "+" + lstInp[1].ToString() + "+" + lstInp[2].ToString() + "+" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] + lstInp[1] + lstInp[2] - lstInp[3] == 7) { sOut = lstInp[0].ToString() + "+" + lstInp[1].ToString() + "+" + lstInp[2].ToString() + "-" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] + lstInp[1] - lstInp[2] + lstInp[3] == 7) { sOut = lstInp[0].ToString() + "+" + lstInp[1].ToString() + "-" + lstInp[2].ToString() + "+" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] + lstInp[1] - lstInp[2] - lstInp[3] == 7) { sOut = lstInp[0].ToString() + "+" + lstInp[1].ToString() + "-" + lstInp[2].ToString() + "-" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] - lstInp[1] + lstInp[2] + lstInp[3] == 7) { sOut = lstInp[0].ToString() + "-" + lstInp[1].ToString() + "+" + lstInp[2].ToString() + "+" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] - lstInp[1] + lstInp[2] - lstInp[3] == 7) { sOut = lstInp[0].ToString() + "-" + lstInp[1].ToString() + "+" + lstInp[2].ToString() + "-" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] - lstInp[1] - lstInp[2] + lstInp[3] == 7) { sOut = lstInp[0].ToString() + "-" + lstInp[1].ToString() + "-" + lstInp[2].ToString() + "+" + lstInp[3].ToString() + "=7"; }
            if (lstInp[0] - lstInp[1] - lstInp[2] - lstInp[3] == 7) { sOut = lstInp[0].ToString() + "-" + lstInp[1].ToString() + "-" + lstInp[2].ToString() + "-" + lstInp[3].ToString() + "=7"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13908
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;

int main(){
    
    int a;
    cin >> a;
    int ue=a/100;
    int sita = a%100;
    
    if((ue==0||ue>12)&&1<=sita&&sita<=12){
        cout << "YYMM"<<endl;
    }else if(1<=ue&&ue<=12&&1<=sita&&sita<=12){
        cout << "AMBIGUOUS"<<endl;
    }else if(1<=ue&&ue<=12){
        cout << "MMYY"<<endl;
    }else{
        cout << "NA"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){

  int k,i;
  int a,b;
  int flag = 0;

  scanf("%d", &k);
  scanf("%d %d", &a, &b);

  i = k;

  while(i <= b){
    if(i <= b && i >= a){
      flag = 1;
      break;
    }

    i += k;
  }

  if(flag) printf("OK\n");

  else printf("NG\n");

  return 0;
}


Measured memory_bytes: 1660
n,m = gets.split.map(&:to_i)
flags = Array.new(m+1){0}
matrix = Array.new(n){gets.split.map(&:to_i)}

matrix.each do |v|
  v[1..-1].each do |a|
    flags[a]+=1
  end
end

p flags.count(n)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,n) for (int i=a;i<n;i++)
#define all(x) (x).begin(),(x).end()

vector<int> a;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m,t;
  cin>>n>>m;
  rep(i,0,m){cin>>t;a.push_back(t);}
  m = accumulate(all(a),0);
  if (n<m)cout << -1 << '\n';
  else cout << n-m << '\n';
}

Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		int bitArray[] = new int[64];

		for(int i = 0; i < q; i++) {
			boolean flag = false;
			switch(sc.nextInt()) {
			case 0:  //test->
				int flagNum = sc.nextInt();
				System.out.println(bitArray[flagNum]);
				break;

			case 1:  //set
				flagNum = sc.nextInt();
				if(bitArray[flagNum] == 0) bitArray[flagNum]++;
				//bitArray[i] = (bitArray[i] + 2) / 2;
				break;

			case 2:  //clear
				flagNum = sc.nextInt();
				if(bitArray[flagNum] == 1) bitArray[flagNum]--;
				//bitArray[i] /= 2;
				break;

			case 3:  //flip
				flagNum = sc.nextInt();
				bitArray[flagNum] = (bitArray[flagNum] + 1) % 2;
				break;

			case 4:  //all->全てのフラグがONになっている場合1、なっていない場合0を出力
				for(int j = 0; j < 64; j++) {
					if(bitArray[j] == 0) {
						flag = true;  //1つでもオフのフラグがあればtrueにする
						break;
					}
				}
				if(flag) System.out.println(0);
				else System.out.println(1);
				break;

			case 5:  //any->何れかのフラグがONになっている場合1、なっていない場合0を出力
				for(int j = 0; j < 64; j++) {
					if(bitArray[j] == 1) {
						flag = true;  //1つでもオンのフラグがあればtrueにする
						break;
					}
				}
				if(flag) System.out.println(1);
				else System.out.println(0);
				break;

			case 6:  //none->全てのフラグがOFFになっている場合1、なっていない場合0を出力
				for(int j = 0; j < 64; j++) {
					if(bitArray[j] == 1) {
						flag = true;  //1つでもオンのフラグがあればtrueにする
						break;
					}
				}
				if(flag) System.out.println(0);
				else System.out.println(1);
				break;

			case 7:  //count->
				int count = 0;
				for(int j = 0; j < 64; j++) {
					if(bitArray[j] == 1) count++;
				}
				System.out.println(count);
				break;

			case 8:  //val->
				/*
				BigDecimal state = new BigDecimal("");
				for(int j = 0; j < 64; j++) {
					if(bitArray[j] == 1) {
						state.add((int)Math.pow(2, j));  //ビット列のj桁目が1のときに2のj乗を加える
					}
				}
				*/
				long state = Long.MIN_VALUE;
				for(int j = 0; j < 64; j++) {
					if(bitArray[j] == 1) {
						state += (long)Math.pow(2, j); //ビット列のj桁目が1のときに2のj乗を加える
					}
				}
				if(state < 0) {
					System.out.println(state + Long.MAX_VALUE + 1);
					break;
				}
				else {
					System.out.println(Long.toUnsignedString(state + Long.MAX_VALUE + 2));
					break;
				}
			}
		}
	}

}


Measured memory_bytes: 134352
#include<bits/stdc++.h>
//#include <boost/lexical_cast.hpp>
using namespace std;

#define pb push_back
#define mp make_pair  //access values using v[i].first,v[i].second
#define mt make_tuple //access values using get<1>(v[i]),get<0>(v[i]) etc

#define inf 1000000000
#define mod 1000000007

#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w",stdout)

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define sc(n) scanf("%c",&n)
#define sd(n) scanf("%lf",&n)

#define pin(n) printf("%d\n",n)
#define pln(n) printf("%lld\n",n)
#define pdn(n) printf("%lf\n",n)

#define pis(n) printf("%d ",n)
#define pls(n) printf("%lld ",n)

#define pn printf("\n")
#define ps(n) printf("%s",n)
#define psn(n) printf("%s\n",n)

vector<int> primes;  //primes.size() = 78498 //last prime number = 999983
void sieve()
{
    vector<bool> a(1000000,false);
    for(int u=2;u<=1000000;u++)
    {
        if(a[u])continue;
        for(int i=2*u;i<=1000000;i+=u)a[i]=true;
    }
    for(int i=2;i<=1000000;i++)
    {
        if(!a[i])primes.pb(i);
    }
}

int gcd(int a, int b)
{
    while(1)
    {
        if(a==0)return b;
        b%=a;
        if(b==0) return a;
        a%=b;
    }
}
int lcm(int a, int b)
{
    int g=gcd(a,b);
    return ((a*b)/g);
}

int digitCount(int n)
{
    int c=0;
    while(n!=0)
    {
        c+=n%10;
        n/=10;
    }
    return c;
}

int totalDigit(int n)
{
    int d;
    for(d=1,n/=10;n!=0;n/=10)d++;
    return d;
}


int parseInt(string str)
{
    int a=0;
    int l=str.length();
    for(int i=0;i<l;i++)
    {
        a*=10;
        a+=str[i]-48;
    }
    return a;
}

long long parseLong(string str)
{
    long long a=0;
    int l=str.length();
    for(int i=0;i<l;i++)
    {
        a*=10;
        a+=str[i]-48;
    }
    return a;
}

int main()
{

    //FIN;
    int n;
    si(n);
    n=sqrt(n);
    pin(n*n);
}


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

int N, A[10010];

int min () {
    int min = 10000010;
    for (int i = 0; i < N; i ++) {
        if (min > A[i]) {
            min = A[i]; 
        }
    }
    return min;
}

int max () {
    int max = - 10000010;
    for (int i = 0; i < N; i++) {
        if (max < A[i]) {
            max = A[i];
        }
    }
    return max;
}

long long int sum () {
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A[i];
    }
    return sum;
}

int main () {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    cout << min() << ' ' << max() << ' ' << sum() << endl;
}



Measured memory_bytes: 3124
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if A[i] +1 == A[i+1]:
        ans += C[A[i]-1]
ans += sum(B)
print(ans)


Measured memory_bytes: 62000
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N - 1; i++) {
		ans += (N - 1) / i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>

void trace(int a[], int n) {
	int i;
	for (i = 0; i < n; i++) {
		if (0 < i && i < n)printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

int selectionsort(int a[], int n) {
	int i, j;
	int minnum;
	int min;
	int count = 0;

	for (i = 0; i < n - 1; i++) {
		min = a[i];
		minnum = i;
		for (j = i + 1; j < n; j++) {
			if (a[j]< min) {
				min = a[j];
				minnum = j;
			}
			
		}
		if (min != a[i]) {
			a[minnum] = a[i];
			a[i] = min;
			count++;
		}
	}
	   
	return count;
	
}




int main(void){

	int a[101];
	int n, i;
	int count;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	count = selectionsort(a, n);
	trace(a, n);
	printf("%d\n", count);


	return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }

ll n,x;
ll a[60];
ll p[60];

ll f(ll N,ll X){
    if(N==0){
        if(X<=0)return 0;
        else return 1;
    }
    else if(X==1)return 0;
    else if(X<=1+a[N-1])return f(N-1,X-1);
    else if(X==2+a[N-1])return p[N-1]+1;
    else if(X<=a[N]-1)return p[N-1]+1+f(N-1,X-a[N-1]-2);
    else return p[N];
}
int main(){
    cin >> n >> x;
    a[0]=1;p[0]=1;
    rep(i,55){
        a[i+1]=a[i]*2+3;
        p[i+1]=p[i]*2+1;
    }
    cout << f(n,x) << endl;

    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    K,N=mis()
    A=lmis()
    f = A[0] - (A[-1] - K)
    for i in range(1, N):
        f = max(f, A[i]-A[i-1])
    print(K - f)



main()







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

int main(){
  int i, n, *R, max, min;

  scanf("%d",&n);

  R = malloc(sizeof(int)*n);

  for(i = 0; i < n; i++) scanf("%d",&R[i]);

  min = R[0];
  max = R[1] - R[0];
  
  for(i = 1; i < n; i++){
    if(max < (R[i] - min)) max = (R[i] - min);

    if(min > R[i]) min = R[i];
  }

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

  free(R);

  return 0;
}


Measured memory_bytes: 2320
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  string s,t;
  cin>>s>>t;
  int kotae=INT_MAX;
  rep(i,s.size()-t.size()+1){
    int tmp=0;
    rep(j,t.size()){
      if(s[i+j]!=t[j])tmp++;
      //cout<<s[i+j]<<t[j]<<" ";
    }
    //cout<<endl;
    kotae=min(kotae,tmp);
  }
  cout<<kotae<<endl;
  return 0;
}
  

Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
    
    int a,b;
    scanf("%d %d", &a, &b);
    if (a < b){
        printf("a < b\n");
    }
    else if (a > b){
        printf("a > b\n");
    }
    else if (a == b){
        printf("a == b\n");
    }
    return 0;
    
}



Measured memory_bytes: 2584
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    int X, A, B;
    cin >> X >> A >> B;

    if(B-A <= 0){
      cout << "delicious";
    }else if(B-A > 0 && B-A <= X){
      cout << "safe";
    }else{
      cout << "dangerous";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ans = a*c;
  chmax(ans, a*d);
  chmax(ans, b*c);
  chmax(ans, b*d);

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3648
// ハッシュ法　p.130

#include <cstdio>
#include <cstring>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];


// 文字から数値に変換
int getChar(char ch) {
    if (ch == 'A')
        return 1;
    else if (ch == 'C')
        return 2;
    else if (ch == 'G')
        return 3;
    else if (ch == 'T')
        return 4;
    else return 0;
}

// 文字列から数値へ変換してkeyを生成する
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;     // 4 + 1ってこと？
    }
    return sum;
}

int h1(int key) {return key % M;}
int h2(int key) {return 1 + (key % (M - 1));}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0)  // 文字列比較: 最後まで同じなら0
            return 1;
        else if (strlen(H[h]) == 0)
            return 0;
    }
    return 0;   // <-必要？
}


int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1; // 今回は起こらない前提？
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];

    for (i=0; i<M; i++)
        H[i][0] = '\0';  // 初期化
    scanf("%d", &n);

    for (i=0; i<n; i++) {
        scanf("%s %s", com, str);

        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}



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

int main() {
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double angle_1 = M / 2 + 30 * H, angle_2 = M * 6, angle_dif;
	angle_dif = abs(angle_1 - angle_2);
	if (angle_dif > 180) {
		angle_dif = 360 - angle_dif;
	}
	double ans = A * A + B * B - 2 * A * B * cos(M_PI * angle_dif / 180);
	printf("%.20lf\n", sqrt(ans));
}

Measured memory_bytes: 4212
#include<iostream>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)
const int M=10000;
int memo[M+1][M+1];

int main(){

   string s, t;
   cin>> s>> t;

   repeat(i, M+1) memo[i][0]=memo[0][i]=i;
   repeat(i, s.size()+1){
      repeat(j, t.size()+1){
         if(i==0 or j==0) continue;
         memo[i][j]=memo[i-1][j]+1;
         memo[i][j]=min(memo[i][j], memo[i][j-1]+1);
         memo[i][j]=min(memo[i][j], memo[i-1][j-1]+(s[i-1]!=t[j-1]));
      }
   }

   cout<< memo[s.size()][t.size()]<< endl;

   return 0;
}

Measured memory_bytes: 47140
n = int(input())
last_t = 0
last_x = 0
last_y = 0
for i in range(n):
    t, x, y = map(int, input().split())
    if abs(last_x - x) + abs(last_y - y) > t - last_t:
        print("No")
        exit()
    else:
        if (t % 2 == 1 and (x + y) % 2 == 0) or (t % 2 == 0 and (x + y) % 2 == 1):
            print("No")
            exit()
    last_t = t
    last_x = x
    last_y = y
print("Yes")

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
a.sort()
dp=[0]*(a[-1]+1)

for i in a :
    dp[i]+=1

for i in a :
    if dp[i] :
        for j in range(i*2,a[-1]+1,i) :
            dp[j]=0

print(dp.count(1))


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

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}node;

typedef struct node *Node;

Node root;

Node treeMinimum(Node x){
  while(x -> left != NIL)
    x = x -> left;
  return x;
}

Node treeMaximum(Node x){
  while(x -> right != NIL)
    x = x -> right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u ->key)
    return u;
    
    if(k < u -> key)
    return treeSearch(u -> left, k);

  if(k > u -> key)
    return treeSearch(u -> right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x -> right != NIL)
    return treeMinimum(x -> right);

  y = x -> parent;

  while(y != NIL && x == y -> right){
    x = y;
    y = y -> parent;
  }

  return y;
}

void treeDelete(Node z){
  Node x;
  Node y;

  if(z -> left == NIL || z -> right == NIL)
    y = z;

  else
    y = treeSuccessor(z);
    
  if(y -> left != NIL)
    x = y -> left;

  else
    x = y -> right;

  if(x != NIL)
    x -> parent = y -> parent;

  if(y -> parent == NIL)
    root = x;

  else if(y == y -> parent -> left)
    y -> parent -> left = x;

  else
   y -> parent -> right = x;

  if(y != z)
    z -> key = y -> key;
}

void insert(int k){
  Node x = root;
  Node y = NIL;
  Node z;

  z = malloc(sizeof(node));

  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;
  
  while( x != NIL){
    y = x;
    if(z -> key < x -> key)
      x = x -> left;

    else
      x = x -> right;
  }

  z -> parent = y;

  if(y == NIL)
    root = z;

  else if(z -> key < y -> key)
    y -> left = z;

  else
    y -> right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u -> left);

    printf(" %d", u -> key);

    inorder(u -> right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d", u -> key);

    preorder(u -> left);
    preorder(u -> right);
  }
}

int main(){
  Node t;
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
     if ( com[0] == 'f' ){
      scanf("%d", &x);
      t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 20488
#include <stdio.h>

int main(void){
  int N,cnt,cnt8 = 0;
  scanf("%d",&N);
  
  int i,j;
  for(i = 1;i <= N; i += 2){
    cnt = 0;
    for(j = 1;j <= i; j += 2){
      if(!(i % j))	cnt++;
    }
    if(cnt == 8) ++cnt8;
  }
  printf("%d\n",cnt8);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main(){
  string s;
  int k,n;
  vector<string> ans;
  cin>>s;
  cin>>k;
  n=s.size();

  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      ans.push_back(s.substr(i,j));
    }
  }
  sort(ans.begin(),ans.end());
  ans.erase(unique(ans.begin(),ans.end()),ans.end());

  cout<<ans[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 1660
import java.util.*;
public class Main {// Main
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        long a = s.nextLong();
        boolean isExists = false;
        while(a > 0) {
            if(a%10 == 7) {
                isExists = true;
                break;
            }
            a = a/10;
        }
        if(isExists) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H*W-h*W-(H-h)*w << endl;
}

Measured memory_bytes: 3560
n = int(input())
A = [int(input()) for _ in range(n)]
B = []
cnt = 0
i = 0
while i != 1:
    i = A[i]-1
    B.append(i)
    cnt += 1
    if cnt > 10**5 + 1:
        print(-1)
        exit()
print(cnt)

Measured memory_bytes: 11052
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

template<class T>
struct SegmentTree {
private:
    int n;
    vector<T> node;
    T def;
    function<T(T,T)> lop;
    function<T(T,T)> out;
    
public:
    SegmentTree() {}
    SegmentTree(const vector<T> &v, T _def, function<T(T,T)> _lop, function<T(T,T)> _out) {
        int vl = (int)v.size();
        n = 1;
        while(n < vl) n *= 2;
        def = _def; lop = _lop; out = _out;
        node = vector<T>(2 * n - 1, def);
        for(int i = 0; i < vl; i++) node[i + n - 1] = v[i];
        for(int i = n - 2; i >= 0; i--) node[i] = out(node[i * 2 + 1], node[i * 2 + 2]);
    }
    
    void update(int idx, T val) {
        idx += (n - 1);
        node[idx] = lop(node[idx], val);
        while(idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = out(node[idx * 2 + 1], node[idx * 2 + 2]);
        }
    }
    
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if ((r <= a) || (b <= l)) return def;
        if ((a <= l) && (r <= b)) return node[k];
        return out(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mv = 300000;
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    auto lop = [](ll a, ll b){ return max(a, b); };
    auto out = [](ll a, ll b){ return max(a, b); };
    SegmentTree<ll> st(vector<ll>(mv + 1, 0), 0, lop, out);
    rep(i, n) {
        ll v = st.query(max(0LL, a[i] - k), min(mv, a[i] + k) + 1);
        st.update(a[i], v + 1);
    }
    ll ans = st.query(0, mv + 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16156
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define all(vec) vec.begin(),vec.end()
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
#define pb push_back
#define fi first
#define se second
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1LL<<60;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
vl siz;
vl met;
void init(int n){
    siz.resize(n+1);
    met.resize(n+1);
    siz[0]=1;
    met[0]=1;
    REP(i,n){
        siz[i+1]=siz[i]*2+3;
        met[i+1]=met[i]*2+1;
    }
}
ll dfs(ll n,ll m){//レベルnの上位m
    if(!n){
        return 1;
    }
    if(m==siz[n]){
        return met[n];
    }
    ll res=0;
    if(m>1){
        res+=dfs(n-1,min(m-1,siz[n-1]));
    }
    if(m>=siz[n-1]+2){
        res++;
    }
    if(m>siz[n-1]+2){
        res+=dfs(n-1,min(m-siz[n-1]-2,siz[n-1]));
    }
    return res;
}
int main(){
    ll n,m;
    cin>>n>>m;
    init(n);
    cout<<dfs(n,m)<<endl;
    return 0;
}

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
vector<int>store;
void recur(int i,string str,int a)
{
	int len=str.length();
	if(i==len)
	{
		store.pb(a);
		return;
	}
	for(int j=i+1;j<=len;j++){
		int num=stol(str.substr(i,j-i));
		recur(j,str,a+num);
	}
}

signed main(){
  string str;
  cin>>str;
  recur(0,str,0);
  int cnt=0;
  for(auto it:store)cnt+=it;
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  
  for (int i = 0; i < N; i++){
    int li, ri;
    cin >> li >> ri;
    sum += ri - li + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;
const int  INF = 1 << 30;
struct node {
	int x;
	int y;
	int c;
	bool operator <(node a)const{
    return c < a.c;
  	}
	bool operator >(node a)const{
    return c > a.c;
  	}
};

int dis[1010][1010];
int nx[10];
int ny[10];
string maze[1010];
int hmax=1;

int main(void){
	int H,W,n;
	cin >> H >> W >> n;
	rep(i,H) cin >> maze[i];
	node init;
	rep(i,H) rep(j,W){
		if(maze[i][j]=='S'){
			nx[0]=j;
			ny[0]=i;
		}else if(isdigit(maze[i][j])){
			nx[maze[i][j]-'0']=j;
			ny[maze[i][j]-'0']=i;
		}
	}
	int ans=0;
	rep(j,n){
		rep(k,H)rep(l,W) dis[k][l]=INF;
		init.x=nx[j];
		init.y=ny[j];
		init.c=0;
		priority_queue <node,vector<node>,greater<node> > q;
		q.push(init);
		int dx[4]={1,0,-1,0};
		int dy[4]={0,1,0,-1};
		while(!q.empty()){
			node cur;
			cur=q.top();q.pop();
			// テァツ渉セテ・ツ慊ィテ、ツスツ催ァツスツョテ」ツ?ョテ・ツ按、テ・ツョツ堙・ツ?ヲテァツ青?
			if(dis[cur.y][cur.x]<=cur.c)
				continue;
			else
				dis[cur.y][cur.x]=cur.c;
			if(hmax==(maze[cur.y][cur.x]-'0')){
				ans+=cur.c;
				hmax++;
				break;
			}
			//テ」ツ??ヲツャツ。テ」ツ?ョテァツ環カテヲツ?凝」ツ?クテ」ツ?ョテゥツ?キテァツァツサ
			rep(i,4){
				node next;
				next.x=cur.x+dx[i];
				next.y=cur.y+dy[i];
				next.c=cur.c+1;
				if(0<=next.x&&next.x<W&&0<=next.y&&next.y<H&&maze[next.y][next.x]!='X')
					q.push(next);
			}	
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6220
n = int(input())
a = list(map(int,input().split()))
r = []
b = 0

for j in range(1,n+1):
    if j%2 == 1:
        b += a[j-1]
    else:
        b -= a[j-1]
r.append(b)

for i in range(2,n+1):
    r.append(2*a[i-2] - r[-1])
print(' '.join(list(map(str,r))))

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

void solve(int test) {
    int n, ans=0;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; ) {
        int j = i;
        while (j < n && s[j]==s[i])j++;
        ans++;
        i=j;
    }
    cout << ans <<"\n";
}

int main(){
#ifdef VPAL
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
    int t = 1;
    //cin >> t;
    for (int test = 1; test <= t; test++) {
        solve(test);
    }
    return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  vector<vector<int> >vvi(555);
  int n,m,q;cin>>n>>m>>q;
  for(int i=0;i<m;i++){
    int l,r;cin>>l>>r;
    vvi[l].pb(r);
  }
  for(int i=1;i<=500;i++){
    vvi[i].pb(INF);
    sort(ALL(vvi[i]));
  }
  for(int i=0;i<q;i++){
    ll ans=0;
    int l,r;cin>>l>>r;
    for(int j=l;j<=r;j++){
      auto num=upper_bound(ALL(vvi[j]),r);
      //   cout<<*num<<endl;
      if((*num)!=INF)ans+=num-vvi[j].begin();
      else ans+=vvi[j].size()-1;
    }
    cout<<ans<<endl;
  }
  return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D))
    cout << "Left" << endl;
  else if ((A + B) == (C + D))
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 3628
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;

	writeln(A * B - A - B + 1);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256