akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    cout << "2018/01/" << s.at(8) << s.at(9) << endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
j = 0
k = 0
l = 0

for i in range(n+1)[1:]:
    l = i
    while l > 0:
        j = j + l % 10
        l = l // 10
    if a <= j and j <= b:
        k += i
    j = 0

print(k)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
#define for_each(it,a) for(__typeof a.begin() it = a.begin();it!=a.end();it++)
template<class T> void chmin(T& a, T b) { if( b < a ) a = b; }

int n, m;
struct edge{
  int pos, dang;
  vector < int >  value;
  edge(){};
  edge( int pos, int dang): pos(pos), dang(dang), value( (n + 1) / 2 + 1, INF){};
};
int main(){
  while( cin >> n >> m , n){
    vector< vector < edge > > info(n + 2);
    for(int i = 0, k, t, d; i < n; i++){
      cin >> k;
      while(k--){
        cin >> t >> d;
        info[i].push_back( edge( t, d));
      }
    }
    for_each( it, info[0]) it -> value[m] = 0;
    for_each( it, info[1]) it -> value[m - 1] = 0;
    for( int i = 0; i < n; i++){
      for_each( now, info[i]){
        for(int j = m; j >= 0; j--){ //ジャンプできる残り回数
          int& cost = now -> value[j], dang = now -> dang, pos = now -> pos;
          if( cost == INF) continue;
          if(j > 0){ //ジャンプしてみる
            for_each( next, info[i + 2]){
              chmin( next -> value[j - 1], cost + (dang + next -> dang) * abs( pos - next -> pos));
            }
          }
          for_each( next, info[i + 1]){
            chmin( next -> value[j], cost + (dang + next -> dang) * abs( pos - next -> pos));
          }
        }
      }
    }
    int ret = INF;
    for_each(it,info[n - 1]) ret = min( ret, *min_element( it->value.begin(), it->value.end()));
    for_each(it,info[n - 2]) ret = min( ret, *min_element( it->value.begin() + 1, it->value.end()));
    cout << ret << endl;
  }
}

Measured memory_bytes: 1604
N = int(input())
s = {0:0}
for i in range(N):
    tmp = input()
    if tmp in s.keys():
        s[tmp]+=1
    else:
        s[tmp] = 1
M = int(input())
for i in range(M):
    tmp = input()
    if tmp in s.keys():
        s[tmp]-=1
    else:
        s[tmp] = -1

print(max(s.values()))

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

