akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	var cards [4][13]bool // S, H, C, D
	m := map[string]int{
		"S": 0,
		"H": 1,
		"C": 2,
		"D": 3,
	}
	revm := []string{"S", "H", "C", "D"}

	var n int
	fmt.Scan(&n)

	var s string
	var x int
	for i := 0; i < n; i++ {
		fmt.Scan(&s, &x)
		cards[m[s]][x-1] = true
	}
	for i := 0; i < 4; i++ {
		for j := 0; j < 13; j++ {
			if !cards[i][j] {
				fmt.Printf("%s %d\n", revm[i], j+1)
			}
		}
	}
}



Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	string str;
	int ans = 0;
	cin >> str;

	for (int i = 0; i < 4; i++)
	{
		if ( str[i] == '+' )
		{
			ans++;
		}
		else
		{
			ans--;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  int K,N;  
  cin>>N>>K;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=p[i];
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
int main(void){
   float N,T,A,Pla,mi,num;
   
   mi=100000000;
   cin>>N>>T>>A;
   vector <int> H(N);
  vector <float> Dif(N);
   
   for(int i=0;i<N;i++){
       cin>>H[i];
      num=A-(T-H[i]*0.006);
       Dif[i]=fabs(num);
       mi=min(mi,Dif[i]);
       }
       
       
   for(int j=0;j<N;j++){
   if(Dif[j]==mi)Pla=j+1;
   }
    cout<<Pla<<endl;
}


Measured memory_bytes: 256
class Bit
  def initialize(n)
    @bit = Array.new(n + 1, 0)
    @n = n
  end

  # 0-origin
  def add(i, x)
    i += 1
    while i <= @n
      @bit[i] += x
      i += i & -i
    end
  end

  # 0-origin
  def sum(i)
    i += 1
    s = 0
    while i > 0
      s += @bit[i]
      i -= i & -i
    end
    s
  end
end

N, D, A = gets.split.map(&:to_i)
XH = N.times.map { gets.split.map(&:to_i) }

sorted = XH.sort_by { |x, _| x }
bit = Bit.new(N)
ans = 0
N.times do |i|
  x, h = sorted[i]
  sum = bit.sum(i) * A
  rest = h - sum
  next if rest <= 0
  count = (rest + A - 1) / A
  bit.add(i, count)
  j = sorted.bsearch_index do |y, _|
    y > x + 2 * D 
  end
  bit.add(j, -count) if j
  ans += count
end
puts ans

Measured memory_bytes: 22520
#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(){
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  int ans = 0;
  if(x1==0) ans = 1;
  if(x2==0) ans = 2;
  if(x3==0) ans = 3;
  if(x4==0) ans = 4;
  if(x5==0) ans = 5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include <numeric>
// #include<string>
#include<vector>
#include <algorithm>
#include <cmath>
// #include <functional>

using namespace std;

int main()
{
    // Input
    unsigned int long long n;
    cin >> n;

    unsigned int long long sum = 0;

    for (unsigned int long long i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 3192
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<vector<int>> vvi;           // intの2次元vector
typedef vector<vector<double>> vvd;        // doubleの2次元vector
typedef vector<vector<ll>> vvll;           // llの2次元vector
typedef vector<vector<ld>> vvld;           // ldの2次元vector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* upper, lower */
struct ToUpper
{
    char operator()(char c)
    {
        return toupper(c);
    }
};
struct ToLower
{
    char operator()(char c)
    {
        return tolower(c);
    }
};

/* main */
void Main(void)
{
    string s, p;
    cin >> s >> p;
    for (int i = 0; i < s.size(); i++)
    {
        string tmp = "";
        for (int j = 0; j < p.size(); j++)
        {
            tmp += s[(i + j) % s.size()];
        }
        if (p == tmp)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3212
#include <stdio.h>
int search(int key,int S[],int n)
{
	int low=0,high=n,mid;
	while(low<=high)
	{
		mid=(low+high)/2;
		if(S[mid]==key)	
		return 1;
		else if(S[mid]<key)
		low=mid+1;
		else
		high=mid-1;
	}
	return 0;
}
int main(int argc, char *argv[])
{
	int S[100000],n,k,q,i,count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&S[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&k);
		if(search(k,S,n))
		count++; 
	}
	printf("%d\n",count);
	return 0;
}




Measured memory_bytes: 2244
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = rl()

X = 0
m = 1
for i in range(N):
	X += m*A[i]
	m *= -1

B = [0] * N
B[0] = X//2
for i in range(1, N):
	B[i] = A[i-1]-B[i-1]

print(*[b*2 for b in B])

Measured memory_bytes: 101736
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n,i,x=0,y=0;
    string X,Y;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>X>>Y;
        if(X==Y){
            x=x+1;
            y=y+1;
        }else if(X>Y){
            x=x+3;
        }else{
            y=y+3;
        }
    }
    cout<<x<<" "<<y<<endl;
    return 0;
}

Measured memory_bytes: 3128
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 20 11:25:20 2019
ABC116C
@author: maezawa
"""

n = int(input())
h = list(map(int, input().split()))

h.append(0)
cnt = 0
finished = False
while True:
    #print(h, cnt)  
    i = 0
    while True:
        if not h:
            break
        elif h[i] == 0:
            h.pop(0)
        else:
            break
    if not h:
        break
    l = 0
    r = 0
    minh = 101
    while True:
        if h[r] == 0 and r != l and minh != 0:
            for i in range(l,r):
                h[i] -= minh
            cnt += minh
            #print(h, cnt, l, r)
            l = r+1
            if l > len(h):
                break
        elif h[r] < minh:
            minh = h[r]
        r += 1
        if r >= len(h):
            break
    if not h:
        break

print(cnt)

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

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  string result;
  if (c-(a+b) < 0) {
    result = "No";
  } else if (4*a*b < (c-(a+b))*(c-(a+b))) {
    result = "Yes";
  } else {
    result = "No";
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
static const int maxN = 86;

void Lucas(int N, vector<int64_t> &n){
  if(N == 0){
    n.at(0) = 2;
    return;
  } else if (N == 1){
    n.at(1) = 1;
    Lucas(0, n);
  } else {
    Lucas(N - 1, n);
    n.at(N) = n.at(N - 1) + n.at(N - 2);
  }
}

int main() {
  int N;
  cin >> N;
  vector<int64_t> n(N + 1);
  
  Lucas(N, n);
  cout << n.at(N) << endl;

}

Measured memory_bytes: 3608
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(vector<int>& A, int K) {
        sort(A.begin(), A.end());

        long long sum = 0;
        long long res = 0;
        for (auto x : A) {
            res = gcd(res, x);
        }

        long long N = 0;
        for (auto x : A) {
            N += x;
        }

        auto check = [&](int d) {
            long long cnt = 0;
            vector<int> X;
            for (auto x : A) {
                int r = x % d;
                X.push_back(r);
                cnt += r;
            }
            sort(X.begin(), X.end(),greater<int>());
            long long n = cnt / d;
            for (int i = 0; i < n; ++i) {
                cnt -= X[i];
            }
            return cnt <= K; 
        };
        
        for (long long i = 1; i * 1LL * i <= N; ++i) {
            if (N % i == 0) {
                if (check(i)) {
                    res = max(res, i);
                }
                if (check(N / i)) {
                    res = max(res, N / i);
                }
            }
        }
        return res;
    }

private:
    long long gcd(long long a, long long b) {
        while (a != 0) {
            b %= a;
            swap(a, b);
        }
        return b;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    Solution sol;
    cout << sol.solve(A, k) << "\n";

    return 0;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a-b==b-c){
    cout<<"YES"<<endl;
    return 0;
    }
    cout<<"NO"<<endl;
    return 0;
}

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

using namespace std;

#define MOD 1000000007
#define N 50
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

ll a[N], b[N], c[N];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin>>n;
	int i, j, k;
	for(i=1; i<=n; i++){
		cin>>a[i];
	}
	for(i=1; i<=n; i++){
		cin>>b[i];
	}
	for(i=1; i<n; i++){
		cin>>c[i];
	}
	int ans = 0;
	for(i=1; i<=n; i++){
		ans = ans + b[a[i]];
		if(a[i] == a[i-1] + 1){
			ans = ans + c[a[i-1]];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	string s;
	int x,y;
}a[110];
bool cmp(const node&s1,const node&s2){
	if(s1.s==s2.s) return s1.x>s2.x;
	return s1.s<s2.s;
}
int main(){
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++){
		cin>>a[i].s>>a[i].x;
		a[i].y=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		cout<<a[i].y<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define sz(a) ((int)(a).size())
#define pii pair<int,int>
#define R(a) scanf("%d",&a)
#define per(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);i++)
#define rix(i,x) for(int i=last[x];i;i=pre[i])
const double eps=1e-8;
int sgn(double x){return x<-eps?-1:x>eps;}
int Mn(int&a,int b){if(a>b){a=b;return 1;}return 0;}
int Mx(int&a,int b){if(a<b){a=b;return 1;}return 0;}
ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
ll inv(ll a,ll b){return a==1?1:(1-b*inv(b%a,a))/a;}
ll exg(ll a,ll b,int&x,int&y){!a?x=0,y=1:(exg(b%a,a,y,x),x-=b/a*y);}
ll pow(ll a,ll b,ll M) {ll t=1;for(a%=M;b;b>>=1){if(b&1)t=t*a%M;a=a*a%M;}return t;}
const int N=805;
char a[N][N];
int n,m,k,dx[4]={0,0,1,-1},dy[4]={1,-1,0,0},ans=1e9,f[N][N];
pii q[N*N];
int dfs(int x,int y){
q[1].ft=x;q[1].sd=y;
for(int l=1,r=1;l<=r;l++){
	int x=q[l].ft,y=q[l].sd;
	if(x==1||y==1||x==n||y==m){
		ans=1;return 0;
	}
	a[x][y]='#';
	Mn(ans,1+(x-2)/k+1);
	Mn(ans,1+(y-2)/k+1);
	Mn(ans,1+(n-x-1)/k+1);
	Mn(ans,1+(m-y-1)/k+1);
	if(f[x][y]==k)continue;
	rep(i,0,3){
		int px=x+dx[i],py=y+dy[i];
		if(a[px][py]=='.'&&Mn(f[px][py],f[x][y]+1))q[++r].ft=px,q[r].sd=py;
	}
}
}
int main()
{
	cin>>n>>m>>k;
	rep(i,1,n)scanf("%s",&a[i][1]);
	memset(f,0x3f,sizeof(f));
	rep(i,1,n)rep(j,1,m)if(a[i][j]=='S')f[i][j]=0,dfs(i,j);
	cout<<ans<<endl;
}




























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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"

int main() {
  int q;
  cin >> q;

  list<int> l;
  auto itr = l.end();

  rep0(i, q) {
    int query; cin >> query;
    if (query == 0) {
      int x; cin >> x;
      itr = l.insert(itr, x);

    } else if (query == 1) {
      int d; cin >> d;
      if (d > 0) rep0(i, d) itr++;
      else rep0(i, -d) itr--;

    } else {
      itr = l.erase(itr);
    }
  }

  for(auto itr2 = l.begin(); itr2 != l.end(); itr2++) {
    cout << *itr2 << BR;
  }

  return 0;
}


Measured memory_bytes: 18548
#include <iostream>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int distance(int x1, int y1, int x2, int y2)
{
  return abs(x1-x2) + abs(y1-y2);
}

bool goable(int x1, int y1, int x2, int y2, int t1, int t2) {
  int dx = distance(x1, y1, x2, y2);
  int dt = t2 - t1;

  return (dx <= dt) && (dx % 2 == dt % 2);
}

int main()
{
  int N; cin >> N;
  vector<int> t(N+1), x(N+1), y(N+1);
  t[0] = x[0] = y[0] = 0;

  rep(i,N)
    cin >> t[i+1] >> x[i+1] >> y[i+1];

  rep(i,N) {
    if(!goable(x[i], y[i], x[i+1], y[i+1], t[i], t[i+1])) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string s;
	int n;
	cin>>s>>n;
	int co=0;
	rep(i,n){
		string a;
		cin>>a;
		a+=a;
		if(a.find(s)!=string::npos)co++;
	}
	cout<<co<<endl;
}

Measured memory_bytes: 1212
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int x, y;
  cin >> x >> y;
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<int> d;
  rep(i, x) d.push_back(p[i]);
  rep(i, y) d.push_back(q[i]);
  rep(i, c) d.push_back(r[i]);
  sort(d.rbegin(), d.rend());
  ll ans = 0;
  rep(i, x + y) ans += d[i];
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll a[n-1];
    rep(i,0,n-2)cin>>a[i];
    ll ans=a[0]+a[n-2];
    rep(i,0,n-3)ans+=min(a[i],a[i+1]);
    cout<<ans<<endl;
    
    return 0;
}

/*

#define N 200005
ll n;
ll a[N];

ll ret[N][2];
void cal(){
    set<l_l>s;
    memset(ret,-1,sizeof(ret));
    rep(i,0,n-1){
        while(!s.empty()){
            l_l t=*s.begin();
            if(t.first<a[i]){
                ret[t.second][0]=i;
                s.erase(t);
            }
        }
        s.insert(l_l(a[i],i));
    }
    rep(i,0,n-1){
        
    }
}

int main(){fastio
    
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    ll dp[n][4];
    cal();
    rep(i,0,n-1)rep(j,0,1){
        dp[i][j]=ret[i][j];
    }
    reverse(a,a+n);
    cal();
    rep(i,0,n-1)rep(j,0,1){
        dp[i][j+2]=ret[i][j];
    }
    reverse(a,a+n);
    
    
    
    return 0;
}
 */













Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define INF (int)1e9
#define INFL (int)1e15
#define MAXN (int)1e6
#define err 1e-15
#define sz size
int getInt(char ch) {
    return (int)(ch - '0');
}
int cdiv(int num, int den) {
    return (num%den == 0) ? (num/den) : (num/den)+1;
}
using namespace std;

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

    int a, b;
    cin >> a >> b;

    int s = 0, e = 1;

    while(e < b) {
        s++;
        e--;
        e += a;
    }

    cout << s << endl;

    return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <functional>

int main(){
  int A, P;
  std::cin>>A>>P;
  int B = A * 3 + P ;
  int result = B / 2 ;
  std::cout<<result<<std::endl;
  return 0;
}


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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int> > v;
    for(int i = 1; i <= n; i++){
        string x;
        int p;
        cin >> x >> p;
        v.PB(MP(MP(x, p), i));
    }
    sort(ALL(v), [&](pair<pair<string, int>, int> p1, pair<pair<string, int>, int> p2){
        if(p1.F.F != p2.F.F){
            return p1.F.F < p2.F.F;
        }
        return p1.F.S > p2.F.S;
    });
    for(auto &x : v){
        cout << x.S << nl;
    }
    return 0;
}
/*
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
	int x, y;

	while (scanf("%d %d", &x, &y) != EOF || x != 0 && y != 0){

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

	return 0;
}

Measured memory_bytes: 600
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    ll n, a, b;cin >> n >> a >> b;
    vector<ll> x(n);
    for(auto &xx : x) cin >> xx;
    ll ans = 0;
    for(int i=0;i<n-1;i++){
        ans += min({b, a*(x[i+1]-x[i])});
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
using namespace std;
char a[8][105];
int main()
{
	scanf("%s",a[1]);
	scanf("%s",a[2]);
	scanf("%s",a[3]);
	printf("%c%c%c\n",a[1][0]-32,a[2][0]-32,a[3][0]-32);
	return 0;
}

Measured memory_bytes: 128
mod=998244353
N,K=map(int, input().split())
A=[list(map(int, input().split())) for _ in range(K)]

S=[0 for _ in range(N+1)]
S[1]=1
for i in range(1,N):
  S[i+1]=S[i]
  for l,r in A:
    S[i+1]+=S[max(0,i-l+1)]-S[max(0,i-r)]
  S[i+1]%=mod
print((S[N]-S[N-1])%mod)

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

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

	int count = 0;
	for (int i = 0;i<S.size();i++) {
		if (S[i] == 'o') {
			count++;
		}
	}
	if (S.size() <= 7 + count) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.util.Scanner;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s=sc.next();
		if (a<3200){
		    System.out.println("red");
		} else{
		    		    System.out.println(s);

		}
	}
}

Measured memory_bytes: 22740
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();

		boolean s[] = new boolean[100];

		for(int n=0;n<num;n++){
			s[n] = false;
		}
		int count = 0;
		for(int n=0;n<num;n++){
			int k = sc.nextInt();
			if(s[k-1] == false){
				s[k-1] = true;
				count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 22996
#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 argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> h(n); rep(i, n) cin >> h[i];

	int ans = 0;
	while (1) {
		if (*max_element(h.begin(), h.end()) == 0) break;
		int i = 0;
		while (i < n) {
			if (h[i] == 0) {
				i++;
			} else {
				ans++;
				while (i < n && h[i] != 0) {
					h[i]--;
					i++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	ll int x, k, d;
	cin >> x >> k >> d;
	ll int t = abs(x) / d;
	if(t >= k){
		cout << abs(x) - d * k << endl;
	}else{
		if(x < 0) x += t * d;
		else x -= t * d;
		k = k - t;
		ll int c = 0;
		if(x > 0) c = x - d;
		else c = x + d;
		if(k%2 == 1) cout << abs(c) << endl;
		else cout << abs(x) << endl;
	}
	// cout << ans << endl;
}

Measured memory_bytes: 3620
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int n; cin >> n;
    vector<ll> as(n), ds(n);
    ll suma = 0;
    ll sum = 1ll * n * (n + 1) / 2;
    for(int i=0;i<n;i++){
        cin >> as[i];
        suma += as[i];
    }
    if(suma % sum){
        cout << "NO" << '\n';
        return 0;
    }
    for(int i=0;i<n;i++){
        ds[i] = as[(i+1) % n] - as[i];
    }
    ll cnt = 0;
    prints(ds);
    for(int i=0;i<n;i++){
        if(ds[(n+i-1)%n] == ds[i]){ continue; }
        if(abs(ds[(n+i-1)%n] - ds[i]) % n){
            cout << "NO" << '\n';
            return 0;
        }
        cnt += abs(ds[(n+i-1)%n] - ds[i]) / n;
        ds[i] = ds[(n+i-1)%n] = max(ds[i], ds[(n+i-1)%n]);
        prints(ds);
    }
    if(suma < cnt * sum){
        cout << "NO" << '\n';
        return 0;
    }
    if((suma - cnt * sum) / n % sum){
        cout << "NO" << '\n';
        return 0;
    }
    cout << "YES" << '\n';
    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>

int main ()
{
	char a [4] [4];
	int i, j;

	for (i = 0; i < 3; i ++) {
		for (j = 0; j < 3; j ++) scanf (" %c", &a [i] [j]);
	}

	printf ("%c%c%c", a [0] [0], a [1] [1], a [2] [2]);

	return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 809;
const int M = N * N;
const int H = M << 3;
const int INF = 1e9;
const double EPS = 0.5;

char pat[N][N];
int n,m,K,S,dis[M],head[M],to[H],nxt[H],done[M]; 
priority_queue<pair<int,int> > que;

inline int read() {
	char c=getchar(); int f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

inline int id(int x, int y) {
	return (x - 1) * m + y;
}

inline void AddEdge(int u, int v) {
	static int E = 1;
	to[++E] = v; nxt[E] = head[u]; head[u] = E;
	to[++E] = u; nxt[E] = head[v]; head[v] = E;
}

inline void Dijkstra() {
	memset(dis, 60, sizeof(dis));
    dis[S] = 0; 
	que.push(make_pair(0, S));
    while (!que.empty()) {
        int w = que.top().second; que.pop();
        if (done[w]) continue; else done[w] = 1;
        for (int i=head[w];i;i=nxt[i]) {
            if (dis[to[i]] > dis[w] + 1) {
                dis[to[i]] = dis[w] + 1;
                que.push(make_pair(-dis[to[i]], to[i]));
            }
        }
    }
}

int main() {
	//freopen("11input.in","r",stdin);
	n = read(); m = read(); K = read();
	for (int i=1;i<=n;i++) {
		scanf("%s",pat[i]+1);
		for (int j=1;j<=m;j++) {
			if (pat[i][j] != '#') {
				if (i > 1 && pat[i-1][j] != '#') {
					AddEdge(id(i,j), id(i-1,j));
				}
				if (j > 1 && pat[i][j-1] != '#') {
					AddEdge(id(i,j), id(i,j-1));
				}
			} 
			if (pat[i][j] == 'S') {
				S = id(i, j);		
			}
		}
	} 
	Dijkstra();
	int ans = INF;
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			if (pat[i][j] != '#') {
				//cout<<"**"<<dis[id(i, j)]<<endl;
				if (dis[id(i,j)] <= K) {
					int tmp = EPS + 1.0 + ceil(min(min(i - 1, j - 1), min(n - i, m - j)) / (double)K);		
					ans = min(ans, tmp);
				}
			}
		}
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 29056
N = 3*10**5+1
MOD = 998244353

p = [1] * (N+1)
q = [1] * (N+1)

for i in range(1, N+1):
    p[i] = (p[i-1]*(i)%MOD)
q[0] = pow(p[-1], MOD-2, MOD)
for i in range(1, N+1):
    q[i] = (N-i+1)*q[i-1]%MOD
q.reverse()

n, a, b, k = map(int, input().split())

def nCk(n,k):
    if k > n or n == 0:
        return 0
    elif k == 0:
        return 1
    else:
        return p[n]*q[k]%MOD*q[n-k]%MOD

ans = 0
for i in range((k//a+1)):
    x = k-a*i
    if x%b == 0 and 0 <= x//b <= n:
        j = x//b
        ans += nCk(n, i) * nCk(n, j) % MOD
        ans %= MOD
print(ans)



Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const ll mod=1e9+7;
const int N=10005;

ll n,mod1,dp[N][105][2];
string str;

ll dpf(int i,int sum,bool flag){
	if(i==n){
		if(sum==0){
			return 1;
		}
		return 0;
	}
	if(dp[i][sum][flag]!=-1)return dp[i][sum][flag]%mod;

	ll ans=0;
	int sayi;
	if(flag)sayi=str[i]-'0';
	else sayi=9;

	for(int j=0;j<=sayi;j++){
		ans+=dpf(i+1,(sum+j+mod1)%mod1,sayi==j && flag);
		ans+=mod;
		ans%=mod;
	}
	dp[i][sum][flag]=(ans+mod)%mod;
	return dp[i][sum][flag];
}

int main(){
//	fri("in.txt");
//	fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>str>>mod1;
	n=str.length();
	memset(dp,-1,sizeof(dp));
	cout<<(dpf(0,0,1)-1+mod)%mod;

return 0;
}


Measured memory_bytes: 17408
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<iso646.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
int n;
cin >>n;
if(n<1000)
cout<<"ABC";
else 
cout<<"ABD";
return 0;
}

Measured memory_bytes: 256
//ΔAGC022E
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int mod = 1e9+7;
void add(int& x,int y){
	x+=y;
	if(x>=mod)
		x-=mod;
}
char ch[333333];
int a,a0,a00,a1,a10,a100,a11;
int b,b0,b00,b1,b10,b100,b11;
int main()
{
	int i;
	cin>>ch;
	//reverse(ch,ch+strlen(ch));
	a=1;
	for(i=0;ch[i];i=i+1){
		b=0;
		b0=0;
		b00=0;
		b1=0;
		b10=0;
		b100=0;
		b11=0;
		if(ch[i]!='1'){
			add(b0,a);
			add(b00,a0);
			add(b0,a00);
			add(b10,a1);
			add(b100,a10);
			add(b10,a100);
			add(b11,a11);
		}
		if(ch[i]!='0'){
			add(b1,a);
			add(b,a0);
			add(b0,a00);
			add(b11,a1);
			add(b1,a10);
			add(b10,a100);
			add(b11,a11);
		}
		a=b;
		a0=b0;
		a00=b00;
		a1=b1;
		a10=b10;
		a100=b100;
		a11=b11;
		//cout<<a<<a0<<a00<<a1<<a10<<a100<<a11<<endl;
	}
	add(a11,a1);
	cout<<a11;
	return 0;
}

Measured memory_bytes: 512
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
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; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string str;
    cin >> str;
    if (str[2] == str[3] && str[4] == str[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL a,b,c,d,i,j,k,m,n,t,x,y,z;
map<LL,LL>H;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for(cin>>t;t--;)
	{
		cin>>n>>a>>b>>c>>d;
		H[n]=0;
		for(;;)
		{
			x=H.rbegin()->first;
			y=H.rbegin()->second;
			//cout<<x<<' '<<y<<endl;
			if(x<2)
			{
				cout<<y+d<<endl;
				break;
			}
			if(x%2)
			{
				if(H[x/2])
				{
					if(x>2000000004)
					{
						H[x/2]=min(H[x/2],y+a+d);
					}
					else
					{
						H[x/2]=min(H[x/2],y+min(a+d,(x/2+1)*d));
					}
				}
				else
				{
					if(x>2000000004)
					{
						//cout<<"A"<<endl;
						H[x/2]=y+a+d;
					}
					else
					{
						//cout<<"B"<<endl;
						//cout<<a+d<<' '<<(x/2+1)*d<<endl;
						H[x/2]=y+min(a+d,(x/2+1)*d);
					}
				}
				if(H[x/2+1])
				{
					if(x>2000000004)
					{
						H[x/2+1]=min(H[x/2+1],y+a+d);
					}
					else
					{
						H[x/2+1]=min(H[x/2+1],y+min(a+d,x/2*d));
					}
				}
				else
				{
					if(x>2000000004)
					{
						//cout<<"C"<<endl;
						H[x/2+1]=y+a+d;
					}
					else
					{
						//cout<<"D"<<endl;
						//cout<<a+d<<' '<<x/2*d<<endl;
						H[x/2+1]=y+min(a+d,x/2*d);
					}
				}
			}
			else
			{
				if(H[x/2])
				{
					if(x>2000000004)
					{
						H[x/2]=min(H[x/2],y+a);
					}
					else
					{
						H[x/2]=min(H[x/2],y+min(a,x/2*d));
					}
				}
				else
				{
					if(x>2000000004)
					{
						H[x/2]=y+a;
					}
					else
					{
						H[x/2]=y+min(a,x/2*d);
					}
				}
			}
			if(x%3>1)
			{
				if(H[x/3+1])
				{
					if(x>1500000018)
					{
						H[x/3+1]=min(H[x/3+1],y+b+d);
					}
					else
					{
						H[x/3+1]=min(H[x/3+1],y+min(b+d,(x-x/3-1)*d));
					}
				}
				else
				{
					if(x>1500000018)
					{
						H[x/3+1]=y+b+d;
					}
					else
					{
						H[x/3+1]=y+min(b+d,(x-x/3-1)*d);
					}
				}
			}
			else
			{
				if(H[x/3])
				{
					if(x>1500000018)
					{
						H[x/3]=min(H[x/3],y+b+x%3*d);
					}
					else
					{
						H[x/3]=min(H[x/3],y+min(b+x%3*d,(x-x/3)*d));
					}
				}
				else
				{
					if(x>1500000018)
					{
						H[x/3]=y+b+x%3*d;
					}
					else
					{
						H[x/3]=y+min(b+x%3*d,(x-x/3)*d);
					}
				}
			}
			if(x%5>2)
			{
				if(H[x/5+1])
				{
					if(x>1250000040)
					{
						H[x/5+1]=min(H[x/5+1],y+c+(5-x%5)*d);
					}
					else
					{
						H[x/5+1]=min(H[x/5+1],y+min(c+(5-x%5)*d,(x-x/5-1)*d));
					}
				}
				else
				{
					if(x>1250000040)
					{
						H[x/5+1]=y+c+(5-x%5)*d;
					}
					else
					{
						H[x/5+1]=y+min(c+(5-x%5)*d,(x-x/5-1)*d);
					}
				}
			}
			else
			{
				if(H[x/5])
				{
					if(x>1250000040)
					{
						H[x/5]=min(H[x/5],y+c+x%5*d);
					}
					else
					{
						H[x/5]=min(H[x/5],y+min(c+x%5*d,(x-x/5)*d));
					}
				}
				else
				{
					if(x>1250000040)
					{
						H[x/5]=y+c+x%5*d;
					}
					else
					{
						H[x/5]=y+min(c+x%5*d,(x-x/5)*d);
					}
				}
			}
			H.erase(x);
		}
		H.clear();
	}
}

Measured memory_bytes: 3664
def piyo():
    _ = int(input())
    a, b = (int(_) for _ in input().split()) 
    p = list(int(i) for i in input().split())
    c1=0
    c2=0
    c3=0
    for i in p:
        if i<=a:
            c1+=1
        elif a<i and i<=b:
            c2+=1
        elif b<i:
            c3+=1
    ans=min(c1,c2,c3)
    print(ans)

if __name__ == '__main__':
    piyo()

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

int main(){
  int N;
  cin >> N;
  vector<int> a(3*N);
  for(int i = 0; i < 3*N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  long int sum = 0;
  for (int i = N; i < 3*N-1; i=i+2){
    sum += a.at(i);
  }
  cout << sum << endl;
  
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  string s; cin >> s;
  set<char> st;
  rep(i, s.size()) {
    st.insert(s[i]);
  }
  rep(i, 26) {
    if (!st.count('a' + i)) {
      cout << s << char('a' + i) << "\n";
      exit(0);
    }
  }
  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << "\n";
  } else {
    auto t = s;
    next_permutation(s.begin(), s.end());
    rep(i, t.size()) {
      cout << s[i];
      if (s[i] != t[i]) {
        break;
      }
    }
    cout << "\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    vector<long long int> a(n);
    REP(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[n-1]-a[0];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';
const int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };


int N, K;
ll A[100000], f[100001], finv[100001], res;

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1)a = a*x%mod;
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll comb(int n, int r) {
	if (n < r)return 0;
	return f[n] * finv[r] % mod*finv[n - r] % mod;
}

int main() {
	f[0] = 1;
	for (ll i = 1; i <= 100000; i++) {
		f[i] = f[i - 1] * i%mod;
	}
	for (int i = 0; i <= 100000; i++) {
		finv[i] = pw(f[i], mod - 2);
	}
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	for (int i = 0; i < N - 1; i++) {
		res += (A[i + 1] - A[i])*((comb(N, K) + mod + mod + mod - comb(i + 1, K) - comb(N - i - 1, K)) % mod);
		res %= mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main(){
    int n;cin >> n;
    map<int,map<int,bool>> invalid;
    if(n&1){
        for(int i = 1;i<=n-1;i++){
            invalid[i][n-i] = true;
        }
    } else {
        for(int i = 1;i<=n;i++){
            invalid[i][n+1-i] = true;
        }
    }
        vector<pair<int,int>> ans ;
        for(int i= 1;i<=n;i++){
            for(int j= i+1;j<=n;j++){
                if(!invalid[i][j]){
                    ans.push_back(make_pair(i,j));
                }
            }
        }
        cout << ans.size()<<endl;
        for(auto s:ans){
            cout << s.first << " " << s.second << endl;
        }
}


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

using namespace std;

int main() {
    int n, l, r, result;

    vector<int> A;
    bool f;
    while (cin >> n >> l >> r, n) {
        A.resize(n);

        result = 0;

        for (int i = 0; i < n; i++) {
            cin >> A[i];
        }
        for (int i = l; i <= r; i++) {
            f = false;
            for (int j = 0; j < n; j++) {
                if (i % A[j] == 0) {
                    if ((j + 1) % 2 == 1) {
                        result++;
                    }
                    f = true;
                    break;
                }
            }
            if (f == false) {
                if (n % 2 == 0) {
                    result++;
                }
            }
        }
        cout << result << endl;
    }
}


Measured memory_bytes: 3140
# Problem B - Maximum Sum

# input
a, b, c = map(int, input().split())
k = int(input())

# initialization
max_cost = 0

# max index search
if a>=b and a>=c:
    for i in range(k):
        a = a * 2
elif b>=a and b>=c:
    for i in range(k):
        b = b * 2
elif c>=a and c>=b:
    for i in range(k):
        c = c * 2

ans = a + b + c
print(ans)


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        if (n % 500 <= a) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}

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

using namespace std;

int main(void) {
  string S; cin >> S;
  long long bdp[2019];
  long long adp[2019];
  memset(bdp, 0, sizeof(bdp));
  memset(adp, 0, sizeof(adp));

  long long ans = 0;
  for (int i = 0; i < (int)S.size(); i++) {
    memcpy(bdp, adp, sizeof(adp));
    memset(adp, 0, sizeof(adp));
    ans += bdp[0];
    int d = S[i]-'0';
    adp[d]++;
    for (int j = 0; j < 2019; j++) {
      if (bdp[j]) {
        adp[(j*10+d)%2019] += bdp[j];
      }
    }
  }
  ans += adp[0];

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

Measured memory_bytes: 3792
using System;

class Hello{

    public static void Main(){
    
        var array = Console.ReadLine().Split(' ');
    
        var n =  int.Parse(array[0]);
        var m =  int.Parse(array[1]);
        if(n <= m){
            Console.WriteLine("Yes");
        }
        else{
            Console.WriteLine("No");
        }
    }

}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

const int MAX = 1e5+5;
const int mod = 1e9+7;

int n;
string s;

ll freq[26];
string m = "MARCH";

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//#ifndef ONLINE_JUDGE
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//#endif

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s;
		freq[s[0]-65]++;
	}

	int l = m.length();
	ll ans = 0;
	for (int i = 0; i < l; i++) {
		for (int j = i+1; j < l; j++) {
			for (int k = j+1; k < l; k++) {
				ll s = freq[m[i]-65] * freq[m[j]-65] * freq[m[k]-65];
				//cout << m[i] << ' ' << m[j] << ' ' << m[k] << ' ' << s << endl;
				ans += s;
			}
		}
	}

	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    int n, k;
    cin >> n >> k;
    const int max_num = (n - 1) * (n - 2) / 2;
    if(k > max_num){
        const int wa_num = -1;
        cout << wa_num << endl;
        return 0;
    }

    vector<int> row(n, 0);
    vector<vector<int>> mat(n, row);
    for(int i = 0; i < n; ++i){
        mat[i][i] = -1;
        if(i < n - 1){
            mat[i][n - 1] = 1;
            mat[n - 1][i] = 1;
        }
    }

    // cout << endl;
    // for(int i = 0; i < n; ++i){
    //     for(int j = 0; j < n; ++j){
    //         printf("%2d", mat[i][j]);
    //         cout << ((j == n - 1)? '\n' : ' ');
    //     }
    // }

    int pair_dist2_num = (n - 1) * (n - 2) / 2;
    int edge_num = n - 1;
    int write_row = 0, write_col = write_row + 1;
    while (pair_dist2_num > k){
        if(mat[write_row][write_col] != 0){
            continue;
        }

        mat[write_row][write_col] = 1;
        mat[write_col][write_row] = 1;

        // cout << endl;
        // for(int i = 0; i < n; ++i){
        //     for(int j = 0; j < n; ++j){
        //         printf("%2d", mat[i][j]);
        //         cout << ((j == n - 1)? '\n' : ' ');
        //     }
        // }

        pair_dist2_num--;
        edge_num++;
        // cout << "pair_dist2_num = " << pair_dist2_num << endl;

        if(write_col == n - 2){
            write_row++;
            write_col = write_row + 1;
        }else{
            write_col++;
        }
    }

    cout << edge_num << endl;
    for(int i = 0; i < n - 1; ++i){
        for(int j = i + 1; j < n; ++j){
            if(mat[i][j] == 1){
                cout << (i + 1) << " " << (j + 1) << endl;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define N (1<<17)+5
const int mod=1e9+7;
int n,m,a[20],fac[N],inv[N],dp[20][N];
int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)r=1ll*r*a%mod;return r;}
int c(int n,int m){return (n<m||n<0||m<0)?0:1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int cnt(int x){int r=0;while(x)r+=(x&1),x>>=1;return r;}
int main()
{
	for(int i=fac[0]=1;i<N;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[N-1]=pw(fac[N-1],mod-2);
	for(int i=N-2;i>=0;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[m-i+1]);
	dp[0][0]=1;
	for(int i=0;i<m;i++)for(int st=0;st<(1<<n);st++)if(dp[i][st])
	{
		(dp[i+1][st]+=dp[i][st])%=mod;
		for(int j=0;j<n;j++)if(!(st&(1<<j)))(dp[i+1][st|(1<<j)]+=1ll*dp[i][st]*fac[1<<j]%mod*c((1<<n)-st-a[i+1],(1<<j)-1)%mod)%=mod;
	}
	int ans=0;
	for(int st=0;st<(1<<n);st++)
	{
		int sgn=(cnt(st)&1)?-1:1;
		(ans+=1ll*sgn*dp[m][st]*fac[(1<<n)-st-1]%mod)%=mod;
	}
	ans=(ans+mod)%mod; 
	printf("%d\n",1ll*ans*(1<<n)%mod);
	return 0;
} 

Measured memory_bytes: 9728