akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*** 0026 */
public class Main {

	/*** 紙 */
	private static int[][] paper;
	/*** インク滴「小」,「中」,「大」 */
	private static final int S = 1, M = 2, L = 3;
	/*** 文字型入力ストリーム（標準入力） */
	private static BufferedReader br;
	/*** 拡大する大きさ */
	private static int plus = 2;
	/*** 通常の紙の大きさ */
	private static int normal = 10;
	/*** 列, 行, インク滴の大きさ, 色のついていない部分, 最も色の濃い部分 */
	private static int x, y, size, blindNum = 0, max;
	/*** 入力行 */
	private static String line;

	/*** 初期化 */
	static {
		paper = new int[normal + plus * plus][normal + plus * plus];// 縦横ともに紙のサイズを拡大する（計算しやすくするため）
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * メインメソッド
	 */
	public static void main(String[] args) throws IOException {

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			setInput(line); // 入力行を設定する
		}
		calcu(); // 計算する
		System.out.println(blindNum + "\n" + max);
	}

	/**
	 * 入力行の設定を設定する
	 */
	private static void setInput(String line) {
		StringTokenizer st = new StringTokenizer(line, ","); // カンマごとに分ける
		x = Integer.parseInt(st.nextToken()) + plus; // 紙を拡大した分マスを大きくする
		y = Integer.parseInt(st.nextToken()) + plus; // 紙を拡大した分マスを大きくする
		size = Integer.parseInt(st.nextToken());
		set(); // インク滴を設定
	}

	/**
	 * 色のついていない部分のマス目の個数と１番濃いマス目の濃さを計算する。
	 */
	private static void calcu() {
		for (x = plus; x < normal + plus; x++) {
			for (y = plus; y < normal + plus; y++) {
				if (paper[x][y] == 0) // 色のついていない部分かどうか
					blindNum++;
				if (max < paper[x][y]) // １番濃いマス目かどうか
					max = paper[x][y];
			}
		}
	}

	/**
	 * 入力値に対応する場所にインキ滴を設定する
	 */
	private static void set() {
		paper[x][y]++;
		if (size >= S) {
			paper[x - 1][y]++;
			paper[x + 1][y]++;
			paper[x][y - 1]++;
			paper[x][y + 1]++;
		}
		if (size >= M) {
			paper[x - 1][y - 1]++;
			paper[x - 1][y + 1]++;
			paper[x + 1][y - 1]++;
			paper[x + 1][y + 1]++;
		}
		if (size >= L) {
			paper[x - 2][y]++;
			paper[x + 2][y]++;
			paper[x][y - 2]++;
			paper[x][y + 2]++;
		}
	}
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    int n; cin >> n;
    set<string> val;

    rep(i, 0, n) {
        string s; cin >> s;
        val.insert(s);
    }

    int m; cin >> m;

    bool isopen = false;
    
    rep(i, 0, m) {
        string s; cin >> s;
        if (val.find(s) != val.end()) {
            if (isopen) cout << "Closed by ";
            else cout << "Opened by ";

            isopen ^= 1;
            cout << s << endl;
        } else {
            cout << "Unknown " << s << endl;
        }
    }
}


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

#pragma GCC optimize ("O3")
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<int, int> mi;
typedef map<ll, ll> ml;
#define fr(i, n) for (int i = 0; i < n; i++)
#define frn(i, k, n) for (int i = k; i < n; i++)
#define rf(i, n) for (int i = n-1; i >= 0; i--)
#define rfn(i, k, n) for (int i = n-1; i >= k; i--)

const int N = 5e5 + 5;
const int M = 998244353;
ll fact[N], inv[N];
vector<bool> prime;
vector<int> drow4{1, -1,  0,  0};
vector<int> dcol4{0,  0, -1,  1};
vector<int> drow8{0,  1,  1,  1,  0, -1, -1, -1};
vector<int> dcol8{1,  1,  0, -1, -1, -1,  0,  1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "debug statement : " << *it << " = " << a << endl;
    err(++it, args...);
} 

