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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}



int main() {
    li n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;

    return 0;
}

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

using namespace std;

int main()
{
	int cnt = 0;
	string str, std;

	cin >> std;
	while (cin>>str)
	{
		for (unsigned int i = 0; i != str.length(); ++i)
		{
			if (str.at(i) >= 'A'&&str.at(i) <= 'Z')
			{
				str.at(i) += 32;
			}
		}

		if (str == std)
		{
			++cnt;
		}

	}

	cout << cnt << endl;

	return 0;

}


Measured memory_bytes: 3180
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solveZerSumRanges();
	}

	public static void solveZerSumRanges(){

		int N = sc.nextInt();
		long[] A = new long[N];

		for(int i=0;i<N;i++){
			A[i] = sc.nextLong();
		}

		long[] cs = new long[N+1];

		cs[0] = 0;

		for(int i=0;i<N;i++){
			cs[i+1] = cs[i] + A[i];
		}

		Map<Long, Long> m = new HashMap<Long, Long>();

		for(long l: cs){

			long mi = m.containsKey(l) ? m.get(l) : 0;
			m.put(l, mi + 1);
		}

		long ans = 0L;
		for(Map.Entry<Long, Long> e : m.entrySet()){
			long n = e.getValue();
			ans += n * (n-1L) / 2L;
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 92432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC169A
    {
        const string FILE = @"..\..\data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            var s = Console.ReadLine();

            char c = s.ToCharArray()[s.Length - 1];


            string result = "hon";
            if (c == '3')
            {
                result = "bon";
            }
            else if (c == '0' || c == '1' || c == '6' || c == '8')
            {
                result = "pon";
            }
            Console.WriteLine(result);

#if DEBUG
            Console.WriteLine("end");
            Console.SetIn(Console.In);
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 25632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

ll a[100010];

int main(void){
    int ans=0;
    int n,k,h;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h;
        if(h>=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a;
    int j=0;
    while(1){
        if(j>=a){
            break;
        }
        cin>>b>>c;
        if(b%c==0){
            cout<<c<<endl;
        }else{
            cout<<b%c<<endl;
        }
        j++;
    }
}



Measured memory_bytes: 3104
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;
ll ans=0,ans2=0;
ll A,B,C,D;
typedef pair<ll,ll> P;
int main() {
	cin>>A>>B>>C>>D;
	if(A+B>C+D)cout<<"Left"<<endl;
	if(A+B<C+D)cout<<"Right"<<endl;
	if(A+B==C+D)cout<<"Balanced"<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int W, H, N, ans, maxy = 0;
vector<PI> e;

int main() {
	cin >> W >> H >> N;
	for (int i = 0; i < N; i++) {
		int x, y; cin >> x >> y;
		e.push_back({x, y});
	}
	sort(e.begin(), e.end());
	ans = e[N - 1].first;
	for (int i = N - 1; i >= 0; i--) {//e[i-1]までx
		maxy = max(maxy, e[i].second);
		ans = min(ans, (i ? e[i - 1].first : 0) + maxy);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3852
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

bool comp(PII &a, PII &b)
{
  return a.second < b.second;
}


int main()
{
   int N, M;
   cin >> N >> M;
   VPII rivals;
   REP(i, M)
   {
    int a, b;
    cin >> a >> b;
    a--; b--;
    rivals.push_back(PII(a, b));
   }
   sort(ALL(rivals), comp);
   int removed = -1;
   int ans = 0;
   int a, b;
   REPx(x, rivals)
   {
    a = x.first;
    b = x.second;
    if (removed == -1)
    {
      removed = b - 1;
      ans++;
    }
    else
    {
      if (a <= removed) continue;
      else
      {
        removed = b - 1;
        ans++;
      }
    }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main(){
 int x,a,b,c,d;
 scanf("%d",&x);
 a=x/1000;
 b=(x-a*1000)/100;
 c=(x-a*1000-b*100)/10;
 d=x-a*1000-b*100-c*10;
 if(a+b+c+d==7){printf("%d+%d+%d+%d=7\n",a,b,c,d);return 0;}
 if(a+b+c-d==7){printf("%d+%d+%d-%d=7\n",a,b,c,d);return 0;}
 if(a+b-c+d==7){printf("%d+%d-%d+%d=7\n",a,b,c,d);return 0;}
 if(a-b+c+d==7){printf("%d-%d+%d+%d=7\n",a,b,c,d);return 0;}
 if(a-b-c-d==7){printf("%d-%d-%d-%d=7\n",a,b,c,d);return 0;}
 if(a+b-c-d==7){printf("%d+%d-%d-%d=7\n",a,b,c,d);return 0;}
 if(a-b+c-d==7){printf("%d-%d+%d-%d=7\n",a,b,c,d);return 0;}
 if(a-b-c+d==7)printf("%d-%d-%d+%d=7",a,b,c,d);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    int N, K;
    cin >> N >> K;
    int l[N];
    rep(i, N) cin >> l[i];
    sort(l, l + N, greater<int>());
    rep(i, K) cnt += l[i];
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = INT_MAX / 2;

vector<int> prices;
vector<vector<int>> unds;

int solve(const int N, const int M, const int X) {
    int cand = INF;
    for (int bits = 0; bits < (1 << N); bits++) {
        int sum_price = 0;
        vector<int> sum_unds(M, 0);
        for (int i = 0; i < N; i++) {
            if (bits & (1 << i)) {
                sum_price += prices[i];
                for (int j = 0; j < M; j++) {
                    sum_unds[j] += unds[i][j];
                }
            }
        }
        bool ok = true;
        for (int i = 0; i < M; i++) {
            if (sum_unds[i] < X) {
                ok = false;
            }
        }
        if (ok) {
            chmin(cand, sum_price);
        }
    }

    return cand;
}

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

    prices.resize(N, 0);
    unds.resize(N, vector<int>(M, 0));
    for (int i = 0; i < N; i++) {
        cin >> prices[i];
        for (int j = 0; j < M; j++) {
            cin >> unds[i][j];
        }
    }

    int ans = solve(N, M, X);
    if (ans == INF) {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
const ll INF = 1LL<<60;

int main(){
	int n,k;
	cin >> n >> k;
	vector<ll> plus;
	vector<ll> minus;
	rep(i,n){
		ll x;
		cin >> x;
		if(x >= 0) plus.push_back(x);
		if(x < 0 ) minus.push_back(x);
	}
	
	reverse(minus.begin(),minus.end());
	int np = plus.size();
	int nm = minus.size();
	
	ll ans = INF;
	
	//正のロウソクをA本、負のロウソクをB本つける。
	for (int A = 0; A <= min(np, k); ++A) {
		int B = min(k-A, nm);
		if(A + B != k) {
			continue;
		}
		ll time = 0;
		if(A == 0){
			time = - minus[B-1];
		} else if (B == 0){
			time = plus[A-1];
		} else{
			time = min(2*plus[A-1] - minus[B-1], -2*minus[B-1]+ plus[A-1]);
		}
		ans = min(ans , time);
	}
	
	cout << ans << endl;
	
    return 0;
}



Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int cnt = 0;  //予選通過確定者の人数
  int kaigai = 0;
  rep(i, n) {
    if (cnt + 1 <= a + b) {
      if (s[i] == 'a') {
        cnt++;
        cout << "Yes" << endl;
      } else if (s[i] == 'b') {
        kaigai++;
        if (kaigai <= b) {
          cout << "Yes" << endl;
          cnt++;
        } else
          cout << "No" << endl;
      } else {
        cout << "No" << endl;
      }
    } else
      cout << "No" << endl;
  }
}

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

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))

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

    cout << r*r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, M;
    cin >> N >> M;
    Graph<int> G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, 1e9);
    vector<int> ans(N, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    ans[0] = 0;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (auto nv : G[v]) {
            if (dist[nv] < 1e9)
                continue;
            dist[nv] = dist[v] + 1;
            ans[nv] = v;
            que.push(nv);
        }
    }

    bool flag = true;
    for (int i = 0; i < N; ++i) {
        if (ans[i] == -1) {
            flag = false;
            break;
        }
    }

    if (!flag)
        cout << "No" << '\n';
    else {
        cout << "Yes" << '\n';
        for (int i = 1; i < N; ++i)
            cout << ans[i] + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 10644
def main():
    n = int(input())
    a = list(map(int, input().split()))

    cnt = 0
    for e in a:
        if e < 0:
            cnt += 1

    a = list(map(abs, a))
    a.sort()
    if cnt % 2:
        ans = sum(a[1:]) - a[0]
    else:
        ans = sum(a)

    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
	int num = 0;
	int a, b ,c ,d;
	int A, B;
	scanf("%d %d", &A, &B);
	for(int i = A; i <= B; i++){
		a = i / 10000;
		b = (i - a*10000) / 1000;
		c = i / 10 % 10;
		d = i % 10;
		if(a == d && b == c) num++;
	}
	printf("%d\n", num);
}

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

using namespace std;
#define l long long int 

int main()
{
  l x,n,ct=0;
  cin>>x>>n;
  vector<l> ar(n,0);
  for(auto &i:ar)
  {
    cin>>i;
    ct+=i;
  }
  if(ct>x)
  {
    cout<<-1;
  }
  else
    cout<<x-ct;
  return 0;
}

Measured memory_bytes: 3672
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public double[] grade = new double[]{ 1.1, 0.6, 0.2 };
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int[] left = new int[]{ 0, 0, 0, 0 };
		int[] right = new int[]{ 0, 0, 0, 0 };
		
		String line;
		while((line = in.readLine()) != null){
			String[] dst = line.split(" ");
			double l = Double.parseDouble(dst[0]);
			double r = Double.parseDouble(dst[1]);
			int lf = 0;
			int rf = 0;
			
			for(int i=0; i<3; i++){
				if(l >= grade[i] && lf==0){
					left[i]++;
					lf = 1;
				}
				
				if(r >= grade[i] && rf==0){
					right[i]++;
					rf = 1;
				}
			}
			
			if(lf == 0){
				left[3]++;
			}
			if(rf == 0){
				right[3]++;
			}
		}
		
		for(int n=0; n<4; n++){
			System.out.printf("%d %d\n", left[n], right[n]);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<queue>
#include<set>

using namespace std;

string reverse(string str){
	for (int i = 0; i < (str.size())/2 ; i++){
		char tmp = str[i];
		str[i] = str[str.size() - i - 1];
		str[str.size() - i - 1] = tmp;
	}
	return str;
}
int main(){
	int n; cin >> n;
	for (int i  = 0; i < n; i++){
		string str; cin >> str;
		set<string> set;
		for (int j = 1; j < str.size(); j++){
			string head = str.substr(0,j);
			string tail = str.substr(j);
			string rhead = reverse(head);	
			string rtail = reverse(tail);	
			set.insert(head + tail);
			set.insert(rhead + tail);
			set.insert(head + rtail);
			set.insert(rhead + rtail);
			set.insert(tail + head);
			set.insert(rtail + head);
			set.insert(tail + rhead);
			set.insert(rtail + rhead);
		}
		cout << set.size() << endl;

	}
return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const double PI = acos(-1.0);
double a, b;
double h, m;
int main() {
	cin >> a >> b >> h >> m;
	double ang1 = 6.0 * m;
	double ang2 = 0.5 * (h * 60 + m);
	double ang = fabs(ang1 - ang2);
	ang = min(ang, 360 - ang);
	printf("%.20lf", sqrt(a * a + b * b - 2 * a * b * cos(ang * PI / 180)));
	return 0;
}

Measured memory_bytes: 4164
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;

int num[100], top;

int pop();
void push(int x);

int main()
{
	int a, b;
	top = 0;
	string s;
	getline(cin, s);

	for(int j = 0; s[j]!='\0'; j++)
	{
		if(s[j] == ' ') continue;
		else if(s[j] != '+' && s[j] != '-' && s[j] != '*')
		{
			int l = 0;
			num[top] = 0;
			while(s[j]!=' ') { l++; j++;}
			num[top] += atoi(&s[j-l]);
			top++;
		} 
		else
		{
			a = pop();
			b = pop();
			if(s[j] == '+')
				push(b+a);
			else if(s[j]=='-')
				push(b-a);
			else if(s[j] == '*')
				push(a*b);
			top++; 
		}
	}
	cout << num[0] << endl;
	return 0;
}

int pop() { top--; return num[top]; }

void push(int x) { num[top] = x; }

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    string n;
    cin >> n;
    
    if (n.back() == '2' || n.back() == '4' || n.back() == '5' || n.back() == '7' || n.back() == '9') cout << "hon";
    else if (n.back() == '0' || n.back() == '1' || n.back() == '6' || n.back() == '8') cout << "pon";
    else cout << "bon";
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int ans[n + 1][m + 1] = {};
    
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i < n && j < m){
                cin >> ans[i][j];
                ans[i][m] += ans[i][j];
            } 

        }

    }
    
     for(int i = 0; i <= m; i++){
        for(int j = 0; j < n; j++){
            ans[n][i] += ans[j][i];
            
        }
    }
    
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(j == m){
                cout << ans[i][j] ;
            } else {
                cout << ans[i][j] << " ";
            }
            
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
L, R = map(int, input().split())
output = 2018


for i in range(L, R + 1):
    for k in range(i + 1, R + 1):
        if output == 0:
            break

        if output > i * k % 2019:
            output = i * k % 2019
    else:
        continue
    break

print(output)

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  string s;
  cin >> s;
  stack<char> st;
  int n = sz(s);
  rep(i,n) {
    if(s[i] != 'B') st.push(s[i]);
    else if(sz(st)) st.pop();
  }
  string ans;
  while(sz(st)) {
    ans += st.top();
    st.pop();
  }
  reverse(all(ans));
  cout << ans << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[][] S = new String[H+2][W+2];
		for(int i = 1;i < H+1;i++) {
			String[] s = sc.next().split("");
			for(int j = 1;j < W+1;j++) {
				S[i][j] = s[j-1];
			}
		}
		sc.close();
		int[][] num = new int[H+2][W+2];
		for(int i = 1;i < H+1;i++) {
			for(int j = 1;j < W+1;j++) {
				if(S[i][j].equals("#")) {
					num[i-1][j-1]+=1;
					num[i-1][j]+=1;
					num[i-1][j+1]+=1;
					num[i][j-1]+=1;
					num[i][j+1]+=1;
					num[i+1][j-1]+=1;
					num[i+1][j]+=1;
					num[i+1][j+1]+=1;
				}
			}
		}
		StringBuilder sb =new StringBuilder();
		for(int i = 1;i < H+1;i++) {
			for(int j = 1;j < W+1;j++) {
				if(S[i][j].equals("#")) {
					sb.append(S[i][j]);
				}else {
					sb.append(num[i][j]);
				}
			}
			System.out.println(sb.toString());
			sb.delete(0, sb.length());
		}
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a[n-1]-a[0] << endl;
}

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

int main(void) {
	int i;
	int a, b, c;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a = atoi(ch);
	ch = strtok(NULL, " ");
	b = atoi(ch);
	ch = strtok(NULL, " ");
	c = atoi(ch);

	if(a + b == c) {
		printf("Yes\n");
	} else if(b + c == a) {
		printf("Yes\n");
	} else if(c + a == b) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


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

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())
#define mod 1000000007
#define pi 3.141592653589793238
#define ll long long int
#define ull unsigned long long
#define be begin()
#define en end()
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORI(i, a, b) for (int i = a; i >= b; i--)

typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef vector<PI> VPI;

int main()
{
    IOS;

    string s;
    cin >> s;

    int maxi = 0;

    for (int i = 0; i < s.length(); i++)
    {
        int cnt = 0;
        while (s[i] == 'R' && int(i) < int(s.length()))
        {
            cnt++;
            i++;
        }
        if (cnt > maxi)
            maxi = cnt;
    }

    cout << maxi << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#define INFTY 1000000001

typedef struct{ //構造体
		int value;
		char key;
} Card;

int partition(Card *A, int  p, int r){
	int i, j, x;
	Card temp;
	x = A[r].value;
	//printf("x:%d\n", x);
	i = p-1;
	for(j=p; j<r; j++){
		if(A[j].value<=x){
			i=i+1;
			//A[i] と A[j] を交換
			temp=A[i];
			A[i]=A[j];
			A[j]=temp;
		}
	}
	//A[i+1] と A[r] を交換
	temp=A[i+1];
	A[i+1]=A[r];
	A[r]=temp;
	
	return i+1;
}

void quicksort(Card *A, int  p, int r){
	int q;
	if(p<r){
		q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q+1, r);
	}
}
void merge(Card *B, int left, int mid, int right) //merge で統治
{
	int n1, n2;
	Card *L, *R;
	L=malloc(sizeof(Card)*right);
	R=malloc(sizeof(Card)*right);
	int i, j, k;
	n1=mid-left;
	n2=right-mid;
	//L[0...n1], R[0...n2] を生成
	for(i=0; i<n1; i++) L[i]=B[left+i];
	for(i=0; i<n2; i++) R[i]=B[mid+i];
	L[n1].value=INFTY;
	R[n2].value=INFTY;
	i=0;
	j=0;
	for(k=left; k<right; k++){
		if(L[i].value<=R[j].value){
			B[k]=L[i];
			i=i+1;
		}
		else{
			B[k]=R[j];
			j=j+1;
		}
	}
	
	free(L);
	free(R);
}

void mergeSort(Card *B, int left, int right) //mergeSort で分割. 部分配列の要素数が 1 以下のときは何もせず終了
{
	//部分配列の中央の位置 mid
	//部分配列の前半部分は left から mid （ mid は含まない
	//後半部分は mid から right （ right は含まない）
	int mid;
	if(left+1<right){
		mid=(left+right)/2;
		mergeSort(B, left, mid);
		mergeSort(B, mid, right);
		merge(B, left, mid, right);
	}
}

int main(void){
	int i, n, no=0;
	Card *A, *B;
	scanf("%d", &n);
	A=malloc(sizeof(Card)*n);
	B=malloc(sizeof(Card)*n);
	for(i=0; i<n; i++){
		scanf(" %c %d", &A[i].key, &A[i].value);
		B[i]=A[i];
	}
	
	quicksort(A, 0, n-1);
	mergeSort(B, 0, n);
	for(i=0; i<n; i++){
		if(B[i].key!=A[i].key){
			no=1;
			break;
		}
	}
	if(no) printf("Not stable\n");
	else printf("Stable\n");
	for(i=0; i<n; i++) printf("%c %d\n", A[i].key, A[i].value);
	
	free(A);
	free(B);
	return 0;
}


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

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

    int a,b,c;
    cin>>a>>b>>c;
    string ans="No";
    if(a<b and b<c){
        ans="Yes";
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3236
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[12345678], cost[1234][1234];
signed main() {
	vector<vector<int>> v(123456); map<string, int> mn;
	int n, m, hi, a, b, c, cnt = 0, ans = 0; string s, t;
	cin >> n;
	for (int h = 0; h <= 1000; h++) {
		test[h] = pow(h, 5);
	}
	for (int h = 0; h <= 1000; h++) {
		for (int i = 0; i <= 1000; i++) {
			if (test[h] - test[i] == n) { cout << h << ' ' << i << endl; return 0; }
			if (test[h] + test[i] == n) { cout << h << " -" << i << endl; return 0; }
		}
	}
	return 0;
}

Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<29;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int count_fin = INF;
    for (int i = 0; i < N; i++){
        bool can = true;
        int j = 1;
        int count = 0;
        while(can){
            if ((A.at(i)&j) != 0){
                can = false;
            }
            else{
                //cout << (A.at(i)&j) << " " << j << endl;
                j *= 2;
                count++;
            }
        }
        if (count_fin > count) count_fin = count;
    }
    cout << count_fin << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

int b[2][2000][2000] = {};
int ru[2][2001][2001] = {};

void solve() {
    int n, K;
    cin >> n >> K;
    int x, y;
    char c;
    REP(i, 0, n) {
        cin >> x >> y >> c;
        x %= (2 * K);
        y %= (2 * K);
        b[c == 'B'][x][y]++;
    }
    REP(k, 0, 2)
    REP(i, 0, 2 * K)
    REP(j, 0, 2 * K) ru[k][i + 1][j + 1] = ru[k][i + 1][j] + b[k][i][j];
    REP(k, 0, 2)
    REP(j, 0, 2 * K) REP(i, 0, 2 * K) ru[k][i + 1][j + 1] += ru[k][i][j + 1];
    int ans = 0;
    REP(i, 0, K) REP(j, 0, K) {
        int cw = 0;
        cw += ru[0][i][j] - ru[0][0][0];
        cw += ru[0][i + K][j + K] + ru[0][i][j] - ru[0][i + K][j] -
              ru[0][i][j + K];
        cw += ru[0][2 * K][2 * K] + ru[0][i + K][j + K] - ru[0][2 * K][j + K] -
              ru[0][i + K][2 * K];
        cw += ru[0][i][2 * K] - ru[0][i][j + K];
        cw += ru[0][2 * K][j] - ru[0][i + K][j];

        int cb = 0;
        cb += ru[1][i][j] - ru[1][0][0];
        cb += ru[1][i + K][j + K] + ru[1][i][j] - ru[1][i + K][j] -
              ru[1][i][j + K];
        cb += ru[1][2 * K][2 * K] + ru[1][i + K][j + K] - ru[1][2 * K][j + K] -
              ru[1][i + K][2 * K];
        cb += ru[1][i][2 * K] - ru[1][i][j + K];
        cb += ru[1][2 * K][j] - ru[1][i + K][j];

        ans = max({ans, cw + (ru[1][2 * K][2 * K] - cb),
                   cb + (ru[0][2 * K][2 * K] - cw)});        
    }
    cout << ans << endl;
}

signed main() {
    solve();

    return 0;
}


Measured memory_bytes: 62720
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    
	    String s  =sc.next();
	    
	    if(s.equals("ABC")){
	        System.out.println("ARC");
	        
	    }else
	      System.out.println("ABC");
	}
}


Measured memory_bytes: 35648
def solve(i, m, array, n)
  return true if m.zero?
  return false if i >= n
  solve(i + 1, m, array, n) || solve(i + 1, m - array[i],array, n)
end

n = gets.to_i
input = gets.split(' ').map(&:to_i)
gets.to_i
hope = gets.split(' ').map(&:to_i)

hope.each do|hope_value|
  case solve 0, hope_value, input, n
  when true
    puts 'yes'
  when false
    puts 'no'
  end
end


Measured memory_bytes: 6920
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;
vector<pair<int , pair<int, int> > > score(51);
int wrongans[51];

int main()
{
	int M, T, P, R;
	while(1){
		cin >> M >> T >> P >> R;
		if(M == 0 && T == 0 && P == 0 && R == 0) break;
		for(int i = 1; i <= T; i++){
			score[i].first = 0;
			(score[i].second).first = 0;
			(score[i].second).second = -i;
		}
		int wrongans[51][11] = {0};
		int m, t, p, j;
		for(int i = 0; i < R; i++){
			cin >> m >> t >> p >> j;
			if(j == 0){
				score[t].first--;
				(score[t].second).first += m + (20 * wrongans[t][p]);
			} else {
				wrongans[t][p]++;
			}
		}
		sort(score.begin() + 1, score.begin() + T + 1);
		for(int i = 1; i <= T; i++){
			cout << -(score[i].second).second;
			if(i == T) cout << endl;
			else if(score[i + 1].first == score[i].first && (score[i + 1].second).first == (score[i].second).first) cout << '=';
			else cout << ',';
		}
	}
	return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	string a,b,c;
	cin >> a >> b >> c;

	if(b[0] >= 'A' && b[0] <= 'Z')
		cout << 'A' << b[0] << 'C';
	else
		cout << 'A' << (char)(b[0] -'a' + 'A') << 'C';
}



Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n,m;
    cin>>n>>m;
	double a[n];
	double sum=0;
	rep(i,0,n){
		cin>>a[i];
		sum+=a[i];
	}
	sum=sum/(4*m);
//	cout<<sum<<endl;
	sort(a,a+n);
	reverse(a,a+n);
	rep(i,0,m){
		if(a[i]<sum)return cout<<"No"<<endl,0;
	}
	cout<<"Yes"<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
import java.util.*;
// import java.io.*;

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

        int num = sc.nextInt();

        ArrayList<Integer> array = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            int tmp = sc.nextInt();
            array.add(tmp);
        }

        int num_query = sc.nextInt();

        for (int i = 0; i < num_query; i++) {
            int left = sc.nextInt();
            int right = sc.nextInt();
            int key = sc.nextInt();

            int cnt = 0;
            for (int j = left; j < right; j++) {
                if (array.get(j) == key) cnt++;
            }
            sb.append(String.format("%d\n", cnt));
        }

        System.out.print(sb);
        
        sc.close();
    }
}



Measured memory_bytes: 41128
#include<iostream>
#include<map>
#include<string>
#include<vector>

using namespace std;

int main() 
{
    int N;
    cin>>N;
    vector<string>S;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin>>s;
        S.push_back(s);
    }

    map<string,int>vote;
    vote.emplace(S.back(),1);
    S.pop_back();

    while (!S.empty())
    {
        auto it = vote.find(S.back());
        if(it!=vote.end())
        {
            ++(it->second);
        }
        else
        {
            vote.emplace(S.back(),1);
        }
        S.pop_back();
    }

    int vmax = 1;
    for(const auto&vt:vote)
    {
        if(vmax<vt.second)
        {
            vmax=vt.second;
        }
    }

    for(const auto&vt:vote)
    {
        if(vt.second==vmax)
        {
            cout<<vt.first<<endl;
        }
    }

}