int main(void){
  char c;

  //is vowel?
  cin >> c;
  switch(c){
  case 'a':  case 'e':  case 'i':  case 'o':  case 'u':
    cout << "vowel" << endl;
    break;
  default:
    cout << "consonant" << endl;
    break;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
int main(){
	long long a, b, n;
	cin >> a >> b >> n;
	if(n >= b)n -= n % b + 1;
	cout << a*n/b - a*(n/b) << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>

using namespace std;

int N;

bool f;//true は女　falseは男

int main() {
	cin >> N;
	int u = N - 1, l = 0;
	cout << 0 << endl;
	string s;
	cin >> s;
	if (s == "Male")f = false;
	else if (s == "Female")f = true;
	else return 0;

	for (int i = 0; i < 17; i++) {

		int mid = (u + l) / 2;
		cout << mid << endl;
		string s1;
		cin >> s1;

		if (s1 == "Vacant")return 0;

		if (!f) {
			if (((mid - l) % 2 == 0 && s1 == "Male") || ((mid - l) % 2 == 1 && s1 == "Female")) {
				l = mid;
				if (s1 == "Male")f = false;
				if (s1 == "Female")f = true;
			}
			else {
				u = mid;
			}
		}
		else {
			if (((mid - l) % 2 == 0 && s1 == "Female") || ((mid - l) % 2 == 1 && s1 == "Male")) {
				l = mid;
				if (s1 == "Male")f = false;
				if (s1 == "Female")f = true;
			}
			else {
				u = mid;
			}
		}

		
	}

	cout << l << endl;
	cin >> s;
	if (s == "Vacant")return 0;
	cout << l + 1 << endl;
	cin >> s;
	if (s == "Vacant")return 0;

	return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int len = s.size();
	
	bool f = 1;
	for(int i = 0;i < len;i++){
		if((!(i & 1) && s[i] == 'L') || ((i & 1) && s[i] == 'R')){
			f = 0;
			break;
		}
	}
	
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static class Common
{
    // ユークリッドの互除法により最大公約数を得る
    public static long GCD(long m, long n)
    {
        if (m < n)
        {
            return GCD(n, m);
        }

        while (n != 0)
        {
            var t = n;
            n = m % n;
            m = t;
        }
        return m;
    }

    public static long LCM(long m, long n)
    {
        return m * n / GCD(m, n);
    }
}

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];
        var S = Console.ReadLine();
        var T = Console.ReadLine();

        var lcm = Common.LCM(N, M);

        var mm = lcm / M;
        for (int i = 0; i < N; i++)
        {
            var x = i * (lcm / N);
            if(x % mm == 0)
            {
                var j = (int)(x / mm);
                if(S[i] != T[j])
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
        }

        Console.WriteLine(lcm);
    }
}

Measured memory_bytes: 13356
<?php
while (true) {
  list($h, $w) = explode(" ", trim(fgets(STDIN)));
  if (!$h) break;

  for ($i = 1; $i <= $h; $i++) {
    for ($j = 1; $j <= $w; $j++) {
      if (($i + $j) % 2 == 0) echo "#";
      else echo ".";
    }
    echo "\n";
  }

  echo "\n";
}



Measured memory_bytes: 9224
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

int rev(int x){return 1-x;}

int main()
{ 
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a[n];//矛盾に関するデータ
    for(int i=0;i<n;i++){
        if(s[i]=='o'){a[i]=0;}
        else{a[i]=1;}
    }
    int b[n];//裏返しに関するデータ
    for(int i=0;i<n;i++){b[i]=0;}

    int c[3];
    for(int i=0;i<3;i++){c[i]=0;}
    for(int i=0;i<n;i++){
        if(a[i]==1){c[i%3]++;}
    }
    for(int i=0;i<3;i++){c[i]=c[i]%2;}

    if(n%3==0){//不可能パターンの出力
        if(c[0]==0&&c[1]==0&&c[2]==0){}
        else if(c[0]!=0&&c[1]!=0&&c[2]!=0){
            b[0]++;
            a[0]=rev(a[0]);
            a[1]=rev(a[1]);
            a[n-1]=rev(a[n-1]);
        }
        else{cout<<-1<<endl;return 0;}
    }
    if(n%3==2){
        if(c[0]==0&&c[1]==0&&c[2]==1){
            a[0]=rev(a[0]);a[2]=rev(a[2]);a[n-2]=rev(a[n-2]);
            b[n-1]++;b[0]++;b[1]++;
        }
        if(c[0]==0&&c[1]==1&&c[2]==0){
            a[n-2]=rev(a[n-2]);a[n-1]=rev(a[n-1]);a[0]=rev(a[0]);
            b[n-1]++;
        }
        if(c[0]==0&&c[1]==1&&c[2]==1){
            a[n-1]=rev(a[n-1]);a[2]=rev(a[2]);
            b[0]++;b[1]++;
        }
        if(c[0]==1&&c[1]==0&&c[2]==0){
            a[n-1]=rev(a[n-1]);a[0]=rev(a[0]);a[1]=rev(a[1]);
            b[0]++;
        }
        if(c[0]==1&&c[1]==0&&c[2]==1){
            a[n-2]=rev(a[n-2]);a[n-1]=rev(a[n-1]);a[1]=rev(a[1]);a[2]=rev(a[2]);
            b[n-1]++;b[1]++;
        }
        if(c[0]==1&&c[1]==1&&c[2]==0){
            a[n-2]=rev(a[n-2]);a[1]=rev(a[1]);
            b[n-1]++;b[0]++;
        }
        if(c[0]==1&&c[1]==1&&c[2]==1){
            a[0]=rev(a[0]);a[1]=rev(a[1]);a[2]=rev(a[2]);
            b[1]++;
        }
    }
    if(n%3==1){
        if(c[0]==0&&c[1]==0&&c[2]==1){
            a[n-2]=rev(a[n-2]);a[n-1]=rev(a[n-1]);a[0]=rev(a[0]);
            b[n-1]++;
        }
        if(c[0]==0&&c[1]==1&&c[2]==0){
            a[n-1]=rev(a[n-1]);a[1]=rev(a[1]);a[0]=rev(a[0]);
            b[0]++;
        }
        if(c[0]==0&&c[1]==1&&c[2]==1){
            a[n-2]=rev(a[n-2]);a[1]=rev(a[1]);
            b[n-1]++;b[0]++;
        }
        if(c[0]==1&&c[1]==0&&c[2]==0){
            a[0]=rev(a[0]);a[2]=rev(a[2]);a[n-2]=rev(a[n-2]);
            b[n-1]++;b[0]++;b[1]++;
        }
        if(c[0]==1&&c[1]==0&&c[2]==1){
            a[n-1]=rev(a[n-1]);a[2]=rev(a[2]);
            b[0]++;b[1]++;
        }
        if(c[0]==1&&c[1]==1&&c[2]==0){
            a[n-3]=rev(a[n-3]);a[0]=rev(a[0]);
            b[n-2]++;b[n-1]++;
        }
        if(c[0]==1&&c[1]==1&&c[2]==1){
            a[0]=rev(a[0]);a[1]=rev(a[1]);a[2]=rev(a[2]);
            b[1]++;
        }
    }
    for(int i=0;i<n-3;i++){
        if(a[i]==1){a[i+3]=rev(a[i+3]);b[i+1]++;b[i+2]++;}
    }
    string t;
    for(int i=0;i<n;i++){
        if(b[i]%2==1){t=t+'W';}
        else{t=t+'S';}
    }

    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,A;
  cin >>N>>M;
  int S = 0;
  for(int i=0 ;M>i;i++){
    cin>>A;
    S+=A;
  }
  if(S>N){
  cout <<-1<<endl;
  }
  else {
    cout <<N-S<<endl;
  }
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <math.h>
    using namespace std;

    int main() {
        string s="aeiuo";
        char c;
        cin>>c;
        for (int i = 0; i <s.size() ; ++i) {
            if(c==s[i]){
            cout<<"vowel";
                return 0;
            }
        }
        cout<<"consonant";}

Measured memory_bytes: 384
#include<stdio.h>

int i,j,n,f,s;
int a[7];


void input(){
    for(i=0;i<6;i++){
        scanf("%d", &a[i+1]);
    }
}

int main(){
    input();
    scanf("%d",&n);
    for(j=0;j<n;j++){
        scanf("%d%d",&f,&s);
        if(f==a[1]&&s==a[2]){
            printf("%d\n",a[3]);
        }else if(f==a[1]&&s==a[3]){
            printf("%d\n",a[5]);
        }else if(f==a[1]&&s==a[4]){
            printf("%d\n",a[2]);
        }else if(f==a[1]&&s==a[5]){
            printf("%d\n",a[4]);
        }else if(f==a[2]&&s==a[1]){
            printf("%d\n",a[4]);
        }else if(f==a[2]&&s==a[3]){
            printf("%d\n",a[1]);
        }else if(f==a[2]&&s==a[4]){
            printf("%d\n",a[6]);
        }else if(f==a[2]&&s==a[6]){
            printf("%d\n",a[3]);
        }else if(f==a[3]&&s==a[1]){
            printf("%d\n",a[2]);
        }else if(f==a[3]&&s==a[2]){
            printf("%d\n",a[6]);
        }else if(f==a[3]&&s==a[5]){
            printf("%d\n",a[1]);
        }else if(f==a[3]&&s==a[6]){
            printf("%d\n",a[5]);
        }else if(f==a[4]&&s==a[1]){
            printf("%d\n",a[5]);
        }else if(f==a[4]&&s==a[2]){
            printf("%d\n",a[1]);
        }else if(f==a[4]&&s==a[5]){
            printf("%d\n",a[6]);
        }else if(f==a[4]&&s==a[6]){
            printf("%d\n",a[2]);
        }else if(f==a[5]&&s==a[1]){
            printf("%d\n",a[3]);
        }else if(f==a[5]&&s==a[3]){
            printf("%d\n",a[6]);
        }else if(f==a[5]&&s==a[4]){
            printf("%d\n",a[1]);
        }else if(f==a[5]&&s==a[6]){
            printf("%d\n",a[4]);
        }else if(f==a[6]&&s==a[2]){
            printf("%d\n",a[4]);
        }else if(f==a[6]&&s==a[3]){
            printf("%d\n",a[2]);
        }else if(f==a[6]&&s==a[4]){
            printf("%d\n",a[5]);
        }else if(f==a[6]&&s==a[5]){
            printf("%d\n",a[3]);
        }
    }
}



Measured memory_bytes: 2148
#include <cstdio>
#include <algorithm>
int main(){
	int n;
	while(scanf("%d",&n),n){
		int m=0,v[4][2] = {{0,-1},{-1,0},{1,-1},{-1,-1}},map[66049] = {0};
		for(int y=1;y<=n;y++)
			for(int x=1;x<=n;x++)scanf("%1d",map+x+257*y);

		for(int i=0;i<4;i++){
			int dp[66049] = {0};
			for(int k=1;k<=n;k++)
				for(int j=1;j<=n;j++)m = std::max(m,dp[j+257*k] = map[j+k*257]?map[j+257*k] + dp[j+v[i][0]+257*(k+v[i][1])]:0);
		}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 1280
import java.util.Scanner;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      Scanner in = new Scanner(System.in);
      int N = in.nextInt();
      long sum = 0;
       for(int i = 1; i <= N; ++i){
           if (!(i % 3 == 0) && !(i % 5 == 0)){
           sum = sum + i;
           }
       }
      System.out.println(sum);
    }
}

Measured memory_bytes: 35720
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
#define FOR(i,n) for(int i=0;i<n;i++)
//map<key,value>

int main(){
  ll r;
  cin >> r;
  cout << r*r*3;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

vector<vector<int>> V;
int N, M, Q;
void gen_seq(int pos, vector<int> v) {
    if (v.back() > 0) {
        V.push_back(v);
    }
    else {
        for (int i = 0; i+v[pos] <= M; i++) {
            v[pos+1] = v[pos]+i;
            gen_seq(pos + 1, v);
        }
    }
}

int main() {
    cin >> N >> M >> Q;
    vector<vector<int>> v(Q);
    for (int i = 0; i < Q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        v[i] = { a, b, c, d };
    }
    vector<int> rand(N, 0);
    rand[0] = 1;
    gen_seq(0, rand);
    long long mx = 0;
    for (int i = 0; i < (int)V.size(); i++) {
        long long sum = 0;
        for (int j = 0; j < v.size(); j++) {
            if (V[i][v[j][1]] - V[i][v[j][0]] == v[j][2]) sum += v[j][3];
        }
        mx = max(mx, sum);
    }
    cout << mx;
    
    return 0;
}

Measured memory_bytes: 6612
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

using P = pair<int, int>;


void solve() {
    int n, q; cin >> n >> q;
    pair<int, P> rd[n];
    for(int i=0; i<n; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        s = max(0ll, s-x);
        t = max(0ll, t-x);
        rd[i] = {x, {s, t}};
    }
    sort(rd, rd+n);
    set<int> ds;
    int d[q];
    for(int i=0; i<q; i++) {
        int x; cin >> x;
        ds.insert(x); 
        d[i] = x;
    }
    map<int, int> ans;
    for(int i=0; i<n; i++) {
        auto l = ds.lower_bound(rd[i].second.first);
        auto r = ds.lower_bound(rd[i].second.second);
        while(l != r) {
            int el = *l;
            ans[el] = rd[i].first;
            ++l;
            ds.erase(el);
        }
    }
    for(int i=0; i<q; i++) {
        cout << (ans[d[i]] ? ans[d[i]] : -1) << endl;
    }
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 28928
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int m,d;
    cin>>m>>d;
    int cnt = 0;
    for(int i=4;i<=m;i++){
	for(int j=1;j<=d;j++){
	    int d1 = j%10;
	    int dt = j/10;
	    if(d1 >= 2 && dt >=2 && i == d1*dt ){
	//	cout<<d1<<' '<<dt<<' '<<m<<endl;
		cnt++;
	    }
	}
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
def biggest_cup(s,v):
    try:
        return s.index(v)
    except ValueError:
        return 127

def neighbors(s):
    a = biggest_cup(s,0)
    b = biggest_cup(s,1)
    c = biggest_cup(s,2)
    if b > a:
        t = list(s)
        t[a] = 1
        yield tuple(t)
    elif b < a:
        t = list(s)
        t[b] = 0
        yield tuple(t)
    if c > b:
        t = list(s)
        t[b] = 2
        yield tuple(t)
    elif c < b:
        t = list(s)
        t[c] = 1
        yield tuple(t)


def solve_bfs(s0, m):
    n = len(s0)
    visited = {s0}
    q = [s0]
    for i in range(m+1):
        nq = []
        for s in q:
            if all(v == 0 for v in s) or all(v == 2 for v in s):
                return i
            for t in neighbors(s):
                if t not in visited:
                    visited.add(t)
                    nq.append(t)
        q = nq
    return -1


def solve_optimized(s0, m):
    qq = []
    q = [s0]
    for i in range(m+1):
        nq = []
        for s in q:
            if all(v == 0 for v in s) or all(v == 2 for v in s):
                return i
            for t in neighbors(s):
                if t not in qq:
                    nq.append(t)
        qq,q = q,nq
    return -1

if __name__ == '__main__':
    while True:
        n,m = map(int,input().split())
        if n == m == 0:
            break
        s = [None]*n
        for i in map(int,input().split()[1:]):
            s[-i] = 0
        for i in map(int,input().split()[1:]):
            s[-i] = 1
        for i in map(int,input().split()[1:]):
            s[-i] = 2
        print(solve_optimized(tuple(s), m))


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int N, B, R;
  cin >> N >> B >> R;
 
  if( B == 0) {
    cout << 0 << endl;
  }
  else {
    long long int n = N / (B+R);
    long long int m = N % (B+R);
    long long int num = n * B + min(m , B);
    cout << num << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
#define mp make_pair
using namespace std;
const int N = 3e5 + 5;
const int INF = 1e9;

int n;
string s;

int ans = INF;

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

   int i;
   int e, w;

   cin >> n;
   cin >> s;

   e = w = 0;
   for(i = 0; i < n; i++)
   {
       if(s[i] == 'E')
        e++;
   }

   for(i = 0; i < n; i++)
   {
       if(s[i] == 'E')
         e--;

       ans = min(ans, e + w);

       if(s[i] == 'W')
        w++;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int a = in(), b = in();
    if (b * 2 > a){
        print(0);
    }
    else{
        print(a - b * 2);
    }
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    var s = readLine()!!

    var prev = '-'
    var greater = 0
    var smaller = 0

    val ss = mutableListOf<Int>()

    s.forEach {
        if (it == '<') {
            if (prev == '-' || prev== '<') {
                greater++
            } else {
                ss.add(smaller)
                greater++
                smaller = 0
            }
            prev = '<'
        } else {
            if (prev == '-' || prev== '>') {
                smaller--
            } else {
                ss.add(greater)
                smaller--
                greater = 0
            }
            prev = '>'
        }
    }

    if (greater > 0) {
        ss.add(greater)
    }
    if (smaller < 0) {
        ss.add(smaller)
    }

    var ans = 0L
    var last = 0
    for (i in ss.indices) {
        if (ss[i] > 0) {   // '<'
            if (i == ss.size-1) {
                repeat(ss[i]) {
                    ans += it+1
                }
                break
            }

            repeat(ss[i]-1) {
                ans += (it+1)
            }
            last = ss[i]-1

        } else {    // '>'
            if (last < -ss[i]) {
                repeat(-ss[i]) {
                    ans += (it+1)
                }
            } else {
                ans += last+1
                repeat(-ss[i]-1) {
                    ans += (it+1)
                }
            }
        }
    }

    println(ans)
}

Measured memory_bytes: 38992
/*
    A story which will never end
    A story which never began
*/

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long

int main(){
    IOS;
    int n;
    cin>>n;
    int x[n], y[n], h[n];
    int id = -1;
    for(int i=0;i<n;++i){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i] != 0)id = i;
    }
    int mx = -1, my = -1, mmh = -1;
    for(int i=0;i<=100;++i)
        for(int j=0;j<=100;++j){
            int mh = abs(i - x[id]) + abs(j - y[id]) + h[id];
            bool check = true;

            for(int k=0;k<n;++k)
                if(h[k] != max(0, mh - abs(i - x[k]) - abs(j - y[k]) ) )
                    check = false;


            if(check && mh >= 1){
                mx = i, my = j, mmh = mh;
            }
        }
    cout<<mx<<" "<<my<<" "<<mmh<<endl;
    return 0;
}


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

int main(){
  ll n,a,c;
  cin >> n;
  ll b[n];
  for(c=0;c<n;c++){
    cin >> a;
    b[a-1]=c+1;
  }
  for(c=0;c<n;c++){
    cout << b[c]<< " ";
  }
}

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

int top = 0, st[2005];

void push(int val) {
  st[++top] = val;
}

int pop() {
  top--;
  return st[top + 1];
}

int main() {
  int a, b;
  char s[105];
  while (scanf("%s", s) != EOF) {
    if (s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if (s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n", pop());
  return 0;
}



Measured memory_bytes: 2128
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b

tmp = 0
for i in range(n):
  for j in range(i+1, n):
    k = j + j - i
    if k < n:
      if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
        tmp+=1

print(ans-tmp)
      

Measured memory_bytes: 9168
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll X, Y;
    cin >> X >> Y;
    if(X % Y == 0){
        output(-1);
    }
    else{
        output(X);
    }
    
    return 0;
}


Measured memory_bytes: 256
#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()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a, b, c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b << "\n";

}


Measured memory_bytes: 256
#include <cstdio>

int timeTable[24*60];

int main(){
  int h, m, isFirst;

  for (int i = 0; i < 2; ++i) {
    int j;
    scanf("%d", &j);
    for (; j > 0; --j) {
      scanf("%d %d",&h, &m);
      timeTable[h*60 + m] = 1;
    }
  }

  isFirst = 1;
  for (h = 0; h < 24; ++h){
    for (m = 0; m < 60; ++m)      {
      if ( timeTable[h*60 + m] ){
        if ( !isFirst ) printf(" ");
        else isFirst = 0;
        printf("%d:%02d", h, m);
      }
    }
  }
  printf("\n");

  return 0;
}




Measured memory_bytes: 2732
n,k = gets.split.map(&:to_i)
h = n.times.map{gets.to_i}.sort

ans = 10**10
q = []
(k-1).times{|i| q << h[i]}
(k-1).upto(n-1){|i|
  q << h[i]
  tmp = q[-1]-q[0]
  q.shift
  ans = tmp if ans > tmp
}

p ans


Measured memory_bytes: 5104
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    char c;
    scan(c);
    auto s = "aeiou";
    foreach(cc;s)
    {
        if (c == cc)
        {
            writeln("vowel");
            return;
        }
    }
    writeln("consonant");
}


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


int main(){
	    int N, R; cin >> N >> R;
        if(N >= 10){
            cout << R << endl;
        }
        else{
            cout << R + 100 * (10 - N) << endl;
        }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if((a1+a2+a3) >= 22)puts("bust");
    else puts("win");

//    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;
typedef complex<double> P;
P ps[55];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    double x, y;
    scanf("%lf%lf", &x, &y);
    ps[i] = P(x, y);
  }
  P o(0, 0);
  double ans = 1e9;
  REP(t, 1000000) {
    // cerr << o.real() << " " << o.imag() << endl;
    double r = 0;
    int idx = -1;
    REP(i, n) {
      double d = abs(ps[i] - o);
      if(d > r) {
        r = d;
        idx = i;
      }
    }
    ans = min(ans, r);
    o += (ps[idx] - o) / double(1+t);
  }
  printf("%.10f\n", ans);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(30);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  k--;
  using D = long double;
  const D PI = acos(-1.0);
  vector<D> ss(n+1);
  for(Int i=0;i<=n;i++)
    ss[i]=sin((D)i/n*PI);

  auto check=
    [&](D x)->Int{
      auto calc=[&](Int a,Int b)->D{return ss[a+b]*ss[a]*ss[b];};
      Int cnt=0;
      // seisankaku (a = b = c)
      if(n%3==0){
        Int e=n/3;
        if(calc(e,e)<=x) cnt+=e;
      }
      // nitouhen (a = b)
      for(Int a=1;a*2<n;a++){
        if(a+a+a==n) continue;
        Int b=a;
        if(calc(a,b)<=x) cnt+=n; 
      }
      // sonota (a < b, a < c, b != c)
      for(Int a=1;a*3<n;a++){
        // a < b
        Int bl=a+1;
        // a < c = n - (a + b)
        Int br=n-2*a-1;
        if(bl>br) continue;
        if(calc(a,bl)>x) continue;
        
        Int bt=(bl+br)>>1;
        // [bl, br]
        if(calc(a,bt)<=x){
          cnt+=(br-bl+1)*n;
          if((bl+br)%2==0) cnt-=n;
          continue;
        }

        // [bl, bt)
        {
          Int l=bl,r=bt;
          while(l+1<r){
            Int m=(l+r)>>1;
            if(calc(a,m)<=x) l=m;
            else r=m;
          }
          cnt+=(l-bl+1)*n;
        }
        // (bt, br]
        {
          Int l=bt,r=br;
          while(l+1<r){
            Int m=(l+r)>>1;
            if(calc(a,m)<=x) r=m;
            else l=m;
          }
          cnt+=(br-r+1)*n;
        }
      }
      return cnt>=k;
    };
  
  D L=0,R=1;
  for(Int k=0;k<50;k++){
    D M=(L+R)/2;
    if(check(M)) R=M;
    else L=M;
  }
  cout<<R*2<<endl;
  return 0;
}


Measured memory_bytes: 1152
MOD = (10 ** 9) + 7
ONE = '1'.freeze

def nCr(n, k)
	(fact(k+1, n) * inv(fact(1, n-k) % MOD)) % MOD
end

def fact(s, e)
	(s..e).reduce(1) { |r, i| (r * i) % MOD }
end

def inv(x)
	g = 1
	beki = x
	(MOD - 2).to_s(2).reverse.chars do |digest|
		g = (beki * g)%MOD if digest == ONE
		beki = (beki * beki)%MOD
	end
	g
end

x, y = gets.chomp.split.map(&:to_i)

min, max = [x, y].sort

# min,maxのdiff回多く片方の遷移をしている。
diff = max - min
d_min = min - diff
d_max = max - 2 * diff
if !(d_min >= 0 && d_min == d_max && d_min % 3 == 0)
	puts 0
else
	a = b = d_min / 3
	a += diff
	puts nCr(a + b, b)
end



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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i] -= (i + 1);
    }

    sort(all(A));

    ll mid = 0, res = 0;
    if (N % 2 == 0)
        mid = (A[N / 2] + A[N / 2 - 1]) / 2;
    else
        mid = A[N / 2];

    rep(i, N) { res += abs(A[i] - mid); }

    cout << res << endl;
}

Measured memory_bytes: 1792
while True:
    m,f,r = [int(x) for x in input().split()]
    if (m,f,r)==(-1,-1,-1): break
    s_mf = m + f
    if   m < 0 or f < 0: print('F')
    elif s_mf <  30:     print('F')
    elif s_mf >= 80:     print('A')
    elif s_mf >= 65:     print('B')
    elif s_mf >= 50:     print('C')
    elif r    >= 50:     print('C')
    else:                print('D')

Measured memory_bytes: 7736
#include<bits/stdc++.h>
#include<tuple>
using namespace std;
#define P pair<int,int>
#define MOD 1000000007
int main(){
  int h,w;
  char a[1001][1001];
  int dp[1001][1001] = {};
  queue<P> q;
  cin >> h >> w;
  for(int x=1;x<=h;x++){
    for(int y=1;y<=w;y++){
      cin >> a[x][y];
    }
  }
  q.push(P(1,1));
  dp[1][1] = 1;
  while(!q.empty()){
    int x,y;
    tie(x,y) = q.front();
    q.pop();
    if(a[x][y] == '#') continue;
    a[x][y] = '#';
    dp[x][y] = (((dp[x][y] + dp[x-1][y]) % MOD) + dp[x][y-1]) % MOD;
    if(x+1 <=h) q.push(P(x+1,y));
    if(y+1 <=w) q.push(P(x,y+1));
  }
  cout << dp[h][w] << endl;
}

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

int h,heap[500001];

void maxheap(int i){
  int l,r,lage;
  
  l=i*2;
  r=i*2+1;
  lage=i;
  
  if(l<=h&&heap[l]>heap[lage]) lage=l;
  if(r<=h&&heap[r]>heap[lage]) lage=r;
  
  if(lage!=i){
    swap(heap[i],heap[lage]);
    maxheap(lage);
  }
  
}

int main(){
  scanf("%d",&h);
  for(int i=1;i<=h;i++) scanf("%d",&heap[i]);
  
  for(int i=h/2;i>=1;--i) maxheap(i);
  for(int i=1;i<=h;++i)printf(" %d",heap[i]);
  printf("\n");
  
  return (0);
}



Measured memory_bytes: 5044
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <queue>

#define ll long long

using namespace std;

int main(){
    int N;  cin >> N;
    string S;   cin >> S;
    
    int cnt=0;
    
    for(int i=N-1; i>=0; i--){
        if(S[i] == ')'){
            cnt++;
        }else{
            if(cnt > 0){
                cnt--;
            }else{
                S += ')';
            }
        }
    }

    cout << string(cnt, '(')+S << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> cnt(20, vector<int>(20, 0));
    vector<int> num2(n), num5(n);
    rep(i,n)
    {
        string s;
        string t = "";
        cin >> s;
        for(int j = 0; j < s.size(); j++)
        {
            if(s[j] == '.')
            {
                t = s.substr(j+1);
                s.erase(s.begin()+j, s.end());
                break;
            }
        }
        //cout << s << " " << t << endl;
        ll a = 0;
        rep(j,t.size())
        {
            a *= 10;
            a += t[j] - '0';
        }
        rep(j,9-t.size()) a *= 10;
        
        ll b = 0;
        rep(j,s.size())
        {
            b *= 10;
            b += s[j] - '0';
        }
        ll c = b * 1000000000 + a;

        //cout << c << endl;

        int cnt2 = 0, cnt5 = 0;
        while(c%2 == 0)
        {
            cnt2++;
            c /= 2;
        }
        while(c%5 == 0)
        {
            cnt5++;
            c /= 5;
        }
        cnt2 = min(18, cnt2);
        cnt5 = min(18, cnt5);
        cnt[cnt2][cnt5]++;
        //cout << cnt2 << " " << cnt5 << endl;
        
        num2[i] = 18 - cnt2;
        num5[i] = 18 - cnt5;
    }
    
    ll ans = 0;
    //cout << " "; rep(i,19) cout << i << " "; cout << endl;
    //rep(i,19) { cout << i << " "; rep(j,19) cout << cnt[i][j] << " "; cout << endl;}
    rep(i,n)
    {
        for(int j = num2[i]; j < 19; j++)
        {
            for(int k = num5[i]; k < 19; k++)
            {
                ans += cnt[j][k];
            }
        }
        if(num2[i] <= 9 && num5[i] <= 9) ans--;
    }
    cout << ans / 2 << endl;

    return 0;
}

Measured memory_bytes: 4836
import queue
h, w = map(int,input().split())
way = ["" for i in range(h+1)]
way[h] = "#"*(w+1)
for i in range(h):
    way[i] = str(input())+"#"
G = [[[] for j in range(w)] for i in range(h)]
road = []
for i in range(h):
    for j in range(w):
        if way[i][j] == "#":
            continue
        else:
            road.append([i,j])
        if way[i+1][j] == ".":
            G[i][j].append([i+1,j])
        if way[i-1][j] == ".":
            G[i][j].append([i-1,j])
        if way[i][j+1] == ".":
            G[i][j].append([i,j+1])
        if way[i][j-1] == ".":
            G[i][j].append([i,j-1])
M = 0

for i in road:
    q = queue.Queue()
    q.put(i)
    t = [[-1 for k in range(w+1)] for j in range(h+1)]
    t[i[0]][i[1]] = 0
    while not q.empty():
        j = q.get()
        for l in G[j[0]][j[1]]:
            if t[l[0]][l[1]] == -1:
                t[l[0]][l[1]] = t[j[0]][j[1]] + 1
                q.put(l)
    for k in t:
        if M < max(k):
            M = max(k)

print(M)


Measured memory_bytes: 4080
n,d = gets.chomp.split(" ").map(&:to_i)
x_arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}

