akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
foods = []
for i in range(0, M):
	foods.append(True)
for i in range(0, N):
	inpt = list(map(int, input().split()))
	lst = []
	for j in range(0, M):
		lst.append(False)
	for j in range(0, inpt[0]):
		lst[inpt[1:][j]-1] = True
	for j in range(0, M):
		foods[j] = foods[j] and lst[j]
cnt = 0
for i in range(0, M):
	if foods[i]:
		cnt += 1
print(cnt)

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

int main() {
  ll x;
  cin >> x;

  ll total = 0;
  if (x/500) {
    total += (x/500)*1000;
    x %= 500;
  }
  if (x/5) {
    total += (x/5)*5;
  }
  cout << total << endl;
  return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 2e5 + 7;
const int Mod = 1e9 + 7;

int n, m, a[N], b[N], x[N], y[N], l[N], r[N];

LL Calc() {
    LL res = 1;
    for (int i = 1; i <= n; i ++) {
        int ll = max(l[i], x[i]);
        int rr = min(r[i], y[i]);
        if (ll > rr) return 0;
        res = res * (rr - ll + 1) % Mod;
    }
    return res;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i ++) scanf("%d", &b[i]);
    l[1] = r[1] = a[1];
    x[n] = y[n] = b[n];
    for (int i = 2; i <= n; i ++) {
        if (a[i] > a[i-1]) l[i] = r[i] = a[i];
        else r[i] = a[i], l[i] = 1;
    }
    for (int i = n - 1; i >= 1; i --) {
        if (b[i] > b[i+1]) x[i] = y[i] = b[i];
        else y[i] = b[i], x[i] = 1;
    }
    cout << Calc() << endl;
}


Measured memory_bytes: 2688
# nを素因数分解
# 2以上の整数n => [[素因数, 指数], ...]の2次元リスト
n = int(input())

if n == 1:
    print(0)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


t = factorization(n)
# print(t)
ans = 0
for (p, i) in t:
    c = 0
    while True:
        c += 1
        if i >= c:
            i -= c
        else:
            break
    ans += (c-1)
print(ans)


Measured memory_bytes: 63444
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
Volume0-0044
Prime Number II
=end

require 'prime'
class P

  def initialize(ulimit)
    @p = [2] + 3.step(ulimit,2).to_a.select{|x| Prime.prime?(x)} 
  end

  def ud(n)
    @p.select{|x| x < n}.last
  end

  def ov(n)
    @p.select{|x| x > n}.first
  end

end

class Main

  def initialize
    fh = STDIN
    #fh = "x.txt"
    p = P.new(50050)
    while fh.gets do
      n = $_.to_i
      printf("%d %d\n", p.ud(n), p.ov(n))
    end
  end

end

if $0 == __FILE__ then
  Main.new
end

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


signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    
    int X=0;
    for(int i=0;i<N;i++){
        X^=a[i];
    }
    
    int ans=0;
    for(int i=29;i>=0;i--) if(X>>i&1){
        for(int j=0;j<N;j++){
            int t=a[j]^(a[j]-1);
            if(t+1==(1<<(i+1))){
                X^=t;
                ans++;
                break;
            }
        }
    }
    if(X==0){
        cout<<ans<<endl;
    }else{
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRectangleCutting solver = new CRectangleCutting();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRectangleCutting {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            double h = s.nextInt(), wi = s.nextInt(), x = s.nextInt(), y = s.nextInt();
            w.println((h * wi / 2) + " " + ((x == h / 2 && y == wi / 2) ? 1 : 0));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lim 200005
#define pb push_back
#define S second
#define pb push_back
#define mp make_pair
#define INF 1e18
#define fr(i,j,k) for(ll i=j;i<=k;i++)
#define frd(i,j,k) for(ll i=j;i>=k;i--)
#define F first
#define sd(n) scanf("%lld",&n)
#define pd(n) printf("%lld\n",n)
#define db double
#define mod 1000000007
#define pii pair<ll,ll>
ll getans(ll n)
{  
  ll ans=n*(n+1);
  ans/=2;
  return ans;
}

int main()
{
  ll w;
  cin>>w;
  for(ll i=1;i<=w;i++)
  {
    if(getans(i)>=w)
    {
      cout<<i;
      return 0;
    }
  }
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
 
if a==1 and b==2:
    print(3)
elif a==1 and b==3:
    print(2)
elif a==2 and b==3:
    print(1)
elif a==2 and b==1:
    print(3)
elif a==3 and b==1:
    print(2)
elif a==3 and b==2:
    print(1)

Measured memory_bytes: 3060
import java.util.Scanner;

import static java.lang.Math.pow;
import static java.lang.Math.sqrt;

class Main{
    
    public static void main(String[] arg){

        Scanner in = new Scanner(System.in);

        String input = in.nextLine();
        String [] param_line = input.split(" ", 0);

        double x1 = Double.parseDouble(param_line[0]);
        double y1 = Double.parseDouble(param_line[1]);
        double x2 = Double.parseDouble(param_line[2]);
        double y2 = Double.parseDouble(param_line[3]);

        double d = sqrt(pow(x2-x1,2)+pow(y2-y1, 2));

        System.out.println(d);
    }
}

Measured memory_bytes: 26216
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
    var a = parseInt(chunk.trim().split(' ')[0], 10);
    var b = parseInt(chunk.trim().split(' ')[1], 10);
    var s = a * b;
    var l = a * 2 + b * 2;

    console.log(s + ' ' + l);
});

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

int main(void) {
	int A, B;
	scanf("%d %d", &A, &B);

	if (A < 9 && B < 9) {
		cout << "Yay!" << "\n";
	} else {
		cout << ":(" << "\n";
	}
	return 0;
}




Measured memory_bytes: 256
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
   ll n,m,ans=0;
   cin >> n >> m;
   vi v(m),w(m-1);
   rep(i,m) {
       cin >> v[i];
   }
   sort(all(v));
   REP(i,1,m){
       w[i-1] = v[i] - v[i-1];
   }
   sort(all(w));
   //rep(i,w.size()) cout << w[i] << " ";
   rep(i,m-n) {
       ans += w[i];
       //cout << ans << endl;
   }
   cout << ans << endl;
   return 0;
}  


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int x,y;

  while(scanf("%d %d",&x,&y),!(x==0&&y==0)){
    if(x<y){
      printf("%d %d\n",x,y);
    }
    else{
      printf("%d %d\n",y,x);
    }
  }
  
  return 0;
}

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