ll powerModM(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res=(res * x)%M; 
        y = y >> 1; 
        x = (x *x) % M;
    } 
    return res % M; 
}

ll power(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x*x;
    } 
    return res; 
}
 
void preCalcFactorial(int n){
    fact[0] = inv[0] = 1;
    for(ll i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % M;
        inv[i] = powerModM(fact[i], M - 2);
    }
}
 
ll nCr(ll n,ll r){
    ll ans = ((fact[n] * inv[r]) % M + M) % M;
    ans = ((ans * inv[n-r]) % M + M) % M;
    return ans;
}

void sieve(int n) { 
    prime.resize(n+1, true);
    prime[1] = false;
    for (int p = 2; p * p <= n; p++){ 
        if (prime[p] == true) {
            for (int i = p*p; i <= n; i += p) 
                prime[i] = false; 
        } 
    }
} 

class BIT{
public:
    int size;
    vector<int> v;
    BIT(int s){
        size = s;
        v.resize(s, 0);
    }
    void update(int i, int delta){
        while(i < size){
            v[i] += delta;
            i += i & (-i);
        }
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= i & (-i);
        }
        return s;
    }
};

void testCase(){
	int l, r, n;
	cin >> l >> r >> n;
	cout << r / n - (l - 1) / n << endl;
}