count = 0
(0..(x_arr.length-2)).each do |i|
  y = x_arr[i]
  ((i+1)..(x_arr.length-1)).each do |j|
    dist = 0
    z = x_arr[j]
    y.each_with_index do |y_i, ind|
      z_i = z[ind]
      dist += (y_i - z_i) ** 2
    end
    dist = Math.sqrt(dist)
    count += 1 if dist == dist.to_i
  end
end
puts count


Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct ind{
	string s;
	int p;
	bool operator<(const ind &right) const{
		return right.s != s ? right.s > s :right.p > p;
	}

};
int main() {
	vector<ind> book;
	string s;
	int n;
	while (cin >> s >> n)
		book.push_back({ s, n });
	SORT(book);
	s = "";
	REP(i, book.size()){
		if (book[i].s != s){
			if (i != 0)cout << endl;
			cout << book[i].s << endl;
			cout << book[i].p;
		}
		else{
			cout << ' ' << book[i].p;
		}
		s = book[i].s;
	}
	cout << endl;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
 
const int inf = 1e9;
 
int n,m,g[705][705],col[705],vis[705],num[705][705],bk,f[705][705];
 
void dfs(int x){
	vis[x] = 1;++ num[col[x]][bk];
	for(int i=1;i<=n;i++)
		if(i!=x && !g[x][i]){
			if(!vis[i])col[i] = col[x] ^ 1, dfs(i);
			else if(col[i] == col[x]){ puts("-1"); exit(0); }
		}
}
int c(int x,int y){return (x*(x-1) + y*(y-1)) / 2;}
 
int main(){
	nfs_mw;
	cin>>n>>m;
	
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		g[x][y] = g[y][x] = 1;
	}
	
	for(int i=1;i<=n;i++)
		if(!vis[i])++bk, dfs(i);
	
	f[0][0] = 1;
	for(int i=0;i<bk;i++) for(int j=0;j<=n;j++)
		f[i+1][j+num[0][i+1]] |= f[i][j],
		f[i+1][j+num[1][i+1]] |= f[i][j];
	
	int ans = 700*700*700;
	for(int i=n; i>=0; i--) if(f[bk][i]) ans = min(ans,c(i,n-i));
	printf("%d\n",ans);
 
	return 0;
}