int main()
{
    int n,a=0,b,p,f,h,c,i,d=0,s,k=0,l;

    cin >> a >> b;

    for(i=22;i<=b;i++){

    d = i/10;
    c = i%10;

    if(c*d<=a && c>=2 && d>=2){
      k++;
    }
    }

    cout << k;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	char s[10];
	bool flag=false;
	scanf("%s",s);
	if(s[0]==s[1] && s[1]==s[2])flag=true;
	if(s[1]==s[2] && s[2]==s[3])flag=true;
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;	
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long L = sc.nextLong();
		long R = sc.nextLong();
		long ans = 0;
		long minium = 2019;
		if( R-L < 2019 ){
			loop:for( long i=L; i<=R-1; i++ ){
				for( long j=i+1; j<=R; j++ ){
					ans = ((i%2019L)*(j%2019L))%2019L;
					minium = Math.min(ans,minium);
					if( minium==0 ){
						break loop;
					}
				}
			}
		}else{
			minium = 0;
		}
		System.out.println(minium);
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;
#ifndef N
#define N 100001
#endif
#ifndef MOD
#define MOD 1000000007
#endif

lli n,m;

lli factrial(lli x){
	static lli dp[N];
	if(dp[x]) return dp[x];
	if(x == 0) 	return dp[x] = 1;
				return dp[x] = (factrial(x-1) * x) % MOD;
}

int main(){
	cin >> n >> m;
	if(abs(n-m) == 1){
		cout << (factrial(n)*factrial(m))%MOD << endl;
		return 0;
	}
	if(abs(n-m) == 0){
		cout << (((factrial(n)*factrial(m))%MOD)*2)%MOD << endl;
		return 0;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> x(n);
    for(int i = 0; i < n; i++){
        std::cin >> x[i];
    }

    int min = *std::min_element(x.begin(),x.end());
    int max = *std::max_element(x.begin(),x.end());

    std::vector<int> ans;
    int sum = 0;

    for(int i = min; i <= max; i++){
        for(int j = 0; j < n; j++){
            sum += std::pow((i - x[j]),2);
        }
        ans.push_back(sum);
        sum = 0;
    }

    int aaa = *std::min_element(ans.begin(),ans.end());
    std::cout << aaa;
    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll combination(ll n, ll r) {
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
    ll divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int main() {
	ll n;
	cin >> n;
	ll ans = n / 11 * 2;
	if (n%11>0&&n%11<=6) {
		ans++;
	}
	else if(n%11>=7){
		ans += 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    ArrayList<Integer> dislike = new ArrayList<Integer>();
    for(int i = 0; i < K; i++) {
      dislike.add(sc.nextInt());
    }
    int ans = N;
    while(true) {
      String s = String.valueOf(ans);
      int count = 0;
      for(int i = 0; i < s.length(); i++) {
        int d = Integer.parseInt(String.valueOf(s.charAt(i)));
        if(dislike.contains(d)) count++;
      }
      if(count == 0) break;
      ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 39720
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
  int a,b;
  string s,num;
  cin>>a>>b;
  cin>>s;

  num="0123456789";

  bool fl=false;

  for(int i=0;i<a;i++){
    bool fl2=false;
    for(int j=0;j<10;j++){
      if(s[i]==num[j]){
        fl2=true;
      }
    }
    if(!(fl2))fl=true;
  }

  if(s[a]!='-')fl=true;

  for(int i=a+1;i<a+b+1;i++){
    bool fl2=false;
    for(int j=0;j<10;j++){
      if(s[i]==num[j]){
        fl2=true;
      }
    }
    if(!(fl2))fl=true;
  }

  if(fl) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
for line in sys.stdin.readlines():
    result="d"
    for i in xrange(3):
        if not line[3*i]=="s" and line[3*i]==line[3*i+1] and line[3*i]==line[3*i+2]:
            result=line[3*i]
        if not line[i]=="s" and line[i]==line[i+3] and line[i]==line[i+6]:
            result=line[i]
    if not line[0]=="s" and line[0]==line[4] and line[0]==line[8]:
        result=line[0]
    if not line[2]=="s" and line[2]==line[4] and line[2]==line[6]:
        result=line[2]
    print result

Measured memory_bytes: 4248
using System;
using System.Linq;

namespace _066
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ');
            var ans = new string[n];
            int s =  n / 2;
            int e = n % 2 == 0 ? n / 2 - 1 : n / 2 + 1;
            for (int i = 0; i < n; i++)
            {
                if(i % 2 == 0)
                {
                    ans[s] = a[i];
                    s += n % 2 ==0 ? 1 : -1;
                }
                else
                {
                    ans[e] = a[i];
                    e -= n % 2 == 0 ? 1 : -1;
                }
            }


            Console.WriteLine(string.Join(" ",ans));

        }

    }
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int func(long long n, std::vector<long long> a) {
    // cout << fixed << setprecision(5);
    vll left(n + 1), right(n + 1);
    rep(i, n) {
        if (i == 0) {
            left[1]  = a[i];
            right[1] = a[n - 1 - i];
        } else {
            left[i + 1]  = gcd(left[i], a[i]);
            right[i + 1] = gcd(right[i], a[n - 1 - i]);
        }
    }

    ll ans = left[n];
    rep(i, n) {
        ll res;
        if (i == 0)
            res = right[n - 1];
        else if (i == n - 1)
            res = left[n - 1];
        else
            res = gcd(left[i], right[n - 1 - i]);
        // ans max((int)ans, (int)res);
        // ans = max((int)ans, (int)res);
        ans = max(ans, res);
    }
    cout << ans << endl;

    return 0;
}

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

    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Panel{
	string name;
	int x1,y1,x2,y2;
	Panel(string n,int x1,int y1,int x2,int y2):name(n),x1(x1),y1(y1),x2(x2),y2(y2){}
};
ostream& operator<<(ostream& os,const Panel& p){
	return os<<'('<<p.name<<','<<p.x1<<','<<p.y1<<','<<p.x2<<','<<p.y2<<')';
}

int parse(string& s,int i,int prev,vector<Panel>& panels,vi& parent)
{
	i++;
	int j=s.find('>',i);
	string name=s.substr(i,j-i);
	j++;
	int x1,y1,x2,y2; sscanf(s.c_str()+j,"%d,%d,%d,%d",&x1,&y1,&x2,&y2);
	int cur=panels.size();
	panels.emplace_back(name,x1,y1,x2,y2);
	parent.push_back(prev);
	for(j=s.find('<',j);;){
		if(s[j+1]=='/')
			break;
		j=parse(s,j,cur,panels,parent);
	}
	j=s.find('>',j);
	return j+1;
}

int main()
{
	for(int n;cin>>n,n;){
		string s; cin>>s;
		
		vector<Panel> panels;
		vi parent;
		parse(s,0,-1,panels,parent);
		
		vi child(panels.size());
		peri(i,1,parent.size())
			child[parent[i]]++;
		
		rep(_,n){
			int x,y; cin>>x>>y;
			int i=-1;
			per(j,panels.size()){
				Panel p=panels[j];
				if(p.x1<=x && x<=p.x2 && p.y1<=y && y<=p.y2){
					i=j;
					break;
				}
			}
			if(i==-1)
				cout<<"OUT OF MAIN PANEL 1"<<endl;
			else
				cout<<panels[i].name<<' '<<child[i]<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
	///*
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// 	freopen("error.txt", "w", stderr);
// #endif
//*/
	int T;
	//scanf("%d", &T);
	T = 1;
	for (int cs = 1; cs <= T; cs++) {
		int a, b, c;
		cin >> a >> b >> c;
		cout << (a * b) / 2 << endl;
	}
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int A, B, C; cin >> A >> B >> C;
  if(A == B && A == C) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int a,b;
  cin >> a >> b;
  int gc = __gcd(a,b);
  int ans = (a*b)/gc;
  cout << ans << endl;
  

return 0;
}
///....


Measured memory_bytes: 256
#include <stdio.h>

void bubbleSort(int numbers[], int array_size)
{
  int i, j, temp;

  for (i = 0; i < (array_size - 1); i++) {
    for (j = (array_size - 1); j > i; j--) {
      if (numbers[j-1] > numbers[j]) {
        temp = numbers[j-1];
        numbers[j-1] = numbers[j];
        numbers[j] = temp;
      }
    }
  }
}



int main(){
    int N;
    int data[52];
    scanf("%d",&N);
    int i,j;
    int count = 0;
    int data2[52];
    for(i=0;i<N;i++){
        scanf("%d",&data[i]);
        data2[i] = data[i];
        
    }
    
    bubbleSort(data,N);

    for(int i=0;i<N;i++){
        
        if(data[i]!=data2[i])count++;
    }
    
       if(count==0 || count==2){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, k;
  cin >> n >> k;
  vll a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  sort(all(a));
  ll ans = 0;
  for(ll i = 0; i < k; i++) ans+=a[i];
  cout << ans;
  return 0;
} //good night.

Measured memory_bytes: 3648
n = int(input())
if n <= 15002:
  if n==3:
    print(2, 5, 63)
  else:
    if n%3:
      l = [2*(i+1) for i in range(n-2)]
      l += [3, 9]
      print(*l)
    else:
      l = [2*(i+1) for i in range(n-1) if i!=2]
      l += [3, 9]
      print(*l)
else:
  if n%2==0:
    l = [2*(i+1) for i in range(15000)]
    l += [3+6*i for i in range(n-15000)]
    print(*l)
  else:
    l = [2*(i+1) for i in range(15000) if i!=2]
    l += [3+6*i for i in range(n-14999)]
    print(*l)

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

using namespace std;
typedef long long ll;

const int MAXN = 1e5+100;
const int INF = 1e9;
int dist[MAXN];

int main(){
  int k;
  cin >> k;
  for(int i = 0; i < k; i++) dist[i] = INF;
  dist[k] = 0;  
  
  deque<int> dq;
  dq.push_front(k);
  while(!dq.empty()){
    int u = dq.front();
    dq.pop_front();
    int nxt0 = u == k ? k : (10 * u) % k;
    int nxt1 = (u + 1) % k;
    if(dist[u] < dist[nxt0]){
      dist[nxt0] = dist[u];
      dq.push_front(nxt0);
    }
    if(dist[u] + 1 < dist[nxt1]){
      dist[nxt1] = dist[u] + 1;
      dq.push_back(nxt1);
    }
  }
  cout<<dist[0]<<endl;
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
int main(){
  int n, W;
  cin >> n >> W;
  int w[n], v[n];
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  ll dp[n + 1][W + 1] = {};
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j <= W; j++) {
      if (j < w[i]) {
        dp[i][j] = dp[i + 1][j];
      } else {
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }
  cout << dp[0][W] << endl;
  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define INF llong(1e18)


int main(){
    int n;
    cin >> n;
    llong T=0,A=0;
    llong t,a;
    llong left,right;
    llong mid;
    REP(i,n){
        scanf("%lld%lld",&t,&a);
        left=0;
        right = INF/max(t,a);
        while(1){
            if(left +1 >=right) break;
            mid = (left + right) /2;
            if(T <=mid*t and A <= mid * a){
                right = mid;
            }
            else{
                left = mid;
            }
        }
        T=right * t;
        A= right * a;
    }
    cout << T+A <<endl;

}

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

int G(int a,int b){
  int r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}
  

 
int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int g=A.at(0);
  for(int i=1;i<N;i++){
    g=G(g,A.at(i));
  }
  cout<<g;
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    a[0]=0;
    rep(i,n){
        cin>>a[i+1];
        a[i+1]+=a[i];
    }
    vector<ll> v;
    v.reserve(n*(n+1)/2);
    for(int i=0;i<n;i++){
        for(int j=i;j<n;++j){
            v.push_back(a[j+1]-a[i]);
        }
    }
    int sz=v.size();
    ll ans=0;
    for(int i=40;i>=0;--i){
        int cnt=0;
        rep(j,sz){
            if(v[j]&(1LL<<i)){
                ++cnt;
            }
        }
        if(cnt>=k){
            rep(j,sz){
                if(!(v[j]&(1LL<<i))){
                    v[j]=0;
                }
            }
            ans+=(1LL<<i);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){

    ll a, b, c;

    cin >> a >>b >> c;

    ll d = c- b - a;

    if(d > 0 && d*d > 4 * a * b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

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

int main() {
    int s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
    return 0;
}

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

int main(void){
  int n;
  int result;
  long double sum;
  long double h;
  long double w;
  long double o;

  result = scanf("%d", &n);

  sum = (long double)n;
  h = sum / 3;
  w = sum / 3;
  o = sum - h - w;

  printf("%Lf", h * w * o);
  return (0);
}


Measured memory_bytes: 128
n = int(input())
#l, r = list(map(int, input().split()))
# A = list(map(int, input().split()))
#a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
#a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#x = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
# for i in range(1, int(n**0.5)+1):

if n < 600:
    print(8)
elif n < 800:
    print(7)
elif n < 1000:
    print(6)
elif n < 1200:
    print(5)
elif n < 1400:
    print(4)
elif n < 1600:
    print(3)
elif n < 1800:
    print(2)
elif n < 2000:
    print(1)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall

	ini(H);
	ini(W);
	ini(k);
	string s[14];
	FOR(i,0,H){
		in(s[i]);
	}
	int tmpmin = 1<<29;
	FOR(mask,0,(1<<(H-1))){
		int to[10] = {};
		int tmp = 0;
		FOR(i,0,H){
			to[i] = tmp;
			if(mask&(1<<i))tmp++;
		}
		int bit = __builtin_popcount(mask);
		int tmp1[10] = {};
		FOR(i,0,W){
			FOR(i1,0,H){
				if(s[i1][i] == '1')tmp1[to[i1]]++;
			}
			FOR(x,0,tmp+1)if(tmp1[x]>k){
				bit++;
				FOR(x1, 0, tmp + 1) { tmp1[x1] = 0; }
				FOR(i1,0,H){
					if(s[i1][i] == '1')tmp1[to[i1]]++;
				}
				break;
			}
			FOR(x,0,tmp+1)if(tmp1[x]>k){
				bit = 1LL<<29;
			}
		}
		tmpmin = min(tmpmin,bit);
	}
	out(tmpmin);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
typedef double db;
const int MX=100005;
const int mod=1000000007;
const int inf=1e9;
ll dp[105][MX],w[105],v[105],n;
ll ok(int i, int W)
{
    if(i>n)return 0;
    if(~dp[i][W])return dp[i][W];
    ll mx=ok(i+1,W);
    if(W-w[i]>=0) mx=max(mx,v[i]+ok(i+1,W-w[i]));
    return dp[i][W]=mx;
}
int main()
{
    FasterIO;
    int i,j,k,W;
    cin>>n>>W;
    for(i=1;i<=n;i++)cin>>w[i]>>v[i];
    memset(dp,-1,sizeof(dp));
    ll res=ok(1,W);
    cout<<res<<endl;
    return 0;
}


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

typedef long long LL;

const int N=6000;

int mod;
 
int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n;

void into(){
  scanf("%d%d",&n,&mod);
}

int dp[N+9][N*2+9],ans;

void Get_dp(){
  n*=3;
  dp[0][N]=1;
  for (int i=1;i<=n;++i)
	for (int j=N-i;j<=N+i;++j){
	  sadd(dp[i][j],dp[i-1][j-1]);
	  if (i>=2) sadd(dp[i][j],mul(dp[i-2][j+1],i-1));
	  if (i>=3) sadd(dp[i][j],mul(dp[i-3][j],mul(i-1,i-2)));
	}
  for (int i=N;i<=n+N;++i) sadd(ans,dp[n][i]);
}

void work(){
  Get_dp();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 167344
#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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dfs(vector<vector<ll>> &graph, ll from, ll now, ll k)
{
    ll tmp;
    if (from == -1)
    {
        tmp = k - 1;
    }
    else
    {
        tmp = k - 2;
    }

    if (k < (ll)graph[now].size())
    {
        return 0;
    }
    else
    {
        ll res = 1;
        for (auto v : graph[now])
        {
            if (v == from)
            {
                continue;
            }
            res = res * tmp % MOD;
            tmp--;
        }
        for (auto v : graph[now])
        {
            if (v == from)
            {
                continue;
            }
            res = res * dfs(graph, now, v, k) % MOD;
        }
        return res;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<vector<ll>> graph(n);
    vector<ll> seen(n, -1);
    seen[0] = k;
    for (ll i = 0; i < n - 1; i++)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    ll ans = k * dfs(graph, -1, 0, k) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 1003455
ll v[5],cant[5];

int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll a,b,c,d;
    cin>>v[0]>>v[1]>>v[2]>>d;
    forr(i,0,3)
    {
        if (d>=v[i])
            cant[i]=v[i],d-=v[i];
        else
            cant[i]=d,d=0;
    }
    cout<<cant[0]*1+cant[2]*-1<<endl;
}
// PLUS ULTRA!!

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N-1);
    REP(i, N-1) {
        cin >> B[i];
    }
    REP(i, N) {
        if (i == 0) {
            A[i] = B[i];
        } else if (i == N-1) {
            A[i] = B[i-1];
        } else {
            A[i] = min(B[i], B[i-1]);
        }
    }
    int result = 0;
    REP(i, N) {
        result += A[i];
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n,k; cin >> n >> k;
    cout<<ceil((n-1)/(k-1.0))<<endl;
    
}

Measured memory_bytes: 3812
// I/O
#include <iostream>
#include <iomanip>

// data structures
#include <set>
#include <queue>
#include <vector>

// manipulations
#include <algorithm>

#define rep(i,n) for(int i=0;i< (n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define for_lowercase(c) for(int c='a';c<='z';++c)
#define for_uppercase(c) for(int c='A';c<='Z';++c)
#define ALL(a) (a).begin(),(a).end()
using LLI = long long int;
LLI GCD(LLI a,LLI b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LLI LCM(LLI a,LLI b){ return (a/GCD(a,b))*b; }
using VI  = std::vector<LLI>;
using PI  = std::pair<LLI,LLI>;
using VVI = std::vector<VI>;
using VPI = std::vector<PI>;
template<class T> bool is_odd (T x){ return   x%2 ; }
template<class T> bool is_even(T x){ return !(x%2); }

int main() {
    std::ios::sync_with_stdio(false);

    LLI N;
    std::cin >> N;

    LLI ans = 12; // INF
    for(LLI A=1;A*A<=N;++A){
        LLI B = N/A;
        if(A*B == N){
            LLI F = std::max(std::to_string(A).size(),std::to_string(B).size());
            ans = std::min(ans,F);
        }
    }

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        while (k>0){
            while (a != 0 && k != 0){
                ans++;
                a--;k--;
            }
            while (b != 0  && k != 0){
                b--;k--;
            }
            while (c != 0 && k != 0){
                ans = (ans-1);
                c--;k--;
            }
            k--;
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 33252
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll dp[1001000][2][2];
int main(void){
    ll n;
    cin >> n;
    dp[0][0][0] = 1;
    rep(i, n){
        rep(j, 2){
            rep(k, 2){
                dp[i + 1][1][k] += dp[i][j][k];
                dp[i + 1][1][k] %= MOD;
                dp[i + 1][j][1] += dp[i][j][k];
                dp[i + 1][j][1] %= MOD;
                dp[i + 1][j][k] += dp[i][j][k] * 8;
                dp[i + 1][j][k] %= MOD;
            }
        }
    }
    cout << dp[n][1][1] << endl;
}


Measured memory_bytes: 34736