int main(){
    FAST
    int t = 1;
    // cin >> t;
    while(t--){
        testCase();
    }
}


Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	A, B := fsc.NextInt(), fsc.NextInt()
	if A == B {
		fmt.Println("Draw")
		os.Exit(0)
	}
	if A == 1 {
		A += 114514
	}
	if B == 1 {
		B += 114514
	}
	if A > B {
		fmt.Println("Alice")
		os.Exit(0)
	}
	if A < B {
		fmt.Println("Bob")
		os.Exit(0)
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
long long n,W,dp[101010],w[111],v[111],sum;
int main()
{
	cin>>n>>W;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
		sum+=v[i];
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=sum;j>=v[i];j--)
		{
			dp[j]=min(dp[j-v[i]]+w[i],dp[j]);
		}
	}
	for(int i=sum;i>=0;i--)
	{
		if(dp[i]<=W)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int A,B;
    char op;
    cin >> A >> op >> B;
    cout << (op=='+'? A+B:A-B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  vector<lint> p(a);
  vector<lint> q(b);
  vector<lint> r(c);
  for (int i = 0; i < a; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> q[i];
  }
  for (int i = 0; i < c; i++) {
    cin >> r[i];
  }
  
  sort(RALL(p));
  sort(RALL(q));
  sort(RALL(r));

  vector<lint> u(x);
  vector<lint> v(y);
  for (int i = 0; i < x; i++) u[i] = p[i];
  for (int i = 0; i < y; i++) v[i] = q[i];

  reverse(ALL(u));
  reverse(ALL(v));
  u.push_back(INF);
  v.push_back(INF);

  int ui = 0;
  int vi = 0;
  for (int i = 0; i < c; i++) {
    if (u[ui] == INF and v[vi] == INF) {
      break;
    }
    if (u[ui] < v[vi]) {
      if (u[ui] < r[i]) {
        u[ui] = r[i];
        ui++;
      } else break;
    } else {
      if (v[vi] < r[i]) {
        v[vi] = r[i];
        vi++;
      }
    }
  }

  lint ans = 0;
  for (int i = 0; i < x; i++) ans += u[i];
  for (int i = 0; i < y; i++) ans += v[i];

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


Measured memory_bytes: 4736
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	const long mod = (long) 1e9 + 7;
	public void Solve(){
		
		long[] dp = new long[N+1];
		dp[0] = 1;
		for(int i=0;i<N;i++){
			long[] nxt = new long[N+1];
			for(int j=0;j<N;j++){
				if(dp[j] == 0) continue;
				if(j == 0){
					nxt[0] += dp[j]; if(nxt[0] >= mod) nxt[0] -= mod;
				} else {
					nxt[j - 1] += dp[j]; if(nxt[j - 1] >= mod) nxt[j - 1] -= mod;
					nxt[j - 1] += dp[j]; if(nxt[j - 1] >= mod) nxt[j - 1] -= mod;
				}
				nxt[j + 1] += dp[j]; if(nxt[j + 1] >= mod) nxt[j + 1] -= mod;
			}
			dp = nxt;
		}
		Console.WriteLine(dp[S.Length]);
		
		
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

    int max = 0;
    int count = 0;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        int tmp = i;
        for (int j = 1; j < 8; j++) {
            if (tmp % 2 == 0) {
                tmp /= 2;
                count = j;
                if (max < count) {
                    max =count;
                    ans = i;
                }
            }
            else {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int n,a[200010];
long long ans;
map<int,int> myd;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        ans+=myd[i-a[i]];
        myd[i+a[i]]++;
    }
    printf("%lld",ans);
}

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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
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;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 300010;

using namespace atcoder;

struct monoid {
    int val;

    static monoid op(monoid lhs, monoid rhs) {
        return lhs.val > rhs.val ? lhs : rhs;
    }

    static monoid e() { return {0}; }
};

int main() {
    int n, K;
    scanf("%d%d", &n, &K);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    segtree<monoid, monoid::op, monoid::e> st(MAX);
    int ans = 1;
    rep(i, n) {
        int l = max(0, a[i] - K), r = min(MAX, a[i] + K + 1);
        int tmp = max(st.get(a[i]).val, st.prod(l, r).val + 1);
        chmax(ans, tmp);
        st.set(a[i], {tmp});
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 9648
#include<stdio.h>
int main(void){
	int n,i,j,v,cnt,minj,temp,fmin;
	int a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	cnt=0;
	for(i=0;i<n;i++){
		minj=i;
		fmin=minj;
		for(j=i;j<n;j++){
			if(a[j]<a[minj]){
				minj=j;
			}
		}
		temp=a[i];
		a[i]=a[minj];
		a[minj]=temp;
		if(fmin!=minj){
			cnt++;
		}
	}
	for(i=0;i<n-1;i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[n-1]);
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 600
//#include <fstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

int main() {
    char s[19];
    cin >> s;
    for (int i = 0; i < 19; i++) {
        if (s[i] == ',')
            s[i] = ' ';
        cout << s[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//
 

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n , m;
  cin >> n >> m;
  vector<ll> box(m);
  rep(i,m){
    box[i]=0;
  }
  rep(i,n){
    ll k;
    cin >> k;
    rep(j,k){
      int a;
      cin >> a;
      box[a-1]++;
    }
  }
  ll ans = 0;
  rep(i,m){
    if(box[i]==n) ans++;
  }
  pri(ans);
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[1001];
		for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		}
		int X= sc.nextInt();
		for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		}
	}
}

Measured memory_bytes: 21844
/*
author：cmathpo8&&yuanchen&&qiyujun
date:2019/8/17 10:11 

*/
#include<bits/stdc++.h>
#define re register
using namespace std;
int h[100010],t,cnt;
char a[100010];
struct node{
	int fro;
	int to;
}el[100010];
int main(){
   	scanf("%s",a+1);
   	int cntl=0;
   	int sst=strlen(a+1);
   	memset(h,0,sizeof(h));
   	t=-1;
    for(re int i=1;i<=sst;i++){
    	if(a[i]=='L'){
    		if(t==-1){
    			el[++cnt].fro=i;
                el[cnt].to=i;
                t=0;
    		}else el[cnt].to=i;
    	}else t=-1;
    } 
    el[0].to=0;
    for(re int i=1;i<=cnt;i++){
    	int dis=(el[i].fro-el[i-1].to-1);
    	int disl=(el[i].to-el[i].fro+1);
    	if(dis%2==1){
    		h[el[i].fro]+=(dis/2);
    		h[el[i].fro-1]+=(dis/2)+1;
    	}else{
    		h[el[i].fro]+=(dis/2);
    		h[el[i].fro-1]+=(dis/2);
    	}
    	if(disl%2==1){
    		h[el[i].fro-1]+=(disl/2);
    		h[el[i].fro]+=(disl/2)+1;
    	}else{
    		h[el[i].fro-1]+=(disl/2);
    		h[el[i].fro]+=(disl/2);
    	}
    }
    for(re int i=1;i<=sst;i++){
    	printf("%d ",h[i]);
    } 
    /*for(re int i=1;i<=cnt;i++){
    	cout<<el[i].fro<<" "<<el[i].to<<" ";
    }*/
    return 0;
}

Measured memory_bytes: 1280
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        v: [i64; n],
        c: [i64; n],
    }

    let mut ans = 0;
    for i in 0..n {
        if v[i] > c[i] {
            ans += v[i] - c[i];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <functional>
template <typename T>
struct Line
{
    T a, b;  // (a,b) <=> f(x)=ax+b
    bool query;
    mutable std::function<const Line*()> succ = nullptr;
    bool operator<(const Line& l) const
    {
        if (not l.query) { return a > l.a; }
        const Line* s = succ();
        if (not s) { return false; }
        return s->b - b < (a - s->a) * l.a;
    }
};
template <typename T>
class DynamicCHT : public std::multiset<Line<T>>
{
    bool needless(const typename DynamicCHT<T>::iterator y) const
    {
        const auto z = std::next(y);
        if (y == this->begin()) { return z != this->end() and y->a == z->a and y->b >= z->b; }
        const auto x = std::prev(y);
        return z == this->end() ? y->a == x->a and y->b >= x->b : (x->b - y->b) * (z->a - y->a) >= (y->b - z->b) * (y->a - x->a);
    }

public:
    void add(const T a, const T b)
    {
        auto y = this->insert({a, b, false});
        y->succ = [=]() { return std::next(y) == this->end() ? nullptr : &*std::next(y); };
        if (needless(y)) { return (void)this->erase(y); }
        while (std::next(y) != this->end() and needless(std::next(y))) { this->erase(std::next(y)); }
        while (y != this->begin() and needless(std::prev(y))) { this->erase(std::prev(y)); }
    }
    T query(const T x) const
    {
        const auto l = *this->lower_bound(Line<T>{x, 0, true});
        return l.a * x + l.b;
    }
};
using ll = long long;
int main()
{
    std::ios::sync_with_stdio(false);
    std::size_t N;
    ll C;
    std::cin >> N >> C;
    std::vector<ll> h(N), dp(N);
    for (std::size_t i = 0; i < N; i++) { std::cin >> h[i]; }
    DynamicCHT<ll> cht;
    cht.add(-2 * h[0], dp[0] + h[0] * h[0]);
    for (std::size_t i = 0; i < N; i++) {
        dp[i] = cht.query(h[i]) + h[i] * h[i] + C;
        cht.add(-2 * h[i], dp[i] + h[i] * h[i]);
    }
    std::cout << dp[N - 1] << std::endl;
    return 0;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
int n;
struct data{
    int a, b;
    bool operator<(const data &r)const{
        return b<r.b;
    }
}arr[200003];
int main(){
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d %d",&arr[i].a,&arr[i].b);
    }
    sort(arr+1,arr+1+n);
    int cur=0;
    for(i=1;i<=n;i++){
        if((cur+=arr[i].a)>arr[i].b) break;
    }
    if(i>n) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

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

    int ans = 200;
    int dist = 200;

    for (int i = 0; i <= 200; ++i) {
        auto it = find(begin(p), end(p), i);
        if (it != end(p)) {
            continue;
        }

        if (abs(i - X) < dist) {
            dist = abs(i - X);
            ans = i;
        } else if (abs(i - X) == dist) {
            ans = min(ans, i);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

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

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data1 = scanner.nextLine();
			String data2 = scanner.nextLine();

			String[] data2Array = data2.split(" ");
			int[] a = Stream.of(data2Array).mapToInt(Integer::parseInt).toArray();

			int[] array = new int[10000005];
			for (int x : a) {
				if (array[x] != 0) {
					array[x] = 2;
					continue;
				}
				for (int i = x; i < 10000005; i += x) {
					array[i]++;
				}
			}

			int ans = 0;
			for (int x : a) {
				if (array[x] == 1) {
					ans++;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 116748
import java.math.BigInteger;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for(int i = 0; i < n; i++){
            String a = scan.next();
            String b = scan.next();
            BigInteger ab = (new BigInteger(a)).add(new BigInteger(b));
            if(ab.toString().length() > 80) System.out.println("overflow");
            else System.out.println(ab);
        }
    }
}

Measured memory_bytes: 26140
import collections
def main():

    N, K = map(int, input().split())
    if K == 1:
        if N == 1: return 1
        else: return 0

    tree = collections.defaultdict(list)
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    mod = pow(10, 9) + 7

    v = inv_factorial(K-1, mod)
    invf = [v]
    for i in range(K-1, 0, -1):
        invf.append((invf[-1] * i) % mod)
    invf = invf[::-1]

    f = [1]
    for i in range(1, K):
        f.append((f[-1]*i) % mod)

    ans = K
    cur = []
    visited = set([1])
    for b in tree[1]:
        cur.append(b)
        visited.add(b)
    l = len(cur)
    if l > K-1: return 0
    ans *= (f[K-1]*invf[K-1-l]) % mod
    ans %= mod

    while cur:
        temp = []
        for a in cur:
            l = len(tree[a])-1
            if l > K-2: return 0
            ans *= (f[K-2]*invf[K-2-l]) % mod
            ans %= mod
            for b in tree[a]:
                if b not in visited:
                    temp.append(b)
                    visited.add(b)
        cur = temp

    return ans


def quickpow(x, y, mod):
    if y == 0: return 1
    elif y == 1: return x
    elif y % 2 == 0: return pow(quickpow(x, y//2, mod), 2) % mod
    elif y % 2 == 1: return (pow(quickpow(x, y//2, mod), 2) * x) % mod

def factorial(x, mod):
    v = 1
    for i in range(2, x+1):
        v *= i
        v %= mod
    return v

def inv_factorial(x, mod):
    v = factorial(x, mod)
    return quickpow(v, mod-2, mod)


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 97240
// In the name of God

#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5+5;
int dp[N];
vector<int> changes;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	string s;
	cin >> s;
	for(int i=0; i<s.length()-1; i++) {
		if( s[i] == 'R' && s[i+1] == 'L' ) changes.push_back(i);
	}
	int last = 0;
	for(auto x : changes) {
		for(int i=last; i<=x; i++) {
			if((x-i)%2==0) dp[x]++;
			else dp[x+1]++;
		}
		for(int i=x+1; s[i]!='R' && i<s.length(); i++) {
			if( (i-x-1)%2==0 ) dp[x+1]++;
			else dp[x]++;
			last=i;
		}
		last++;
	}
	for(int i=0; i<s.length(); i++) cout << dp[i] << " ";
	return 0;
}


Measured memory_bytes: 1232
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[110];
    rep(i, H) cin >> S[i];
    bool a[2][110] = {};
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') a[0][i] = true;
        }
    }
    rep(j, W) {
        rep(i, H) {
            if (S[i][j] == '#') a[1][j] = true;
        }
    }
    rep(i, H) {
        if(!a[0][i]) continue;
        rep(j, W) {
            if(!a[1][j]) continue;
            cout << S[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

int N,M;
bool dp[10][10];
int arr[10];
void solve() {
	int i,x,y;
	cin>>N>>M;
	for(int i=0;i<M;i++) {
		cin>>x>>y;
		dp[x-1][y-1]=1;
		dp[y-1][x-1]=1;
	}
	for(int i=0;i<N;i++) arr[i]=i;
	int res=0;
	do {
		if(arr[0]!=0) continue;
		for(i=0;i<N-1;i++) {
			if(dp[arr[i]][arr[i+1]]==0) break;
		}
		if(i==N-1) res++;
	} while (next_permutation(arr,arr+N));
	cout<<res<<endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll> p1;

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

    int n,a,b;
    cin >>n>>a>>b;
    cout << min(n*a, b);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n, k, mn = 9e20;
pair<ll, ll> a[55];
int main() {
     int i, j, l;
     cin >> n >> k;
     for (i = 0; i < n; i++) cin >> a[i].F >> a[i].S;
     sort(a, a + n);
     for (i = 0; i <= n - k; i++) {
          vector<ll> v;
          for (j = 0; j < k - 1; j++) v.push_back(a[i + j].S);
          for (; i + j < n; j++) {
               v.push_back(a[i + j].S);
               sort(v.begin(), v.end());
               for (l = 0; l <= v.size() - k; l++) {
                    mn = min(mn, (v[l + k - 1] - v[l]) * (a[i + j].F - a[i].F));
               }
          }
     }
     cout << mn;
     return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(in);
    int N = sc.nextInt(), M = sc.nextInt();
    int[] array = new int[N];
    for (int i=0; i<M; i++) {
      int a = sc.nextInt()-1, b = sc.nextInt()-1;
      array[a] += 1;
      array[b] += 1;
    }
    for (int ans : array)
      out.println(ans);
  }
}

Measured memory_bytes: 35936
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
string S,T,U;
int A,B;

int main()
{
  int n;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if (U == S) A--;
  if (U == T) B--;

  printf("%d %d\n", A, B);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
#define TIME (chrono::steady_clock::now().time_since_epoch().count())
const int MXN = 2e5+5;
int cnt[MXN];
int pot10[MXN];
int p;

int main()
{
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n >> p;
  pot10[0] = 1; FOR(i, 1, n)pot10[i] = pot10[i-1] * 10 % p;
  string s;
  cin >> s;

  if(p == 2 || p == 5)
    {
    LL res = 0;
    REP(i, n)
      {
      if((s[i]-'0') % p == 0)
        res += i+1;
      }
    cout << res << endl;
    return 0;
    }

  int hasz = 0;
  cnt[0]++;

  LL res = 0;
  REP(i, n)
    {
    hasz = (hasz * 10 + s[i] - '0') % p;
    res += cnt[hasz * pot10[n-i-1] % p]++;
    }
  cout << res << endl;
}

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

int min(int,int);

int main(void){
  char dp[1001][1001];
  int n,i,j,max,M[1001][1001];
  
  
  while(cin >> n,n){
      max=0;

      for(i=0;i<n;i++){
	  for(j=0;j<n;j++){
	      M[i][j]=1;
	    }
	} 

      for(i=0;i<n;i++){
	  for(j=0;j<n;j++){
	      cin >> dp[i][j];
	      if(i==0){
		  if(dp[i][j]!='*')M[i][j]=1;
		  else M[i][j]=-1;
		}
	      else{
		  if(dp[i][j]!='*'){
		  if(j==0)M[i][j]=1;
		  else{
		      if(M[i-1][j]==-1 || M[i-1][j-1]==-1 || M[i][j-1]==-1)
			M[i][j]=1;
		      else M[i][j]=min(M[i-1][j],min(M[i-1][j-1],M[i][j-1]))+1;
		  }
		  }
	      }
	      if(dp[i][j]=='*')M[i][j]=-1;
	  }
      }
      
      for(i=0;i<n;i++){
	  for(j=0;j<n;j++){
	      if(M[i][j]>=0 && max<M[i][j])max=M[i][j];
	    }
	}
      cout << max <<"\n";
    }
  return 0;
}

int min(int x,int y){
  return x<y?x:y;
}

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

// youtube 
int dist[100005][3];
const int INF = 1001001001;
int main() {
    int N, M, S, T;
    cin >> N >> M;
    vector<vector<int>> to(N);
    rep(i,M) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        to[u].push_back(v);
    }
    cin >> S >> T;
    --S; --T;
    rep(i,N)rep(j,3) dist[i][j] = INF;
    queue<P> q;
    q.push(P(S, 0));
    dist[S][0] = 0;
    while (!q.empty()) {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for(int u:to[v]){
            int nl = (l+1)%3;
            if(dist[u][nl] != INF) continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push(P(u,nl));
        }
    }
    int ans = dist[T][0];
    if( ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
typedef long long ll;

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	if (m == 0){
		if (n == 1){
			printf("0");
			return 0;
		}else if(n == 2){
			printf("10");
			return 0;
		}else{
			printf("100");
			return 0; 
		}
	}
	int s[m], c[m];
	rep(i, m){
		scanf("%d%d", &s[i], &c[i]);
		if(s[i] > n){
			printf("-1");
			return 0;
		}
	}
	rep(i, m){
		rep(j, m){
			if ((s[i] == s[j]) && (c[i] != c[j])){
				printf("-1");
				return 0;
			}
		}
	}
	if(n == 1){
		printf("%d", c[0]);
		return 0;
	}
  	rep(i, m)
      if ((s[i] == 1) && (c[i] == 0)){
    	printf("-1");
      	return 0;
    }
	if(n == 2){
		int xx = 1, x = 0;
		rep(i, m){
			if (s[i] == 1)	xx = c[i];
            else x = c[i];
		}
		printf("%d%d", xx, x);
		return 0;
	}
	if(n == 3){
		int xxx = 1, xx = 0, x = 0;
		rep(i, m){
			if (s[i] == 1)	xxx = c[i];
			else if (s[i] == 2)	xx = c[i];
			else x = c[i];
		}
		printf("%d%d%d", xxx, xx, x);
		return 0;
	}
		
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){     
        int n;
        cin >> n;
        vector<int> a(n);
        int s = 0;
        for(int i=0;i<n;i++){
                cin >> a[i];
                s += a[i];
        }
        int ans = 0;
        int mindiff = 100000000;
        for(int i = 0;i<n;i++){
                if (abs(s-n*a[i]) < mindiff){
                    mindiff = abs(s-n*a[i]);
                    ans = i;
                }
        }
        cout << ans << endl;
}




Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	prev := sc.NextInt()
	ans := prev
	for i := 1; i < n-1; i++ {
		tmp := sc.NextInt()
		if tmp < prev {
			ans += tmp
		} else {
			ans += prev
		}
		prev = tmp

	}
	ans += prev
	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
n, m = map(int, input().split())
if n==1 and m==0:
    print(0)
    exit()
r = pow(10, n-1)
S = []
C = []
for i in range(m):
    s, c = map(int, input().split())
    if s in S:
        if C[S.index(s)] != c:
            r = -1
            break
        else:
            continue
    if s==1 and c==0:
        if n==1:
            r = 0
            S.append(s)
            C.append(c)
        else:
            r = -1
            break
    else:
        S.append(s)
        C.append(c)
        if s==1:
            r += (c-1)*pow(10, n-s)
        else:
            r += c*pow(10, n-s)
print(r)

Measured memory_bytes: 3064
// 鳩ノ巣原理よりn回試せば可能かどうかわかる.
#include<iostream>
using namespace std;
int main(){
  int n; cin >> n;
  int a[100050];
  for(int i=1;i<=n;i++) cin >> a[i];
  int j = 1;
  for(int c=1;c<=n;c++){
    int k = a[j]; // 連続で写像する.
    if(k==2){
      cout << c << endl;
      return 0;
    }
    j = k;
  }
  
  cout << -1 << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

    FAST;

    cin >> n;
    string s;
    set <string> ss;
    for (int i = 0; i < n; i ++) {
        cin >> s;
        ss.insert(s);
    }
    cout << ss.size() << '\n';
    return 0;
}


Measured memory_bytes: 19208
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

const int N=1000005;

int n,l,r,mid,len;
int a[N];
char s[N];

bool check(int w){
	int i,sum; len=n;
	for (i=1;i<=n;i++) a[i]=(s[i]-'0')*9;
	a[1]+=9*w;
	for (i=1;i<=n;i++){
		a[i+1]+=a[i]/10;
		a[i]=a[i]%10;
	}
	while (a[len+1]){
		len++;
		a[len+1]+=a[len]/10;
		a[len]=a[len]%10;
	}
	sum=0;
	for (i=1;i<=len;i++) sum+=a[i];
	for (i=1;i<=len;i++) a[i]=0;
	if (sum<=9*w) return 1;
	return 0;
}

int main(){
	int i;
	scanf("%s",s+1); n=strlen(s+1);
	reverse(s+1,s+1+n);
	l=1; r=n;
	while (l<r){
		mid=l+(r-l)/2;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 3840
#include<cstdio>
#define ll long long
using namespace std;
int main()
{
	ll n, m;
	scanf("%lld %lld", &n, &m);
	if (n == 1 && m == 1)
	{
		puts("1");
		return 0;
	}
	if (n == 1 || m == 1)
	{
		printf("%lld", n*m - 2);
		return 0;
	}
	printf("%lld", n*m - 2 * m - (n - 2) * 2);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef map<int, int> mii;

int main() {FIN
	
	int n, i, x, _min = 0, smin;
	cin >> n;
	mii pos;
	for (i = 0; i < n; i++) {
		cin >> x;
		pos[x]++;
	}
	for (i = 1; i <= 100; i++) {
		
		smin = 0;
		for (auto it = pos.begin(); it != pos.end(); it++) {
			smin += (it->second * (it->first - i) * (it->first - i));
		}
		if (i == 1 or _min > smin)
			_min = smin;
	}
	cout << _min << "\n";
	return 0;
}


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

#define ll long long
ll MOD = 1000000007;

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> seq(n), a(n), b(n - 1);
    for (int i = 0; i < n; i++) cin >> seq[i];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++) cin >> b[i];
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[i];
        if (i < n - 1 && seq[i + 1] == seq[i] + 1) ans += b[seq[i] - 1];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import sys, math,os
from io import BytesIO, IOBase
#data = BytesIO(os.read(0,os.fstat(0).st_size)).readline
# from bisect import bisect_left as bl, bisect_right as br, insort
# from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
# from decimal import Decimal
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
#sys.setrecursionlimit(100000 + 1)
INF = 10**9
mod = 998244353


def recur1(r,c,a):
    global ans
    if a==w:
        cnt=0
        for i in range(h):
            for j in range(w):
                if i in r or j in c:
                    continue
                if mat[i][j] == '#':
                    cnt += 1
        if cnt==k:
            ans+=1
    else:
        recur1(r,c, a + 1)
        c1=c.copy()
        c1.add(a)
        recur1(r,c1, a + 1)

def recur(r,a):
    if a==h:
        recur1(r,set(),0)
    else:
        recur(r,a+1)
        r1=r.copy()
        r1.add(a)
        recur(r1,a+1)

h,w,k=mdata()
ans=0
mat=[data() for i in range(h)]
recur(set(),0)
out(ans)








Measured memory_bytes: 70708
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,c = 1,a,b;
    bool pflag,qflag;
    cin >> N;
    vector<int> P(N),Q(N);

    rep(i, N){
        cin >> P[i];
    }

    rep(i, N){
        cin >> Q[i];
    }

    vector<int> order(N);
    rep(i, N){
        order[i] = i + 1;
    }

    do {
        pflag = true;
        qflag = true;

        rep(i, N){
            if(order[i] != P[i]){
                pflag = false;
            }

            if(order[i] != Q[i]){
                qflag = false;
            }
        }

        if(pflag){
            a = c;
        }

        if(qflag){
            b = c;
        }

        c++;
    }while(next_permutation(all(order)));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256