Measured memory_bytes: 6016
<?php
  $price = trim(fgets(STDIN));
  for($i = 0; $i < 25; $i++){
  for($j= 0; $j < 25; $j++){
    if($i * 4 + $j * 7 == $price){
      echo "Yes";exit;
    }
  }
  }
echo "No";

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

int main()
{
  int a, b, c, d;
  int count_t, count_a;
  string ans;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  count_t = 0;
  while(a > 0)
  {
    a -= d;
    count_t++;
  }
  count_a = 0;
  while(c > 0)
  {
    c -= b;
    count_a++;
  }
  ans ="Yes";
  if(count_t < count_a) ans ="No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, cnt;
	cin>>n;
	string s1, s2, s3;
	cin>>s1>>s2>>s3;
	cnt = 0;
	for(char c = 'a'; c <= 'z'; ++c){
		for(int i = 0; i < n; ++i){
			if(s1[i] == c && s2[i] == c && s3[i] != c){
				cnt++;
				s3[i] = c;
			}
			else if(s1[i] == c && s3[i] == c && s2[i] != c){
				cnt++;
				s2[i] = c;

			}
			else if(s1[i] != c && s2[i] == c && s3[i] == c){
				cnt++;
				s1[i] = c;
			}
			else if(s1[i] != s2[i] && s2[i] != s3[i] && s3[i] != s1[i]){
				cnt += 2;
				s1[i] = s2[i] = s3[i];
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}


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

using namespace std;

int main(void)
{
  int numbers_count;
  vector<int> limit_values;
  
  cin >> numbers_count;
  
  for(int i = 0; i < numbers_count - 1; i++){
    int lv;
    cin >> lv;
    limit_values.push_back(lv);
  }
  
  int sum = limit_values[0];
  for(int i = 1; i < numbers_count - 1; i++){
    sum += min(limit_values[i - 1], limit_values[i]);
  }
  sum += limit_values.back();
  
  cout << sum << endl;
  
  return 0;
}

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

long long N, M, L, K[100009], S[100009], T[100009];
long long dp[2009][2009];

long long scores(long long a, long long b) {
	return (T[b] - T[a - 1]) / L;
}

int main() {
	cin >> N >> M >> L;
	for (int i = 1; i <= N; i++) cin >> K[i];
	for (int i = 1; i <= M; i++) cin >> S[i];
	for (int i = 1; i <= M; i++) T[i] = T[i - 1] + S[i];

	for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) dp[i][j] = (1LL << 60); }
	sort(K + 1, K + N + 1);

	dp[1][1] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (dp[i][j] == (1LL << 60)) continue;
			// i : この前のやつ, j : もう一方のやつ
			
			if (i == N - 1) {
				dp[N][N] = min(dp[N][N], dp[i][j] + scores(K[i], K[N]) + scores(K[j], K[N]));
			}
			else {
				dp[i + 1][i] = min(dp[i + 1][i], dp[i][j] + scores(K[j], K[i + 1]));
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + scores(K[i], K[i + 1]));
			}
		}
	}
	cout << dp[N][N] << endl;
	return 0;
}