Measured memory_bytes: 24964
N, K = map(int, input().split())
lst = [int(input()) for i in range(N)]

def num_luggage(P, K, lst):
    weight = 0
    n_track = 1
    for i, e in enumerate(lst):
        if (e > P):
            return i
        if (weight + e <= P):
            weight += e
        else:
            n_track += 1
            weight = e
        if (n_track == K+1):
            return i
    return len(lst)

left, right = 0, 10000 * N
i_break = 0
while right - left > 1:
    mid = (left+right)//2
    if N <= num_luggage(mid, K, lst):
        right = mid  # ギリギリOKなのはrightに最終的に格納されているはず
    else:  # 余裕がなければ(n>n_nimotu_if_P())、Pを増やす
        left = mid

print(right)


Measured memory_bytes: 9560
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
h = []
m.times do
  h << gets.split.map(&:to_i)
end
i = 0
h.sort_by{|u, v| -v}.each do |x, y|
  break if a[i] >= y
  x.times do
    a[i] = y
    i += 1
    break if i >= n
    break if a[i] >= y
  end
  break if i >= n
end
puts a.inject(:+)

Measured memory_bytes: 26056
using System;

namespace ABC138
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] v = new int[N];

            for (int i = 0; i < N; i++)
            {
                v[i] = int.Parse(input[i]);
            }

            Array.Sort(v);

            double res = 0;
            res += v[0] / Math.Pow(2, N - 1);
            res += v[1] / Math.Pow(2, N - 1);
            for (int i = 2; i < N; i++)
            {
                res += v[i] / Math.Pow(2, N - i);
            }
            Console.WriteLine(res);
        }
    }
}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
vector<pair<ll, ll>> vp;
vector<ll> dp;
ll n;

int Binary_search(ll x) {
    int ok = n, ng = x;
    while(ok - ng > 1) {
        int mid = (ok - ng) / 2 + ng;
        if(vp[mid].first >= vp[x].second) {
            ok = mid;
        } else
            ng = mid;
    }
    return ok;
}

ll ret(ll x) {
    if(x == n) return 0ll;
    if(dp[x] != INF) return dp[x];
    //cout << 1 << endl;
    return dp[x] = max(ret(x + 1) ,1ll + ret(Binary_search(x)));
}

int main() {
    ll m, i, j, k;
    cin >> n;
    vp = vector<pair<ll,ll>> (n);
    for(i=0;i<n;i++){
        ll x,y;
        cin >> x >> y;
        vp[i].first = x-y;
        vp[i].second = x+y;
    }
    sort(vp.begin(),vp.end());
    dp = vector<ll> (n,INF);
    cout << ret(0ll) << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100; 
int n;
long long h[N], c;

struct Sol {
	long long m = 0;
	long long k = 0;

	Sol() = default;
	Sol(long long _m, long long _k) {
		m = _m;
		k = _k;
	}

	long long eval(long long x) {
		return m * x + k;
	}

	double to(Sol &s) {
		if (m == s.m) {
			return LLONG_MAX;
		}
		return (double) (s.k - k) / (m - s.m);
	}
};

Sol dq[N];

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

	cin >> n >> c;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	
	int l = 0, r = 0;
	long long opt = 0;
	for (int i = 2; i <= n; i++) {
		Sol nsol(-2 * h[i - 1], opt + c + h[i - 1] * h[i - 1]);

		while (r - l >= 2 && dq[r - 2].to(dq[r - 1]) >= dq[r - 2].to(nsol)) {
			r--;
		}
		dq[r++] = nsol;

		while (l + 1 < r && dq[l].eval(h[i]) >= dq[l + 1].eval(h[i])) {
			l++;
		}

		opt = dq[l].eval(h[i]) + h[i] * h[i];
	}

	cout << opt << '\n';

	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9 + 7;
ll L, R, dp[62][2][2][2], ans = 0;

int main(){
	cin >> L >> R;
	dp[61][0][0][0] = 1;
	for(int i=60; i>=0; i--){
		rep(j,2)rep(k,2)rep(s,2){
			int lb = L>>i&1, rb = R>>i&1;
			rep(x,2)rep(y,2){
				int nj = j, nk = k, ns = s;
				if(x && !y) continue;
				if(!j && x < lb) continue;
				if(!k && y > rb) continue;
				if(!s && x+y==1) continue;
				if(!j && x > lb) nj = 1;
				if(!k && y < rb) nk = 1;
				if(!s && x+y==2) ns = 1;
				dp[i][nj][nk][ns] = (dp[i][nj][nk][ns] + dp[i+1][j][k][s]) % mod;
			}
		}
	}
	rep(j,2)rep(k,2)rep(s,2) ans = (ans + dp[0][j][k][s]) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin>>s;
    int l=s.size()-1;
    if(s[l]=='2' || s[l]=='4' || s[l]=='5' || s[l]=='7' || s[l]=='9')
        cout<<"hon"<<endl;
    else if(s[l]=='0' || s[l]=='1' || s[l]=='6' || s[l]=='8')
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
using namespace std;
char a;
int tot=0;
char aa[1000000];
string s;
int main(){
	while(cin>>a){
		tot++;
		aa[tot]=a;
		if(a=='b')s=s+'d';
		if(a=='d')s=s+'b';
		if(a=='p')s=s+'q';
		if(a=='q')s=s+'p';
	}
	for(int i=0;i<s.size();i++){
		if(s[i]==aa[tot]){
			tot--;
		}
		else {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 840
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

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

	int n;
	cin>>n;
	vi dp(n,inf),in(n);
	dp[0]=0;
	rep(i,n){
		cin>>in[i];
		if(i-1>=0)cmin(dp[i],dp[i-1]+abs(in[i]-in[i-1]));
		if(i-2>=0)cmin(dp[i],dp[i-2]+abs(in[i]-in[i-2]));
	}
	cout<<dp[n-1]<<endl;
}



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

typedef long long ll;
typedef unsigned long long ull;

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

    int cnt=0;
    while(true){
        string t;
        cin >> t;
        if(t=="END_OF_TEXT") break;
        transform(t.begin(),t.end(),t.begin(),::tolower);

        if(w==t) cnt++;
    }

    cout << cnt << endl;
    
    return 0;
}


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

using namespace std;

int main() {

    string N;
    cin >> N;

    for (int i = 0; i <= 2; i++) {
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderTest
{
    class CardGameForTwo
    {
        static int gameResult(List<int> inData)
        {
            var nData = inData.Count();

            var sortedData = inData.OrderByDescending(x => x).ToList();

            var nPlayBob = nData / 2;

            int score = 0;

            for (int iPlayBob=0; iPlayBob<nPlayBob; ++iPlayBob)
            {
                score += sortedData[2 * iPlayBob] - sortedData[2 * iPlayBob + 1];
            }

            if (nPlayBob * 2 < nData)
                score += sortedData.Last();

            return score;
        }

        public static string core()
        {
            var inStr = Console.ReadLine();
            var inStr2 = Console.ReadLine();
            var inList = inStr2.Split(' ').Select(x => int.Parse(x)).ToList();

            var retStr = gameResult(inList).ToString();
            return retStr;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(CardGameForTwo.core());
        }
    }

}


Measured memory_bytes: 13396
import fileinput
    
def frog(stones):
    stone_cost = [0]
    for i in range(1, len(stones)):
        single_step_cost = abs(stones[i] - stones[i - 1])
        if i == 1:
            stone_cost.append(single_step_cost)
        else:
            double_step_cost = abs(stones[i] - stones[i - 2])
            stone_cost.append(min(single_step_cost + stone_cost[-1], double_step_cost + stone_cost[-2]))
    
    return stone_cost[-1]
    
    
inp = fileinput.input()
inp.readline()
stones = [int(v) for v in inp.readline().split(" ")]
print(frog(stones))

Measured memory_bytes: 14068
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

VI t;
int N,T;

int main(){

	cin >> N >> T;
	t.resize(N);
	REP(i,N){
		cin >> t[i];
	}

	long long X = 0;
	int time = 0;
	FOR(i,0,N-1){
		time += T;
		if(time > t[i+1]) {
			X += t[i+1] - (time - T);
		} else {
			X += T;
		}
		time = t[i+1];
	}
	X += T;

	cout << X << endl;

}

Measured memory_bytes: 1024