Measured memory_bytes: 36140
/*input
4
ushi
tapu
nichia
kun



*/

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

int main() { 
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	map<string, int> mp;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	int mf = 0;
	for(auto i : mp) {
		mf = max(mf, i.second);
	}
	vector<string> v;
	for(auto i : mp) {
		if(i.second == mf) {
			v.push_back(i.first);
		}
	}
	sort(v.begin(), v.end());
	for(auto i : v) cout << i << '\n';

	return 0; 
} 

Measured memory_bytes: 26096
#include <iostream>

int main(){
    int Chocolate;
    int N,D,X;
    std::cin >> N >> D >> X;
    int array[N];
    int i=0, j=0;
    for(i=0;i<N; i++){std::cin >> array[i];}

    for(i=0;i<N; i++) {
        Chocolate = 0;
        for(j=1;j<D+1; j=j+array[i]) {
            Chocolate++; 
        }
        X += Chocolate;
    }
    std::cout << X << std::endl;  
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

int n;
ll a[200200], p[200200];
ll ans = (ll)1e15, sum;

int main() {
	
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
		p[i] = p[i-1] + a[i];
	}


	for(int i = 1; i < n; i++) {
		ans = min(ans, abs(p[i] - (sum - p[i])));
	}


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3328
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll R;
    cin>>R;
    if(R < 1200)cout<<"ABC"<<endl;
    else if(R < 2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007 
using namespace std;
vector<int> v[100001];
int ar[100001];

void solve()
{
    int n;
    cin >> n;
    if(n>=30)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

}

int main()
{
  int t=1;
  //cin >> t;
  for(int i=0 ; i<100001 ; i++) ar[i]=0;
  while(t--)
    solve();
    return 0 ;
}
  

Measured memory_bytes: 6364
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

void test() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 3644
function Main(input){
    var nums = input.split(' ').map((n) => parseInt(n, 10));
    var N = nums[0];
    var A = nums[1];
    var B = nums[2];
    var sum = 0;
    for (var i=1; i<=N; i++){
        var test = i.toString().split('');
        var total = test.map((str)=>parseInt(str,10)).reduce((a,b)=>(a+b));
        if (total >=A && total <= B){
          sum += i;
        }
    }
    console.log(sum);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 13020
H,W=map(int,input().split())
a=[]
mod=10**9+7

for i in range(H):
    temp=list(map(str,input()))
    a.append(temp)

dp=[[0]*(W) for _ in range(H)]
dp[0][0]=1

for h in range(H):
    for w in range(W):
        if h==w==0:continue
        if a[h][w]=="#":continue
        if h-1<0:
            dp[h][w]=dp[h][w-1]%mod
        elif w-1<0:
            dp[h][w] = dp[h-1][w]%mod
        else:
            dp[h][w] = (dp[h][w -1] + dp[h -1][w])%mod

ans=dp[H-1][W-1]%mod
print(ans)

Measured memory_bytes: 50888
x, n = map(int, input().split())
p = list(map(int, input().split()))
diff = 101 - x
ans = 101
for i in range(-1, 101):
    if i in p:
        continue
    if abs(i - x) < diff:
        diff = abs(i - x)
        ans = i
    elif abs(i - x) == diff:
        ans = min(ans, i)
print(ans)

Measured memory_bytes: 9192
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a: Vec<i32> = (0..n).map(|_| input()).collect();
    a.sort_by_key(|&a| a.abs());

    let mut sum: i64 = a.iter().map(|&a| a.abs() as i64).sum();
    let neg: usize = a.iter().filter(|&&a| a < 0).count();
    if neg & 1 == 1 {
        sum -= 2 * a[0].abs() as i64;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll a,b,c; cin >> a >> b >> c;
    ll mx = max({a,b,c});
    ll sum = a + b + c;
    if((mx*3-sum) % 2 == 0) cout << (mx*3-sum) / 2 << endl;
    else cout << (mx*3-sum+3) / 2 << endl;
}

Measured memory_bytes: 256